diff --git a/.gitignore b/.gitignore index 1e6c8cdcecef6..406a5a58d34aa 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ atlassian* /.gitattributes /app/config_sandbox /app/etc/config.php +/app/etc/env.php /app/code/Magento/TestModule* /lib/internal/flex/uploader/.actionScriptProperties /lib/internal/flex/uploader/.flexProperties @@ -37,6 +38,7 @@ atlassian* !/pub/media/wysiwyg/.htaccess /pub/media/tmp/* !/pub/media/tmp/.htaccess +/pub/media/captcha/* /pub/static/* !/pub/static/.htaccess diff --git a/.htaccess b/.htaccess index 404488eb7ff0e..e1744eea7fb58 100644 --- a/.htaccess +++ b/.htaccess @@ -188,4 +188,4 @@ ## If running in cluster environment, uncomment this ## http://developer.yahoo.com/performance/rules.html#etags - #FileETag none + #FileETag none \ No newline at end of file diff --git a/.php_cs b/.php_cs index 743cab6ee0d17..8381e44cf08ff 100644 --- a/.php_cs +++ b/.php_cs @@ -15,7 +15,6 @@ $finder = Symfony\CS\Finder\DefaultFinder::create() ->exclude('dev/tests/functional/vendor') ->exclude('dev/tests/integration/tmp') ->exclude('dev/tests/integration/var') - ->exclude('lib/internal/CardinalCommerce') ->exclude('lib/internal/Cm') ->exclude('lib/internal/Credis') ->exclude('lib/internal/JSMin') diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a6d17e6ede41..7d4916a0f3610 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,136 @@ +0.74.0-beta11 +============= +* Framework improvements: + * Improved component Bookmarks component in scope of Enhanced Data Grids on CMS + * Improved component Advanced Filtering component in scope of Enhanced Data Grids on CMS +* Fixed bugs: + * Fixed an issue where incorrect keys in REST request body allowed the request to go through successfully + * Fixed an issue where interceptors were Generated with Invalid __wakeup() + * Fixed an issue where redirect on the current page was not working in certain conditions + * Fixed an issue where first store could not be selected on frontend + * Fixed an issue with performance toolkit category creation + * Fixed an issue when columns 'Interval', 'Price Rule' had incorrect values in Coupon Usage report + * Fixed an issue where fatal error occured on Abandoned Carts report grid + * Fixed an issue where it was not possible to add product to shopping cart if Use Secure URLs in Frontend = Yes + * Fixed an issue where email was not required during Guest Checkout + * Fixed broken ability to skip reindex in `bin/magento setup:performance:generate-fixtures` command + * Fixed an issue where `bin/magento indexer:reindex` command failed after `bin/magento setup:di:compile` was run + * Fixed bug with broken JS i18n + * Fixed an issue with wrong value at created_at updated_at fields after quote* save + * Fixed an issue where customer could not be created in backend after adding Image type attribute + * Fixed Sales InvoiceItem and Order data interfaces implementation + * Fixed an issue with performance toolkit medium profile + * Fixed an issue where Excel Formula Injection via CSV/XML export + * Fixed an issue where it was not possible to open the Customers page in backend + * Fixed an issue with internal server error after clicking Continue on Billing information + * Fixed an issue where it was not possible to place order with Fedex shipping method +* Various changes: + * Magento Centinel Removal + * Removed ability to have multi-statement queries +* Test coverage: + * Unit tests coverage + * Covered php code by unit tests after new checkout implementation +* Github issues: + * [#424](https://github.com/magento/magento2/issues/424) -- Combine tier pricing messages into block sentences + * [#1300](https://github.com/magento/magento2/issues/1300), [#1311](https://github.com/magento/magento2/issues/1311), [#1313](https://github.com/magento/magento2/issues/1313) -- Creating product error with startdate + +0.74.0-beta10 +============= +* Framework improvements: + * Created Admin Login support into the Upgrade Setup Tool + * Added support for image types as custom attributes + * Added @api annotations to all classes that are considered as stable public APIs; marked public data interfaces with '@api' + * Defined Public API for modules: Catalog, CatalogRule, Msrp, UrlRewrite, CatalogUrlRewrite, CmsUrlRewrite, Sales, Quote, SalesRule, Captcha, Cms, Widget + * Created documentation and code samples for Sales & Checkout Module Integration APIs + * Increased code coverage of Integration module + * Fixed performance issues in unit tests + * Moved Sample Data install.php, dev/shell/cron.sh, performance-toolkit/generate.php, dependencies tools, and xmlUpdater to new bin/magento CLI + * Separated Config File (config.php) into Environmental and App configs + * Better validation of install and setup CLI commands + * Changed option names to use dashes in order to conform to naming convention +* Code quality improvements: + * Removed unused classes in Magento\Reports module + * Overall unit test coverage was improved + * Replaced all functional tests which were not end-to-end with injectable test + * Replaced end-to-end test for automatic tax applying with injectable test + * Functional tests maintained + * Updated getElements method for Selenium Driver class in MTF + * Implemented mechanism of cleaning up all data after scenario execution + * Fixed integration testLayoutFilesTest +* Design improvements: + * New look&feel for Collapsible Panels in backend + * New look&feel for System Warnings Pop-Ups in backend + * New look&feel for Grid Tables in backend +* Various improvements: + * Implemented checkout UI rendering in browser + * Added exact image sizes provision in templates + * Added width and height attributes to Frontend logo + * Integrated JIT(Just In Time) plugin loader for Grunt.js + * Handling Invalid Less During PHP Compilation + * Enhanced PageCache invalidation + * Private data rendering in browser based on JSON data obtained from server side and kept in Local Storage instead of HTML obtained using AJAX PageCache action + * Refactor blocks on most frequently used pages (Catalog, CMS) to use new private data rendering mechanism + * Refactor blocks which can be added on any page (like widgets, banners) to use new private data rendering mechanism + * Default PageCache entries TTL value increased from 2 minutes to 24 hours + * Cache entries invalidation logging was introduced in order to simplify running of invalidation process +* Fixed bugs: + * Fixed an issue where orders total report was not showing results grouped by day + * Fixed an issue with non-displaying Abandoned Carts report grid + * Fixed integration test failure in Reports GridTest + * Fixed an issue where fixed bundle product could not be created + * Fixed an issue where grouped product with quantity 0 was added to cart with quantity of 1 + * Fixed an issue where versions tab was absent after publish CMS page + * Fixed an issue where shopping cart was empty after attempt to update it + * Fixed an issue where there was no redirect to shopping cart after EDIT/UPDATE cart product if custom options + * Fixed an issue where New Accounts report did not work + * Fixed bug when Admin user wasn't locked after exceeding maximum login failures attempts + * Fixed an issue where downloadable Product detailed info wasn't displayed in Cart & on Checkout + * Fixed an issue with wrong copyright year for store front + * Fixed: JSMinException when deploying static files in production mode with minification enabled + * Fixed: Overlapped FPT Attribute in Mini Shopping Cart + * Fixed: View of current item for Customer menu tabs + * Fixed an issue where status label was not refreshed when disabling/enabling cache + * Fixed an issue where Success Page of Web Setup did not show https + * Fixed an issue with irrelevant/unused template + * Fixed an issue where static content running setup:static-content:deploy with language code {a-Z}{a-Z}{a-Z} couldn't be generated + * [Usability] Output from language, and timezone help commands is alphabetized + * Fixed an issue with two identical IdentityInterface definitions in code base. + * Fixed an issue where default value of timezone in installer was not correct + * Fixed an issue where bank Transfer payment instructions were not displayed + * Fixed an issue when New Accounts report did not work + * Fixed an issue when New Accounts report showed invalid data + * Fixed an issue with Exception in setup wizard after Magento is installed + * Fixed visual misfits for Custom Options on "edit Bundle Product" Frontend page + * Fixed broken layout for configurable variations when changing from pricing measure from $ to % + * Fixed widget UI issues on Frontend + * Fixed an issue with Float button bar on Backend + * Fixed UI issue shown in ACL Resource Tree + * Fixed an issue where it was not possible to place order on frontend using secure urls + * Fixed an issue with wrong behaviour for save new shipping address during checkout + * Fixed an issue with customers information leak via Checkout + * Fixed an issue where users could not login to Magento admin & front on HipHop Virtual Machine + * Fixed an issue where product Options details were not shown in Mini Cart + * Fixed an issue where Create Permanent Redirect check-box was inactive on Edit Category page + * Fixed an issue where it was impossible to perform product mass update + * Fixed an issue where category redirect was absent after update category url +* Github issues: + * [#566](https://github.com/magento/magento2/issues/566) -- Fulltext search index: slow query in resetSearchResults() + * [#1269](https://github.com/magento/magento2/issues/1269) -- Magento dashboard revenue ,shipping ,qty,tax all are 0. + * [#1200](https://github.com/magento/magento2/issues/1200) -- I'm not getting default values (name & email) in contact form when i logged in + * [#1087](https://github.com/magento/magento2/pull/1087) -- Check for select and multiselect to ignore corrupted attributes + * [#1268](https://github.com/magento/magento2/issues/1268) -- Dist front: search is broken + * [#1195](https://github.com/magento/magento2/pull/1195) -- Use table alias for qty field + * [#1274](https://github.com/magento/magento2/pull/1274) -- CatalogImportExport validation + * [#1233](https://github.com/magento/magento2/issues/1233) -- Wrong message when moving a category + * [#1040](https://github.com/magento/magento2/issues/1040) -- Required date validation on Magento2 Backend + * [#1246](https://github.com/magento/magento2/issues/1246) -- How to load product store wise? + * [#1222](https://github.com/magento/magento2/issues/1222) -- Sku attribute save error + * [#1237](https://github.com/magento/magento2/issues/1237) -- Category admin reset button does nothing + * [#1046](https://github.com/magento/magento2/issues/1046) -- Two equal files + * [#1282](https://github.com/magento/magento2/pull/1282), [#1285](https://github.com/magento/magento2/pull/1285) -- Fix broken link in CHANGELOG.md + * [#1223](https://github.com/magento/magento2/issues/1223) -- Store config re-encrypt encrypted values on save + * [#1242](https://github.com/magento/magento2/issues/1242) -- Eclipse pdt validator error + 0.74.0-beta9 ============= * Framework improvements @@ -9,7 +142,7 @@ * Refactored controller actions in the Product area * Moved commands cache.php, indexer.php, log.php, test.php, compiler.php, singletenant\_compiler.php, generator.php, pack.php, deploy.php and file\_assembler.php to the new bin/magento CLI framework * Data Migration Tool - * The Data Migraiton Tool is published in the separate [repository](https://github.com/magento/data-migration-tool-ce, "Data Migration Tool repository") + * The Data Migraiton Tool is published in the separate [repository](https://github.com/magento/data-migration-tool-ce "Data Migration Tool repository") * Fixed bugs * Fixed an issue where error appeared during placing order with virtual product * Fixed an issue where billing and shipping sections didn't contain address information on order print diff --git a/Gruntfile.js b/Gruntfile.js index dbdca189e092f..4718c7cb6dbe4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,17 +23,17 @@ module.exports = function (grunt) { require('load-grunt-config')(grunt, { configPath: path.join(__dirname, configDir), init: true, - loadGruntTasks: { - pattern: [ - 'grunt-*' - ] + jitGrunt: { + staticMappings: { + usebanner: 'grunt-banner' + } } }); _.each({ /** * Assembling tasks. - * ToDo UI: define default tasks. + * ToDo: define default tasks. */ default: function () { grunt.log.subhead('I\'m default task and at the moment I\'m empty, sorry :/'); @@ -43,17 +43,19 @@ module.exports = function (grunt) { * Production preparation task. */ prod: function (component) { - if (component === 'setup') { - grunt.task.run([ - 'less:' + component, - 'autoprefixer:' + component, - 'cssmin:' + component, - 'usebanner:' + component - ]); - } + var tasks = [ + 'less', + 'autoprefixer', + 'cssmin', + 'usebanner' + ].map(function(task){ + return task + ':' + component; + }); if (typeof component === 'undefined') { grunt.log.subhead('Tip: Please make sure that u specify prod subtask. By default prod task do nothing'); + } else { + grunt.task.run(tasks); } }, diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 9bd1aaf5df08d..949ba575abe85 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -123,6 +123,7 @@ public function getSystemMessageDialogJson() 'autoOpen' => false, 'width' => '75%', 'modal' => true, + 'minHeight' => '0', 'dialogClass' => 'ui-dialog-active ui-popup-message', 'ajaxUrl' => $this->_getMessagesUrl() ], diff --git a/app/code/Magento/AdminNotification/Model/Feed.php b/app/code/Magento/AdminNotification/Model/Feed.php index 99f3b30a2ce45..ddbb35a31bb6d 100644 --- a/app/code/Magento/AdminNotification/Model/Feed.php +++ b/app/code/Magento/AdminNotification/Model/Feed.php @@ -5,7 +5,7 @@ */ namespace Magento\AdminNotification\Model; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; /** * AdminNotification Feed model @@ -137,7 +137,7 @@ public function checkUpdate() $feedXml = $this->getFeedData(); - $installDate = strtotime($this->_deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE)); + $installDate = strtotime($this->_deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)); if ($feedXml && $feedXml->channel && $feedXml->channel->item) { foreach ($feedXml->channel->item as $item) { @@ -239,6 +239,8 @@ public function getFeedData() } /** + * Retrieve feed as XML element + * * @return \SimpleXMLElement */ public function getFeedXml() diff --git a/app/code/Magento/AdminNotification/Model/Inbox.php b/app/code/Magento/AdminNotification/Model/Inbox.php index f10b4f031276e..6bac69b76c77c 100644 --- a/app/code/Magento/AdminNotification/Model/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/Inbox.php @@ -7,6 +7,7 @@ use Magento\Framework\Notification\MessageInterface; use Magento\Framework\Notification\NotifierInterface; +use Magento\AdminNotification\Model\InboxInterface; /** * AdminNotification Inbox model @@ -30,7 +31,7 @@ * * @author Magento Core Team */ -class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface +class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface, InboxInterface { /** * @return void @@ -41,10 +42,7 @@ protected function _construct() } /** - * Retrieve Severity collection array - * - * @param int|null $severity - * @return array|string|null + * {@inheritdoc} */ public function getSeverities($severity = null) { @@ -66,9 +64,7 @@ public function getSeverities($severity = null) } /** - * Retrieve Latest Notice - * - * @return $this + * {@inheritdoc} */ public function loadLatestNotice() { @@ -78,9 +74,7 @@ public function loadLatestNotice() } /** - * Retrieve notice statuses - * - * @return array + * {@inheritdoc} */ public function getNoticeStatus() { diff --git a/app/code/Magento/AdminNotification/Model/InboxInterface.php b/app/code/Magento/AdminNotification/Model/InboxInterface.php new file mode 100644 index 0000000000000..1295c5ba8a285 --- /dev/null +++ b/app/code/Magento/AdminNotification/Model/InboxInterface.php @@ -0,0 +1,39 @@ + + */ +interface InboxInterface +{ + /** + * Retrieve Severity collection array + * + * @param int|null $severity + * @return array|string|null + * @api + */ + public function getSeverities($severity = null); + + /** + * Retrieve Latest Notice + * + * @return $this + * @api + */ + public function loadLatestNotice(); + + /** + * Retrieve notice statuses + * + * @return array + * @api + */ + public function getNoticeStatus(); +} diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index 2e7a56b69c91e..8bed182bb2662 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\AdminNotification\Model\System\Message; use Magento\Store\Model\Store; @@ -121,7 +119,9 @@ public function isDisplayed() public function getText() { return __( - '{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. It is highly recommended to change this value in your Magento configuration.', + '{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure ' + . 'URL / Base Secure URL. It is highly recommended to change this value in your Magento ' + . 'configuration.', $this->_getConfigUrl() ); } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php index 748ec28eddf7b..88e85643d784e 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\AdminNotification\Model\System\Message\Media\Synchronization; class Error extends \Magento\AdminNotification\Model\System\Message\Media\AbstractSynchronization @@ -36,7 +34,8 @@ protected function _shouldBeDisplayed() public function getText() { return __( - 'One or more media files failed to be synchronized during the media storages synchronization process. Refer to the log file for details.' + 'One or more media files failed to be synchronized during the media storages synchronization process. ' + . 'Refer to the log file for details.' ); } } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php index 378596188378e..7462ab7c8370a 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\AdminNotification\Model\System\Message; use Magento\Store\Model\Store; @@ -26,6 +24,7 @@ class Security implements \Magento\Framework\Notification\MessageInterface /** * Time out for HTTP verification request + * * @var int */ private $_verificationTimeOut = 2; @@ -136,7 +135,8 @@ public function isDisplayed() public function getText() { return __( - 'Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside. Please contact your hosting provider.' + 'Your web server is configured incorrectly. As a result, configuration files ' + . ' with sensitive information are accessible from the outside. Please contact your hosting provider.' ); } diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php index 00ebf99bdcf24..5ef5ca8bc970b 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php @@ -7,7 +7,7 @@ namespace Magento\AdminNotification\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -141,7 +141,7 @@ public function testCheckUpdate($callInbox, $curlRequest) $this->backendConfig->expects($this->at(1))->method('getValue') ->will($this->returnValue('http://feed.magento.com')); $this->deploymentConfig->expects($this->once())->method('get') - ->with(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE) + ->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE) ->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC')); if ($callInbox) { $this->inboxFactory->expects($this->once())->method('create') diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index 1ff43cfd52a30..ce97ab237f9cd 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml index c0818bb7a81f9..3652e763a1c9b 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml +++ b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml @@ -31,6 +31,7 @@ require([ resizable: false, width: '75%', modal: true, + minHeight: '0', dialogClass: 'ui-popup-message', position: { my: 'left+12.5% top', diff --git a/app/code/Magento/Authorization/Model/UserContextInterface.php b/app/code/Magento/Authorization/Model/UserContextInterface.php index 1a814873f48d4..18287aeb658c4 100644 --- a/app/code/Magento/Authorization/Model/UserContextInterface.php +++ b/app/code/Magento/Authorization/Model/UserContextInterface.php @@ -24,6 +24,7 @@ interface UserContextInterface * Identify current user ID. * * @return int|null + * @api */ public function getUserId(); @@ -31,6 +32,7 @@ public function getUserId(); * Retrieve current user type. * * @return int|null + * @api */ public function getUserType(); } diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index d841928ce1108..1477b5edab926 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.5.0|~5.6.0", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Backend/App/AbstractAction.php b/app/code/Magento/Backend/App/AbstractAction.php index 4be4b77472880..952ff01c1bcc9 100644 --- a/app/code/Magento/Backend/App/AbstractAction.php +++ b/app/code/Magento/Backend/App/AbstractAction.php @@ -285,7 +285,7 @@ public function _processUrlKeys() protected function _processLocaleSettings() { $forceLocale = $this->getRequest()->getParam('locale', null); - if ($this->_objectManager->get('Magento\Framework\Locale\Validator')->isValid($forceLocale)) { + if ($this->_objectManager->get('Magento\Framework\Validator\Locale')->isValid($forceLocale)) { $this->_getSession()->setSessionLocale($forceLocale); } diff --git a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php index 380409e7bdcce..a38e4cfedc5c3 100644 --- a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php +++ b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php @@ -7,6 +7,9 @@ use Magento\Framework\Exception\AuthenticationException; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Authentication { /** @@ -45,25 +48,49 @@ class Authentication */ protected $messageManager; + /** + * @var \Magento\Backend\Model\UrlInterface + */ + protected $backendUrl; + + /** + * @var \Magento\Backend\App\BackendAppList + */ + protected $backendAppList; + + /** + * @var \Magento\Framework\Controller\Result\RedirectFactory + */ + protected $resultRedirectFactory; + /** * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\Model\UrlInterface $url * @param \Magento\Framework\App\ResponseInterface $response * @param \Magento\Framework\App\ActionFlag $actionFlag * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param \Magento\Backend\Model\UrlInterface $backendUrl + * @param \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory + * @param \Magento\Backend\App\BackendAppList $backendAppList */ public function __construct( \Magento\Backend\Model\Auth $auth, \Magento\Backend\Model\UrlInterface $url, \Magento\Framework\App\ResponseInterface $response, \Magento\Framework\App\ActionFlag $actionFlag, - \Magento\Framework\Message\ManagerInterface $messageManager + \Magento\Framework\Message\ManagerInterface $messageManager, + \Magento\Backend\Model\UrlInterface $backendUrl, + \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory, + \Magento\Backend\App\BackendAppList $backendAppList ) { $this->_auth = $auth; $this->_url = $url; $this->_response = $response; $this->_actionFlag = $actionFlag; $this->messageManager = $messageManager; + $this->backendUrl = $backendUrl; + $this->resultRedirectFactory = $resultRedirectFactory; + $this->backendAppList = $backendAppList; } /** @@ -90,6 +117,18 @@ public function aroundDispatch( $this->_processNotLoggedInUser($request); } else { $this->_auth->getAuthStorage()->prolong(); + + $backendApp = null; + if ($request->getParam('app')) { + $backendApp = $this->backendAppList->getCurrentApp(); + } + + if ($backendApp) { + $resultRedirect = $this->resultRedirectFactory->create(); + $baseUrl = \Magento\Framework\App\Request\Http::getUrlNoScript($this->backendUrl->getBaseUrl()); + $baseUrl = $baseUrl . $backendApp->getStartupPage(); + return $resultRedirect->setUrl($baseUrl); + } } } $this->_auth->getAuthStorage()->refreshAcl(); diff --git a/app/code/Magento/Backend/App/BackendApp.php b/app/code/Magento/Backend/App/BackendApp.php new file mode 100644 index 0000000000000..a912c8b4f6d5b --- /dev/null +++ b/app/code/Magento/Backend/App/BackendApp.php @@ -0,0 +1,73 @@ +cookiePath = $cookiePath; + $this->startupPage = $startupPage; + $this->aclResourceName = $aclResourceName; + } + + /** + * Cookie path for the application to set cookie to + * + * @return string + */ + public function getCookiePath() + { + return $this->cookiePath; + } + + /** + * Startup Page of the application to redirect after login + * + * @return string + */ + public function getStartupPage() + { + return $this->startupPage; + } + + /** + * ACL resource name to authorize access to + * + * @return string + */ + public function getAclResource() + { + return $this->aclResourceName; + } +} diff --git a/app/code/Magento/Backend/App/BackendAppList.php b/app/code/Magento/Backend/App/BackendAppList.php new file mode 100644 index 0000000000000..5a39ef354e4f2 --- /dev/null +++ b/app/code/Magento/Backend/App/BackendAppList.php @@ -0,0 +1,62 @@ +backendApps = $backendApps; + $this->request = $request; + } + + /** + * Get Backend app based on its name + * + * @return BackendApp|null + */ + public function getCurrentApp() + { + $appName = $this->request->getQuery('app'); + if ($appName && isset($this->backendApps[$appName])) { + return $this->backendApps[$appName]; + } + } + + /** + * Retrieve backend application by name + * + * @param string $appName + * @return BackendApp|null + */ + public function getBackendApp($appName) + { + if (isset($this->backendApps[$appName])) { + return $this->backendApps[$appName]; + } + return null; + } +} diff --git a/app/code/Magento/Backend/Block/Context.php b/app/code/Magento/Backend/Block/Context.php index 65ff72a54758f..cf30f5e9b400b 100644 --- a/app/code/Magento/Backend/Block/Context.php +++ b/app/code/Magento/Backend/Block/Context.php @@ -24,7 +24,6 @@ class Context extends \Magento\Framework\View\Element\Context * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Framework\TranslateInterface $translator * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Session\SessionManagerInterface $session @@ -47,7 +46,6 @@ public function __construct( \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\TranslateInterface $translator, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Session\SessionManagerInterface $session, @@ -69,7 +67,6 @@ public function __construct( $layout, $eventManager, $urlBuilder, - $translator, $cache, $design, $session, diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index da4142f87c2f1..035a909cb3b38 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -48,7 +48,6 @@ class Context extends \Magento\Framework\View\Element\Template\Context * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Framework\TranslateInterface $translator * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Session\Generic $session @@ -81,7 +80,6 @@ public function __construct( \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\TranslateInterface $translator, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Session\Generic $session, @@ -117,7 +115,6 @@ public function __construct( $layout, $eventManager, $urlBuilder, - $translator, $cache, $design, $session, diff --git a/app/code/Magento/Backend/Block/Widget/Context.php b/app/code/Magento/Backend/Block/Widget/Context.php index 40bb65bc78fba..dacc0fe3379c5 100644 --- a/app/code/Magento/Backend/Block/Widget/Context.php +++ b/app/code/Magento/Backend/Block/Widget/Context.php @@ -31,7 +31,6 @@ class Context extends \Magento\Backend\Block\Template\Context * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Framework\TranslateInterface $translator * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Session\Generic $session @@ -66,7 +65,6 @@ public function __construct( \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\TranslateInterface $translator, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Session\Generic $session, @@ -99,7 +97,6 @@ public function __construct( $layout, $eventManager, $urlBuilder, - $translator, $cache, $design, $session, diff --git a/app/code/Magento/Backend/Block/Widget/Grid.php b/app/code/Magento/Backend/Block/Widget/Grid.php index 1d33dc1814621..b95a5af2763bb 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid.php +++ b/app/code/Magento/Backend/Block/Widget/Grid.php @@ -436,12 +436,12 @@ protected function _prepareFilterButtons() $this->getLayout()->createBlock( 'Magento\Backend\Block\Widget\Button' )->setData( - ['label' => __('Reset Filter'), 'onclick' => $this->getJsObjectName() . '.resetFilter()', 'class' => 'action-reset'] - )->setDataAttribute( [ - 'action' => 'grid-filter-reset' + 'label' => __('Reset Filter'), + 'onclick' => $this->getJsObjectName() . '.resetFilter()', + 'class' => 'action-reset action-tertiary' ] - ) + )->setDataAttribute(['action' => 'grid-filter-reset']) ); $this->setChild( 'search_button', @@ -451,13 +451,9 @@ protected function _prepareFilterButtons() [ 'label' => __('Search'), 'onclick' => $this->getJsObjectName() . '.doFilter()', - 'class' => 'task', + 'class' => 'action-secondary', ] - )->setDataAttribute( - [ - 'action' => 'grid-filter-apply' - ] - ) + )->setDataAttribute(['action' => 'grid-filter-apply']) ); } @@ -820,8 +816,8 @@ public function getMainButtonsHtml() { $html = ''; if ($this->getColumnSet()->isFilterVisible()) { - $html .= $this->getResetFilterButtonHtml(); $html .= $this->getSearchButtonHtml(); + $html .= $this->getResetFilterButtonHtml(); } return $html; } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php index 9288cf5df470c..0404a6050c228 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php @@ -58,7 +58,7 @@ public function getHtml() ' value="' . $this->getEscapedValue( 'from' - ) . '" class="input-text no-changes" placeholder="' . __( + ) . '" class="admin__control-text input-text no-changes" placeholder="' . __( 'From' ) . '" ' . $this->getUiId( 'filter', @@ -74,7 +74,7 @@ public function getHtml() ' value="' . $this->getEscapedValue( 'to' - ) . '" class="input-text no-changes" placeholder="' . __( + ) . '" class="input-text admin__control-text no-changes" placeholder="' . __( 'To' ) . '" ' . $this->getUiId( 'filter', diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php index c06fb05c9a4e0..ccf950fd706b1 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php @@ -66,7 +66,7 @@ public function getHtml() $html = '' . + '' . $value . '' . + $this->_getInputValueElement($row) . '' ; } return $this->_getValue($row); } @@ -123,26 +122,23 @@ public function renderHeader() $dir = strtolower($this->getColumn()->getDir()); $nDir = $dir == 'asc' ? 'desc' : 'asc'; if ($this->getColumn()->getDir()) { - $className = 'sort-arrow-' . $dir; + $className = '_' . $dir . 'end'; } - $out = 'getColumn()->getId() . - '" title="' . + '" data-direction="' . $nDir . - '" class="' . - $className . - '">' . - ''; + ''; } else { - $out = ''; + ''; } return $out; } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php index 2da717929a0ec..6bbbf0b5284bd 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php @@ -55,7 +55,7 @@ public function render(\Magento\Framework\Object $row) } } - $out = '' . ''; $i = 0; foreach ($actions as $action) { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php index bca3b3038445b..867dfc9f56ee2 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php @@ -141,11 +141,11 @@ public function renderHeader() if ($this->getColumn()->getDisabled()) { $disabled = ' disabled="disabled"'; } - $html = 'getColumn()->getFieldName() . '" '; $html .= 'onclick="' . $this->getColumn()->getGrid()->getJsObjectName() . '.checkCheckboxes(this)" '; - $html .= 'class="checkbox"' . $checked . $disabled . ' '; - $html .= 'title="' . __('Select All') . '"/>'; + $html .= 'class="admin__control-checkbox"' . $checked . $disabled . ' '; + $html .= 'title="' . __('Select All') . '"/>'; return $html; } } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php index a805ba971295b..529b3f4e0ddde 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php @@ -63,8 +63,12 @@ public function render(\Magento\Framework\Object $row) */ protected function _getCheckboxHtml($value, $checked) { - $html = 'escapeHtml($value) . '" class="massaction-checkbox"' . $checked . '/>'; + $id = 'id_' . rand(0, 999); + $html = ''; return $html; } } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Extended.php index 516c3eaae5040..e19827a61b65a 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Extended.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Extended.php @@ -206,7 +206,7 @@ protected function _prepareLayout() [ 'label' => __('Reset Filter'), 'onclick' => $this->getJsObjectName() . '.resetFilter()', - 'class' => 'action-reset' + 'class' => 'action-reset action-tertiary' ] )->setDataAttribute( [ @@ -220,7 +220,7 @@ protected function _prepareLayout() [ 'label' => __('Search'), 'onclick' => $this->getJsObjectName() . '.doFilter()', - 'class' => 'task', + 'class' => 'task action-secondary', ] )->setDataAttribute( [ @@ -1302,8 +1302,8 @@ public function getMainButtonsHtml() { $html = ''; if ($this->getFilterVisibility()) { - $html .= $this->getResetFilterButtonHtml(); $html .= $this->getSearchButtonHtml(); + $html .= $this->getResetFilterButtonHtml(); } return $html; } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/BackendApp/Redirect.php b/app/code/Magento/Backend/Controller/Adminhtml/BackendApp/Redirect.php new file mode 100644 index 0000000000000..f622e39e4917e --- /dev/null +++ b/app/code/Magento/Backend/Controller/Adminhtml/BackendApp/Redirect.php @@ -0,0 +1,65 @@ +backendAppList = $backendAppList; + } + + /** + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + $resultRedirect = $this->resultRedirectFactory->create(); + if ($this->getRequest()->getParam('app')) { + $url = $this->getUrl('*/*/*', []) . '?app=' . $this->getRequest()->getParam('app'); + return $resultRedirect->setUrl($url); + } + return $resultRedirect->setUrl($this->getUrl('*/index/index')); + } + + /** + * @return bool + */ + protected function _isAllowed() + { + $backendApp = $this->backendAppList->getBackendApp( + $this->getRequest()->getParam('app') + ); + if ($backendApp) { + return $this->_authorization->isAllowed($backendApp->getAclResource()); + } + return true; + } +} diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php index 06ade97d1e905..ffe913807319e 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php @@ -33,7 +33,7 @@ public function execute() ->setLastname($this->getRequest()->getParam('lastname', false)) ->setEmail(strtolower($this->getRequest()->getParam('email', false))); - if ($this->_objectManager->get('Magento\Framework\Locale\Validator')->isValid($interfaceLocale)) { + if ($this->_objectManager->get('Magento\Framework\Validator\Locale')->isValid($interfaceLocale)) { $user->setInterfaceLocale($interfaceLocale); /** @var \Magento\Backend\Model\Locale\Manager $localeManager */ $localeManager = $this->_objectManager->get('Magento\Backend\Model\Locale\Manager'); diff --git a/app/code/Magento/Backend/Helper/Dashboard/Data.php b/app/code/Magento/Backend/Helper/Dashboard/Data.php index 601c68c131ebd..4fe2b5d5b131c 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Data.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Data.php @@ -6,7 +6,7 @@ namespace Magento\Backend\Helper\Dashboard; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; /** * Data helper for dashboard @@ -41,7 +41,7 @@ public function __construct( parent::__construct( $context ); - $this->_installDate = $deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE); + $this->_installDate = $deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE); $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php index a15f8e1526e07..215111aee82e9 100644 --- a/app/code/Magento/Backend/Model/Auth.php +++ b/app/code/Magento/Backend/Model/Auth.php @@ -175,7 +175,7 @@ public function login($username, $password) 'backend_auth_user_login_failed', ['user_name' => $username, 'exception' => $e] ); - self::throwException(__('Please correct the user name or password.')); + self::throwException(__($e->getMessage()? : 'Please correct the user name or password.')); } } diff --git a/app/code/Magento/Backend/Model/Locale/Resolver.php b/app/code/Magento/Backend/Model/Locale/Resolver.php index b27fcf1468311..c7002cc6abe27 100644 --- a/app/code/Magento/Backend/Model/Locale/Resolver.php +++ b/app/code/Magento/Backend/Model/Locale/Resolver.php @@ -26,7 +26,7 @@ class Resolver extends \Magento\Framework\Locale\Resolver protected $_request; /** - * @var \Magento\Framework\Locale\Validator + * @var \Magento\Framework\Validator\Locale */ protected $_localeValidator; @@ -37,7 +37,7 @@ class Resolver extends \Magento\Framework\Locale\Resolver * @param \Magento\Backend\Model\Session $session * @param Manager $localeManager * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\Locale\Validator $localeValidator + * @param \Magento\Framework\Validator\Locale $localeValidator * @param null $locale * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -48,7 +48,7 @@ public function __construct( \Magento\Backend\Model\Session $session, \Magento\Backend\Model\Locale\Manager $localeManager, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\Locale\Validator $localeValidator, + \Magento\Framework\Validator\Locale $localeValidator, $locale = null ) { $this->_session = $session; diff --git a/app/code/Magento/Backend/Model/Session/AdminConfig.php b/app/code/Magento/Backend/Model/Session/AdminConfig.php index 564f9540a9703..532a7f0446c63 100644 --- a/app/code/Magento/Backend/Model/Session/AdminConfig.php +++ b/app/code/Magento/Backend/Model/Session/AdminConfig.php @@ -34,6 +34,11 @@ class AdminConfig extends Config */ protected $_storeManager; + /** + * @var \Magento\Backend\App\BackendAppList + */ + private $backendAppList; + /** * @param \Magento\Framework\ValidatorFactory $validatorFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -42,6 +47,7 @@ class AdminConfig extends Config * @param Filesystem $filesystem * @param DeploymentConfig $deploymentConfig * @param string $scopeType + * @param \Magento\Backend\App\BackendAppList $backendAppList * @param FrontNameResolver $frontNameResolver * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param string $lifetimePath @@ -56,6 +62,7 @@ public function __construct( Filesystem $filesystem, DeploymentConfig $deploymentConfig, $scopeType, + \Magento\Backend\App\BackendAppList $backendAppList, FrontNameResolver $frontNameResolver, \Magento\Store\Model\StoreManagerInterface $storeManager, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME, @@ -71,9 +78,9 @@ public function __construct( $scopeType, $lifetimePath ); - $this->_frontNameResolver = $frontNameResolver; $this->_storeManager = $storeManager; + $this->backendAppList = $backendAppList; $adminPath = $this->extractAdminPath(); $this->setCookiePath($adminPath); $this->setName($sessionName); @@ -86,10 +93,17 @@ public function __construct( */ private function extractAdminPath() { - $parsedUrl = parse_url($this->_storeManager->getStore()->getBaseUrl()); - $baseUrl = $parsedUrl['path']; - $adminPath = $this->_frontNameResolver->getFrontName(); - - return $baseUrl . $adminPath; + $backendApp = $this->backendAppList->getCurrentApp(); + $cookiePath = null; + $baseUrl = parse_url($this->_storeManager->getStore()->getBaseUrl(), PHP_URL_PATH); + if (!$backendApp) { + $cookiePath = $baseUrl . $this->_frontNameResolver->getFrontName(); + return $cookiePath; + } + //In case of application authenticating through the admin login, the script name should be removed + //from the path, because application has own script. + $baseUrl = \Magento\Framework\App\Request\Http::getUrlNoScript($baseUrl); + $cookiePath = $baseUrl . $backendApp->getCookiePath(); + return $cookiePath; } } diff --git a/app/code/Magento/Backend/Setup/ConfigOptionsList.php b/app/code/Magento/Backend/Setup/ConfigOptionsList.php index 83a953cd2f223..2a6a39f88af73 100644 --- a/app/code/Magento/Backend/Setup/ConfigOptionsList.php +++ b/app/code/Magento/Backend/Setup/ConfigOptionsList.php @@ -19,7 +19,7 @@ class ConfigOptionsList implements ConfigOptionsListInterface /** * Input key for the options */ - const INPUT_KEY_BACKEND_FRONTNAME = 'backend_frontname'; + const INPUT_KEY_BACKEND_FRONTNAME = 'backend-frontname'; /** * Path to the values in the deployment config @@ -48,7 +48,7 @@ public function getOptions() */ public function createConfig(array $options, DeploymentConfig $deploymentConfig) { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); + $configData = new ConfigData(ConfigFilePool::APP_ENV); if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) { $configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]); @@ -60,7 +60,7 @@ public function createConfig(array $options, DeploymentConfig $deploymentConfig) /** * {@inheritdoc} */ - public function validate(array $options) + public function validate(array $options, DeploymentConfig $deploymentConfig) { $errors = []; if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME]) diff --git a/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php b/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php index 04873cb730437..5958ae65d94c7 100644 --- a/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php @@ -10,7 +10,7 @@ class UserConfigTest extends \PHPUnit_Framework_TestCase { public function testUserRequestCreation() { - $factoryMock = $this->getMock('Magento\Config\Model\Config\Factory', [], [], '', false); + $factoryMock = $this->getMock('Magento\Config\Model\Config\Factory', ['create'], [], '', false); $responseMock = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); $configMock = $this->getMock('Magento\Config\Model\Config', [], [], '', false); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php index 012d90382443e..44907b2e8a1e2 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php @@ -33,7 +33,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\User\Model\User */ protected $_userMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Locale\Validator */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Validator\locale */ protected $_validatorMock; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Locale\Manager */ @@ -80,7 +80,7 @@ protected function setUp() ) ->getMock(); - $this->_validatorMock = $this->getMockBuilder('Magento\Framework\Locale\Validator') + $this->_validatorMock = $this->getMockBuilder('Magento\Framework\Validator\Locale') ->disableOriginalConstructor() ->setMethods(['isValid']) ->getMock(); @@ -172,7 +172,7 @@ public function testSaveAction() )->method( 'get' )->with( - $this->equalTo('Magento\Framework\Locale\Validator') + $this->equalTo('Magento\Framework\Validator\Locale') )->will( $this->returnValue($this->_validatorMock) ); diff --git a/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php b/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php index ba0f8c12d3d39..1d713187c130b 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php @@ -59,7 +59,8 @@ public function testLoginFailed() ->method('create') ->with('Magento\Backend\Model\Auth\Credential\StorageInterface') ->will($this->returnValue($this->_credentialStorage)); - $exceptionMock = new \Magento\Framework\Exception\LocalizedException(__('message')); + $exceptionMock = + new \Magento\Framework\Exception\LocalizedException(__('Please correct the user name or password.')); $this->_credentialStorage ->expects($this->once()) ->method('login') diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index fd3af33800233..1c89077b1b161 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -177,7 +177,7 @@ protected function setUp() ); $this->orderFactoryMock = $this->getMock( 'Magento\Sales\Model\OrderFactory', - [], + ['create'], [], '', false diff --git a/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php b/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php index 279d11ddfbff8..596834426c74e 100644 --- a/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php +++ b/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php @@ -42,7 +42,7 @@ public function testCreateConfig() $expectedData = [ [ - 'file' => ConfigFilePool::APP_CONFIG, + 'file' => ConfigFilePool::APP_ENV, 'segment' => 'backend', 'data' => [ 'backend' => ['frontName' => 'admin'] @@ -62,7 +62,7 @@ public function testCreateConfig() public function testValidate() { $options = [ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'admin']; - $errors = $this->object->validate($options); + $errors = $this->object->validate($options, $this->deploymentConfig); $this->assertEmpty($errors); } @@ -73,7 +73,7 @@ public function testValidate() */ public function testValidateInvalid(array $options, $expectedError) { - $errors = $this->object->validate($options); + $errors = $this->object->validate($options, $this->deploymentConfig); $this->assertSame([$expectedError], $errors); } diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index 6438f78960f6f..2f0f0eb54f449 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-developer": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-cron": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-reports": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-user": "0.74.0-beta9", - "magento/module-backup": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-translation": "0.74.0-beta9", - "magento/module-require-js": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-developer": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-cron": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-reports": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-user": "0.74.0-beta11", + "magento/module-backup": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-translation": "0.74.0-beta11", + "magento/module-require-js": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Backend/etc/acl.xml b/app/code/Magento/Backend/etc/acl.xml index 2a37baeb42262..01b54591ef6ef 100644 --- a/app/code/Magento/Backend/etc/acl.xml +++ b/app/code/Magento/Backend/etc/acl.xml @@ -38,6 +38,7 @@ + diff --git a/app/code/Magento/Backend/etc/adminhtml/menu.xml b/app/code/Magento/Backend/etc/adminhtml/menu.xml index 08f50423e9818..acba492937e56 100644 --- a/app/code/Magento/Backend/etc/adminhtml/menu.xml +++ b/app/code/Magento/Backend/etc/adminhtml/menu.xml @@ -27,5 +27,6 @@ + diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index a0617b8e645a4..56a68a70f058c 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -160,4 +160,18 @@ + + + setup + setup + Magento_Backend::setup_wizard + + + + + + Magento\Setup\BackendApp + + + diff --git a/app/code/Magento/Backend/view/adminhtml/layout/default.xml b/app/code/Magento/Backend/view/adminhtml/layout/default.xml index d7b6b01231109..f52bbb4f8021f 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/default.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/default.xml @@ -42,9 +42,6 @@ - - - diff --git a/app/code/Magento/Backend/view/adminhtml/templates/admin/login_buttons.phtml b/app/code/Magento/Backend/view/adminhtml/templates/admin/login_buttons.phtml index 6d155f3d05cc5..c9916a41e983d 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/admin/login_buttons.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/admin/login_buttons.phtml @@ -7,7 +7,7 @@
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/dashboard/grid.phtml b/app/code/Magento/Backend/view/adminhtml/templates/dashboard/grid.phtml index e9a724fdbf857..9ee5d5025d968 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/dashboard/grid.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/dashboard/grid.phtml @@ -25,7 +25,7 @@ $numColumns = sizeof($block->getColumns()); getHeadersVisibility()): ?> getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>>getHeaderHtml() ?> + getHeaderHtml() ?> diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/js/translate.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/js/translate.phtml deleted file mode 100644 index a1d60a9ec5109..0000000000000 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/js/translate.phtml +++ /dev/null @@ -1,52 +0,0 @@ - - - - __('Please select an option.'), - 'This is a required field.' => __('This is a required field.'), - 'Please enter a valid number in this field.' => __('Please enter a valid number in this field.'), - 'Please enter only numbers (1-9) into this field. Do not use spaces, commas, or any other characters.' => __('Please enter only numbers (1-9) into this field. Do not use spaces, commas, or any other characters.'), - 'Please enter only letters (a-z) into this field.' => __('Please enter only letters (a-z) into this field.'), - 'Please enter only numbers (0-9) or letters (a-z) into this field.' => __('Please enter only numbers (0-9) or letters (a-z) into this field.'), - 'Please enter only numbers or letters into this field. Do not use spaces, commas, or any other characters.' => __('Please enter only numbers or letters into this field. Do not use spaces, commas, or any other characters.'), - 'Please enter only letters (a-z), numbers (0-9), spaces and the "#" character into this field.' => __('Please enter only letters (a-z), numbers (0-9), spaces and the "#" character into this field.'), - 'Please enter a valid phone number (for example, (123) 456-7890 or 123-456-7890).' => __('Please enter a valid phone number (for example, (123) 456-7890 or 123-456-7890).'), - 'Please enter a valid date.' => __('Please enter a valid date.'), - 'Please enter a valid email address(for example johndoe@domain.com.).' => __('Please enter a valid email address(for example johndoe@domain.com.).'), - 'Please enter 6 or more characters.' => __('Please enter 6 or more characters.'), - 'Please make sure your passwords match.' => __('Please make sure your passwords match.'), - 'Please enter a valid URL (for example, the URL must begin with "http://").' => __('Please enter a valid URL (for example, the URL must begin with "http://").'), - 'Please enter a valid URL (for examples, http://www.example.com or www.example.com).' => __('Please enter a valid URL (for examples, http://www.example.com or www.example.com).'), - 'Please enter a valid social security number (for example, 123-45-6789).' => __('Please enter a valid social security number (for example, 123-45-6789).'), - 'Please enter a valid zip code (for example, 90602 or 90602-1234).' => __('Please enter a valid zip code (for example, 90602 or 90602-1234).'), - 'Please enter a valid zip code.' => __('Please enter a valid zip code.'), - 'Please use this date format: dd/mm/yyyy. For example, enter "17/03/2006" to represent March 17, 2006.' => __('Please use this date format: dd/mm/yyyy. For example, enter "17/03/2006" to represent March 17, 2006.'), - 'Please enter a valid dollar amount (for example, $100.00).' => __('Please enter a valid dollar amount (for example, $100.00).'), - 'Please select one of these options.' => __('Please select one of these options.'), - 'Please select an option.' => __('Please select an option.'), - 'Please enter a valid URL (for example, the URL must begin with "http://").' => __('Please enter a valid URL (for example, the URL must begin with "http://").'), - 'Please select State/Province.' => __('Please select State/Province.'), - 'Please enter a valid password.' => __('Please enter a valid password.'), - 'Please enter a number greater than 0 in this field.' => __('Please enter a number greater than 0 in this field.'), - 'Please enter a valid credit card number.' => __('Please enter a valid credit card number.'), - 'Please wait, loading...' => __('Please wait, loading...'), -]; -?> - diff --git a/app/code/Magento/Backend/view/adminhtml/templates/system/cache/edit.phtml b/app/code/Magento/Backend/view/adminhtml/templates/system/cache/edit.phtml index c96c9a0c43738..976fa606ed42d 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/system/cache/edit.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/system/cache/edit.phtml @@ -37,7 +37,7 @@

- +
getCatalogData() as $_item): ?> @@ -70,7 +70,7 @@
-
+
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/system/info.phtml b/app/code/Magento/Backend/view/adminhtml/templates/system/info.phtml deleted file mode 100644 index c87029504a287..0000000000000 --- a/app/code/Magento/Backend/view/adminhtml/templates/system/info.phtml +++ /dev/null @@ -1,121 +0,0 @@ - - -
-

-
-

Last Logged in: June, 16, 2007 ( Currently OFFLINE )
- Account Created on: April 01, 2001
- Account Created in: Magento Store

-
- Default Billing Address
- Yoav Kutner
- 3402 Motor Ave Suite B
- Los Angeles, CA 90034
- United States
- T | (310) 123-1234
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
StoreLifetime SaleAverage Sale
Total$2076.97$116.74
Magento Store (EN)$1875.99$89.99
Varien Store (EN)$200.98$26.75
- - - -
-
-
-
Last 5 Orders
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Order #DateShip ToOrder TotalBought From
2DRF23406/15/2007Yoav Kutner$65.50Magento Store (EN)View
Z1234124701/12/2007Yoav Kutner$98.75Varien Store (EN)View
Z987614507/30/2006Yoav Kutner$124.99Magento Store (EN)View
Z012312303/26/2006Yoav Kutner$70.99Magento Store (EN)View
S1230K8901/17/2006Yoav Kutner$54.65Magento Store (EN)View
-
Shopping Cart (3 items)
-
-
Wishlist (1 item)
-
-
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset.phtml index 88470e31c7d16..ed79720277308 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset.phtml @@ -38,11 +38,13 @@ if ($isField) { */ ?> -
- > + > getLegend() ?> diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml index ce39df8da943b..c750a63e8e1e4 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml @@ -22,152 +22,161 @@ $numColumns = sizeof($block->getColumns()); ?> getCollection()): ?> + canDisplayContainer()): ?> - getGridHeader()): ?> -
-

getGridHeader(); ?>

-
- +
+ +getLayout()->getMessagesBlock()->getGroupedHtml() ?> + + +
+ getChildBlock('grid.massaction') && $block->getChildBlock('grid.massaction')->isAvailable() ?> + getPagerVisibility() || $block->getExportTypes() || $block->getChildBlock('grid.columnSet')->getFilterVisibility()): ?> +
+ + getMainButtonsHtml() ? '
' . $block->getMainButtonsHtml() . '
' : ''; ?> + -
- - getLayout()->getMessagesBlock()->getGroupedHtml() ?> - - getPagerVisibility() || $block->getExportTypes() || $block->getChildBlock('grid.columnSet')->getFilterVisibility()): ?> -
getChildBlock('grid.export')): ?> -
- getChildHtml('grid.export'); ?> -
+ getChildHtml('grid.export'); ?> -
- getMainButtonsHtml() ?> -
- getPagerVisibility()): ?> -
- getCollection()->getSize(); ?> - - getUiId('total-count') ?>> +
+ +
+ + getChildHtml('grid.massaction') ?> + + getMainButtonsHtml() ? '
' . $block->getMainButtonsHtml() . '
' : ''; ?> + + getCollection()->getSize(); ?> +
+ getUiId('total-count') ?>> - + + 0
- -
- - getChildBlock('grid.massaction') && $block->getChildBlock('grid.massaction')->isAvailable()): ?> - getChildHtml('grid.massaction') ?> - - - getGridCssClass()): ?> -
- - - getChildHtml('grid.columnSet'); ?> -
-
- -
-
- - - getChildHtml('grid.columnSet'); ?> -
-
getPagerVisibility()): ?> -
- +
+ + +
+ getCollection()->getCurPage() ?> + getCollection()->getLastPageNumber() ?> - getCollection()->getCurPage() ?> - getCollection()->getLastPageNumber() ?> + 1): ?> + + + + - 1): ?> - - - - - - getUiId('current-page') ?> /> - - - getCollection()->getLastPageNumber()) ?> - + getUiId('current-page') ?> /> - - - - - - getChildBlock('grid.bottom.links')): ?> - getChildHtml('grid.bottom.links') ?> - + + + + + + +
+
+
+ getGridCssClass()): ?> + + + getChildHtml('grid.columnSet'); ?> +
+ + + + + getChildHtml('grid.columnSet'); ?> +
+ + getChildBlock('grid.bottom.links')): ?> + getChildHtml('grid.bottom.links') ?> + + - canDisplayContainer()): ?> -
- - getChildBlock('grid.js')): ?> - getChildHtml('grid.js'); ?> - + +getChildBlock('grid.js')): ?> + getChildHtml('grid.js'); ?> + + diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/column_set.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/column_set.phtml index 7474b6b0219be..2ba8f456149f4 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/column_set.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/column_set.phtml @@ -20,31 +20,35 @@ $numColumns = sizeof($block->getColumns()); /* foreach ($block->getColumns() as $_column): ?> getHtmlProperty() ?> /> - isHeaderVisible() || $block->isFilterVisible()): ?> + isHeaderVisible()): ?> - isHeaderVisible()): ?> - + isHeaderVisible() || $block->getFilterVisibility()): ?> + getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>> - getHeaderHtml() ?> - + getHeaderHtml() == ' '):?> + getHeaderHtmlProperty() ?>>  + + getHeaderHtml()?> + isFilterVisible()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>> - getFilterHtml() ?> - - + + getColumns() as $_column): ?> + getHeaderHtmlProperty() ?>> + getFilterHtml() ?> + + + getCollection()->getSize() > 0 && !$block->getIsCollapsed()): ?> getCollection() as $_index => $_item): ?> hasMultipleRows($_item)) :?> @@ -56,7 +60,7 @@ $numColumns = sizeof($block->getColumns()); $_rowspan = $block->getRowspan($_item, $_column); ?> - class="getCssProperty() ?> " + class="getCssProperty() ?> getId() == 'massaction' ? 'data-grid-checkbox-cell': ''?> " > getRowField($_item)) != '' ? $_html : ' ') ?> getColumns()); getMultipleRowColumns($_i) as $_column): ?> getRowField($_i)) != '' ? $_html : ' ') ?> getColumns()); getMultipleRowColumns() as $_column): ?> hasSubtotalsLabel() ? $_column->getSubtotalsLabel() : $_column->getRowField($block->getSubTotals($_item)); @@ -104,7 +108,7 @@ $numColumns = sizeof($block->getColumns()); getColumns() as $_column): ?> shouldRenderCell($_item, $_column)):?> getRowField($_item)) != '' ? $_html : ' ') ?> @@ -122,10 +126,9 @@ $numColumns = sizeof($block->getColumns()); getEmptyText()): ?> - + getEmptyText() ?> + colspan="">getEmptyText() ?> diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/export.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/export.phtml index 94e11d5377914..05387761a7b59 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/export.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/export.phtml @@ -7,13 +7,14 @@ // @codingStandardsIgnoreFile ?> - - - -getExportButtonHtml() ?> +
+ + + getExportButtonHtml() ?> +
\ No newline at end of file diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml index c8f1b79cf2cca..b266fd638eaf6 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml @@ -25,24 +25,25 @@ $numColumns = sizeof($block->getColumns()); ?> getCollection()): ?> canDisplayContainer()): ?> - getGridHeader()): ?> -
-

getGridHeader(); ?>

-
- -
+
getLayout()->getMessagesBlock()->getGroupedHtml() ?> getPagerVisibility() || $block->getExportTypes() || $block->getFilterVisibility()): ?> -
+ getMassactionBlock() && $block->getMassactionBlock()->isAvailable() ?> +
+
+ + getMainButtonsHtml() ? '
' . $block->getMainButtonsHtml() . '
' : ''; ?> + getExportTypes()): ?> -
- +
+ - - - - - - - - +
+ + + +
+ getCollection()->getCurPage() ?> + getCollection()->getLastPageNumber() ?> + 1): ?> + + + + + getUiId('current-page') ?> /> + + + + + + +
+
- getMassactionBlock() && $block->getMassactionBlock()->isAvailable()): ?> - getMassactionBlockHtml() ?> - -
-
- - tags from the code. */ - /* foreach ($block->getColumns() as $_column): ?> - getHtmlProperty() ?> /> - - getHeadersVisibility() || $block->getFilterVisibility()): ?> - - getHeadersVisibility()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>> - getHeaderHtml() ?> - - - - - getFilterVisibility()): ?> - - getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>>getFilterHtml() ?> - - - - - - getCountTotals()): ?> - - + +
+
+ tags from the code. */ + /* foreach ($block->getColumns() as $_column): ?> + getHtmlProperty() ?> /> + + getHeadersVisibility() || $block->getFilterVisibility()): ?> + + getHeadersVisibility()): ?> + getColumns() as $_column): ?> - + getHeaderHtml() == ' '):?> + + + getHeaderHtml()?> + - + getFilterVisibility()): ?> + + getColumns() as $_column): ?> + + + + + + + getCountTotals()): ?> + + + getColumns() as $_column): ?> + + + + + - - getCollection()->getSize() > 0) && (!$block->getIsCollapsed())): ?> - getCollection() as $_index => $_item): ?> - getRowClass($_item)): ?> - class="" >getColumns() as $_column): - if ($block->shouldRenderCell($_item, $_column)): - $_rowspan = $block->getRowspan($_item, $_column); + + getCollection()->getSize() > 0) && (!$block->getIsCollapsed())): ?> + getCollection() as $_index => $_item): ?> + getRowClass($_item)): ?> + class="" >getColumns() as $_column): + if ($block->shouldRenderCell($_item, $_column)): + $_rowspan = $block->getRowspan($_item, $_column); + ?> + shouldRenderEmptyCell($_item, $_column)): ?> - shouldRenderEmptyCell($_item, $_column)): - ?> - getEmptyCellColspan($_item) ?>" + class="last">getEmptyCellLabel() ?> - - getMultipleRows($_item)): ?> - - - getMultipleRowColumns($_i) as $_column): ?> - - - - - - - shouldRenderSubTotal($_item)): ?> - + endif; + endforeach; ?> + + getMultipleRows($_item)): ?> + + getSubTotalColumns() as $_column): ?> - - - - getEmptyText()): ?> - - - - - -
- hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?> - getHeaderHtmlProperty() ?>> 
getHeaderHtmlProperty() ?>> + getFilterHtml() ?> +
+ hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?> +
+ class="getCssProperty() ?> + getId() == 'massaction' ? 'data-grid-checkbox-cell': ''?>"> + getRowField($_item)) != '' ? $_html : ' ') ?> + class="getCssProperty() ?> "> - getRowField($_item)) != '' ? $_html : ' ') ?> - getEmptyCellLabel() ?>
- getRowField($_i)) != '' ? $_html : ' ') ?> -
- hasSubtotalsLabel() ? $_column->getSubtotalsLabel() : - $_column->getRowField($block->getSubTotalItem($_item)) - ); - ?> + foreach ($block->getMultipleRowColumns($_i) as $_column): ?> + + getRowField($_i)) != '' ? $_html : ' ') ?>
getEmptyText() ?>
-
- getPagerVisibility()): ?> -
- - - getCollection()->getCurPage() ?> - getCollection()->getLastPageNumber() ?> - - 1): ?> - - - - - - + + - - getCollection()->getLastPageNumber()) ?> - + shouldRenderSubTotal($_item)): ?> + + getSubTotalColumns() as $_column): ?> + + hasSubtotalsLabel() ? $_column->getSubtotalsLabel() : + $_column->getRowField($block->getSubTotalItem($_item)) + ); + ?> + + + + + + getEmptyText()): ?> + + getEmptyText() ?> + + + + - - - - - - getChildBlock('grid.bottom.links')): ?> - getChildHtml('grid.bottom.links') ?> - -
-
canDisplayContainer()): ?>
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/massaction.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/massaction.phtml index c759fdb6fac26..901d1f1e1f7db 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/massaction.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/massaction.phtml @@ -7,70 +7,70 @@ // @codingStandardsIgnoreFile ?> -
-
-
- getHideFormElement() !== true):?> -
- - getBlockHtml('formkey')?> - - - - - - - - getApplyButtonHtml() ?> - - getHideFormElement() !== true):?> -
- -
- getItems() as $_item): ?> -
- getBlockName()):?> - getChildHtml($_item->getBlockName());?> - -
- +getSomething(); ?> +
+ + getHideFormElement() !== true):?> +
+ +
+ getBlockHtml('formkey')?> + + + + getApplyButtonHtml() ?> +
+ getHideFormElement() !== true):?> +
+ +
+ getItems() as $_item): ?> +
+ getBlockName()):?> + getChildHtml($_item->getBlockName());?> +
+
-
- + + + getUseSelectAll()):?> + + + + - - - - + - - 0 - +
-
- -
-
+
+
- + getTabLabel() ?>
@@ -38,7 +40,9 @@ if(typeof Bundle=='undefined') {
-
+
getOptionsBoxHtml() ?>
diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option.phtml index 15746df355437..930f02bfe5e77 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option.phtml @@ -10,9 +10,9 @@ ?> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml index 6ff26601b2322..6c032a04d412f 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/compare/sidebar.phtml @@ -5,59 +5,44 @@ */ // @codingStandardsIgnoreFile - -/* @var $block \Magento\Catalog\Block\Product\Compare\Sidebar */ -?> -helper('Magento\Catalog\Helper\Product\Compare'); -$_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null; -$count = $_helper->getItemCount(); +/* @var $block \Magento\Framework\View\Element\Template */ ?> -
+
- 0): ?> - - +
-
- getItemCount() > 0): ?> -
    - $_item): ?> -
  1. - - - - helper('Magento\Catalog\Helper\Output')->productAttribute($_item, $_item->getName(), 'name') ?> + +
    +
      +
    1. + + + + + + - - helper('Magento\Catalog\Helper\Product\Compare');?> - - - -
    2. - -
    -
    -
    - -
    -
    - - - +
  2. +
+
+
+ +
+
+ + + +
- -
- -
+ + +
+
+ diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/image.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/image.phtml index e7f36852a9a97..5131b06ba0594 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/image.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/image.phtml @@ -7,8 +7,8 @@ getAddAttribute(); ?> src="getProductImageView()->getUrl() ?>" + width="getProductImageView()->getWidth();?>" + height="getProductImageView()->getHeight();?>" alt="stripTags($block->getProductImageView()->getLabel(), null, true) ?>" /> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml index 9f3c28041885a..8657a2410affc 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml @@ -15,5 +15,7 @@ $ratio = $block->getProductImageView()->getHeight() / $block->getProductImageVie getAddAttribute(); ?> src="getProductImageView()->getUrl() ?>" + width="getProductImageView()->getResizedImageWidth()?>" + height="getProductImageView()->getResizedImageHeight()?>" alt="stripTags($block->getProductImageView()->getLabel(), null, true) ?>"/> diff --git a/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js b/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js new file mode 100644 index 0000000000000..8f6a31c32358e --- /dev/null +++ b/app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js @@ -0,0 +1,43 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data' +], function (Component, customerData) { + 'use strict'; + + var sidebarInitialized = false; + + function initSidebar() { + if (sidebarInitialized) { + return ; + } + sidebarInitialized = true; + require([ + 'jquery', + 'mage/mage' + ], function ($) { + $('[data-role=compare-products-sidebar]').mage('compareItems', { + "removeConfirmMessage": $.mage.__( + "Are you sure you would like to remove this item from the compare products?" + ), + "removeSelector": "#compare-items a.action.delete", + "clearAllConfirmMessage": $.mage.__( + "Are you sure you would like to remove all products from your comparison?" + ), + "clearAllSelector": "#compare-clear-all" + }); + }); + } + + return Component.extend({ + initialize: function () { + this._super(); + this.compareProducts = customerData.get('compare-products'); + + initSidebar(); + } + }); +}); diff --git a/app/code/Magento/Catalog/view/frontend/web/js/view/image.js b/app/code/Magento/Catalog/view/frontend/web/js/view/image.js new file mode 100644 index 0000000000000..a19f9e72a1a0c --- /dev/null +++ b/app/code/Magento/Catalog/view/frontend/web/js/view/image.js @@ -0,0 +1,18 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'uiComponent' +], function (Component) { + 'use strict'; + + return Component.extend({ + initialize: function () { + this._super(); + + this.template = window.checkout.imageTemplate || this.template; + } + }); +}); diff --git a/app/code/Magento/Catalog/view/frontend/web/template/product/image.html b/app/code/Magento/Catalog/view/frontend/web/template/product/image.html new file mode 100644 index 0000000000000..da88b3236c986 --- /dev/null +++ b/app/code/Magento/Catalog/view/frontend/web/template/product/image.html @@ -0,0 +1,7 @@ + + diff --git a/app/code/Magento/Catalog/view/frontend/web/template/product/image_with_borders.html b/app/code/Magento/Catalog/view/frontend/web/template/product/image_with_borders.html new file mode 100644 index 0000000000000..fdb2c321f5df7 --- /dev/null +++ b/app/code/Magento/Catalog/view/frontend/web/template/product/image_with_borders.html @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 72810dc82611f..7b3303731f345 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -123,6 +123,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity */ protected $_attributeTypes = []; + /** + * Product collection + * + * @var \Magento\Catalog\Model\Resource\Product\CollectionFactory + */ + protected $_entityCollectionFactory; + /** * Product collection * @@ -231,7 +238,7 @@ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Store\Model\StoreManagerInterface $storeManager, \Psr\Log\LoggerInterface $logger, - \Magento\Catalog\Model\Resource\Product\Collection $collection, + \Magento\Catalog\Model\Resource\Product\CollectionFactory $collectionFactory, \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig, \Magento\Catalog\Model\Resource\ProductFactory $productFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $attrSetColFactory, @@ -243,7 +250,7 @@ public function __construct( \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider, \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer ) { - $this->_entityCollection = $collection; + $this->_entityCollectionFactory = $collectionFactory; $this->_exportConfig = $exportConfig; $this->_logger = $logger; $this->_productFactory = $productFactory; @@ -669,12 +676,13 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows) } /** - * Get product collection - * - * @return \Magento\Catalog\Model\Resource\Product\Collection + * {@inheritdoc} */ - protected function _getEntityCollection() + protected function _getEntityCollection($resetCollection = false) { + if ($resetCollection || empty($this->_entityCollection)) { + $this->_entityCollection = $this->_entityCollectionFactory->create(); + } return $this->_entityCollection; } @@ -735,7 +743,6 @@ protected function paginateCollection($page, $pageSize) /** * Export process * - * @see https://jira.corp.x.com/browse/MAGETWO-7894 * @return string */ public function export() @@ -743,15 +750,16 @@ public function export() //Execution time may be very long set_time_limit(0); - $this->_prepareEntityCollection($this->_getEntityCollection()); - $this->_getEntityCollection()->setOrder('has_options', 'asc'); - $this->_getEntityCollection()->setStoreId(Store::DEFAULT_STORE_ID); $writer = $this->getWriter(); $page = 0; while (true) { ++$page; + $entityCollection = $this->_getEntityCollection(true); + $entityCollection->setOrder('has_options', 'asc'); + $entityCollection->setStoreId(Store::DEFAULT_STORE_ID); + $this->_prepareEntityCollection($entityCollection); $this->paginateCollection($page, $this->getItemsPerPage()); - if ($this->_getEntityCollection()->count() == 0) { + if ($entityCollection->count() == 0) { break; } $exportData = $this->getExportData(); @@ -761,7 +769,7 @@ public function export() foreach ($exportData as $dataRow) { $writer->writeRow($dataRow); } - if ($this->_getEntityCollection()->getCurPage() >= $this->_getEntityCollection()->getLastPageNumber()) { + if ($entityCollection->getCurPage() >= $entityCollection->getLastPageNumber()) { break; } } diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 97eb4ce5fbeff..2a2a7bafff820 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -1682,6 +1682,7 @@ protected function _saveValidatedBunches() } $rowData = $source->current(); $this->validateRow($rowData, $source->key()); + $this->_processedRowsCount++; $source->next(); } $this->getOptionEntity()->validateAmbiguousData(); diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php index be21e3e2019ab..36ee69ed7d718 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php @@ -5,6 +5,8 @@ */ namespace Magento\CatalogImportExport\Model\Import\Product\Type; +use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface; + /** * Import entity abstract product type model * @@ -270,7 +272,7 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true) )) ) { $this->_entityModel->addRowError( - \Magento\CatalogImportExport\Model\Import\Product::ERROR_VALUE_IS_REQUIRED, + RowValidatorInterface::ERROR_VALUE_IS_REQUIRED, $rowNum, $attrCode ); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php new file mode 100644 index 0000000000000..5f4185031e587 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php @@ -0,0 +1,150 @@ +entityModel = $this->getMock( + '\Magento\CatalogImportExport\Model\Import\Product', + [], + [], + '', + false + ); + $attrSetColFactory = $this->getMock( + '\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory', + ['create'], + [], + '', + false + ); + $attrSetCollection = $this->getMock( + '\Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection', + [], + [], + '', + false + ); + $attrColFactory = $this->getMock( + '\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory', + ['create'], + [], + '', + false + ); + $attributeSet = $this->getMock( + '\Magento\Eav\Model\Entity\Attribute\Set', + [], + [], + '', + false + ); + $attrCollection = $this->getMock( + '\Magento\Eav\Model\Resource\Entity\Attribute\Collection', + [], + [], + '', + false + ); + $attribute = $this->getMock( + '\Magento\Eav\Model\Entity\Attribute', + [ + 'getAttributeCode', + 'getId', + 'getIsVisible', + 'getIsGlobal', + 'getIsRequired', + 'getIsUnique', + 'getFrontendLabel', + 'isStatic', + 'getApplyTo', + 'getDefaultValue', + 'usesSource', + 'getFrontendInput', + ], + [], + '', + false + ); + + $this->entityModel->expects($this->any())->method('getEntityTypeId')->willReturn(3); + $this->entityModel->expects($this->any())->method('getAttributeOptions')->willReturn(['option1', 'option2']); + $attrSetColFactory->expects($this->any())->method('create')->willReturn($attrSetCollection); + $attrSetCollection->expects($this->any())->method('setEntityTypeFilter')->willReturn([$attributeSet]); + $attrColFactory->expects($this->any())->method('create')->willReturn($attrCollection); + $attrCollection->expects($this->any())->method('setAttributeSetFilter')->willReturn([$attribute]); + $attributeSet->expects($this->any())->method('getId')->willReturn(1); + $attributeSet->expects($this->any())->method('getAttributeSetName')->willReturn('attribute_set_name'); + $attribute->expects($this->any())->method('getAttributeCode')->willReturn('attr_code'); + $attribute->expects($this->any())->method('getId')->willReturn('1'); + $attribute->expects($this->any())->method('getIsVisible')->willReturn(true); + $attribute->expects($this->any())->method('getIsGlobal')->willReturn(true); + $attribute->expects($this->any())->method('getIsRequired')->willReturn(true); + $attribute->expects($this->any())->method('getIsUnique')->willReturn(true); + $attribute->expects($this->any())->method('getFrontendLabel')->willReturn('frontend_label'); + $attribute->expects($this->any())->method('isStatic')->willReturn(true); + $attribute->expects($this->any())->method('getApplyTo')->willReturn(['simple']); + $attribute->expects($this->any())->method('getDefaultValue')->willReturn('default_value'); + $attribute->expects($this->any())->method('usesSource')->willReturn(true); + $attribute->expects($this->any())->method('getFrontendInput')->willReturn('multiselect'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->simpleType = $this->objectManagerHelper->getObject( + 'Magento\CatalogImportExport\Model\Import\Product\Type\Simple', + [ + 'attrSetColFac' => $attrSetColFactory, + 'prodAttrColFac' => $attrColFactory, + 'params' => [$this->entityModel, 'simple'], + ] + ); + } + + public function testIsRowValidSuccess() + { + $rowData = ['_attribute_set' => 'attribute_set_name']; + $rowNum = 1; + $this->entityModel->expects($this->any())->method('getRowScope')->willReturn(null); + $this->entityModel->expects($this->never())->method('addRowError'); + $this->assertTrue($this->simpleType->isRowValid($rowData, $rowNum)); + } + + public function testIsRowValidError() + { + $rowData = ['_attribute_set' => 'attribute_set_name']; + $rowNum = 1; + $this->entityModel->expects($this->any())->method('getRowScope')->willReturn(1); + $this->entityModel->expects($this->once())->method('addRowError') + ->with( + \Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface::ERROR_VALUE_IS_REQUIRED, + 1, + 'attr_code' + ) + ->willReturnSelf(); + $this->assertFalse($this->simpleType->isRowValid($rowData, $rowNum)); + } +} diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 7830e06201718..11fd42942bf68 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.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-import-export": "0.74.0-beta9", - "magento/module-indexer": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-import-export": "0.74.0-beta11", + "magento/module-indexer": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php index 8f5bdc39025cb..c3f4b5dcc4d01 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php @@ -13,6 +13,7 @@ /** * Interface StockCollectionInterface + * @api */ interface StockCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php index 47bd9b85cc321..8908ea0ee96af 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php @@ -9,6 +9,7 @@ /** * Interface Stock + * @api */ interface StockInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php index fad64f575cc00..bd649dc6f41c3 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php @@ -13,7 +13,7 @@ /** * Interface StockItemCollectionInterface - * @package Magento\CatalogInventory\Api\Data + * @api */ interface StockItemCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php index 0a620ce1562d5..0c4216fd46a99 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php @@ -9,6 +9,7 @@ /** * Interface StockItem + * @api */ interface StockItemInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php index c20852455ee36..6f53ba8238eb0 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php @@ -9,6 +9,7 @@ /** * Stock Status collection interface + * @api */ interface StockStatusCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php index 3c90ea451776a..f4996ac62ec6b 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php @@ -9,6 +9,7 @@ /** * Interface StockStatusInterface + * @api */ interface StockStatusInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php index 5052ea004b256..7b4179c7a7188 100644 --- a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php @@ -7,6 +7,7 @@ /** * Interface StockConfigurationInterface + * @api */ interface StockConfigurationInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php index 537db0ce5aff1..15e299f8591c7 100644 --- a/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php @@ -7,6 +7,7 @@ /** * Interface StockCriteriaInterface + * @api */ interface StockCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php b/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php index 6edba0a23b537..f57936402f0c9 100644 --- a/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php @@ -7,6 +7,7 @@ /** * Interface StockIndexInterface + * @api */ interface StockIndexInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php index 878aa26d3c2f7..df76cc37f3153 100644 --- a/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php @@ -7,6 +7,7 @@ /** * Interface StockItemCriteriaInterface + * @api */ interface StockItemCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php index 17a2287692281..97804d7043750 100644 --- a/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php @@ -7,6 +7,7 @@ /** * Interface StockItemRepository + * @api */ interface StockItemRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php b/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php index 748ed9b39cfc7..b4cd1008bf5ce 100644 --- a/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php @@ -7,6 +7,7 @@ /** * Interface StockManagementInterface + * @api */ interface StockManagementInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php index 27f90e740f961..95c848f1865b7 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php @@ -7,6 +7,7 @@ /** * Interface StockRegistryInterface + * @api */ interface StockRegistryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php index 06f5d2f4e9cf7..28b839c6fedb6 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php @@ -7,6 +7,7 @@ /** * Interface StockRepositoryInterface + * @api */ interface StockRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStateInterface.php b/app/code/Magento/CatalogInventory/Api/StockStateInterface.php index 490f92644df78..140ccee031bfa 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStateInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStateInterface.php @@ -7,6 +7,7 @@ /** * Interface StockStateInterface + * @api */ interface StockStateInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php index af80ddd5c5caf..7b5dfafa3116a 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php @@ -7,6 +7,7 @@ /** * Interface StockStatusCriteriaInterface + * @api */ interface StockStatusCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php index b531c815ceb55..7a8ac82565413 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php @@ -7,6 +7,7 @@ /** * Interface StockStatusRepositoryInterface + * @api */ interface StockStatusRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php index 27f77189a73b8..06334160c1fe8 100644 --- a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php +++ b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php @@ -6,7 +6,7 @@ namespace Magento\CatalogInventory\Block; -use Magento\Framework\View\Block\IdentityInterface; +use Magento\Framework\Object\IdentityInterface; use Magento\Framework\View\Element\Template; /** diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php index eee89e30ab9cd..2f2e3de76c97d 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php @@ -9,7 +9,7 @@ /** * Product stock qty default block */ -class DefaultStockqty extends AbstractStockqty implements \Magento\Framework\View\Block\IdentityInterface +class DefaultStockqty extends AbstractStockqty implements \Magento\Framework\Object\IdentityInterface { /** * Render block HTML diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php index bbb3df89c8688..860c889637094 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php @@ -7,8 +7,7 @@ /** * CatalogInventory Stock Indexer Interface - * - * @author Magento Core Team + * @api */ interface StockInterface { diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php index 77b8985cac84c..c81c51a770485 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php @@ -35,6 +35,7 @@ protected function setUp() { $stockRegistryMock = $this->getMock('\Magento\CatalogInventory\Api\StockRegistryInterface'); $this->productExtensionFactoryMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory') + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 64d8d2b45ae9a..3979f2b2fd217 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-indexer": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-indexer": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogRule/Helper/Data.php b/app/code/Magento/CatalogRule/Helper/Data.php index 4a3d8b67b1193..439cff4600693 100644 --- a/app/code/Magento/CatalogRule/Helper/Data.php +++ b/app/code/Magento/CatalogRule/Helper/Data.php @@ -18,6 +18,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param int $ruleAmount * @param float $price * @return float|int + * @api */ public function calcPriceRule($actionOperator, $ruleAmount, $price) { diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php index af1dee02649e9..55b77da9849ce 100755 --- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php @@ -115,6 +115,7 @@ public function __construct( * * @param int $id * @return void + * @api */ public function reindexById($id) { @@ -127,6 +128,7 @@ public function reindexById($id) * @param array $ids * @throws \Magento\Framework\Exception\LocalizedException * @return void + * @api */ public function reindexByIds(array $ids) { @@ -134,7 +136,7 @@ public function reindexByIds(array $ids) $this->doReindexByIds($ids); } catch (\Exception $e) { $this->critical($e); - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage(), $e->getCode(), $e); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e); } } @@ -160,6 +162,7 @@ protected function doReindexByIds($ids) * * @throws \Magento\Framework\Exception\LocalizedException * @return void + * @api */ public function reindexFull() { @@ -167,7 +170,7 @@ public function reindexFull() $this->doReindexFull(); } catch (\Exception $e) { $this->critical($e); - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage(), $e->getCode(), $e); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e); } } diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php index f313f59c1dbef..d23367451d26c 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php @@ -35,6 +35,7 @@ protected function _construct() * * @param string $attributeCode * @return $this + * @api */ public function addAttributeInConditionFilter($attributeCode) { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php index 8457f6f68d320..8775a9b18f44a 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php @@ -21,6 +21,7 @@ protected function _construct() /** * @return array + * @api */ public function getProductIds() { diff --git a/app/code/Magento/CatalogRule/Model/Rule/Job.php b/app/code/Magento/CatalogRule/Model/Rule/Job.php index 1b5b91b9b5549..a4aebae5b289e 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Job.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Job.php @@ -45,6 +45,7 @@ public function __construct(RuleProductProcessor $ruleProcessor) * Dispatch event "catalogrule_apply_all" and set success or error message depends on result * * @return \Magento\CatalogRule\Model\Rule\Job + * @api */ public function applyAll() { diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 6de258254dcc5..7a1d7d902f805 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-rule": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-indexer": "0.74.0-beta9", - "magento/module-import-export": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-rule": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-indexer": "0.74.0-beta11", + "magento/module-import-export": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php b/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php index 190422909c624..dfc0013e6e23f 100644 --- a/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php +++ b/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php @@ -14,7 +14,6 @@ class Index extends \Magento\Framework\App\Action\Action public function execute() { $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/CatalogSearch/Controller/Result/Index.php b/app/code/Magento/CatalogSearch/Controller/Result/Index.php index 4392814b229bd..3a711c6e13422 100644 --- a/app/code/Magento/CatalogSearch/Controller/Result/Index.php +++ b/app/code/Magento/CatalogSearch/Controller/Result/Index.php @@ -94,7 +94,6 @@ public function execute() $this->_objectManager->get('Magento\CatalogSearch\Helper\Data')->checkNotes(); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); if (!$this->_objectManager->get('Magento\CatalogSearch\Helper\Data')->isMinQueryLength()) { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Engine.php b/app/code/Magento/CatalogSearch/Model/Resource/Engine.php index 8a6d49963700a..15b56ec7b331e 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Engine.php @@ -37,13 +37,6 @@ class Engine extends AbstractDb implements EngineInterface */ protected $_catalogSearchData = null; - /** - * Catalog search data - * - * @var \Magento\Search\Model\Resource\Helper - */ - protected $_resourceHelper; - /** * Construct * @@ -51,7 +44,6 @@ class Engine extends AbstractDb implements EngineInterface * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility * @param Advanced $searchResource * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData - * @param \Magento\Search\Model\Resource\Helper $resourceHelper * @param string|null $resourcePrefix */ public function __construct( @@ -59,13 +51,11 @@ public function __construct( \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\CatalogSearch\Model\Resource\Advanced $searchResource, \Magento\CatalogSearch\Helper\Data $catalogSearchData, - \Magento\Search\Model\Resource\Helper $resourceHelper, $resourcePrefix = null ) { $this->_catalogProductVisibility = $catalogProductVisibility; $this->_searchResource = $searchResource; $this->_catalogSearchData = $catalogSearchData; - $this->_resourceHelper = $resourceHelper; parent::__construct($context, $resourcePrefix); } @@ -118,7 +108,7 @@ public function saveEntityIndexes($storeId, $entityIndexes, $entity = 'product') } if ($data) { - $this->_resourceHelper->insertOnDuplicate($this->getMainTable(), $data, ['data_index']); + $this->_getWriteAdapter()->insertOnDuplicate($this->getMainTable(), $data, ['data_index']); } return $this; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php index 5997b47553eb1..8d2870e9b832d 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php @@ -5,20 +5,11 @@ */ namespace Magento\CatalogSearch\Model\Resource; -use Magento\Search\Model\Resource\Helper; - /** * CatalogSearch Fulltext Index resource model */ class Fulltext extends \Magento\Framework\Model\Resource\Db\AbstractDb { - /** - * Core string - * - * @var \Magento\Framework\Filter\FilterManager - */ - protected $filter; - /** * Core event manager proxy * @@ -26,30 +17,17 @@ class Fulltext extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected $_eventManager; - /** - * CatalogSearch resource helper - * - * @var \Magento\Search\Model\Resource\Helper - */ - protected $_resourceHelper; - /** * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Framework\Filter\FilterManager $filter - * @param Helper $resourceHelper * @param string|null $resourcePrefix */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Framework\Filter\FilterManager $filter, - \Magento\Search\Model\Resource\Helper $resourceHelper, $resourcePrefix = null ) { $this->_eventManager = $eventManager; - $this->filter = $filter; - $this->_resourceHelper = $resourceHelper; parent::__construct($context, $resourcePrefix); } @@ -71,7 +49,7 @@ protected function _construct() public function resetSearchResults() { $adapter = $this->_getWriteAdapter(); - $adapter->update($this->getTable('search_query'), ['is_processed' => 0]); + $adapter->update($this->getTable('search_query'), ['is_processed' => 0], ['is_processed != 0']); $this->_eventManager->dispatch('catalogsearch_reset_search_result'); return $this; } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Resource/FulltextTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Resource/FulltextTest.php new file mode 100644 index 0000000000000..f6e16d3332e7b --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Resource/FulltextTest.php @@ -0,0 +1,76 @@ +context = $this->getMockBuilder('\Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->resource = $this->getMockBuilder('\Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->once()) + ->method('getResources') + ->willReturn($this->resource); + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with('core_write') + ->willReturn($this->adapter); + + $objectManager = new ObjectManager($this); + $this->target = $objectManager->getObject( + '\Magento\CatalogSearch\Model\Resource\Fulltext', + [ + 'context' => $this->context, + ] + ); + } + + public function testResetSearchResult() + { + $this->resource->expects($this->once()) + ->method('getTableName') + ->with('search_query', 'core_read') + ->willReturn('table_name_search_query'); + $this->adapter->expects($this->once()) + ->method('update') + ->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0']) + ->willReturn(10); + $result = $this->target->resetSearchResults(); + $this->assertEquals($this->target, $result); + } +} diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index f0e801b8c4f57..8e44d35fe165c 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-search": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-indexer": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-search": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-indexer": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index bdca8f56960b6..78fa946bb5859 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-backend": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-catalog-import-export": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-import-export": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-url-rewrite": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-backend": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-catalog-import-export": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-import-export": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-url-rewrite": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogUrlRewrite/etc/eav_attributes.xml b/app/code/Magento/CatalogUrlRewrite/etc/eav_attributes.xml index 65818ad4546d1..076ffe0382866 100644 --- a/app/code/Magento/CatalogUrlRewrite/etc/eav_attributes.xml +++ b/app/code/Magento/CatalogUrlRewrite/etc/eav_attributes.xml @@ -9,6 +9,7 @@ + diff --git a/app/code/Magento/CatalogWidget/composer.json b/app/code/Magento/CatalogWidget/composer.json index a1627f0d1771a..cb51c8bad8528 100644 --- a/app/code/Magento/CatalogWidget/composer.json +++ b/app/code/Magento/CatalogWidget/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-rule": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-wishlist": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-rule": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-wishlist": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Centinel/Block/Adminhtml/Validation.php b/app/code/Magento/Centinel/Block/Adminhtml/Validation.php deleted file mode 100644 index cd3ee0a70796a..0000000000000 --- a/app/code/Magento/Centinel/Block/Adminhtml/Validation.php +++ /dev/null @@ -1,61 +0,0 @@ -setId('sales_order_create_validation_card'); - } - - /** - * Return text for block`s header - * - * @return \Magento\Framework\Phrase - */ - public function getHeaderText() - { - return __('3D Secure Card Validation'); - } - - /** - * Return css class name for header block - * - * @return string - */ - public function getHeaderCssClass() - { - return 'head-payment-method'; - } - - /** - * Prepare html output - * - * @return string - */ - protected function _toHtml() - { - $payment = $this->getQuote()->getPayment(); - if (!$payment->getMethod() || - $payment->getMethodInstance()->getIsDummy() || - !$payment->getMethodInstance()->getIsCentinelValidationEnabled() - ) { - return ''; - } - return parent::_toHtml(); - } -} diff --git a/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php b/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php deleted file mode 100644 index 1bb63f2cee86d..0000000000000 --- a/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -namespace Magento\Centinel\Block\Adminhtml\Validation; - -class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate -{ - /** - * Prepare validation and template parameters - * - * @return string - */ - protected function _toHtml() - { - $payment = $this->getQuote()->getPayment(); - if ($payment) { - $method = $payment->getMethodInstance(); - if ($method->getIsCentinelValidationEnabled() && ($centinel = $method->getCentinelValidator())) { - $this->setFrameUrl( - $centinel->getValidatePaymentDataUrl() - )->setContainerId( - 'centinel_authenticate_iframe' - )->setMethodCode( - $method->getCode() - ); - return parent::_toHtml(); - } - } - return ''; - } -} diff --git a/app/code/Magento/Centinel/Block/Authentication.php b/app/code/Magento/Centinel/Block/Authentication.php deleted file mode 100644 index 149548fec10bb..0000000000000 --- a/app/code/Magento/Centinel/Block/Authentication.php +++ /dev/null @@ -1,91 +0,0 @@ -_checkoutSession = $checkoutSession; - parent::__construct($context, $data); - $this->_isScopePrivate = true; - } - - /** - * Add identifier of related block - * - * @param string $blockId - * @return $this - */ - public function addRelatedBlock($blockId) - { - $this->_relatedBlocks[] = $blockId; - return $this; - } - - /** - * Return identifiers of related blocks - * - * @return string[] - */ - public function getRelatedBlocks() - { - return $this->_relatedBlocks; - } - - /** - * Check whether authentication is required and prepare some template data - * - * @return string - */ - protected function _toHtml() - { - $method = $this->_checkoutSession->getQuote()->getPayment()->getMethodInstance(); - if ($method->getIsCentinelValidationEnabled()) { - $centinel = $method->getCentinelValidator(); - if ($centinel && $centinel->shouldAuthenticate()) { - $this->setAuthenticationStart(true); - $this->setFrameUrl($centinel->getAuthenticationStartUrl()); - return parent::_toHtml(); - } - } - return parent::_toHtml(); - } -} diff --git a/app/code/Magento/Centinel/Block/Authentication/Complete.php b/app/code/Magento/Centinel/Block/Authentication/Complete.php deleted file mode 100644 index 6fb32e49efa70..0000000000000 --- a/app/code/Magento/Centinel/Block/Authentication/Complete.php +++ /dev/null @@ -1,49 +0,0 @@ -_coreRegistry = $registry; - parent::__construct($context, $data); - } - - /** - * Prepare authentication result params and render - * - * @return string - */ - protected function _toHtml() - { - $validator = $this->_coreRegistry->registry('current_centinel_validator'); - if ($validator) { - $this->setIsProcessed(true); - $this->setIsSuccess($validator->isAuthenticateSuccessful()); - } - return parent::_toHtml(); - } -} diff --git a/app/code/Magento/Centinel/Block/Authentication/Start.php b/app/code/Magento/Centinel/Block/Authentication/Start.php deleted file mode 100644 index 10fd701433be3..0000000000000 --- a/app/code/Magento/Centinel/Block/Authentication/Start.php +++ /dev/null @@ -1,49 +0,0 @@ -_coreRegistry = $registry; - parent::__construct($context, $data); - } - - /** - * Prepare form parameters and render - * - * @return string - */ - protected function _toHtml() - { - $validator = $this->_coreRegistry->registry('current_centinel_validator'); - if ($validator && $validator->shouldAuthenticate()) { - $this->addData($validator->getAuthenticateStartData()); - return parent::_toHtml(); - } - return ''; - } -} diff --git a/app/code/Magento/Centinel/Block/Logo.php b/app/code/Magento/Centinel/Block/Logo.php deleted file mode 100644 index bcefadeeacbbc..0000000000000 --- a/app/code/Magento/Centinel/Block/Logo.php +++ /dev/null @@ -1,28 +0,0 @@ -getMethod()->getCode(); - } -} diff --git a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php deleted file mode 100644 index cb8ffb4afa3bd..0000000000000 --- a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -namespace Magento\Centinel\Controller\Adminhtml\Centinel; - -class Index extends \Magento\Backend\App\Action -{ - /** - * Core registry - * - * @var \Magento\Framework\Registry - */ - protected $_coreRegistry = null; - - /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Registry $coreRegistry - */ - public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry) - { - $this->_coreRegistry = $coreRegistry; - parent::__construct($context); - } - - /** - * Return payment model - * - * @return \Magento\Quote\Model\Quote\Payment - */ - protected function _getPayment() - { - return $this->_objectManager->get('Magento\Sales\Model\AdminOrder\Create')->getQuote()->getPayment(); - } - - /** - * Return Centinel validation model - * - * @return \Magento\Centinel\Model\Service - */ - protected function _getValidator() - { - if ($this->_getPayment()->getMethodInstance()->getIsCentinelValidationEnabled()) { - return $this->_getPayment()->getMethodInstance()->getCentinelValidator(); - } - return false; - } -} diff --git a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/AuthenticationComplete.php b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/AuthenticationComplete.php deleted file mode 100644 index fa7ee1ffd32fb..0000000000000 --- a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/AuthenticationComplete.php +++ /dev/null @@ -1,35 +0,0 @@ -_getValidator(); - if ($validator) { - $request = $this->getRequest(); - - $data = new \Magento\Framework\Object(); - $data->setTransactionId($request->getParam('MD')); - $data->setPaResPayload($request->getParam('PaRes')); - - $validator->authenticate($data); - $this->_coreRegistry->register('current_centinel_validator', $validator); - } - } catch (\Exception $e) { - $this->_coreRegistry->register('current_centinel_validator', false); - } - $this->_view->loadLayout()->renderLayout(); - } -} diff --git a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/AuthenticationStart.php b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/AuthenticationStart.php deleted file mode 100644 index 33bdc10cc336f..0000000000000 --- a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/AuthenticationStart.php +++ /dev/null @@ -1,24 +0,0 @@ -_getValidator(); - if ($validator) { - $this->_coreRegistry->register('current_centinel_validator', $validator); - } - $this->_view->loadLayout()->renderLayout(); - } -} diff --git a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/ValidatePaymentData.php b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/ValidatePaymentData.php deleted file mode 100644 index 13d3154b90053..0000000000000 --- a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index/ValidatePaymentData.php +++ /dev/null @@ -1,38 +0,0 @@ -getRequest()->getParam('payment'); - $validator = $this->_getValidator(); - if (!$validator) { - throw new \Exception('This payment method does not have centinel validation.'); - } - $validator->reset(); - $this->_getPayment()->importData($paymentData); - $result['authenticationUrl'] = $validator->getAuthenticationStartUrl(); - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $result['message'] = $e->getMessage(); - } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); - $result['message'] = __('Validation failed.'); - } - $this->getResponse()->representJson( - $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) - ); - } -} diff --git a/app/code/Magento/Centinel/Controller/Index.php b/app/code/Magento/Centinel/Controller/Index.php deleted file mode 100644 index 1cbca3d3e6442..0000000000000 --- a/app/code/Magento/Centinel/Controller/Index.php +++ /dev/null @@ -1,56 +0,0 @@ -_coreRegistry = $coreRegistry; - parent::__construct($context); - } - - /** - * Return payment model - * - * @return \Magento\Quote\Model\Quote\Payment - */ - protected function _getPayment() - { - return $this->_objectManager->get('Magento\Checkout\Model\Session')->getQuote()->getPayment(); - } - - /** - * Return Centinel validation model - * - * @return \Magento\Centinel\Model\Service - */ - protected function _getValidator() - { - if ($this->_getPayment()->getMethodInstance()->getIsCentinelValidationEnabled()) { - return $this->_getPayment()->getMethodInstance()->getCentinelValidator(); - } - return false; - } -} diff --git a/app/code/Magento/Centinel/Controller/Index/AuthenticationComplete.php b/app/code/Magento/Centinel/Controller/Index/AuthenticationComplete.php deleted file mode 100644 index 2c726b855a8df..0000000000000 --- a/app/code/Magento/Centinel/Controller/Index/AuthenticationComplete.php +++ /dev/null @@ -1,35 +0,0 @@ -_getValidator(); - if ($validator) { - $request = $this->getRequest(); - - $data = new \Magento\Framework\Object(); - $data->setTransactionId($request->getParam('MD')); - $data->setPaResPayload($request->getParam('PaRes')); - - $validator->authenticate($data); - $this->_coreRegistry->register('current_centinel_validator', $validator); - } - } catch (\Exception $e) { - $this->_coreRegistry->register('current_centinel_validator', false); - } - $this->_view->loadLayout()->renderLayout(); - } -} diff --git a/app/code/Magento/Centinel/Controller/Index/AuthenticationStart.php b/app/code/Magento/Centinel/Controller/Index/AuthenticationStart.php deleted file mode 100644 index ecddad03418c1..0000000000000 --- a/app/code/Magento/Centinel/Controller/Index/AuthenticationStart.php +++ /dev/null @@ -1,24 +0,0 @@ -_getValidator(); - if ($validator) { - $this->_coreRegistry->register('current_centinel_validator', $validator); - } - $this->_view->loadLayout()->renderLayout(); - } -} diff --git a/app/code/Magento/Centinel/Helper/Data.php b/app/code/Magento/Centinel/Helper/Data.php deleted file mode 100644 index 393505eef9eb0..0000000000000 --- a/app/code/Magento/Centinel/Helper/Data.php +++ /dev/null @@ -1,145 +0,0 @@ - - */ -namespace Magento\Centinel\Helper; - -class Data extends \Magento\Framework\App\Helper\AbstractHelper -{ - /** - * Return label for cmpi field - * - * @param string $fieldName - * @return \Magento\Framework\Phrase|string - */ - public function getCmpiLabel($fieldName) - { - switch ($fieldName) { - case \Magento\Centinel\Model\Service::CMPI_PARES: - return __('3D Secure Verification Result'); - case \Magento\Centinel\Model\Service::CMPI_ENROLLED: - return __('3D Secure Cardholder Validation'); - case \Magento\Centinel\Model\Service::CMPI_ECI: - return __('3D Secure Electronic Commerce Indicator'); - case \Magento\Centinel\Model\Service::CMPI_CAVV: - return __('3D Secure CAVV'); - case \Magento\Centinel\Model\Service::CMPI_XID: - return __('3D Secure XID'); - } - return ''; - } - - /** - * Return value for cmpi field - * - * @param string $fieldName - * @param string $value - * @return string - */ - public function getCmpiValue($fieldName, $value) - { - switch ($fieldName) { - case \Magento\Centinel\Model\Service::CMPI_PARES: - return $this->_getCmpiParesValue($value); - case \Magento\Centinel\Model\Service::CMPI_ENROLLED: - return $this->_getCmpiEnrolledValue($value); - case \Magento\Centinel\Model\Service::CMPI_ECI: - return $this->_getCmpiEciValue($value); - case \Magento\Centinel\Model\Service::CMPI_CAVV: - // break intentionally omitted - case \Magento\Centinel\Model\Service::CMPI_XID: - return $value; - } - return ''; - } - - /** - * Return text value for cmpi eci flag field - * - * @param string $value - * @return \Magento\Framework\Phrase|string - */ - private function _getCmpiEciValue($value) - { - switch ($value) { - case '01': - case '07': - return __('Merchant Liability'); - case '02': - case '05': - case '06': - return __('Card Issuer Liability'); - default: - return $value; - } - } - - /** - * Return text value for cmpi enrolled field - * - * @param string $value - * @return \Magento\Framework\Phrase - */ - private function _getCmpiEnrolledValue($value) - { - switch ($value) { - case 'Y': - return __('Enrolled'); - case 'U': - return __('Enrolled but Authentication Unavailable'); - case 'N': - // break intentionally omitted - default: - return __('Not Enrolled'); - } - } - - /** - * Return text value for cmpi pares field - * - * @param string $value - * @return \Magento\Framework\Phrase|string - */ - private function _getCmpiParesValue($value) - { - switch ($value) { - case 'Y': - return __('Successful'); - case 'N': - return __('Failed'); - case 'U': - return __('Unable to complete'); - case 'A': - return __('Successful attempt'); - default: - return $value; - } - } - - /** - * Return url of page about visa verification - * - * @return string - */ - public function getVisaLearnMorePageUrl() - { - return 'https://usa.visa.com/personal/security/vbv/index.html?ep=v_sym_verifiedbyvisa'; - } - - /** - * Return url of page about mastercard verification - * - * @return string - */ - public function getMastercardLearnMorePageUrl() - { - return 'http://www.mastercardbusiness.com/mcbiz/index.jsp?template=/orphans&content=securecodepopup'; - } -} diff --git a/app/code/Magento/Centinel/LICENSE.txt b/app/code/Magento/Centinel/LICENSE.txt deleted file mode 100644 index 49525fd99da9c..0000000000000 --- a/app/code/Magento/Centinel/LICENSE.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Open Software License ("OSL") v. 3.0 - -This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Open Software License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/Centinel/LICENSE_AFL.txt b/app/code/Magento/Centinel/LICENSE_AFL.txt deleted file mode 100644 index 87943b95d43a5..0000000000000 --- a/app/code/Magento/Centinel/LICENSE_AFL.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Academic Free License ("AFL") v. 3.0 - -This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Academic Free License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/Centinel/Model/AbstractState.php b/app/code/Magento/Centinel/Model/AbstractState.php deleted file mode 100644 index 58f3b6dee34d1..0000000000000 --- a/app/code/Magento/Centinel/Model/AbstractState.php +++ /dev/null @@ -1,151 +0,0 @@ -_dataStorage = $dataStorageModel; - return $this; - } - - /** - * Getter for storage data model - * - * @return \Magento\Framework\Object - */ - public function getDataStorage() - { - return $this->_dataStorage; - } - - /** - * Retrieves data from the object - * - * If $key is empty will return all the data as an array - * Otherwise it will return value of the attribute specified by $key - * - * $index parameter is ignored - * - * @param string $key - * @param string|int $index - * @return mixed - * @see \Magento\Framework\Session\SessionManager::getData() - */ - public function getData($key = '', $index = null) - { - return $this->getDataStorage()->getData($key); - } - - /** - * Overwrite data in the object. - * - * Parameter $key can be string or array. - * If $key is string, the attribute value will be overwritten by $value - * - * If $key is an array, it will overwrite all the data in the object. - * - * @param string|array $key - * @param mixed $value - * @return $this - */ - public function setData($key, $value = null) - { - $this->getDataStorage()->setData($key, $value); - return $this; - } - - /** - * Save lookup result in state model - * - * @param \Magento\Framework\Object $result - * @return $this - */ - public function setLookupResult($result) - { - foreach ($result->getData() as $key => $value) { - $this->setData('lookup_' . $key, $value); - } - return $this; - } - - /** - * Save authenticate result in state model - * - * @param \Magento\Framework\Object $result - * @return $this - */ - public function setAuthenticateResult($result) - { - foreach ($result->getData() as $key => $value) { - $this->setData('authenticate_' . $key, $value); - } - return $this; - } - - /** - * Analyse lookup`s results. If lookup is successful return true and false if it failure - * Result depends from flag self::getIsModeStrict() - * - * @return bool - */ - final public function isLookupSuccessful() - { - if ($this->_isLookupStrictSuccessful()) { - return true; - } elseif (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) { - return true; - } - return false; - } - - /** - * Analyse lookup`s results. If lookup is strict successful return true - * - * @return bool - */ - abstract protected function _isLookupStrictSuccessful(); - - /** - * Analyse lookup`s results. If lookup is soft successful return true - * - * @return bool - */ - abstract protected function _isLookupSoftSuccessful(); - - /** - * Analyse lookup`s results. If it has require params for authenticate, return true - * - * @return bool - */ - abstract public function isAuthenticateAllowed(); - - /** - * Analyse authenticate`s results. If authenticate is successful return true and false if it failure - * Result depends from flag self::getIsModeStrict() - * - * @return bool - */ - abstract public function isAuthenticateSuccessful(); -} diff --git a/app/code/Magento/Centinel/Model/Api.php b/app/code/Magento/Centinel/Model/Api.php deleted file mode 100644 index 29babcc6a118e..0000000000000 --- a/app/code/Magento/Centinel/Model/Api.php +++ /dev/null @@ -1,424 +0,0 @@ - '784', - 'AFN' => '971', - 'ALL' => '008', - 'AMD' => '051', - 'ANG' => '532', - 'AOA' => '973', - 'ARS' => '032', - 'AUD' => '036', - 'AWG' => '533', - 'AZN' => '944', - 'BAM' => '977', - 'BBD' => '052', - 'BDT' => '050', - 'BGN' => '975', - 'BHD' => '048', - 'BIF' => '108', - 'BMD' => '060', - 'BND' => '096', - 'BOB' => '068', - 'BOV' => '984', - 'BRL' => '986', - 'BSD' => '044', - 'BTN' => '064', - 'BWP' => '072', - 'BYR' => '974', - 'BZD' => '084', - 'CAD' => '124', - 'CDF' => '976', - 'CHE' => '947', - 'CHF' => '756', - 'CHW' => '948', - 'CLF' => '990', - 'CLP' => '152', - 'CNY' => '156', - 'COP' => '170', - 'COU' => '970', - 'CRC' => '188', - 'CUC' => '931', - 'CUP' => '192', - 'CVE' => '132', - 'CZK' => '203', - 'DJF' => '262', - 'DKK' => '208', - 'DOP' => '214', - 'DZD' => '012', - 'EEK' => '233', - 'EGP' => '818', - 'ERN' => '232', - 'ETB' => '230', - 'EUR' => '978', - 'FJD' => '242', - 'FKP' => '238', - 'GBP' => '826', - 'GEL' => '981', - 'GHS' => '936', - 'GIP' => '292', - 'GMD' => '270', - 'GNF' => '324', - 'GTQ' => '320', - 'GYD' => '328', - 'HKD' => '344', - 'HNL' => '340', - 'HRK' => '191', - 'HTG' => '332', - 'HUF' => '348', - 'IDR' => '360', - 'ILS' => '376', - 'INR' => '356', - 'IQD' => '368', - 'IRR' => '364', - 'ISK' => '352', - 'JMD' => '388', - 'JOD' => '400', - 'JPY' => '392', - 'KES' => '404', - 'KGS' => '417', - 'KHR' => '116', - 'KMF' => '174', - 'KPW' => '408', - 'KRW' => '410', - 'KWD' => '414', - 'KYD' => '136', - 'KZT' => '398', - 'LAK' => '418', - 'LBP' => '422', - 'LKR' => '144', - 'LRD' => '430', - 'LSL' => '426', - 'LTL' => '440', - 'LVL' => '428', - 'LYD' => '434', - 'MAD' => '504', - 'MDL' => '498', - 'MGA' => '969', - 'MKD' => '807', - 'MMK' => '104', - 'MNT' => '496', - 'MOP' => '446', - 'MRO' => '478', - 'MUR' => '480', - 'MVR' => '462', - 'MWK' => '454', - 'MXN' => '484', - 'MXV' => '979', - 'MYR' => '458', - 'MZN' => '943', - 'NAD' => '516', - 'NGN' => '566', - 'NIO' => '558', - 'NOK' => '578', - 'NPR' => '524', - 'NZD' => '554', - 'OMR' => '512', - 'PAB' => '590', - 'PEN' => '604', - 'PGK' => '598', - 'PHP' => '608', - 'PKR' => '586', - 'PLN' => '985', - 'PYG' => '600', - 'QAR' => '634', - 'RON' => '946', - 'RSD' => '941', - 'RUB' => '643', - 'RWF' => '646', - 'SAR' => '682', - 'SBD' => '090', - 'SCR' => '690', - 'SDG' => '938', - 'SEK' => '752', - 'SGD' => '702', - 'SHP' => '654', - 'SLL' => '694', - 'SOS' => '706', - 'SRD' => '968', - 'STD' => '678', - 'SYP' => '760', - 'SZL' => '748', - 'THB' => '764', - 'TJS' => '972', - 'TMT' => '934', - 'TND' => '788', - 'TOP' => '776', - 'TRY' => '949', - 'TTD' => '780', - 'TWD' => '901', - 'TZS' => '834', - 'UAH' => '980', - 'UGX' => '800', - 'USD' => '840', - 'USN' => '997', - 'USS' => '998', - 'UYU' => '858', - 'UZS' => '860', - 'VEF' => '937', - 'VND' => '704', - 'VUV' => '548', - 'WST' => '882', - 'XAF' => '950', - 'XAG' => '961', - 'XAU' => '959', - 'XBA' => '955', - 'XBB' => '956', - 'XBC' => '957', - 'XBD' => '958', - 'XCD' => '951', - 'XDR' => '960', - 'XOF' => '952', - 'XPD' => '964', - 'XPF' => '953', - 'XPT' => '962', - 'XTS' => '963', - 'XXX' => '999', - 'YER' => '886', - 'ZAR' => '710', - 'ZMK' => '894', - 'ZWL' => '932', - ]; - - /** - * Centinel validation client - * - * @var \CentinelClient - */ - protected $_clientInstance = null; - - /** - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * @param \Psr\Log\LoggerInterface $logger - * @param array $data - */ - public function __construct(\Psr\Log\LoggerInterface $logger, array $data = []) - { - $this->logger = $logger; - parent::__construct($data); - } - - /** - * Return Centinel thin client object - * - * @return \CentinelClient - */ - protected function _getClientInstance() - { - if (empty($this->_clientInstance)) { - $this->_clientInstance = new \CentinelClient(); - } - return $this->_clientInstance; - } - - /** - * Return Centinel Api version - * - * @return string - */ - protected function _getVersion() - { - return '1.7'; - } - - /** - * Return transaction type. according centinel documetation it should be "C" - * - * @return string - */ - protected function _getTransactionType() - { - return 'C'; - } - - /** - * Return Timeout Connect - * - * @return int - */ - protected function _getTimeoutConnect() - { - return 100; - } - - /** - * Return Timeout Read - * - * @return int - */ - protected function _getTimeoutRead() - { - return 100; - } - - /** - * Call centinel api methods by given method name and data - * - * @param string $method - * @param array $data - * @return \CentinelClient - * @throws \Exception - */ - protected function _call($method, $data) - { - $client = $this->_getClientInstance(); - $request = array_merge( - [ - 'MsgType' => $method, - 'Version' => $this->_getVersion(), - 'ProcessorId' => $this->getProcessorId(), - 'MerchantId' => $this->getMerchantId(), - 'TransactionPwd' => $this->getTransactionPwd(), - 'TransactionType' => $this->_getTransactionType(), - ], - $data - ); - - $debugData = ['request' => $request]; - - try { - foreach ($request as $key => $val) { - $client->add($key, $val); - } - $client->sendHttp($this->_getApiEndpointUrl(), $this->_getTimeoutConnect(), $this->_getTimeoutRead()); - } catch (\Exception $e) { - $debugData['response'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; - $this->_debug($debugData); - throw $e; - } - - $debugData['response'] = $client->response; - $this->_debug($debugData); - - return $client; - } - - /** - * Getter for API call URL - * - * @return string - * @throws \Exception - */ - protected function _getApiEndpointUrl() - { - if ($this->getIsTestMode()) { - return 'https://centineltest.cardinalcommerce.com/maps/txns.asp'; - } - $url = $this->getApiEndpointUrl(); - if (!$url) { - throw new \Exception('Centinel API endpoint URL is not configured properly.'); - } - return $url; - } - - /** - * Call centinel api lookup method - * - * @param \Magento\Framework\Object $data - * @return \Magento\Framework\Object - */ - public function callLookup($data) - { - $result = new \Magento\Framework\Object(); - - $month = strlen($data->getCardExpMonth()) == 1 ? '0' . $data->getCardExpMonth() : $data->getCardExpMonth(); - $currencyCode = $data->getCurrencyCode(); - $currencyNumber = isset( - self::$_iso4217Currencies[$currencyCode] - ) ? self::$_iso4217Currencies[$currencyCode] : ''; - if (!$currencyNumber) { - return $result->setErrorNo(1)->setErrorDesc(__('Unsupported currency code: %1.', $currencyCode)); - } - - $clientResponse = $this->_call( - 'cmpi_lookup', - [ - 'Amount' => round($data->getAmount() * 100), - 'CurrencyCode' => $currencyNumber, - 'CardNumber' => $data->getCardNumber(), - 'CardExpMonth' => $month, - 'CardExpYear' => $data->getCardExpYear(), - 'OrderNumber' => $data->getOrderNumber() - ] - ); - - $result->setErrorNo($clientResponse->getValue('ErrorNo')); - $result->setErrorDesc($clientResponse->getValue('ErrorDesc')); - $result->setTransactionId($clientResponse->getValue('TransactionId')); - $result->setEnrolled($clientResponse->getValue('Enrolled')); - $result->setAcsUrl($clientResponse->getValue('ACSUrl')); - $result->setPayload($clientResponse->getValue('Payload')); - $result->setEciFlag($clientResponse->getValue('EciFlag')); - - return $result; - } - - /** - * Call centinel api authentication method - * - * @param \Magento\Framework\Object $data - * @return \Magento\Framework\Object - */ - public function callAuthentication($data) - { - $result = new \Magento\Framework\Object(); - - $clientResponse = $this->_call( - 'cmpi_authenticate', - ['TransactionId' => $data->getTransactionId(), 'PAResPayload' => $data->getPaResPayload()] - ); - - $result->setErrorNo($clientResponse->getValue('ErrorNo')); - $result->setErrorDesc($clientResponse->getValue('ErrorDesc')); - $result->setPaResStatus($clientResponse->getValue('PAResStatus')); - $result->setSignatureVerification($clientResponse->getValue('SignatureVerification')); - $result->setCavv($clientResponse->getValue('Cavv')); - $result->setEciFlag($clientResponse->getValue('EciFlag')); - $result->setXid($clientResponse->getValue('Xid')); - - return $result; - } - - /** - * Log debug data to file - * - * @param array $debugData - * @return void - */ - protected function _debug($debugData) - { - if ($this->getDebugFlag()) { - $this->logger->debug(var_export($debugData, true)); - } - } -} diff --git a/app/code/Magento/Centinel/Model/Config.php b/app/code/Magento/Centinel/Model/Config.php deleted file mode 100644 index 81d187f3ed2ed..0000000000000 --- a/app/code/Magento/Centinel/Model/Config.php +++ /dev/null @@ -1,150 +0,0 @@ -_scopeConfig = $scopeConfig; - $this->_coreConfig = $coreConfig; - $this->_encryptor = $encryptor; - } - - /** - * Set store to congif model - * - * @param int|\Magento\Store\Model\Store $store - * @return $this - */ - public function setStore($store) - { - $this->_store = $store; - return $this; - } - - /** - * Return store - * - * @return int|\Magento\Store\Model\Store - */ - public function getStore() - { - return $this->_store; - } - - /** - * Return centinel processorId - * - * @return string - */ - public function getProcessorId() - { - return $this->_getServiceConfigValue('processor_id'); - } - - /** - * Return centinel merchantId - * - * @return string - */ - public function getMerchantId() - { - return $this->_getServiceConfigValue('merchant_id'); - } - - /** - * Return centinel transactionPwd - * - * @return string - */ - public function getTransactionPwd() - { - return $this->_encryptor->decrypt($this->_getServiceConfigValue('password')); - } - - /** - * Return flag - is centinel mode test - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getIsTestMode() - { - return (bool)(int)$this->_getServiceConfigValue('test_mode'); - } - - /** - * Return value of node of centinel config section - * - * @param string $key - * @return string - */ - private function _getServiceConfigValue($key) - { - return $this->_scopeConfig->getValue($this->_serviceConfigPath . '/' . $key, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->getStore()); - } - - /** - * Define if debugging is enabled - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getDebugFlag() - { - return $this->_getServiceConfigValue('debug'); - } -} diff --git a/app/code/Magento/Centinel/Model/Observer.php b/app/code/Magento/Centinel/Model/Observer.php deleted file mode 100644 index 7f3c95ef9ce96..0000000000000 --- a/app/code/Magento/Centinel/Model/Observer.php +++ /dev/null @@ -1,133 +0,0 @@ - - */ -namespace Magento\Centinel\Model; - -class Observer extends \Magento\Framework\Object -{ - /** - * Centinel data - * - * @var \Magento\Centinel\Helper\Data - */ - protected $_centinelData = null; - - /** - * Constructor - * - * By default is looking for first argument as array and assigns it as object - * attributes This behavior may change in child classes - * - * @param \Magento\Centinel\Helper\Data $centinelData - * @param array $data - */ - public function __construct(\Magento\Centinel\Helper\Data $centinelData, array $data = []) - { - $this->_centinelData = $centinelData; - parent::__construct($data); - } - - /** - * Set cmpi data to payment - * - * @param \Magento\Framework\Object $observer - * @return $this - */ - public function salesEventConvertQuoteToOrder($observer) - { - $payment = $observer->getEvent()->getQuote()->getPayment(); - - if ($payment->getMethodInstance()->getIsCentinelValidationEnabled()) { - $to = [$payment, 'setAdditionalInformation']; - $payment->getMethodInstance()->getCentinelValidator()->exportCmpiData($to); - } - return $this; - } - - /** - * Add cmpi data to info block - * - * @param \Magento\Framework\Object $observer - * @return void|$this - */ - public function paymentInfoBlockPrepareSpecificInformation($observer) - { - if ($observer->getEvent()->getBlock()->getIsSecureMode()) { - return; - } - - $payment = $observer->getEvent()->getPayment(); - $transport = $observer->getEvent()->getTransport(); - $helper = $this->_centinelData; - - $info = [ - \Magento\Centinel\Model\Service::CMPI_PARES, - \Magento\Centinel\Model\Service::CMPI_ENROLLED, - \Magento\Centinel\Model\Service::CMPI_ECI, - \Magento\Centinel\Model\Service::CMPI_CAVV, - \Magento\Centinel\Model\Service::CMPI_XID, - ]; - foreach ($info as $key) { - if ($value = $payment->getAdditionalInformation($key)) { - $transport->setData($helper->getCmpiLabel($key), $helper->getCmpiValue($key, $value)); - } - } - return $this; - } - - /** - * Add centinel logo block into payment form - * - * @param \Magento\Framework\Object $observer - * @return $this - */ - public function paymentFormBlockToHtmlBefore($observer) - { - $paymentFormBlock = $observer->getEvent()->getBlock(); - $method = $paymentFormBlock->getMethod(); - - if ($method && $method->getIsCentinelValidationEnabled()) { - $layout = $paymentFormBlock->getLayout(); - $block = $layout->createBlock('Magento\Centinel\Block\Logo'); - $block->setMethod($method); - - $paymentFormBlock->setChild( - 'payment.method.' . $method->getCode() . 'centinel.logo', - $block - ); - } - return $this; - } - - /** - * Reset validation data - * - * @param \Magento\Framework\Object $observer - * @return $this - */ - public function checkoutSubmitAllAfter($observer) - { - $method = false; - - if ($order = $observer->getEvent()->getOrder()) { - $method = $order->getPayment()->getMethodInstance(); - } elseif ($orders = $observer->getEvent()->getOrders()) { - if ($order = array_shift($orders)) { - $method = $order->getPayment()->getMethodInstance(); - } - } - - if ($method && $method->getIsCentinelValidationEnabled()) { - $method->getCentinelValidator()->reset(); - } - return $this; - } -} diff --git a/app/code/Magento/Centinel/Model/Service.php b/app/code/Magento/Centinel/Model/Service.php deleted file mode 100644 index b21fc2db73797..0000000000000 --- a/app/code/Magento/Centinel/Model/Service.php +++ /dev/null @@ -1,448 +0,0 @@ - self::CMPI_ENROLLED, - 'lookup_eci_flag' => self::CMPI_ECI, - 'authenticate_pa_res_status' => self::CMPI_PARES, - 'authenticate_cavv' => self::CMPI_CAVV, - 'authenticate_eci_flag' => self::CMPI_ECI, - 'authenticate_xid' => self::CMPI_XID, - ]; - - /** - * Validation api model factory - * - * @var \Magento\Centinel\Model\Api - */ - protected $_apiFactory; - - /** - * Config - * - * @var \Magento\Centinel\Model\Config - */ - protected $_config; - - /** - * Backend url - * - * @var \Magento\Framework\UrlInterface - */ - protected $_url; - - /** - * Centinel session - * - * @var \Magento\Framework\Session\SessionManagerInterface - */ - protected $_centinelSession; - - /** - * State factory - * - * @var \Magento\Centinel\Model\StateFactory - */ - protected $_stateFactory; - - /** - * Validation state model - * - * @var \Magento\Centinel\Model\AbstractState - */ - protected $_validationState; - - /** - * Url prefix - * - * @var string - */ - protected $_urlPrefix; - - /** - * @var \Magento\Framework\Data\Form\FormKey - */ - protected $formKey; - - /** - * @param \Magento\Centinel\Model\Config $config - * @param \Magento\Centinel\Model\ApiFactory $apiFactory - * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\Session\SessionManagerInterface $centinelSession - * @param \Magento\Centinel\Model\StateFactory $stateFactory - * @param \Magento\Framework\Data\Form\FormKey $formKey - * @param string $urlPrefix - * @param array $data - */ - public function __construct( - \Magento\Centinel\Model\Config $config, - \Magento\Centinel\Model\ApiFactory $apiFactory, - \Magento\Framework\UrlInterface $url, - \Magento\Framework\Session\SessionManagerInterface $centinelSession, - \Magento\Centinel\Model\StateFactory $stateFactory, - \Magento\Framework\Data\Form\FormKey $formKey, - $urlPrefix = 'centinel/index/', - array $data = [] - ) { - $this->_config = $config; - $this->_apiFactory = $apiFactory; - $this->_url = $url; - $this->_centinelSession = $centinelSession; - $this->_stateFactory = $stateFactory; - $this->formKey = $formKey; - $this->_urlPrefix = $urlPrefix; - parent::__construct($data); - } - - /** - * Return value from section of centinel config - * - * @return \Magento\Centinel\Model\Config - */ - protected function _getConfig() - { - return $this->_config->setStore($this->getStore()); - } - - /** - * Generate checksum from all passed parameters - * - * @param string $paymentMethodCode - * @param string $cardType - * @param string $cardNumber - * @param string $cardExpMonth - * @param string $cardExpYear - * @param float $amount - * @param string $currencyCode - * @return string - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - protected function _generateChecksum( - $paymentMethodCode, - $cardType, - $cardNumber, - $cardExpMonth, - $cardExpYear, - $amount, - $currencyCode - ) { - return md5(implode(func_get_args(), '_')); - } - - /** - * Unified validation/authentication URL getter - * - * @param string $suffix - * @param bool $current - * @return string - */ - protected function _getUrl($suffix, $current = false) - { - $params = [ - '_secure' => true, - '_current' => $current, - 'form_key' => $this->formKey->getFormKey(), - 'isIframe' => true, - ]; - return $this->_url->getUrl($this->_urlPrefix . $suffix, $params); - } - - /** - * Return validation api model - * - * @return \Magento\Centinel\Model\Api - */ - protected function _getApi() - { - $config = $this->_getConfig(); - $api = $this->_apiFactory->create(); - $api->setProcessorId( - $config->getProcessorId() - )->setMerchantId( - $config->getMerchantId() - )->setTransactionPwd( - $config->getTransactionPwd() - )->setIsTestMode( - $config->getIsTestMode() - )->setDebugFlag( - $config->getDebugFlag() - )->setApiEndpointUrl( - $this->getCustomApiEndpointUrl() - ); - return $api; - } - - /** - * Return validation state model - * - * @param string $cardType - * @return \Magento\Centinel\Model\AbstractState - */ - protected function _getValidationState($cardType = null) - { - $type = $cardType ? $cardType : $this->_centinelSession->getData('card_type'); - if (!$this->_validationState && $type) { - $model = $this->_stateFactory->createState($type); - if (!$model) { - return false; - } - $model->setDataStorage($this->_centinelSession); - $this->_validationState = $model; - } - return $this->_validationState; - } - - /** - * Drop validation state model - * - * @return void - */ - protected function _resetValidationState() - { - $this->_centinelSession->setData([]); - $this->_validationState = false; - } - - /** - * Drop old and init new validation state model - * - * @param string $cardType - * @param string $dataChecksum - * @return \Magento\Centinel\Model\AbstractState - */ - protected function _initValidationState($cardType, $dataChecksum) - { - $this->_resetValidationState(); - $state = $this->_stateFactory->createState($cardType); - $state->setDataStorage( - $this->_centinelSession - )->setCardType( - $cardType - )->setChecksum( - $dataChecksum - )->setIsModeStrict( - $this->getIsModeStrict() - ); - return $this->_getValidationState(); - } - - /** - * Process lookup validation and init new validation state model - * - * @param \Magento\Framework\Object $data - * @return void - */ - public function lookup($data) - { - $newChecksum = $this->_generateChecksum( - $data->getPaymentMethodCode(), - $data->getCardType(), - $data->getCardNumber(), - $data->getCardExpMonth(), - $data->getCardExpYear(), - $data->getAmount(), - $data->getCurrencyCode() - ); - - $validationState = $this->_initValidationState($data->getCardType(), $newChecksum); - - $api = $this->_getApi(); - $result = $api->callLookup($data); - $validationState->setLookupResult($result); - } - - /** - * Process authenticate validation - * - * @param \Magento\Framework\Object $data - * @return void - * @throws \Exception - */ - public function authenticate($data) - { - $validationState = $this->_getValidationState(); - if (!$validationState || $data->getTransactionId() != $validationState->getLookupTransactionId()) { - throw new \Exception('Authentication impossible: transaction id or validation state is wrong.'); - } - - $api = $this->_getApi(); - $result = $api->callAuthentication($data); - $validationState->setAuthenticateResult($result); - if (!$validationState->isAuthenticateSuccessful()) { - $this->reset(); - } - } - - /** - * Validate payment data - * - * This check is performed on payment information submission, as well as on placing order. - * Workflow state is stored validation state model - * - * @param \Magento\Framework\Object $data - * @return void - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function validate($data) - { - $newChecksum = $this->_generateChecksum( - $data->getPaymentMethodCode(), - $data->getCardType(), - $data->getCardNumber(), - $data->getCardExpMonth(), - $data->getCardExpYear(), - $data->getAmount(), - $data->getCurrencyCode() - ); - - $validationState = $this->_getValidationState($data->getCardType()); - if (!$validationState) { - $this->_resetValidationState(); - return; - } - - // check whether is authenticated before placing order - if ($this->getIsPlaceOrder()) { - if ($validationState->getChecksum() != $newChecksum) { - throw new \Magento\Framework\Exception\LocalizedException( - __('Payment information error. Please start over.') - ); - } - if ($validationState->isAuthenticateSuccessful()) { - return; - } - throw new \Magento\Framework\Exception\LocalizedException( - __('Please verify the card with the issuer bank before placing the order.') - ); - } else { - if ($validationState->getChecksum() != $newChecksum || !$validationState->isLookupSuccessful()) { - $this->lookup($data); - $validationState = $this->_getValidationState(); - } - if ($validationState->isLookupSuccessful()) { - return; - } - throw new \Magento\Framework\Exception\LocalizedException( - __('This card has failed validation and cannot be used.') - ); - } - } - - /** - * Reset validation state and drop api object - * - * @return $this - */ - public function reset() - { - $this->_resetValidationState(); - return $this; - } - - /** - * Return URL for authentication - * - * @return string - */ - public function getAuthenticationStartUrl() - { - return $this->_getUrl('authenticationstart'); - } - - /** - * Return URL for validation - * - * @return string - */ - public function getValidatePaymentDataUrl() - { - return $this->_getUrl('validatepaymentdata'); - } - - /** - * If authenticate is should return true - * - * @return bool - */ - public function shouldAuthenticate() - { - $validationState = $this->_getValidationState(); - return $validationState && $validationState->isAuthenticateAllowed(); - } - - /** - * Return data for start authentication (redirect customer to bank page) - * - * @return array - */ - public function getAuthenticateStartData() - { - $validationState = $this->_getValidationState(); - if (!$validationState && $this->shouldAuthenticate()) { - throw new \Exception('Authentication impossible: validation state is wrong.'); - } - $data = [ - 'acs_url' => $validationState->getLookupAcsUrl(), - 'pa_req' => $validationState->getLookupPayload(), - 'term_url' => $this->_getUrl('authenticationcomplete', true), - 'md' => $validationState->getLookupTransactionId(), - ]; - return $data; - } - - /** - * If authenticate is successful return true - * - * @return bool - */ - public function isAuthenticateSuccessful() - { - $validationState = $this->_getValidationState(); - return $validationState && $validationState->isAuthenticateSuccessful(); - } - - /** - * Export cmpi lookups and authentication information stored in session into array - * - * @param array|object $to - * @param array|bool $map - * @return array|object - */ - public function exportCmpiData($to, $map = false) - { - if (!$map) { - $map = $this->_cmpiMap; - } - if ($validationState = $this->_getValidationState()) { - $to = \Magento\Framework\Object\Mapper::accumulateByMap($validationState, $to, $map); - } - return $to; - } -} diff --git a/app/code/Magento/Centinel/Model/State/Jcb.php b/app/code/Magento/Centinel/Model/State/Jcb.php deleted file mode 100644 index 82ab2944c32d2..0000000000000 --- a/app/code/Magento/Centinel/Model/State/Jcb.php +++ /dev/null @@ -1,135 +0,0 @@ -_isLookupStrictSuccessful() && $this->getAuthenticateEciFlag() === null; - } - - /** - * Analyse authenticate`s results. If authenticate is successful return true and false if it failure - * Result depends from flag self::getIsModeStrict() - * - * @return bool - */ - public function isAuthenticateSuccessful() - { - if (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) { - return true; - } - - if ($this->_isLookupStrictSuccessful()) { - if ($this->_isAuthenticationSuccessful()) { - return true; - } - if ($this->_isAuthenticationUnavailable() && !$this->getIsModeStrict()) { - return true; - } - if ($this->_isAuthenticationAttemptsPerformed()) { - return true; - } - } - - return false; - } - - /** - * Returns true if authentication successful (Test case 1) - * - * @return bool - */ - protected function _isAuthenticationSuccessful() - { - return $this->getAuthenticatePaResStatus() === 'Y' && - $this->getAuthenticateEciFlag() === '05' && - $this->getAuthenticateXid() != '' && - $this->getAuthenticateCavv() != '' && - $this->getAuthenticateErrorNo() === '0' && - $this->getAuthenticateSignatureVerification() === 'Y'; - } - - /** - * Returns true if authentication unavailable (Test case 4) or timeout encountered (Test case 5) - * - * @return bool - */ - protected function _isAuthenticationUnavailable() - { - return $this->getAuthenticatePaResStatus() === 'U' && - $this->getAuthenticateSignatureVerification() === 'Y' && - $this->getAuthenticateEciFlag() === '07' && - $this->getAuthenticateXid() != '' && - $this->getAuthenticateCavv() === '' && - $this->getAuthenticateErrorNo() === '0'; - } - - /** - * Returns true if processing attempts performed (Test case 11) - * - * @return bool - */ - protected function _isAuthenticationAttemptsPerformed() - { - return $this->getAuthenticatePaResStatus() === 'A' && - $this->getAuthenticateSignatureVerification() === 'Y' && - $this->getAuthenticateEciFlag() === '06' && - $this->getAuthenticateXid() != '' && - $this->getAuthenticateCavv() != '' && - $this->getAuthenticateErrorNo() === '0'; - } - - /** - * Analyse lookup`s results. If lookup is strict successful return true (Test cases 1-4, 6, 10-11) - * - * @return bool - */ - protected function _isLookupStrictSuccessful() - { - return $this->getLookupEnrolled() === 'Y' && - $this->getLookupAcsUrl() != '' && - $this->getLookupPayload() != '' && - $this->getLookupErrorNo() === '0'; - } - - /** - * Analyse lookup`s results. If lookup is soft successful return true (Test cases 5,7,8,9) - * - * @return bool - */ - protected function _isLookupSoftSuccessful() - { - $acsUrl = $this->getLookupAcsUrl(); - $payload = $this->getLookupPayload(); - $errorNo = $this->getLookupErrorNo(); - $enrolled = $this->getLookupEnrolled(); - - if ($acsUrl !== '' || $payload !== '') { - return false; - } - - if ($enrolled === '' && $errorNo === '0') { - return true; - } - - if ($enrolled === 'U' && ($errorNo === '0' || $errorNo !== '')) { - return true; - } - - return false; - } -} diff --git a/app/code/Magento/Centinel/Model/State/Mastercard.php b/app/code/Magento/Centinel/Model/State/Mastercard.php deleted file mode 100644 index 803dc7d12e631..0000000000000 --- a/app/code/Magento/Centinel/Model/State/Mastercard.php +++ /dev/null @@ -1,164 +0,0 @@ -_isLookupStrictSuccessful() && $this->getAuthenticateEciFlag() === null; - } - - /** - * Analyse authenticate`s results. If authenticate is successful return true and false if it failure - * Result depends from flag self::getIsModeStrict() - * - * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function isAuthenticateSuccessful() - { - $paResStatus = $this->getAuthenticatePaResStatus(); - $eciFlag = $this->getAuthenticateEciFlag(); - $xid = $this->getAuthenticateXid(); - $cavv = $this->getAuthenticateCavv(); - $errorNo = $this->getAuthenticateErrorNo(); - $signatureVerification = $this->getAuthenticateSignatureVerification(); - - //Test cases 1-4, 10 - if ($this->_isLookupStrictSuccessful()) { - if ($paResStatus == 'Y' && $eciFlag == '02' && $xid != '' && $cavv != '' && $errorNo == '0') { - //Test case 1 - if ($signatureVerification == 'Y') { - return true; - } - //Test case 2 - if ($signatureVerification == 'N') { - return false; - } - } - - //Test case 3 - if ($paResStatus == 'N' && - $signatureVerification == 'Y' && - $eciFlag == '01' && - $xid != '' && - $cavv == '' && - $errorNo == '0' - ) { - return false; - } - - //Test case 4 - if ($paResStatus == 'U' && - $signatureVerification == 'Y' && - $eciFlag == '01' && - $xid != '' && - $cavv == '' && - $errorNo == '0' - ) { - if ($this->getIsModeStrict()) { - return false; - } else { - return true; - } - } - - //Test case 10 - if ($paResStatus == '' && - $signatureVerification == '' && - $eciFlag == '01' && - $xid == '' && - $cavv == '' && - $errorNo == '1050' - ) { - return false; - } - } - - //Test cases 5-9 - if (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) { - if ($paResStatus == '' && - $signatureVerification == '' && - $eciFlag == '' && - $xid == '' && - $cavv == '' && - $errorNo == '0' - ) { - return true; - } elseif ($paResStatus == false && - $signatureVerification == false && - $eciFlag == false && - $xid == false && - $cavv == false && - $errorNo == false - ) { - return true; - } - } - - return false; - } - - /** - * Analyse lookup`s results. If lookup is strict successful return true - * - * @return bool - */ - protected function _isLookupStrictSuccessful() - { - //Test cases 1-4, 10 - if ($this->getLookupEnrolled() == 'Y' && - $this->getLookupAcsUrl() != '' && - $this->getLookupPayload() != '' && - $this->getLookupErrorNo() == '0' - ) { - return true; - } - return false; - } - - /** - * Analyse lookup`s results. If lookup is soft successful return true - * - * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - protected function _isLookupSoftSuccessful() - { - $acsUrl = $this->getLookupAcsUrl(); - $payload = $this->getLookupPayload(); - $errorNo = $this->getLookupErrorNo(); - $enrolled = $this->getLookupEnrolled(); - - //Test cases 6,7 - if ($acsUrl == '' && $payload == '' && $errorNo == '0' && ($enrolled == 'N' || $enrolled == 'U')) { - return true; - } - - //Test case 5 - if ($enrolled == '' && $acsUrl == '' && $payload == '' && $errorNo == 'Timeout number') { - return true; - } - - //Test cases 8,9 - if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001') { - return true; - } - - return false; - } -} diff --git a/app/code/Magento/Centinel/Model/State/Visa.php b/app/code/Magento/Centinel/Model/State/Visa.php deleted file mode 100644 index d667cc51daa15..0000000000000 --- a/app/code/Magento/Centinel/Model/State/Visa.php +++ /dev/null @@ -1,184 +0,0 @@ -_isLookupStrictSuccessful() && $this->getAuthenticateEciFlag() === null; - } - - /** - * Analyse authenticate`s results. If authenticate is successful return true and false if it failure - * Result depends from flag self::getIsModeStrict() - * - * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function isAuthenticateSuccessful() - { - $paResStatus = $this->getAuthenticatePaResStatus(); - $eciFlag = $this->getAuthenticateEciFlag(); - $xid = $this->getAuthenticateXid(); - $cavv = $this->getAuthenticateCavv(); - $errorNo = $this->getAuthenticateErrorNo(); - $signatureVerification = $this->getAuthenticateSignatureVerification(); - - //Test cases 1-5, 11 - if ($this->_isLookupStrictSuccessful()) { - if ($paResStatus == 'Y' && $eciFlag == '05' && $xid != '' && $cavv != '' && $errorNo == '0') { - //Test case 1 - if ($signatureVerification == 'Y') { - return true; - } - //Test case 2 - if ($signatureVerification == 'N') { - return false; - } - } - - //Test case 3 - if ($paResStatus == 'N' && - $signatureVerification == 'Y' && - $eciFlag == '07' && - $xid != '' && - $cavv == '' && - $errorNo == '0' - ) { - return false; - } - - //Test case 4 - if ($paResStatus == 'A' && - $signatureVerification == 'Y' && - $eciFlag == '06' && - $xid != '' && - $cavv != '' && - $errorNo == '0' - ) { - if ($this->getIsModeStrict()) { - return false; - } else { - return true; - } - } - - //Test case 5 - if ($paResStatus == 'U' && - $signatureVerification == 'Y' && - $eciFlag == '07' && - $xid != '' && - $cavv == '' && - $errorNo == '0' - ) { - if ($this->getIsModeStrict()) { - return false; - } else { - return true; - } - } - - //Test case 11 - if ($paResStatus == 'U' && - $signatureVerification == '' && - $eciFlag == '07' && - $xid == '' && - $cavv == '' && - $errorNo == '1050' - ) { - if ($this->getIsModeStrict()) { - return false; - } else { - return true; - } - } - } - - //Test cases 6-10 - if (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) { - if ($paResStatus == '' && - $signatureVerification == '' && - $eciFlag == '' && - $xid == '' && - $cavv == '' && - $errorNo == '0' - ) { - return true; - } elseif ($paResStatus == false && - $signatureVerification == false && - $eciFlag == false && - $xid == false && - $cavv == false && - $errorNo == false - ) { - return true; - } - } - - return false; - } - - /** - * Analyse lookup`s results. If lookup is strict successful return true - * - * @return bool - */ - protected function _isLookupStrictSuccessful() - { - //Test cases 1-5, 11 - if ($this->getLookupEnrolled() == 'Y' && - $this->getLookupAcsUrl() != '' && - $this->getLookupPayload() != '' && - $this->getLookupErrorNo() == '0' - ) { - return true; - } - return false; - } - - /** - * Analyse lookup`s results. If lookup is soft successful return true - * - * @return bool - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - protected function _isLookupSoftSuccessful() - { - $acsUrl = $this->getLookupAcsUrl(); - $payload = $this->getLookupPayload(); - $errorNo = $this->getLookupErrorNo(); - $enrolled = $this->getLookupEnrolled(); - - //Test cases 7,8 - if ($acsUrl == '' && $payload == '' && $errorNo == '0' && ($enrolled == 'N' || $enrolled == 'U')) { - return true; - } - - //Test case 6 - if ($enrolled == '' && $acsUrl == '' && $payload == '' && $errorNo == 'Timeout number') { - return true; - } - - //Test cases 9,10 - if ($enrolled == 'U' && $acsUrl == '' && $payload == '' && $errorNo == '1001') { - return true; - } - - return false; - } -} diff --git a/app/code/Magento/Centinel/Model/StateFactory.php b/app/code/Magento/Centinel/Model/StateFactory.php deleted file mode 100644 index 71e949e5e6056..0000000000000 --- a/app/code/Magento/Centinel/Model/StateFactory.php +++ /dev/null @@ -1,51 +0,0 @@ -_objectManager = $objectManager; - $this->_stateClassMap = $stateClassMap; - } - - /** - * Create state object - * - * @param string $cardType - * @return \Magento\Centinel\Model\AbstractState|false - */ - public function createState($cardType) - { - if (!isset($this->_stateClassMap[$cardType])) { - return false; - } - return $this->_objectManager->create($this->_stateClassMap[$cardType]); - } -} diff --git a/app/code/Magento/Centinel/README.md b/app/code/Magento/Centinel/README.md deleted file mode 100644 index f0b3f3f7bd253..0000000000000 --- a/app/code/Magento/Centinel/README.md +++ /dev/null @@ -1 +0,0 @@ -The Magento_Centinel module implements the integration with Centinel (Cardinal Centinel Thin Client), a payment gateway from Cardinal Commerce, and enables 3-D Secure credit card validation (that is, Verified by Visa, MasterCard SecureCode and JCB J/Secure Payer Authentication programs). diff --git a/app/code/Magento/Centinel/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Centinel/Test/Unit/Model/ObserverTest.php deleted file mode 100644 index a37c377bc7600..0000000000000 --- a/app/code/Magento/Centinel/Test/Unit/Model/ObserverTest.php +++ /dev/null @@ -1,91 +0,0 @@ -getMockBuilder('Magento\Framework\Model\AbstractExtensibleModel') - ->disableOriginalConstructor() - ->setMethods(['getIsCentinelValidationEnabled', 'getCode']) - ->getMockForAbstractClass(); - $method->expects($this->once()) - ->method('getIsCentinelValidationEnabled') - ->will($this->returnValue(true)); - - $method->expects($this->once()) - ->method('getCode') - ->willReturn('payflowpro'); - - $blockLogo = $this->getMock( - 'Magento\Centinel\Block\Logo', - ['setMethod'], - [], - '', - false - ); - $blockLogo->expects($this->once()) - ->method('setMethod') - ->with($method); - - $layout = $this->getMock( - 'Magento\Framework\View\Layout', - ['createBlock'], - [], - '', - false - ); - $layout->expects($this->once()) - ->method('createBlock') - ->will($this->returnValue($blockLogo)); - - $block = $this->getMock( - 'Magento\Framework\View\Element\Template', - ['getMethod', 'getLayout', 'setChild'], - [], - '', - false - ); - $block->expects($this->once()) - ->method('getMethod') - ->will($this->returnValue($method)); - $block->expects($this->once()) - ->method('getLayout') - ->will($this->returnValue($layout)); - $block->expects($this->once()) - ->method('setChild') - ->with('payment.method.payflowprocentinel.logo', $blockLogo); - - $event = $this->getMock( - 'Magento\Framework\Event', - ['getBlock'], - [], - '', - false - ); - $event->expects($this->once()) - ->method('getBlock') - ->will($this->returnValue($block)); - - $observer = $this->getMock( - 'Magento\Framework\Event\Observer', - [], - [], - '', - false - ); - $observer->expects($this->once()) - ->method('getEvent') - ->will($this->returnValue($event)); - - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Centinel\Model\Observer $model */ - $model = $this->objectManager->getObject('Magento\Centinel\Model\Observer'); - - $this->assertEquals($model->paymentFormBlockToHtmlBefore($observer), $model); - } -} diff --git a/app/code/Magento/Centinel/Test/Unit/Model/ServiceTest.php b/app/code/Magento/Centinel/Test/Unit/Model/ServiceTest.php deleted file mode 100644 index e9b5237e16ead..0000000000000 --- a/app/code/Magento/Centinel/Test/Unit/Model/ServiceTest.php +++ /dev/null @@ -1,137 +0,0 @@ -getMock('Magento\Framework\Url', ['getUrl'], [], '', false); - $url->expects( - $this->once() - )->method( - 'getUrl' - )->with( - $this->equalTo('url_prefix/authenticationstart'), - $this->equalTo(['_secure' => true, '_current' => false, 'form_key' => false, 'isIframe' => true]) - )->will( - $this->returnValue('some value') - ); - - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Centinel\Model\Service $model */ - $model = $helper->getObject( - 'Magento\Centinel\Model\Service', - ['url' => $url, 'urlPrefix' => 'url_prefix/'] - ); - $this->assertEquals('some value', $model->getAuthenticationStartUrl()); - } - - public function testLookup() - { - $centinelSession = $this->getMock( - 'Magento\Framework\Session\SessionManager', - ['setData', 'getData'], - [], - '', - false - ); - $centinelSession->expects($this->once())->method('setData')->with([]); - $centinelSession->expects($this->once())->method('getData')->will($this->returnValue('cardType')); - - $api = $this->getMock( - 'Magento\Centinel\Model\Api', - [ - 'setProcessorId', - 'setMerchantId', - 'setTransactionPwd', - 'setIsTestMode', - 'setDebugFlag', - 'callLookup' - ], - [], - '', - false - ); - $api->expects($this->once())->method('setProcessorId')->will($this->returnValue($api)); - $api->expects($this->once())->method('setMerchantId')->will($this->returnValue($api)); - $api->expects($this->once())->method('setTransactionPwd')->will($this->returnValue($api)); - $api->expects($this->once())->method('setIsTestMode')->will($this->returnValue($api)); - $api->expects($this->once())->method('setDebugFlag')->will($this->returnValue($api)); - $api->expects($this->once())->method('callLookup')->will($this->returnValue('result')); - $apiFactory = $this->getMock('Magento\Centinel\Model\ApiFactory', ['create'], [], '', false); - $apiFactory->expects($this->once())->method('create')->will($this->returnValue($api)); - - $state = $this->getMock( - '\Magento\Centinel\Model\State', - ['setDataStorage', 'setCardType', 'setChecksum', 'setIsModeStrict', 'setLookupResult'], - [], - '', - false - ); - $state->expects( - $this->any() - )->method( - 'setDataStorage' - )->with( - $centinelSession - )->will( - $this->returnValue($state) - ); - $state->expects($this->once())->method('setCardType')->with('cardType')->will($this->returnValue($state)); - $state->expects($this->once())->method('setChecksum')->will($this->returnValue($state)); - $state->expects($this->once())->method('setLookupResult')->with('result'); - $stateFactory = $this->getMock( - '\Magento\Centinel\Model\StateFactory', - ['createState'], - [], - '', - false - ); - $stateFactory->expects( - $this->any() - )->method( - 'createState' - )->with( - 'cardType' - )->will( - $this->returnValue($state) - ); - - $config = $this->getMock( - '\Magento\Centinel\Model\Config', - ['setStore', 'getProcessorId', 'getMerchantId', 'getTransactionPwd', 'getIsTestMode', 'getDebugFlag'], - [], - '', - false - ); - $config->expects($this->once())->method('setStore')->will($this->returnValue($config)); - - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Centinel\Model\Service $model */ - $model = $helper->getObject( - 'Magento\Centinel\Model\Service', - [ - 'apiFactory' => $apiFactory, - 'centinelSession' => $centinelSession, - 'stateFactory' => $stateFactory, - 'config' => $config - ] - ); - - $data = new \Magento\Framework\Object(['card_type' => 'cardType']); - - $model->lookup($data); - } -} diff --git a/app/code/Magento/Centinel/Test/Unit/Model/State/JcbTest.php b/app/code/Magento/Centinel/Test/Unit/Model/State/JcbTest.php deleted file mode 100644 index bf72a0b64e878..0000000000000 --- a/app/code/Magento/Centinel/Test/Unit/Model/State/JcbTest.php +++ /dev/null @@ -1,848 +0,0 @@ -_model = new \Magento\Centinel\Model\State\Jcb(); - $this->_model->setDataStorage(new \Magento\Framework\Object()); - } - - /** - * @param bool $result - * @param array $lookupResults - * @param array $params - * @dataProvider testIsAuthenticateAllowedDataProvider - */ - public function testIsAuthenticateAllowed($result, $lookupResults, $params) - { - $this->_model->setLookupResult(new \Magento\Framework\Object($lookupResults)); - $this->_model->setAuthenticateResult(new \Magento\Framework\Object($params)); - $this->assertEquals($result, $this->_model->isAuthenticateAllowed()); - } - - public function testIsAuthenticateAllowedDataProvider() - { - return [ - 'successful lookup and empty authentication' => [ - true, - [ - 'enrolled' => 'Y', - 'acs_url' => 'no empty value', - 'payload' => 'no empty value', - 'error_no' => '0' - ], - [], - ], - 'wrong lookup and empty authentication' => [false, [], []], - 'successful lookup and not empty authentication' => [ - false, - [ - 'enrolled' => 'Y', - 'acs_url' => 'no empty value', - 'payload' => 'no empty value', - 'error_no' => '0' - ], - ['eci_flag' => 'value'], - ], - 'wrong lookup and not empty authentication' => [false, [], ['eci_flag' => 'value']] - ]; - } - - public function testIsAuthenticateSuccessfulWithSoftLookup() - { - $lookupResults = ['enrolled' => '', 'acs_url' => '', 'payload' => '', 'error_no' => '0']; - $this->_model->setLookupResult(new \Magento\Framework\Object($lookupResults)); - - $this->_model->setIsModeStrict(true); - $this->assertEquals(false, $this->_model->isAuthenticateSuccessful()); - - $this->_model->setIsModeStrict(false); - $this->assertEquals(true, $this->_model->isAuthenticateSuccessful()); - } - - /** - * @param bool $result - * @param bool $strictMode - * @param array $params - * @dataProvider isAuthenticateSuccessfulDataProvider - */ - public function testIsAuthenticateSuccessful($result, $strictMode, $params) - { - $strictMode = $strictMode; - // PHPMD bug: unused local variable warning - $this->_model->setIsModeStrict($strictMode); - $lookupResult = [ - 'enrolled' => 'Y', - 'acs_url' => 'no empty value', - 'payload' => 'no empty value', - 'error_no' => '0', - ]; - $this->_model->setLookupResult(new \Magento\Framework\Object($lookupResult)); - $this->_model->setAuthenticateResult(new \Magento\Framework\Object($params)); - - $this->assertEquals($result, $this->_model->isAuthenticateSuccessful()); - } - - public function isAuthenticateSuccessfulDataProvider() - { - return array_merge( - $this->_getAuthenticationSuccessfulData(), - $this->_getAuthenticationUnavailableData(), - $this->_getProcessingAttemptsPerformedData(), - [ - 'Centinel case 2' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'N' - ], - ], - 'Centinel case 3' => [ - false, - true, - [ - 'pa_res_status' => 'N', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 10' => [ - false, - true, - [ - 'pa_res_status' => '', - 'signature_verification' => '', - 'eci_flag' => '07', - 'xid' => '', - 'cavv' => '', - 'error_no' => 'not zero' - ], - ] - ] - ); - } - - /** - * Data for successful authentication - * - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function _getAuthenticationSuccessfulData() - { - return [ - 'Centinel case 1' => [ - true, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 pa_res_status is absent' => [ - false, - true, - [ - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 eci_flag is absent' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 xid is absent' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 cavv is absent' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 error_no is absent' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 signature_verification is absent' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 1 wrong pa_res_status' => [ - false, - true, - [ - 'pa_res_status' => 'wrong value', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 wrong eci_flag' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => 'wrong value', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 empty xid' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => '', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 empty cavv' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 no zero error_no' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => 'no zero', - 'signature_verification' => 'Y' - ], - ], - 'Centinel case 1 wrong signature_verification' => [ - false, - true, - [ - 'pa_res_status' => 'Y', - 'eci_flag' => '05', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0', - 'signature_verification' => 'wrong value' - ], - ], - 'Centinel case 1 no params' => [false, true, []] - ]; - } - - /** - * Data for unavailable authentication - * - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function _getAuthenticationUnavailableData() - { - return [ - 'Centinel case 4,5 in strict mode' => [ - false, - true, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5' => [ - true, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 pa_res_status is absent' => [ - false, - false, - [ - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 signature_verification is absent' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 eci_flag is absent' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 xid is absent' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 cavv is absent' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 error_no is absent' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '' - ], - ], - 'Centinel case 4,5 wrong pa_res_status' => [ - false, - false, - [ - 'pa_res_status' => 'wrong value', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 wrong signature_verification' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'wrong value', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 wrong eci_flag' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => 'wrong value', - 'xid' => '', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 empty xid' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => '', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 not empty cavv' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => 'not empty', - 'error_no' => '0' - ], - ], - 'Centinel case 4,5 no zero error_no' => [ - false, - false, - [ - 'pa_res_status' => 'U', - 'signature_verification' => 'Y', - 'eci_flag' => '07', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => 'no zero' - ], - ], - 'Centinel case 4,5 no params' => [false, false, []] - ]; - } - - /** - * Data for attempts performed processing - * - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function _getProcessingAttemptsPerformedData() - { - return [ - 'Centinel case 11' => [ - true, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 pa_res_status is absent' => [ - false, - true, - [ - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 signature_verification is absent' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 eci_flag is absent' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 xid is absent' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 cavv is absent' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 error_no is absent' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string' - ], - ], - 'Centinel case no params' => [false, true, []], - 'Centinel case 11 wrong pa_res_status' => [ - false, - true, - [ - 'pa_res_status' => 'wrong value', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 wrong signature_verification' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'wrong value', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 wrong eci_flag' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => 'wrong value', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 empty xid' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => '', - 'cavv' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel case 11 empty cavv' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => '', - 'error_no' => '0' - ], - ], - 'Centinel case 11 no zero' => [ - false, - true, - [ - 'pa_res_status' => 'A', - 'signature_verification' => 'Y', - 'eci_flag' => '06', - 'xid' => 'some string', - 'cavv' => 'some string', - 'error_no' => 'no zero' - ], - ] - ]; - } - - /** - * @param bool $result - * @param bool $strictMode - * @param array $params - * @dataProvider isLookupSuccessfulDataProvider - */ - public function testIsLookupSuccessful($result, $strictMode, $params) - { - $this->_model->setLookupResult(new \Magento\Framework\Object($params)); - $this->_model->setIsModeStrict($strictMode); - $this->assertEquals($result, $this->_model->isLookupSuccessful()); - } - - public function isLookupSuccessfulDataProvider() - { - return array_merge($this->_getSoftSuccessfulLookupData(), $this->_getStrictSuccessfulLookupData()); - } - - /** - * Data for soft successful lookup - * - * @return array - */ - protected function _getSoftSuccessfulLookupData() - { - return [ - 'Centinel case 5' => [ - true, - false, - ['enrolled' => '', 'acs_url' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 5 enrolled is absent' => [ - false, - false, - ['acs_url' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 5 acs_url is absent' => [ - false, - false, - ['enrolled' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 5 payload is absent' => [ - false, - false, - ['enrolled' => '', 'acs_url' => '', 'error_no' => '0'], - ], - 'Centinel case 5 error_no is absent' => [ - false, - false, - ['enrolled' => '', 'acs_url' => '', 'payload' => ''], - ], - 'Centinel case 5 no params' => [false, false, []], - 'Centinel case 5 not empty enrolled' => [ - false, - false, - ['enrolled' => 'not empty', 'acs_url' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 5 not empty acs_url' => [ - false, - false, - ['enrolled' => '', 'acs_url' => 'not empty', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 5 not empty payload' => [ - false, - false, - ['enrolled' => '', 'acs_url' => '', 'payload' => 'not empty', 'error_no' => '0'], - ], - 'Centinel case 5 no zero error_no' => [ - false, - false, - ['enrolled' => '', 'acs_url' => '', 'payload' => '', 'error_no' => 'not zero'], - ], - 'Centinel case 5 empty error_no' => [ - false, - false, - ['enrolled' => '', 'acs_url' => '', 'payload' => '', 'error_no' => ''], - ], - 'Centinel case 7' => [ - true, - false, - ['enrolled' => 'U', 'acs_url' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 8,9' => [ - true, - false, - ['enrolled' => 'U', 'acs_url' => '', 'payload' => '', 'error_no' => 'some string'], - ], - 'Centinel case 7,8,9 enrolled is absent' => [ - false, - false, - ['acs_url' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 7,8,9 acs_url is absent' => [ - false, - false, - ['enrolled' => 'U', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 7,8,9 payload is absent' => [ - false, - false, - ['enrolled' => 'U', 'acs_url' => '', 'error_no' => '0'], - ], - 'Centinel case 7,8,9 error_no no params' => [false, false, []], - 'Centinel case 7,8,9 wrong enrolled' => [ - false, - false, - ['enrolled' => 'wrong value', 'acs_url' => '', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 7,8,9 not empty acs_url' => [ - false, - false, - ['enrolled' => 'U', 'acs_url' => 'not empty', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel case 7,8,9 not empty payload' => [ - false, - false, - ['enrolled' => 'U', 'acs_url' => '', 'payload' => 'not empty', 'error_no' => '0'], - ] - ]; - } - - /** - * Data for strict successful lookup - * - * @return array - */ - protected function _getStrictSuccessfulLookupData() - { - return [ - 'Centinel cases 1-4, 6, 10-11' => [ - true, - true, - ['enrolled' => 'Y', 'acs_url' => 'some string', 'payload' => 'some string', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 enrolled is absent' => [ - false, - true, - ['acs_url' => 'some string', 'payload' => 'some string', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 acs_url is absent' => [ - false, - true, - ['enrolled' => 'Y', 'payload' => 'some string', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 payload is absent' => [ - false, - true, - ['enrolled' => 'Y', 'acs_url' => 'some string', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 error_no is absent' => [ - false, - true, - ['enrolled' => 'Y', 'acs_url' => 'some string', 'payload' => 'some string'], - ], - 'Centinel cases 1-4, 6, 10-11 no params' => [false, true, []], - 'Centinel cases 1-4, 6, 10-11 wrong enrolled' => [ - false, - true, - [ - 'enrolled' => 'wrong value', - 'acs_url' => 'some string', - 'payload' => 'some string', - 'error_no' => '0' - ], - ], - 'Centinel cases 1-4, 6, 10-11 empty enrolled' => [ - false, - true, - ['enrolled' => '', 'acs_url' => 'some string', 'payload' => 'some string', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 empty acs_url' => [ - false, - true, - ['enrolled' => 'Y', 'acs_url' => '', 'payload' => 'some string', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 empty payload' => [ - false, - true, - ['enrolled' => 'Y', 'acs_url' => 'some string', 'payload' => '', 'error_no' => '0'], - ], - 'Centinel cases 1-4, 6, 10-11 wrong error_no' => [ - false, - true, - [ - 'enrolled' => 'Y', - 'acs_url' => 'some string', - 'payload' => 'some string', - 'error_no' => 'wrong value' - ], - ], - 'Centinel cases 1-4, 6, 10-11 empty error_no' => [ - false, - true, - ['enrolled' => 'Y', 'acs_url' => 'some string', 'payload' => 'some string', 'error_no' => ''], - ] - ]; - } -} diff --git a/app/code/Magento/Centinel/Test/Unit/Model/StateFactoryTest.php b/app/code/Magento/Centinel/Test/Unit/Model/StateFactoryTest.php deleted file mode 100644 index 4614ed11af44e..0000000000000 --- a/app/code/Magento/Centinel/Test/Unit/Model/StateFactoryTest.php +++ /dev/null @@ -1,78 +0,0 @@ -getMock('Magento\Framework\ObjectManagerInterface'); - $objectManager->expects( - $this->at(0) - )->method( - 'create' - )->with( - 'Magento\Centinel\Model\State\Visa' - )->will( - $this->returnValue($this->getMock('Magento\Centinel\Model\State\Visa')) - ); - $objectManager->expects( - $this->at(1) - )->method( - 'create' - )->with( - 'Magento\Centinel\Model\State\Mastercard' - )->will( - $this->returnValue($this->getMock('Magento\Centinel\Model\State\Mastercard')) - ); - $objectManager->expects( - $this->at(2) - )->method( - 'create' - )->with( - 'Magento\Centinel\Model\State\Jcb' - )->will( - $this->returnValue($this->getMock('Magento\Centinel\Model\State\Jcb')) - ); - $objectManager->expects( - $this->at(3) - )->method( - 'create' - )->with( - 'Magento\Centinel\Model\State\Mastercard' - )->will( - $this->returnValue($this->getMock('Magento\Centinel\Model\State\Mastercard')) - ); - - $factory = new \Magento\Centinel\Model\StateFactory( - $objectManager, - [ - 'VI' => 'Magento\Centinel\Model\State\Visa', - 'MC' => 'Magento\Centinel\Model\State\Mastercard', - 'JCB' => 'Magento\Centinel\Model\State\Jcb', - 'SM' => 'Magento\Centinel\Model\State\Mastercard' - ] - ); - $this->assertInstanceOf('Magento\Centinel\Model\State\Visa', $factory->createState('VI')); - $this->assertInstanceOf('Magento\Centinel\Model\State\Mastercard', $factory->createState('MC')); - $this->assertInstanceOf('Magento\Centinel\Model\State\Jcb', $factory->createState('JCB')); - $this->assertInstanceOf('Magento\Centinel\Model\State\Mastercard', $factory->createState('SM')); - $this->assertFalse($factory->createState('LOL')); - } - - public function testCreateStateMapIsEmpty() - { - $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $factory = new \Magento\Centinel\Model\StateFactory($objectManager); - $this->assertFalse($factory->createState('VI')); - $this->assertFalse($factory->createState('MC')); - $this->assertFalse($factory->createState('JCB')); - $this->assertFalse($factory->createState('SM')); - $this->assertFalse($factory->createState('LOL')); - } -} diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json deleted file mode 100644 index c5d8f9f3577f9..0000000000000 --- a/app/code/Magento/Centinel/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "magento/module-centinel", - "description": "N/A", - "require": { - "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/magento-composer-installer": "*" - }, - "type": "magento2-module", - "version": "0.74.0-beta9", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "extra": { - "map": [ - [ - "*", - "Magento/Centinel" - ] - ] - } -} diff --git a/app/code/Magento/Centinel/etc/adminhtml/di.xml b/app/code/Magento/Centinel/etc/adminhtml/di.xml deleted file mode 100644 index 87e976b536e30..0000000000000 --- a/app/code/Magento/Centinel/etc/adminhtml/di.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - centinel_validator - - - - - Magento\Centinel\Model\Session\Storage - - - - - Magento\Backend\Model\UrlInterface - Magento\Centinel\Model\Session - adminhtml/centinel_index/ - - - diff --git a/app/code/Magento/Centinel/etc/adminhtml/system.xml b/app/code/Magento/Centinel/etc/adminhtml/system.xml deleted file mode 100644 index 643f1878b6282..0000000000000 --- a/app/code/Magento/Centinel/etc/adminhtml/system.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - -
- - sales - Magento_Payment::payment_services - - - - - - - - - - - Magento\Config\Model\Config\Backend\Encrypted - - - - This overrides any API URL that may be specified by a payment method. - Magento\Config\Model\Config\Source\Yesno - - - - Magento\Config\Model\Config\Source\Yesno - - -
-
-
diff --git a/app/code/Magento/Centinel/etc/di.xml b/app/code/Magento/Centinel/etc/di.xml deleted file mode 100644 index b970db56e8625..0000000000000 --- a/app/code/Magento/Centinel/etc/di.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - Magento\Centinel\Model\State\Visa - Magento\Centinel\Model\State\Mastercard - Magento\Centinel\Model\State\Jcb - Magento\Centinel\Model\State\Mastercard - - - - diff --git a/app/code/Magento/Centinel/etc/events.xml b/app/code/Magento/Centinel/etc/events.xml deleted file mode 100644 index 3a09cd0c0da1b..0000000000000 --- a/app/code/Magento/Centinel/etc/events.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/Centinel/etc/frontend/di.xml b/app/code/Magento/Centinel/etc/frontend/di.xml deleted file mode 100644 index 4ec66c4094e59..0000000000000 --- a/app/code/Magento/Centinel/etc/frontend/di.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - centinel_validator - - - - - Magento\Centinel\Model\Session\Storage - - - - - - /centinel/ - - - - - - Magento\Centinel\Model\Session - - - diff --git a/app/code/Magento/Centinel/i18n/de_DE.csv b/app/code/Magento/Centinel/i18n/de_DE.csv deleted file mode 100644 index 01df77c497be5..0000000000000 --- a/app/code/Magento/Centinel/i18n/de_DE.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","3D Secure Kartenvalidierung" -"Validation failed.","Validierung ist fehlgeschlagen." -"3D Secure Verification Result","3D Secure Verifizierungsergebnis" -"3D Secure Cardholder Validation","3D Secure Karteninhabervalidierung" -"3D Secure Electronic Commerce Indicator","3D Secure Electronic Commerce Indicator" -"3D Secure CAVV","3D Secure CAVV" -"3D Secure XID","3D Secure XD" -"Merchant Liability","Haftung für Händler" -"Card Issuer Liability","Haftung für Kartenausteller" -Enrolled,Eingeschrieben -"Enrolled but Authentication Unavailable","Eingeschrieben, aber Authentifizierung nicht verfügbar" -"Not Enrolled","Nicht eingeschrieben" -Successful,Erfolgreich -Failed,Fehlgeschlagen -"Unable to complete","Fertigstellung nicht möglich" -"Successful attempt","Erfolgreicher Versuch" -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.","Fehler bei Zahlungsinformation. Bitte versuchen Sie es erneut." -"Please verify the card with the issuer bank before placing the order.","Bitte verifizieren Sie die Karte mit der Ausstellerbank bevor Sie die Bestellung durchführen." -"This card has failed validation and cannot be used.","Diese Karte konnte nicht validiert werden und kann nicht benützt werden." -"Verification Successful","Verifizierung erfolgreich" -"Please continue with placing order.","Bitte fahren Sie mit der Bestellung fort." -"Verification Failed","Verifizierung fehlgeschlagen" -"The card has failed verification with the issuer bank.","Die Karte konnte nicht mit der Ausstellerbank verifiziert werden." -"Order cannot be placed.","Bestellung kann nicht durchgeführt werden." -"Verification cannot be processed","Verifizierung kann nicht verarbeitet werden" -"There has been wrong payment information submitted or time limit has expired. Please, try again.","Es wurden falsche Zahlungsinformationen abgeschickt, oder Zeitlimit ist abgelaufen. Bitte versuchen Sie es erneut." -"Card Verification",Kartenverifizierung -"Start/Reset Validation...","Validierung starten/zurücksetzen..." -"Please verify the card with the issuer bank:","Bitte verifizieren Sie die Karte mit der Ausstellerbank:" -"There has been wrong payment information submitted or the time limit has expired. Please, try again.","Es wurden falsche Zahlungsinformationen abgeschickt, oder das Zeitlimit ist abgelaufen. Bitte versuchen Sie es erneut." -"To ensure the security of your transactions","Um die Sicherheit ihrer Transaktionen zu gewährleisten" -"Verified by Visa","Verified by Visa" -"MasterCard SecureCode","MasterCard SecureCode" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/i18n/en_US.csv b/app/code/Magento/Centinel/i18n/en_US.csv deleted file mode 100644 index 98e02de675243..0000000000000 --- a/app/code/Magento/Centinel/i18n/en_US.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","3D Secure Card Validation" -"Validation failed.","Validation failed." -"3D Secure Verification Result","3D Secure Verification Result" -"3D Secure Cardholder Validation","3D Secure Cardholder Validation" -"3D Secure Electronic Commerce Indicator","3D Secure Electronic Commerce Indicator" -"3D Secure CAVV","3D Secure CAVV" -"3D Secure XID","3D Secure XID" -"Merchant Liability","Merchant Liability" -"Card Issuer Liability","Card Issuer Liability" -Enrolled,Enrolled -"Enrolled but Authentication Unavailable","Enrolled but Authentication Unavailable" -"Not Enrolled","Not Enrolled" -Successful,Successful -Failed,Failed -"Unable to complete","Unable to complete" -"Successful attempt","Successful attempt" -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.","Payment information error. Please start over." -"Please verify the card with the issuer bank before placing the order.","Please verify the card with the issuer bank before placing the order." -"This card has failed validation and cannot be used.","This card has failed validation and cannot be used." -"Verification Successful","Verification Successful" -"Please continue with placing order.","Please continue with placing order." -"Verification Failed","Verification Failed" -"The card has failed verification with the issuer bank.","The card has failed verification with the issuer bank." -"Order cannot be placed.","Order cannot be placed." -"Verification cannot be processed","Verification cannot be processed" -"There has been wrong payment information submitted or time limit has expired. Please, try again.","There has been wrong payment information submitted or time limit has expired. Please, try again." -"Card Verification","Card Verification" -"Start/Reset Validation...","Start/Reset Validation..." -"Please verify the card with the issuer bank:","Please verify the card with the issuer bank:" -"There has been wrong payment information submitted or the time limit has expired. Please, try again.","There has been wrong payment information submitted or the time limit has expired. Please, try again." -"To ensure the security of your transactions","To ensure the security of your transactions" -"Verified by Visa","Verified by Visa" -"MasterCard SecureCode","MasterCard SecureCode" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/i18n/es_ES.csv b/app/code/Magento/Centinel/i18n/es_ES.csv deleted file mode 100644 index d4b4792979a6c..0000000000000 --- a/app/code/Magento/Centinel/i18n/es_ES.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","Validación segura 3D de tarjeta" -"Validation failed.","Validación errónea." -"3D Secure Verification Result","Resultados de la verificación segura 3D" -"3D Secure Cardholder Validation","Validación segura 3D del títular de la tarjeta" -"3D Secure Electronic Commerce Indicator","Indicador comercio electrónico seguro 3D" -"3D Secure CAVV","CAVV Seguro 3D" -"3D Secure XID","XID Seguro 3D" -"Merchant Liability","Responsabilidad del comerciante" -"Card Issuer Liability","Responsabilidad del emisor de la tarjeta" -Enrolled,Inscrito -"Enrolled but Authentication Unavailable","Inscrito pero autentificación no disponible" -"Not Enrolled","No inscrito" -Successful,Exitoso -Failed,"Ha fallado" -"Unable to complete","No se ha podido completar" -"Successful attempt","Intento exitoso" -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.","Error de información de pago. Por favor, comience de nuevo." -"Please verify the card with the issuer bank before placing the order.","Por favor verifique la tarjeta con el banco emisor antes de realizar el pedido." -"This card has failed validation and cannot be used.","Esta tarjeta ha fallado su validación y no puede ser usada." -"Verification Successful","Verificación exitosa" -"Please continue with placing order.","Por favor continue con su pedido." -"Verification Failed","Verificación errónea" -"The card has failed verification with the issuer bank.","La tarjeta ha fallado la verificación con el banco emisor." -"Order cannot be placed.","El pedido no puede ser realizado." -"Verification cannot be processed","La verificación no puede ser procesada" -"There has been wrong payment information submitted or time limit has expired. Please, try again.","Se ha enviado información errónea o el límite de tiempo ha expirado. Por favor, inténtelo de nuevo." -"Card Verification","Verificación de tarjeta" -"Start/Reset Validation...","Comenzar/Resetear validación..." -"Please verify the card with the issuer bank:","Por favor verifique la tarjeta con el banco emisor:" -"There has been wrong payment information submitted or the time limit has expired. Please, try again.","Se ha enviado información errónea o el límite de tiempo ha expirado. Por favor, inténtelo de nuevo." -"To ensure the security of your transactions","Para asegurar la seguridad de sus transacciones" -"Verified by Visa","Verificado por Visa" -"MasterCard SecureCode","MasterCard Código Seguro" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/i18n/fr_FR.csv b/app/code/Magento/Centinel/i18n/fr_FR.csv deleted file mode 100644 index c4679155db4df..0000000000000 --- a/app/code/Magento/Centinel/i18n/fr_FR.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","Validation carte 3D sécurisée" -"Validation failed.","Validation a échouée." -"3D Secure Verification Result","Résultat vérification 3D sécurisé" -"3D Secure Cardholder Validation","Validation porteur de carte 3D sécurisée" -"3D Secure Electronic Commerce Indicator","Indicateur commerce électronique 3D sécurisé" -"3D Secure CAVV","CAVV 3D sécurisé" -"3D Secure XID","XID 3D sécurisé" -"Merchant Liability","Responsabilité du commerçant" -"Card Issuer Liability","Responsabilité de l'émetteur de la carte" -Enrolled,Enrôlé -"Enrolled but Authentication Unavailable","Enrôlé mais authentification non disponible" -"Not Enrolled","Non enrôlé" -Successful,Réussi -Failed,Échec -"Unable to complete","Ne peut compléter" -"Successful attempt","Tentative réussie" -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.","Erreur d'infos de paiement. Veuillez recommencer." -"Please verify the card with the issuer bank before placing the order.","Veuillez vérifier la carte avec la banque émettrice avant de passer la commande." -"This card has failed validation and cannot be used.","La carte n'a pu être validée et ne peut être utilisée." -"Verification Successful","Vérification réussie" -"Please continue with placing order.","Veuillez continuer à faire la commande." -"Verification Failed","Vérification a échouée" -"The card has failed verification with the issuer bank.","La carte n'a pas réussie sa vérification avec la banque émettrice." -"Order cannot be placed.","Commande ne peut être placée." -"Verification cannot be processed","Vérification ne peut être traitée" -"There has been wrong payment information submitted or time limit has expired. Please, try again.","Une mauvaise information de paiement a été soumise ou temps imparti est achevé. Veuillez réessayer." -"Card Verification","Vérification carte" -"Start/Reset Validation...","Démarrer/réinitialiser validation..." -"Please verify the card with the issuer bank:","Veuillez vérifier la carte avec la banque émettrice" -"There has been wrong payment information submitted or the time limit has expired. Please, try again.","Une mauvaise information de paiement a été soumise ou le temps imparti s'est achevé. Veuillez réessayer." -"To ensure the security of your transactions","Pour assurer la sécurité de vos transactions" -"Verified by Visa","Vérifié par Visa" -"MasterCard SecureCode","Code sûr MasterCard" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/i18n/nl_NL.csv b/app/code/Magento/Centinel/i18n/nl_NL.csv deleted file mode 100644 index 9cc11c4a1041b..0000000000000 --- a/app/code/Magento/Centinel/i18n/nl_NL.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","3D Secure Card Validation" -"Validation failed.","Validatie mislukt." -"3D Secure Verification Result","3D Veilig Verificatie Resultaat" -"3D Secure Cardholder Validation","3D Veilige Kaarthouder Verificatie" -"3D Secure Electronic Commerce Indicator","3D Veilige Electronische Commerce Indicator" -"3D Secure CAVV","3D Veilige CAVV" -"3D Secure XID","3D Veilige XID" -"Merchant Liability","Winkelier Aansprakelijkheid" -"Card Issuer Liability","Kaart Uitgever Verplichting" -Enrolled,Ingeschreven -"Enrolled but Authentication Unavailable","Ingeschreven maar Authenticatie niet Beschikbaar" -"Not Enrolled","Niet Ingeschreven" -Successful,Succesvol -Failed,Mislukt -"Unable to complete","Niet afgemaakt" -"Successful attempt","Succesvolle poging" -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.","Betalingsinformatie fout. Start a.u.b. overnieuw." -"Please verify the card with the issuer bank before placing the order.","Verifieer de kaart a.u.b. met de uitgevende bank, voordat u de order plaatst." -"This card has failed validation and cannot be used.","Deze kaart kon niet worden gevalideerd en is onbruikbaar." -"Verification Successful","Verificatie geslaagd" -"Please continue with placing order.","Ga aub verder met plaatsen order." -"Verification Failed","Verificatie mislukt" -"The card has failed verification with the issuer bank.","De kaart verificatie met de uitgevende bank is mislukt." -"Order cannot be placed.","Order kan niet geplaatst worden." -"Verification cannot be processed","Verificatie kan niet worden verwerkt" -"There has been wrong payment information submitted or time limit has expired. Please, try again.","Er is verkeerde betalingsinformatie verzonden of tijdslimiet is verlopen. Probeer a.u.b. opnieuw." -"Card Verification","Kaart Verificatie" -"Start/Reset Validation...","Begin/Herstel Validatie..." -"Please verify the card with the issuer bank:","Verifieer de kaart a.u.b. met de uitgevende bank:" -"There has been wrong payment information submitted or the time limit has expired. Please, try again.","Er is verkeerde betalingsinformatie verzonden of de tijdslimiet is verlopen. Probeer het a.u.b. opnieuw." -"To ensure the security of your transactions","Om de veiligheid van uw transacties te verzekeren" -"Verified by Visa","Geverifieerd door Visa" -"MasterCard SecureCode","MasterCard SecureCode" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/i18n/pt_BR.csv b/app/code/Magento/Centinel/i18n/pt_BR.csv deleted file mode 100644 index c72f80d7a9436..0000000000000 --- a/app/code/Magento/Centinel/i18n/pt_BR.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","Validação de Cartão 3D Secure" -"Validation failed.","Falha de validação." -"3D Secure Verification Result","Resultado de Verificação 3D Secure" -"3D Secure Cardholder Validation","Validação de Portador de Cartão 3D Secure" -"3D Secure Electronic Commerce Indicator","Indicador de Comércio Eletrônico 3D Secure" -"3D Secure CAVV","3D Secure CAVV" -"3D Secure XID","3D Secure XID" -"Merchant Liability","Responsabilidade do Comerciante" -"Card Issuer Liability","Responsabilidade do Emissor do Cartão" -Enrolled,Inscritos -"Enrolled but Authentication Unavailable","Inscritos mas Autenticação Não Disponível" -"Not Enrolled","Não Inscrito" -Successful,"Bem sucedido" -Failed,Falha -"Unable to complete","Incapaz de completar" -"Successful attempt","Tentativa bem sucedida" -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.","Erro de informações de pagamento. Por favor comece de novo." -"Please verify the card with the issuer bank before placing the order.","Por favor verifique o cartão com o banco emissor antes de colocar a ordem." -"This card has failed validation and cannot be used.","A validação do cartão falhou e ele não pode ser utilizado." -"Verification Successful","Sucesso na Verificação" -"Please continue with placing order.","Por favor continuem com a colocação da ordem." -"Verification Failed","Falha de Verificação" -"The card has failed verification with the issuer bank.","O cartão falhou a verificação com o banco emissor." -"Order cannot be placed.","Pedido não pode ser realizado." -"Verification cannot be processed","A verificação não pode ser processada" -"There has been wrong payment information submitted or time limit has expired. Please, try again.","Houve apresentação de informações erradas de pagamento ou prazo expirou. Por favor, tente novamente." -"Card Verification","Verificação de Cartão" -"Start/Reset Validation...","Iniciar/Reiniciar Validação..." -"Please verify the card with the issuer bank:","Por favor verifique o cartão com o banco emissor:" -"There has been wrong payment information submitted or the time limit has expired. Please, try again.","Houve informações de pagamento erradas apresentadas ou o prazo expirou. Por favor tente novamente." -"To ensure the security of your transactions","Para garantir a segurança da sua transação" -"Verified by Visa","Verificado pela Visa" -"MasterCard SecureCode","MasterCard SecureCode" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/i18n/zh_CN.csv b/app/code/Magento/Centinel/i18n/zh_CN.csv deleted file mode 100644 index 225cea16dee0c..0000000000000 --- a/app/code/Magento/Centinel/i18n/zh_CN.csv +++ /dev/null @@ -1,42 +0,0 @@ -"3D Secure Card Validation","3D 安全信用卡验证" -"Validation failed.",验证失败。 -"3D Secure Verification Result","3D 安全验证结果" -"3D Secure Cardholder Validation","3D 安全持卡人验证" -"3D Secure Electronic Commerce Indicator","3D 安全电子商务指标" -"3D Secure CAVV","3D 安全 CAVV" -"3D Secure XID","3D 安全 XID" -"Merchant Liability",商家责任 -"Card Issuer Liability",发卡机构法律责任 -Enrolled,登记 -"Enrolled but Authentication Unavailable",已登记但验证不可用 -"Not Enrolled",未登记 -Successful,成功 -Failed,已失败 -"Unable to complete",无法完成 -"Successful attempt",成功尝试 -"Unsupported currency code: %1.","Unsupported currency code: %1." -"Payment information error. Please start over.",支付信息错误。请重新开始。 -"Please verify the card with the issuer bank before placing the order.",在下订单前,请与发卡行验证信用卡。 -"This card has failed validation and cannot be used.",信用卡验证失败,无法使用。 -"Verification Successful",验证成功 -"Please continue with placing order.",请继续下订单。 -"Verification Failed",验证失败 -"The card has failed verification with the issuer bank.",卡片与发卡行的验证失败。 -"Order cannot be placed.",无法下订单。 -"Verification cannot be processed",验证工作无法处理 -"There has been wrong payment information submitted or time limit has expired. Please, try again.",提交的支付信息错误,或时间限制已到。请重试。 -"Card Verification",信用卡验证 -"Start/Reset Validation...",开始/重设验证... -"Please verify the card with the issuer bank:",请与发卡行验证信用卡: -"There has been wrong payment information submitted or the time limit has expired. Please, try again.",已提交错误的支付信息,或时间限制已过。请重试。 -"To ensure the security of your transactions",要确保您的交易安全 -"Verified by Visa","Visa 已验证" -"MasterCard SecureCode","MasterCard 安全代码" -Password,Password -"Test Mode","Test Mode" -"Payment Services","Payment Services" -"3D Secure Credit Card Validation","3D Secure Credit Card Validation" -"Processor ID","Processor ID" -"Merchant ID","Merchant ID" -"This overrides any API URL that may be specified by a payment method.","This overrides any API URL that may be specified by a payment method." -"Debug Mode","Debug Mode" diff --git a/app/code/Magento/Centinel/view/adminhtml/layout/adminhtml_centinel_index_authenticationcomplete.xml b/app/code/Magento/Centinel/view/adminhtml/layout/adminhtml_centinel_index_authenticationcomplete.xml deleted file mode 100644 index 24bd3da34274c..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/layout/adminhtml_centinel_index_authenticationcomplete.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/app/code/Magento/Centinel/view/adminhtml/layout/adminhtml_centinel_index_authenticationstart.xml b/app/code/Magento/Centinel/view/adminhtml/layout/adminhtml_centinel_index_authenticationstart.xml deleted file mode 100644 index c7710e5391f00..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/layout/adminhtml_centinel_index_authenticationstart.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_index.xml deleted file mode 100644 index 2289c87584180..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_index.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_load_block_card_validation.xml b/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_load_block_card_validation.xml deleted file mode 100644 index 6da07e72baf68..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_load_block_card_validation.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_load_block_data.xml b/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_load_block_data.xml deleted file mode 100644 index 0a7d6cead32ae..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_load_block_data.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_start.xml b/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_start.xml deleted file mode 100644 index 5966970282ad3..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/layout/sales_order_create_start.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/app/code/Magento/Centinel/view/adminhtml/templates/authentication/complete.phtml b/app/code/Magento/Centinel/view/adminhtml/templates/authentication/complete.phtml deleted file mode 100644 index 6d7a00e1d9fd0..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/templates/authentication/complete.phtml +++ /dev/null @@ -1,21 +0,0 @@ - -getIsProcessed()):?> - getIsSuccess()):?> -

-

- -

-

- - -

-

- diff --git a/app/code/Magento/Centinel/view/adminhtml/templates/authentication/start.phtml b/app/code/Magento/Centinel/view/adminhtml/templates/authentication/start.phtml deleted file mode 100644 index fc8b8705c57a3..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/templates/authentication/start.phtml +++ /dev/null @@ -1,18 +0,0 @@ - -
- - - -
- diff --git a/app/code/Magento/Centinel/view/adminhtml/templates/order/create/abstract.phtml b/app/code/Magento/Centinel/view/adminhtml/templates/order/create/abstract.phtml deleted file mode 100644 index 802e8c8759f97..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/templates/order/create/abstract.phtml +++ /dev/null @@ -1,14 +0,0 @@ - - -
- getHeaderText() ?> -
getButtonsHtml() ?>
-
-
- getChildHtml('', true) ?> -
diff --git a/app/code/Magento/Centinel/view/adminhtml/templates/validation/form.phtml b/app/code/Magento/Centinel/view/adminhtml/templates/validation/form.phtml deleted file mode 100644 index 0f6bc0416f160..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/templates/validation/form.phtml +++ /dev/null @@ -1,33 +0,0 @@ - - -
-
- -
-
- -
- -
- - diff --git a/app/code/Magento/Centinel/view/adminhtml/web/order_create.js b/app/code/Magento/Centinel/view/adminhtml/web/order_create.js deleted file mode 100644 index 184bfd307a3f0..0000000000000 --- a/app/code/Magento/Centinel/view/adminhtml/web/order_create.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define(["prototype"], function(){ - -window.centinelValidator = new Class.create(); - -centinelValidator.prototype = { - - initialize : function(method, validationUrl, containerId){ - this.method = method; - this.validationUrl = validationUrl; - this.containerId = containerId; - }, - - validate : function(){ - if (order.paymentMethod != this.method) { - return false; - } - var params = order.getPaymentData(); - params = order.prepareParams(params); - params.json = true; - - new Ajax.Request(this.validationUrl, { - parameters:params, - method:'post', - onSuccess: function(transport) { - var response = transport.responseText.evalJSON(); - if (response.authenticationUrl) { - this.autenticationStart(response.authenticationUrl); - } - if (response.message) { - this.autenticationFinish(response.message); - } - }.bind(this) - }); - }, - - autenticationStart : function(url) { - this.getContainer().src = url; - this.getContainer().style.display = 'block'; - }, - - autenticationFinish : function(message) { - alert(message); - this.getContainer().style.display = 'none'; - }, - - getContainer : function() { - return $(this.containerId); - } - -}; - -}); \ No newline at end of file diff --git a/app/code/Magento/Centinel/view/frontend/layout/centinel_index_authenticationcomplete.xml b/app/code/Magento/Centinel/view/frontend/layout/centinel_index_authenticationcomplete.xml deleted file mode 100644 index c8d40e57f459b..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/layout/centinel_index_authenticationcomplete.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/app/code/Magento/Centinel/view/frontend/layout/centinel_index_authenticationstart.xml b/app/code/Magento/Centinel/view/frontend/layout/centinel_index_authenticationstart.xml deleted file mode 100644 index 5305d4fdb46b7..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/layout/centinel_index_authenticationstart.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/app/code/Magento/Centinel/view/frontend/layout/checkout_onepage_review.xml b/app/code/Magento/Centinel/view/frontend/layout/checkout_onepage_review.xml deleted file mode 100644 index 6bdbb4f91bf78..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/layout/checkout_onepage_review.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - instant - - - - - diff --git a/app/code/Magento/Centinel/view/frontend/layout/multishipping_checkout_overview.xml b/app/code/Magento/Centinel/view/frontend/layout/multishipping_checkout_overview.xml deleted file mode 100644 index d94c2799038d7..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/layout/multishipping_checkout_overview.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - window - - - - - diff --git a/app/code/Magento/Centinel/view/frontend/requirejs-config.js b/app/code/Magento/Centinel/view/frontend/requirejs-config.js deleted file mode 100644 index ffffa3738afb2..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/requirejs-config.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -var config = { - map: { - '*': { - centinelAuthenticate: 'Magento_Centinel/centinel-authenticate' - } - } -}; \ No newline at end of file diff --git a/app/code/Magento/Centinel/view/frontend/templates/authentication.phtml b/app/code/Magento/Centinel/view/frontend/templates/authentication.phtml deleted file mode 100644 index eadafd6baadf0..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/templates/authentication.phtml +++ /dev/null @@ -1,26 +0,0 @@ - -getAuthenticationStart()):?> -
-

-

-
- -
-
- - - diff --git a/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml b/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml deleted file mode 100644 index 7e0f67b8c22f5..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml +++ /dev/null @@ -1,24 +0,0 @@ - -getIsProcessed()):?> - getIsSuccess()):?> - - -

-

- - -

-

- diff --git a/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml b/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml deleted file mode 100644 index 22763408138fb..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml +++ /dev/null @@ -1,21 +0,0 @@ - -
-
- - - -
-
- diff --git a/app/code/Magento/Centinel/view/frontend/templates/logo.phtml b/app/code/Magento/Centinel/view/frontend/templates/logo.phtml deleted file mode 100644 index f67f720dc7f34..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/templates/logo.phtml +++ /dev/null @@ -1,18 +0,0 @@ - - diff --git a/app/code/Magento/Centinel/view/frontend/web/centinel-authenticate.js b/app/code/Magento/Centinel/view/frontend/web/centinel-authenticate.js deleted file mode 100644 index 701d373ebee08..0000000000000 --- a/app/code/Magento/Centinel/view/frontend/web/centinel-authenticate.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint jquery:true*/ -define([ - "jquery", - "jquery/ui" -], function($){ - "use strict"; - - $.widget('mage.centinelAuthenticate', { - options : { - frameUrl: '', - iframeSelector: '[data-container="iframe"]', - bodySelector: '[data-container="body"]' - }, - - _create : function() { - // listen for the custom event for changing state - this.element.closest(this.options.bodySelector).on("paymentAuthentication", $.proxy(this._paymentmentAthenticationTrigger, this)); - }, - - _init: function() { - this._isAuthenticationStarted = false; - - // show the frame with the appropriate URL - this.element.find(this.options.iframeSelector).prop('src', this.options.frameUrl); - this.element.show(); - }, - - /** - * This method is used to cancel the call to Centinel from a display perspective as it shows the related blocks and hides the frame. - * @public - */ - cancel : function() { - this.element.hide(); - this.element.find(this.options.iframeSelector).prop('src', ''); - this._isAuthenticationStarted = false; - }, - - /** - * This method is used to complete the interaction from Centinel and resets the display so the order can be placed. - * @public - */ - success : function() { - this.element.hide(); - this._isAuthenticationStarted = false; - }, - - /** - * This method processes the paymentAuthentication actions. - */ - _paymentmentAthenticationTrigger : function(event, data) { - if (data.state === 'start') { - this._start(); - } else if (data.state === 'success') { - this.success(); - } else if (data.state === 'cancel') { - this.cancel(); - } - }, - - /** - * This method is used to initiate the call to Centinel from a display perspective as it hides the related blocks and shows the frame. It also sets the URL in the frame, which initiates the interaction with Centinel. - * @private - */ - _start : function() { - this._isAuthenticationStarted = true; - } - }); - - return $.mage.centinelAuthenticate; -}); \ No newline at end of file diff --git a/app/code/Magento/Centinel/view/frontend/web/images/sc_learn_62x34.png b/app/code/Magento/Centinel/view/frontend/web/images/sc_learn_62x34.png deleted file mode 100644 index 54991ada1dd7b..0000000000000 Binary files a/app/code/Magento/Centinel/view/frontend/web/images/sc_learn_62x34.png and /dev/null differ diff --git a/app/code/Magento/Centinel/view/frontend/web/images/vbv_ltbg_71x57.png b/app/code/Magento/Centinel/view/frontend/web/images/vbv_ltbg_71x57.png deleted file mode 100644 index 691741056a416..0000000000000 Binary files a/app/code/Magento/Centinel/view/frontend/web/images/vbv_ltbg_71x57.png and /dev/null differ diff --git a/app/code/Magento/Checkout/Block/Cart/AbstractCart.php b/app/code/Magento/Checkout/Block/Cart/AbstractCart.php index 0b383b5c87f7f..be743df6033e1 100644 --- a/app/code/Magento/Checkout/Block/Cart/AbstractCart.php +++ b/app/code/Magento/Checkout/Block/Cart/AbstractCart.php @@ -33,6 +33,8 @@ class AbstractCart extends \Magento\Framework\View\Element\Template protected $_itemRenders = []; /** + * TODO: MAGETWO-34827: unused object? + * * @var \Magento\Customer\Model\Session */ protected $_customerSession; diff --git a/app/code/Magento/Checkout/Block/Cart/EmptyCart.php b/app/code/Magento/Checkout/Block/Cart/EmptyCart.php deleted file mode 100644 index 75928dc465489..0000000000000 --- a/app/code/Magento/Checkout/Block/Cart/EmptyCart.php +++ /dev/null @@ -1,39 +0,0 @@ -_isScopePrivate = false; - } -} diff --git a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php index f8e52e1bde13b..7394a876366be 100644 --- a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php @@ -21,7 +21,7 @@ * @method \Magento\Checkout\Block\Cart\Item\Renderer setDeleteUrl(string) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Renderer extends \Magento\Framework\View\Element\Template implements \Magento\Framework\View\Block\IdentityInterface +class Renderer extends \Magento\Framework\View\Element\Template implements \Magento\Framework\Object\IdentityInterface { /** * @var \Magento\Checkout\Model\Session @@ -375,7 +375,7 @@ public function getMessages() } /* @var $collection \Magento\Framework\Message\Collection */ - $collection = $this->messageManager->getMessages('quote_item' . $quoteItem->getId()); + $collection = $this->messageManager->getMessages(true, 'quote_item' . $quoteItem->getId()); if ($collection) { $additionalMessages = $collection->getItems(); foreach ($additionalMessages as $message) { diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar.php b/app/code/Magento/Checkout/Block/Cart/Sidebar.php index 549b8c8a54437..593f1bd35806d 100644 --- a/app/code/Magento/Checkout/Block/Cart/Sidebar.php +++ b/app/code/Magento/Checkout/Block/Cart/Sidebar.php @@ -8,156 +8,58 @@ namespace Magento\Checkout\Block\Cart; -use Magento\Framework\View\Block\IdentityInterface; use Magento\Store\Model\ScopeInterface; /** - * Wishlist sidebar block + * Cart sidebar block */ -class Sidebar extends AbstractCart implements IdentityInterface +class Sidebar extends AbstractCart { /** - * Xml pah to chackout sidebar count value + * Xml pah to checkout sidebar count value */ - const XML_PATH_CHECKOUT_SIDEBAR_COUNT = 'checkout/sidebar/count'; const XML_PATH_CHECKOUT_SIDEBAR_DISPLAY = 'checkout/sidebar/display'; /** - * @var \Magento\Catalog\Model\Resource\Url + * @var \Magento\Catalog\Model\Product\Image\View */ - protected $_catalogUrl; - - /** - * @var \Magento\Checkout\Model\Cart - */ - protected $_checkoutCart; - - /** - * @var \Magento\Checkout\Helper\Data - */ - protected $_checkoutHelper; + protected $imageView; /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Checkout\Model\Cart $checkoutCart - * @param \Magento\Checkout\Helper\Data $checkoutHelper + * @param \Magento\Catalog\Model\Product\Image\View $imageView + * @param \Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface $jsLayoutDataProvider * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Checkout\Model\Cart $checkoutCart, - \Magento\Checkout\Helper\Data $checkoutHelper, + \Magento\Catalog\Model\Product\Image\View $imageView, + \Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface $jsLayoutDataProvider, array $data = [] ) { - $this->_checkoutHelper = $checkoutHelper; - $this->_catalogUrl = $catalogUrl; - $this->_checkoutCart = $checkoutCart; - parent::__construct($context, $customerSession, $checkoutSession, $data); - $this->_isScopePrivate = true; - } - - /** - * Retrieve count of display recently added items - * - * @return int - */ - public function getItemCount() - { - $count = $this->getData('item_count'); - if (is_null($count)) { - $count = $this->_scopeConfig->getValue( - self::XML_PATH_CHECKOUT_SIDEBAR_COUNT, - ScopeInterface::SCOPE_STORE - ); - $this->setData('item_count', $count); - } - return $count; - } - - /** - * Get array of last added items - * - * @param int|null $count - * @return array - */ - public function getRecentItems($count = null) - { - if ($count === null) { - $count = $this->getItemCount(); - } - - $items = []; - if (!$this->getSummaryCount()) { - return $items; + if (isset($data['jsLayout'])) { + $this->jsLayout = array_merge_recursive($jsLayoutDataProvider->getData(), $data['jsLayout']); + unset($data['jsLayout']); + } else { + $this->jsLayout = $jsLayoutDataProvider->getData(); } - - $i = 0; - $allItems = array_reverse($this->getItems()); - foreach ($allItems as $item) { - /* @var $item \Magento\Quote\Model\Quote\Item */ - if (!$item->getProduct()->isVisibleInSiteVisibility()) { - $productId = $item->getProduct()->getId(); - $products = $this->_catalogUrl->getRewriteByProductStore([$productId => $item->getStoreId()]); - if (!isset($products[$productId])) { - continue; - } - $urlDataObject = new \Magento\Framework\Object($products[$productId]); - $item->getProduct()->setUrlDataObject($urlDataObject); - } - - $items[] = $item; - if (++$i == $count) { - break; - } - } - - return $items; - } - - /** - * Get shopping cart subtotal. - * - * @return float - */ - public function getSubtotal() - { - $subtotal = 0; - $totals = $this->getTotals(); - if (isset($totals['subtotal'])) { - $subtotal = $totals['subtotal']->getValue(); - } - return $subtotal; - } - - /** - * Get shopping cart items qty based on configuration (summary qty or items qty) - * - * @return int|float - */ - public function getSummaryCount() - { - if ($this->getData('summary_qty')) { - return $this->getData('summary_qty'); - } - return $this->_checkoutCart->getSummaryQty(); + parent::__construct($context, $customerSession, $checkoutSession, $data); + $this->_isScopePrivate = false; + $this->imageView = $imageView; } /** - * Check if one page checkout is available - * - * @return bool + * @return string */ - public function isPossibleOnepageCheckout() + public function getImageHtmlTemplate() { - return $this->_checkoutHelper->canOnepageCheckout() && !$this->getQuote()->getHasError(); + return $this->imageView->isWhiteBorders() + ? 'Magento_Catalog/product/image' + : 'Magento_Catalog/product/image_with_borders'; } /** @@ -214,20 +116,6 @@ public function getIsNeedToDisplaySideBar() ); } - /** - * Return customer quote items - * - * @return array - */ - public function getItems() - { - if ($this->getCustomQuote()) { - return $this->getCustomQuote()->getAllVisibleItems(); - } - - return parent::getItems(); - } - /** * Return totals from custom quote if needed * @@ -242,79 +130,6 @@ public function getTotalsCache() return $this->_totals; } - /** - * Get cache key informative items - * - * @return array - */ - public function getCacheKeyInfo() - { - $cacheKeyInfo = parent::getCacheKeyInfo(); - $cacheKeyInfo['item_renders'] = $this->_serializeRenders(); - return $cacheKeyInfo; - } - - /** - * Serialize renders - * - * @return string - */ - protected function _serializeRenders() - { - $result = []; - foreach ($this->getLayout()->getChildBlocks( - $this->_getRendererList()->getNameInLayout() - ) as $alias => $block) { - /** @var $block \Magento\Framework\View\Element\Template */ - $result[] = implode('|', [$alias, get_class($block), $block->getTemplate()]); - } - return implode('|', $result); - } - - /** - * De-serialize renders from string - * - * @param string $renders - * @return $this - */ - public function deserializeRenders($renders) - { - if (!is_string($renders)) { - return $this; - } - $rendererList = $this->addChild('renderer.list', 'Magento\Framework\View\Element\RendererList'); - - $renders = explode('|', $renders); - while (!empty($renders)) { - $template = array_pop($renders); - $block = array_pop($renders); - $alias = array_pop($renders); - if (!$template || !$block || !$alias) { - continue; - } - - if (!$rendererList->getChildBlock($alias)) { - $rendererList->addChild($alias, $block, ['template' => $template]); - } - } - return $this; - } - - /** - * Retrieve block cache tags - * - * @return array - */ - public function getIdentities() - { - $identities = []; - /** @var $item \Magento\Quote\Model\Quote\Item */ - foreach ($this->getItems() as $item) { - $identities = array_merge($identities, $item->getProduct()->getIdentities()); - } - return $identities; - } - /** * Retrieve subtotal block html * @@ -324,15 +139,4 @@ public function getTotalsHtml() { return $this->getLayout()->getBlock('checkout.cart.minicart.totals')->toHtml(); } - - /** - * Retrieve items qty text - * - * @param int $qty - * @return \Magento\Framework\Phrase - */ - public function getSummaryText($qty) - { - return ($qty == 1) ? __(' item') : __(' items'); - } } diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar/Totals.php b/app/code/Magento/Checkout/Block/Cart/Sidebar/Totals.php deleted file mode 100644 index 7e3325d7dc9de..0000000000000 --- a/app/code/Magento/Checkout/Block/Cart/Sidebar/Totals.php +++ /dev/null @@ -1,32 +0,0 @@ -getTotals(); - if (isset($totals['subtotal'])) { - $subtotal = $totals['subtotal']->getValue(); - } - return $subtotal; - } -} diff --git a/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php index 867be6583a61e..df6e2ba345d29 100644 --- a/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php +++ b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php @@ -43,7 +43,6 @@ public function __construct( ); $this->cartHelper = $cartHelper; $this->currency = $currency; - $this->_isScopePrivate = true; } /** @@ -52,11 +51,11 @@ public function __construct( protected function _prepareLayout() { if ($this->cartHelper->getItemsCount()) { - $this->validateMinimunAmount(); + $this->validateMinimumAmount(); $this->addQuoteMessages(); - return parent::_prepareLayout(); + $this->addMessages($this->messageManager->getMessages(true)); } - return $this; + return parent::_prepareLayout(); } /** @@ -64,7 +63,7 @@ protected function _prepareLayout() * * @return void */ - public function validateMinimunAmount() + protected function validateMinimumAmount() { if (!$this->cartHelper->getQuote()->validateMinimumAmount()) { $warning = $this->_scopeConfig->getValue( @@ -90,7 +89,7 @@ public function validateMinimunAmount() * * @return void */ - public function addQuoteMessages() + protected function addQuoteMessages() { // Compose array of messages to add $messages = []; diff --git a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php new file mode 100644 index 0000000000000..224079faff6ff --- /dev/null +++ b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php @@ -0,0 +1,267 @@ +addressHelper = $addressHelper; + $this->customerSession = $customerSession; + $this->customerRepository = $customerRepository; + $this->directoryHelper = $directoryHelper; + } + + /** + * Merge additional address fields for given provider + * + * @param array $elements + * @param string $providerName name of the storage container used by UI component + * @param string $dataScopePrefix + * @param array $fields + * @return array + */ + public function merge($elements, $providerName, $dataScopePrefix, array $fields = []) + { + foreach ($elements as $attributeCode => $attributeConfig) { + $additionalConfig = isset($fields[$attributeCode]) ? $fields[$attributeCode] : []; + if (!$this->isFieldVisible($attributeCode, $attributeConfig, $additionalConfig)) { + continue; + } + $fields[$attributeCode] = $this->getFieldConfig( + $attributeCode, + $attributeConfig, + $additionalConfig, + $providerName, + $dataScopePrefix + ); + } + return $fields; + } + + /** + * Retrieve UI field configuration for given attribute + * + * @param string $attributeCode + * @param array $attributeConfig + * @param array $additionalConfig field configuration provided via layout XML + * @param string $providerName name of the storage container used by UI component + * @param string $dataScopePrefix + * @return array + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function getFieldConfig( + $attributeCode, + array $attributeConfig, + array $additionalConfig, + $providerName, + $dataScopePrefix + ) { + // street attribute is unique in terms of configuration, so it has its own configuration builder + if ($attributeCode == 'street') { + return $this->getStreetFieldConfig($attributeCode, $attributeConfig, $providerName, $dataScopePrefix); + } + + $uiComponent = $attributeConfig['formElement'] == 'select' + ? 'Magento_Ui/js/form/element/select' + : 'Magento_Ui/js/form/element/abstract'; + $elementTemplate = $attributeConfig['formElement'] == 'select' + ? 'ui/form/element/select' + : 'ui/form/element/input'; + + $element = [ + 'component' => isset($additionalConfig['component']) ? $additionalConfig['component'] : $uiComponent, + 'config' => [ + // customScope is used to group elements within a single form (e.g. they can be validated separately) + 'customScope' => $dataScopePrefix, + 'customEntry' => isset($additionalConfig['config']['customEntry']) + ? $additionalConfig['config']['customEntry'] + : null, + 'template' => 'ui/form/field', + 'elementTmpl' => isset($additionalConfig['config']['elementTmpl']) + ? $additionalConfig['config']['elementTmpl'] + : $elementTemplate, + ], + 'dataScope' => $dataScopePrefix . '.' . $attributeCode, + 'label' => $attributeConfig['label'], + 'provider' => $providerName, + 'sortOrder' => isset($additionalConfig['sortOrder']) + ? $additionalConfig['sortOrder'] + : $attributeConfig['sortOrder'], + 'validation' => $this->mergeConfigurationNode('validation', $additionalConfig, $attributeConfig), + 'options' => isset($attributeConfig['options']) ? $attributeConfig['options'] : [], + 'filterBy' => isset($additionalConfig['filterBy']) ? $additionalConfig['filterBy'] : null, + 'customEntry' => isset($additionalConfig['customEntry']) ? $additionalConfig['customEntry'] : null, + 'visible' => isset($additionalConfig['visible']) ? $additionalConfig['visible'] : true, + ]; + + $defaultValue = $this->getDefaultValue($attributeCode); + if (null !== $defaultValue) { + $element['default'] = $defaultValue; + } + return $element; + } + + /** + * Merge two configuration nodes recursively + * + * @param string $nodeName + * @param array $mainSource + * @param array $additionalSource + * @return array + */ + protected function mergeConfigurationNode($nodeName, array $mainSource, array $additionalSource) + { + $mainData = isset($mainSource[$nodeName]) ? $mainSource[$nodeName] : []; + $additionalData = isset($additionalSource[$nodeName]) ? $additionalSource[$nodeName] : []; + return array_replace_recursive($additionalData, $mainData); + } + + /** + * Check if address attribute is visible on frontend + * + * @param string $attributeCode + * @param array $attributeConfig + * @param array $additionalConfig field configuration provided via layout XML + * @return bool + */ + protected function isFieldVisible($attributeCode, array $attributeConfig, array $additionalConfig = []) + { + // TODO move this logic to separate model so it can be customized + if ($attributeConfig['visible'] == false + || (isset($additionalConfig['visible']) && $additionalConfig['visible'] == false) + ) { + return false; + } + if ($attributeCode == 'vat_id' && !$this->addressHelper->isVatAttributeVisible()) { + return false; + } + return true; + } + + /** + * Retrieve field configuration for street address attribute + * + * @param string $attributeCode + * @param array $attributeConfig + * @param string $providerName name of the storage container used by UI component + * @param string $dataScopePrefix + * @return array + */ + protected function getStreetFieldConfig($attributeCode, array $attributeConfig, $providerName, $dataScopePrefix) + { + $streetLines = []; + for ($lineIndex = 0; $lineIndex < $this->addressHelper->getStreetLines(); $lineIndex++) { + $isFirstLine = $lineIndex === 0; + $streetLines[] = [ + 'component' => 'Magento_Ui/js/form/element/abstract', + 'config' => [ + // customScope is used to group elements within a single form e.g. they can be validated separately + 'customScope' => $dataScopePrefix, + 'template' => 'ui/form/field', + 'elementTmpl' => 'ui/form/element/input' + ], + 'dataScope' => $lineIndex, + 'provider' => $providerName, + 'validation' => $isFirstLine ? ['required-entry' => true] : [], + 'additionalClasses' => $isFirstLine ? : 'additional' + ]; + } + return [ + 'component' => 'Magento_Ui/js/form/components/group', + 'label' => __('Address'), + 'required' => true, + 'dataScope' => $dataScopePrefix . '.' . $attributeCode, + 'provider' => $providerName, + 'sortOrder' => $attributeConfig['sortOrder'], + 'type' => 'group', + 'config' => [ + 'template' => 'ui/group/group', + 'additionalClasses' => 'street' + ], + 'children' => $streetLines, + ]; + } + + /** + * @param string $attributeCode + * @return null|string + */ + protected function getDefaultValue($attributeCode) + { + switch ($attributeCode) { + case 'firstname': + if ($this->getCustomer()) { + return $this->getCustomer()->getFirstname(); + } + break; + case 'lastname': + if ($this->getCustomer()) { + return $this->getCustomer()->getLastname(); + } + break; + case 'country_id': + return $this->directoryHelper->getDefaultCountry(); + } + return null; + } + + /** + * @return \Magento\Customer\Api\Data\CustomerInterface|null + */ + protected function getCustomer() + { + if (!$this->customer) { + if ($this->customerSession->isLoggedIn()) { + $this->customer = $this->customerRepository->getById($this->customerSession->getCustomerId()); + } else { + return null; + } + } + return $this->customer; + } +} diff --git a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php new file mode 100644 index 0000000000000..9f5ffc3f6ef6d --- /dev/null +++ b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php @@ -0,0 +1,91 @@ +attributeMetadataDataProvider = $attributeMetadataDataProvider; + $this->attributeMapper = $attributeMapper; + $this->merger = $merger; + } + + /** + * Process js Layout of block + * + * @param array $jsLayout + * @return array + */ + public function process($jsLayout) + { + /** @var \Magento\Eav\Api\Data\AttributeInterface[] $attributes */ + $attributes = $this->attributeMetadataDataProvider->loadAttributesCollection( + 'customer_address', + 'customer_register_address' + ); + + $elements = []; + foreach ($attributes as $attribute) { + if ($attribute->getIsUserDefined()) { + continue; + } + $elements[$attribute->getAttributeCode()] = $this->attributeMapper->map($attribute); + } + + // The following code is a workaround for custom address attributes + if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billingAddress'] + ['children']['billing-address-fieldset']['children'] + )) { + $fields = $jsLayout['components']['checkout']['children']['steps']['children']['billingAddress'] + ['children']['billing-address-fieldset']['children']; + $jsLayout['components']['checkout']['children']['steps']['children']['billingAddress'] + ['children']['billing-address-fieldset']['children'] = $this->merger->merge( + $elements, + 'checkoutProvider', + 'billingAddress', + $fields + ); + } + if (isset($jsLayout['components']['checkout']['children']['steps']['children']['shippingAddress'] + ['children']['shipping-address-fieldset']['children'] + )) { + $fields = $jsLayout['components']['checkout']['children']['steps']['children']['shippingAddress'] + ['children']['shipping-address-fieldset']['children']; + $jsLayout['components']['checkout']['children']['steps']['children']['shippingAddress'] + ['children']['shipping-address-fieldset']['children'] = $this->merger->merge( + $elements, + 'checkoutProvider', + 'shippingAddress', + $fields + ); + } + return $jsLayout; + } +} diff --git a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessorInterface.php b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessorInterface.php new file mode 100644 index 0000000000000..b8d0a8256e960 --- /dev/null +++ b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessorInterface.php @@ -0,0 +1,17 @@ +formKey = $formKey; $this->_isScopePrivate = true; + $this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : []; + $this->configProvider = $configProvider; + $this->layoutProcessors = $layoutProcessors; } /** - * Get 'one step checkout' step data - * - * @return array + * @return string */ - public function getSteps() + public function getJsLayout() { - $steps = []; - $stepCodes = $this->_getStepCodes(); - - if ($this->isCustomerLoggedIn()) { - $stepCodes = array_diff($stepCodes, ['login']); + foreach ($this->layoutProcessors as $processor) { + $this->jsLayout = $processor->process($this->jsLayout); } + return \Zend_Json::encode($this->jsLayout); + } - foreach ($stepCodes as $step) { - $steps[$step] = $this->getCheckout()->getStepData($step); - } + /** + * Retrieve form key + * + * @return string + */ + public function getFormKey() + { + return $this->formKey->getFormKey(); + } - return $steps; + /** + * Retrieve checkout configuration + * + * @return array + */ + public function getCheckoutConfig() + { + return $this->configProvider->getConfig(); } /** - * Get active step + * Get base url for block. * * @return string */ - public function getActiveStep() + public function getBaseUrl() { - return $this->isCustomerLoggedIn() ? 'billing' : 'login'; + return $this->_storeManager->getStore()->getBaseUrl(); } } diff --git a/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php b/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php index 3ccfd3cbd52de..dd87c65ecee83 100644 --- a/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php +++ b/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php @@ -188,6 +188,8 @@ public function isCustomerLoggedIn() /** * @return Collection + * @deprecated + * @removeCandidate */ public function getCountryCollection() { @@ -199,6 +201,8 @@ public function getCountryCollection() /** * @return RegionCollection + * @deprecated + * @removeCandidate */ public function getRegionCollection() { @@ -212,6 +216,8 @@ public function getRegionCollection() /** * @return int + * @deprecated + * @removeCandidate */ public function customerHasAddresses() { @@ -225,6 +231,8 @@ public function customerHasAddresses() /** * @param string $type * @return string + * @deprecated + * @removeCandidate */ public function getAddressesHtmlSelect($type) { @@ -277,6 +285,8 @@ public function getAddressesHtmlSelect($type) /** * @param string $type * @return string + * @deprecated + * @removeCandidate */ public function getCountryHtmlSelect($type) { @@ -305,6 +315,8 @@ public function getCountryHtmlSelect($type) /** * @param string $type * @return string + * @deprecated + * @removeCandidate */ public function getRegionHtmlSelect($type) { @@ -329,6 +341,8 @@ public function getRegionHtmlSelect($type) /** * @return mixed + * @deprecated + * @removeCandidate */ public function getCountryOptions() { @@ -349,6 +363,8 @@ public function getCountryOptions() * Get checkout steps codes * * @return string[] + * @deprecated + * @removeCandidate */ protected function _getStepCodes() { @@ -359,6 +375,8 @@ protected function _getStepCodes() * Retrieve is allow and show block * * @return bool + * @deprecated + * @removeCandidate */ public function isShow() { @@ -370,6 +388,8 @@ public function isShow() * * @param \Magento\Quote\Model\Quote\Address\Rate $rate * @return string + * @deprecated + * @removeCandidate */ public function getShippingPriceHtml(\Magento\Quote\Model\Quote\Address\Rate $rate) { diff --git a/app/code/Magento/Checkout/Block/Onepage/Billing.php b/app/code/Magento/Checkout/Block/Onepage/Billing.php index 4ed67a76af4dc..7522552dfdfda 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Billing.php +++ b/app/code/Magento/Checkout/Block/Onepage/Billing.php @@ -11,6 +11,8 @@ /** * One page checkout status * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @removeCandidate */ class Billing extends \Magento\Checkout\Block\Onepage\AbstractOnepage { diff --git a/app/code/Magento/Checkout/Block/Onepage/Login.php b/app/code/Magento/Checkout/Block/Onepage/Login.php deleted file mode 100644 index b3a6047ca1770..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Login.php +++ /dev/null @@ -1,207 +0,0 @@ -registration = $registration; - $this->customerUrl = $customerUrl; - $this->_checkoutData = $checkoutData; - $this->messageManager = $messageManager; - parent::__construct( - $context, - $directoryHelper, - $configCacheType, - $customerSession, - $resourceSession, - $countryCollectionFactory, - $regionCollectionFactory, - $customerRepository, - $addressConfig, - $httpContext, - $addressMapper, - $data - ); - $this->_isScopePrivate = true; - } - - /** - * @return void - */ - protected function _construct() - { - if (!$this->isCustomerLoggedIn()) { - $this->getCheckout()->setStepData('login', ['label' => __('Checkout Method'), 'allow' => true]); - } - parent::_construct(); - } - - /** - * Get customer registration - * - * @return \Magento\Customer\Model\Registration - */ - public function getRegistration() - { - return $this->registration; - } - - /** - * Return registration URL - * - * @return string - */ - public function getRegisterUrl() - { - return $this->customerUrl->getRegisterUrl(); - } - - /** - * Return forgot password URL - * - * @return string - */ - public function getForgotPasswordUrl() - { - return $this->customerUrl->getForgotPasswordUrl(); - } - - /** - * @return Collection - */ - public function getMessages() - { - return $this->messageManager->getMessages(true); - } - - /** - * @return string - */ - public function getPostAction() - { - return $this->getUrl('customer/account/loginPost', ['_secure' => true]); - } - - /** - * @return string - */ - public function getMethod() - { - return $this->getQuote()->getMethod(); - } - - /** - * @return mixed - */ - public function getMethodData() - { - return $this->getCheckout()->getMethodData(); - } - - /** - * @return string - */ - public function getSuccessUrl() - { - return $this->getUrl('*/*'); - } - - /** - * @return string - */ - public function getErrorUrl() - { - return $this->getUrl('*/*'); - } - - /** - * Retrieve username for form field - * - * @return string - */ - public function getUsername() - { - return $this->_customerSession->getUsername(true); - } - - /** - * Check if guests checkout is allowed - * - * @return bool - */ - public function isAllowedGuestCheckout() - { - return $this->_checkoutData->isAllowedGuestCheckout($this->getQuote()); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment.php b/app/code/Magento/Checkout/Block/Onepage/Payment.php index 42b1c03a2ef64..ad6fe3ff05067 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Payment.php +++ b/app/code/Magento/Checkout/Block/Onepage/Payment.php @@ -9,6 +9,8 @@ * One page checkout status * * @author Magento Core Team + * @deprecated + * @removeCandidate */ class Payment extends \Magento\Checkout\Block\Onepage\AbstractOnepage { diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php b/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php index 072b1efb77fee..594927cb117b3 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php +++ b/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php @@ -9,6 +9,8 @@ * Checkout payment information data * * @author Magento Core Team + * @deprecated + * @removeCandidate */ class Info extends \Magento\Payment\Block\Info\AbstractContainer { diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php b/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php index 796a1bceb16c6..7ee38eae1823b 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php +++ b/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php @@ -8,6 +8,8 @@ * One page checkout status * * @author Magento Core Team + * @deprecated + * @removeCandidate */ namespace Magento\Checkout\Block\Onepage\Payment; diff --git a/app/code/Magento/Checkout/Block/Onepage/Progress.php b/app/code/Magento/Checkout/Block/Onepage/Progress.php deleted file mode 100644 index 81426da154a8d..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Progress.php +++ /dev/null @@ -1,105 +0,0 @@ - - */ -class Progress extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ - /** - * @return Address - */ - public function getBilling() - { - return $this->getQuote()->getBillingAddress(); - } - - /** - * @return Address - */ - public function getShipping() - { - return $this->getQuote()->getShippingAddress(); - } - - /** - * @return string - */ - public function getShippingMethod() - { - return $this->getQuote()->getShippingAddress()->getShippingMethod(); - } - - /** - * @return string - */ - public function getShippingDescription() - { - return $this->getQuote()->getShippingAddress()->getShippingDescription(); - } - - /** - * @return float - */ - public function getShippingAmount() - { - return $this->getQuote()->getShippingAddress()->getShippingAmount(); - } - - /** - * @return string - */ - public function getPaymentHtml() - { - return $this->getChildHtml('payment_info'); - } - - /** - * Get is step completed. if is set 'toStep' then all steps after him is not completed. - * - * @param string $currentStep - * @return bool - * - * @see: \Magento\Checkout\Block\Onepage\AbstractOnepage::_getStepCodes() for allowed values - */ - public function isStepComplete($currentStep) - { - $stepsRevertIndex = array_flip($this->_getStepCodes()); - - $toStep = $this->getNextStep(); - - if (empty($toStep) || !isset($stepsRevertIndex[$currentStep])) { - return $this->getCheckout()->getStepData($currentStep, 'complete'); - } - - if ($stepsRevertIndex[$currentStep] > $stepsRevertIndex[$toStep]) { - return false; - } - - return $this->getCheckout()->getStepData($currentStep, 'complete'); - } - - /** - * Return selected shipping rate - * - * @return false|Address\Rate - */ - public function getShippingRate() - { - $address = $this->getQuote()->getShippingAddress(); - $rate = $address->getShippingRateByCode($address->getShippingMethod()); - - return $rate; - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Review.php b/app/code/Magento/Checkout/Block/Onepage/Review.php deleted file mode 100644 index 6e98651bf5e34..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Review.php +++ /dev/null @@ -1,21 +0,0 @@ -getCheckout()->setStepData( - 'review', - ['label' => __('Order Review'), 'is_show' => $this->isShow()] - ); - parent::_construct(); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Review/Button.php b/app/code/Magento/Checkout/Block/Onepage/Review/Button.php index 23e8162f9c148..769b747d91ea0 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Review/Button.php +++ b/app/code/Magento/Checkout/Block/Onepage/Review/Button.php @@ -9,6 +9,8 @@ /** * One page checkout order review button + * @deprecated + * @removeCandidate */ class Button extends Template { diff --git a/app/code/Magento/Checkout/Block/Onepage/Review/Info.php b/app/code/Magento/Checkout/Block/Onepage/Review/Info.php index 9bf5382c3adfd..89dea275fec90 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Review/Info.php +++ b/app/code/Magento/Checkout/Block/Onepage/Review/Info.php @@ -7,6 +7,8 @@ /** * One page checkout order review + * @deprecated + * @removeCandidate */ class Info extends \Magento\Sales\Block\Items\AbstractItems { diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping.php b/app/code/Magento/Checkout/Block/Onepage/Shipping.php index 536c5d951f630..8f0ab4985149e 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping.php +++ b/app/code/Magento/Checkout/Block/Onepage/Shipping.php @@ -11,6 +11,8 @@ /** * One page checkout status * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @removeCandidate */ class Shipping extends \Magento\Checkout\Block\Onepage\AbstractOnepage { diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php index 2e59db5236d57..015c661dc3b60 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php +++ b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php @@ -9,6 +9,8 @@ * One page checkout status * * @author Magento Core Team + * @deprecated + * @removeCandidate */ class Method extends \Magento\Checkout\Block\Onepage\AbstractOnepage { diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php index c4e4031ce3158..1078da93c7150 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php +++ b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php @@ -9,6 +9,8 @@ * Block for additional information in shipping method * * @author Magento Core Team + * @deprecated + * @removeCandidate */ class Additional extends \Magento\Checkout\Block\Onepage\AbstractOnepage { diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php index 3d39ed9eae113..5c68cde56d177 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php +++ b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php @@ -12,6 +12,8 @@ /** * One page checkout status * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @removeCandidate */ class Available extends \Magento\Checkout\Block\Onepage\AbstractOnepage { diff --git a/app/code/Magento/Checkout/Controller/Cart/Add.php b/app/code/Magento/Checkout/Controller/Cart/Add.php index c26c171daea13..6bf5cecdfb0e3 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Add.php +++ b/app/code/Magento/Checkout/Controller/Cart/Add.php @@ -171,15 +171,6 @@ protected function goBack($backUrl = null, $product = null) if ($backUrl || $backUrl = $this->getBackUrl()) { $result['backUrl'] = $backUrl; } else { - $this->_view->loadLayout(['default'], true, true, false); - $layout = $this->_view->getLayout(); - - $result['messages'] = $layout->getBlock('global_messages')->toHtml(); - - if ($this->_checkoutSession->getCartWasUpdated()) { - $result['minicart'] = $layout->getBlock('minicart')->toHtml(); - } - if ($product && !$product->getIsSalable()) { $result['product'] = [ 'statusText' => __('Out of stock') diff --git a/app/code/Magento/Checkout/Controller/Cart/Index.php b/app/code/Magento/Checkout/Controller/Cart/Index.php index de1a954f86ae2..36c42488f0f1b 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Index.php +++ b/app/code/Magento/Checkout/Controller/Cart/Index.php @@ -51,7 +51,6 @@ public function __construct( public function execute() { $resultPage = $this->resultPageFactory->create(); - $resultPage->getLayout()->initMessages(); $resultPage->getConfig()->getTitle()->set(__('Shopping Cart')); return $resultPage; } diff --git a/app/code/Magento/Checkout/Controller/Index/Index.php b/app/code/Magento/Checkout/Controller/Index/Index.php deleted file mode 100644 index de5f3dea47424..0000000000000 --- a/app/code/Magento/Checkout/Controller/Index/Index.php +++ /dev/null @@ -1,18 +0,0 @@ -resultRedirectFactory->create()->setPath('checkout/onepage', ['_secure' => true]); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/Index.php b/app/code/Magento/Checkout/Controller/Onepage/Index.php index 4686ece6b0b82..5e16fbd5f2f01 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/Index.php +++ b/app/code/Magento/Checkout/Controller/Onepage/Index.php @@ -30,7 +30,6 @@ public function execute() $this->_objectManager->get('Magento\Customer\Model\Session')->setBeforeAuthUrl($currentUrl); $this->getOnepage()->initCheckout(); $resultPage = $this->resultPageFactory->create(); - $resultPage->getLayout()->initMessages(); $resultPage->getConfig()->getTitle()->set(__('Checkout')); return $resultPage; } diff --git a/app/code/Magento/Checkout/Controller/Onepage/Review.php b/app/code/Magento/Checkout/Controller/Onepage/Review.php deleted file mode 100644 index 21be8905b2a78..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/Review.php +++ /dev/null @@ -1,26 +0,0 @@ -_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - - return $this->resultLayoutFactory->create(); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveBilling.php b/app/code/Magento/Checkout/Controller/Onepage/SaveBilling.php deleted file mode 100644 index c9f0fc3478af5..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveBilling.php +++ /dev/null @@ -1,65 +0,0 @@ -getRequest()->isPost() || $this->_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - $data = $this->getRequest()->getPost('billing', []); - $customerAddressId = $this->getRequest()->getPost('billing_address_id', false); - - if (isset($data['email'])) { - $data['email'] = trim($data['email']); - } - $result = $this->getOnepage()->saveBilling($data, $customerAddressId); - $quote = $this->getOnepage()->getQuote(); - - if (!isset($result['error'])) { - if ($quote->isVirtual()) { - $result['goto_section'] = 'payment'; - $result['update_section'] = [ - 'name' => 'payment-method', - 'html' => $this->_getPaymentMethodsHtml(), - ]; - } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) { - if (!$quote->validateMinimumAmount()) { - $result = [ - 'error' => -1, - 'message' => $this->scopeConfig->getValue( - 'sales/minimum_order/error_message', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $quote->getStoreId() - ), - ]; - } else { - $result['goto_section'] = 'shipping_method'; - $result['update_section'] = [ - 'name' => 'shipping-method', - 'html' => $this->_getShippingMethodsHtml(), - ]; - - $result['allow_sections'] = ['shipping']; - $result['duplicateBillingInfo'] = 'true'; - $result['update_progress'] = ['html' => $this->getProgressHtml($result['goto_section'])]; - } - } else { - $result['goto_section'] = 'shipping'; - } - } - - return $this->resultJsonFactory->create()->setData($result); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveMethod.php b/app/code/Magento/Checkout/Controller/Onepage/SaveMethod.php deleted file mode 100644 index e9a79177a9149..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveMethod.php +++ /dev/null @@ -1,26 +0,0 @@ -getRequest()->isPost() || $this->_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - $method = $this->getRequest()->getPost('method'); - $result = $this->getOnepage()->saveCheckoutMethod($method); - - return $this->resultJsonFactory->create()->setData($result); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php index 7249f26f18540..205174f25e2e4 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php +++ b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php @@ -8,6 +8,10 @@ use Magento\Framework\Object; use Magento\Framework\Exception\PaymentException; +/** + * @deprecated + * @removeCandidate + */ class SaveOrder extends \Magento\Checkout\Controller\Onepage { /** diff --git a/app/code/Magento/Checkout/Controller/Onepage/SavePayment.php b/app/code/Magento/Checkout/Controller/Onepage/SavePayment.php deleted file mode 100644 index 19e17acf91ee5..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/SavePayment.php +++ /dev/null @@ -1,57 +0,0 @@ -_getHtmlByHandle('checkout_onepage_review'); - } - - /** - * Save payment ajax action - * - * Sets either redirect or a JSON response - * - * @return \Magento\Framework\Controller\ResultInterface - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - public function execute() - { - if (!$this->getRequest()->isPost() || $this->_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - try { - $data = $this->getRequest()->getPost('payment', []); - $result = $this->getOnepage()->savePayment($data); - - // get section and redirect data - $redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl(); - if (empty($result['error']) && !$redirectUrl) { - $result['goto_section'] = 'review'; - $result['update_section'] = ['name' => 'review', 'html' => $this->_getReviewHtml()]; - $result['update_progress'] = ['html' => $this->getProgressHtml('review')]; - } - if ($redirectUrl) { - $result['redirect'] = $redirectUrl; - } - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $result['error'] = $e->getMessage(); - } catch (\Exception $e) { - $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); - $result['error'] = __('Unable to set Payment Method'); - } - - return $this->resultJsonFactory->create()->setData($result); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveShipping.php b/app/code/Magento/Checkout/Controller/Onepage/SaveShipping.php deleted file mode 100644 index 491a0411bccdd..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveShipping.php +++ /dev/null @@ -1,48 +0,0 @@ -getRequest()->isPost() || $this->_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - $data = $this->getRequest()->getPost('shipping', []); - $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false); - $result = $this->getOnepage()->saveShipping($data, $customerAddressId); - - $quote = $this->getOnepage()->getQuote(); - if (!isset($result['error'])) { - if (!$quote->validateMinimumAmount()) { - $result = [ - 'error' => -1, - 'message' => $this->scopeConfig->getValue( - 'sales/minimum_order/error_message', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $quote->getStoreId() - ), - ]; - } else { - $result['goto_section'] = 'shipping_method'; - $result['update_section'] = [ - 'name' => 'shipping-method', - 'html' => $this->_getShippingMethodsHtml(), - ]; - $result['update_progress'] = ['html' => $this->getProgressHtml($result['goto_section'])]; - } - } - - return $this->resultJsonFactory->create()->setData($result); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveShippingMethod.php b/app/code/Magento/Checkout/Controller/Onepage/SaveShippingMethod.php deleted file mode 100644 index eccadcd5ab4d8..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveShippingMethod.php +++ /dev/null @@ -1,42 +0,0 @@ -getRequest()->isPost() || $this->_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - - $data = $this->getRequest()->getPost('shipping_method', ''); - $result = $this->getOnepage()->saveShippingMethod($data); - // $result will contain error data if shipping method is empty - if (!$result) { - $this->_eventManager->dispatch( - 'checkout_controller_onepage_save_shipping_method', - ['request' => $this->getRequest(), 'quote' => $this->getOnepage()->getQuote()] - ); - $this->getOnepage()->getQuote()->collectTotals(); - - $result['goto_section'] = 'payment'; - $result['update_section'] = [ - 'name' => 'payment-method', - 'html' => $this->_getPaymentMethodsHtml(), - ]; - $result['update_progress'] = ['html' => $this->getProgressHtml($result['goto_section'])]; - } - $this->quoteRepository->save($this->getOnepage()->getQuote()->collectTotals()); - return $this->resultJsonFactory->create()->setData($result); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/ShippingMethod.php b/app/code/Magento/Checkout/Controller/Onepage/ShippingMethod.php deleted file mode 100644 index 0f3a69eebe6bf..0000000000000 --- a/app/code/Magento/Checkout/Controller/Onepage/ShippingMethod.php +++ /dev/null @@ -1,22 +0,0 @@ -_expireAjax()) { - return $this->_ajaxRedirectResponse(); - } - - return $this->resultLayoutFactory->create(); - } -} diff --git a/app/code/Magento/Checkout/Controller/Onepage/Success.php b/app/code/Magento/Checkout/Controller/Onepage/Success.php index 22df006d4fac2..6287f4785441a 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/Success.php +++ b/app/code/Magento/Checkout/Controller/Onepage/Success.php @@ -22,7 +22,6 @@ public function execute() $session->clearQuote(); //@todo: Refactor it to match CQRS $resultPage = $this->resultPageFactory->create(); - $resultPage->getLayout()->initMessages(); $this->_eventManager->dispatch( 'checkout_onepage_controller_success_action', ['order_ids' => [$session->getLastOrderId()]] diff --git a/app/code/Magento/Checkout/Controller/ShippingRates/Index.php b/app/code/Magento/Checkout/Controller/ShippingRates/Index.php new file mode 100644 index 0000000000000..91fe0d8f962b9 --- /dev/null +++ b/app/code/Magento/Checkout/Controller/ShippingRates/Index.php @@ -0,0 +1,53 @@ +checkoutSession = $session; + parent::__construct($context); + } + + /** + * Dispatch request + * + * @return \Magento\Framework\Controller\ResultInterface + * @throws Action\NotFoundException + */ + public function execute() + { + $quote = $this->checkoutSession->getQuote(); + $address = $quote->getShippingAddress(); + $address->collectShippingRates()->save(); + $rates = $address->getGroupedAllShippingRates(); + $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_JSON); + $result->setData($rates); + return $result; + } +} diff --git a/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php b/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php index d0ed1515f9047..10ad9a7bb71b6 100644 --- a/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php +++ b/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php @@ -85,12 +85,6 @@ protected function jsonResponse($error = '') { $response = $this->sidebar->getResponseData($error); - if (empty($error)) { - $resultPage = $this->resultPageFactory->create(); - $block = $resultPage->getLayout()->getBlock('minicart.content')->toHtml(); - $response['content'] = $block; - } - return $this->getResponse()->representJson( $this->jsonHelper->jsonEncode($response) ); diff --git a/app/code/Magento/Checkout/CustomerData/AbstractItem.php b/app/code/Magento/Checkout/CustomerData/AbstractItem.php new file mode 100644 index 0000000000000..32146ab9c3ae8 --- /dev/null +++ b/app/code/Magento/Checkout/CustomerData/AbstractItem.php @@ -0,0 +1,39 @@ +item = $item; + return \array_merge( + ['product_type' => $item->getProductType()], + $this->doGetItemData() + ); + } + + /** + * Get item data. Template method + * + * @return array + */ + abstract protected function doGetItemData(); +} diff --git a/app/code/Magento/Checkout/CustomerData/Cart.php b/app/code/Magento/Checkout/CustomerData/Cart.php new file mode 100644 index 0000000000000..ae306dc9439a2 --- /dev/null +++ b/app/code/Magento/Checkout/CustomerData/Cart.php @@ -0,0 +1,176 @@ +checkoutSession = $checkoutSession; + $this->catalogUrl = $catalogUrl; + $this->checkoutCart = $checkoutCart; + $this->checkoutHelper = $checkoutHelper; + $this->itemPoolInterface = $itemPoolInterface; + $this->layout = $layout; + } + + /** + * {@inheritdoc} + */ + public function getSectionData() + { + $totals = $this->getQuote()->getTotals(); + return [ + 'summary_count' => $this->getSummaryCount(), + 'subtotal' => isset($totals['subtotal']) + ? $this->checkoutHelper->formatPrice($totals['subtotal']->getValue()) + : 0, + 'possible_onepage_checkout' => $this->isPossibleOnepageCheckout(), + 'items' => $this->getRecentItems(), + 'extra_actions' => $this->layout->createBlock('Magento\Catalog\Block\ShortcutButtons')->toHtml(), + ]; + } + + /** + * Get active quote + * + * @return \Magento\Quote\Model\Quote + */ + protected function getQuote() + { + if (null === $this->quote) { + $this->quote = $this->checkoutSession->getQuote(); + } + return $this->quote; + } + + /** + * Get shopping cart items qty based on configuration (summary qty or items qty) + * + * @return int|float + */ + protected function getSummaryCount() + { + if (!$this->summeryCount) { + $this->summeryCount = $this->checkoutCart->getSummaryQty() ?: 0; + } + return $this->summeryCount; + } + + /** + * Check if one page checkout is available + * + * @return bool + */ + protected function isPossibleOnepageCheckout() + { + return $this->checkoutHelper->canOnepageCheckout() && !$this->getQuote()->getHasError(); + } + + /** + * Get array of last added items + * + * @return \Magento\Quote\Model\Quote\Item[] + */ + protected function getRecentItems() + { + $items = []; + if (!$this->getSummaryCount()) { + return $items; + } + + foreach (array_reverse($this->getAllQuoteItems()) as $item) { + /* @var $item \Magento\Quote\Model\Quote\Item */ + if (!$item->getProduct()->isVisibleInSiteVisibility()) { + $productId = $item->getProduct()->getId(); + $products = $this->catalogUrl->getRewriteByProductStore([$productId => $item->getStoreId()]); + if (!isset($products[$productId])) { + continue; + } + $urlDataObject = new \Magento\Framework\Object($products[$productId]); + $item->getProduct()->setUrlDataObject($urlDataObject); + } + $items[] = $this->itemPoolInterface->getItemData($item); + } + return $items; + } + + /** + * Return customer quote items + * + * @return \Magento\Quote\Model\Quote\Item[] + */ + protected function getAllQuoteItems() + { + if ($this->getCustomQuote()) { + return $this->getCustomQuote()->getAllVisibleItems(); + } + return $this->getQuote()->getAllVisibleItems(); + } +} diff --git a/app/code/Magento/Checkout/CustomerData/DefaultItem.php b/app/code/Magento/Checkout/CustomerData/DefaultItem.php new file mode 100644 index 0000000000000..f50c2deaabb99 --- /dev/null +++ b/app/code/Magento/Checkout/CustomerData/DefaultItem.php @@ -0,0 +1,180 @@ +configurationPool = $configurationPool; + $this->productImageView = $productImageView; + $this->msrpHelper = $msrpHelper; + $this->urlBuilder = $urlBuilder; + $this->checkoutHelper = $checkoutHelper; + } + + /** + * {@inheritdoc} + */ + protected function doGetItemData() + { + $this->productImageView->init( + $this->getProductForThumbnail(), + 'mini_cart_product_thumbnail', + 'Magento_Catalog' + ); + return [ + 'options' => $this->getOptionList(), + 'qty' => $this->item->getQty() * 1, + 'item_id' => $this->item->getId(), + 'configure_url' => $this->getConfigureUrl(), + 'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(), + 'product_name' => $this->item->getProduct()->getName(), + 'product_url' => $this->getProductUrl(), + 'product_has_url' => $this->hasProductUrl(), + 'product_price' => $this->checkoutHelper->formatPrice($this->item->getCalculationPrice()), + 'product_image' => [ + 'src' => $this->productImageView->getUrl(), + 'alt' => $this->productImageView->getLabel(), + 'width' => $this->productImageView->getWidth(), + 'height' => $this->productImageView->getHeight(), + ], + 'canApplyMsrp' => $this->msrpHelper->isShowBeforeOrderConfirm($this->item->getProduct()) + && $this->msrpHelper->isMinimalPriceLessMsrp($this->item->getProduct()), + ]; + } + + /** + * Get list of all options for product + * + * @return array + */ + protected function getOptionList() + { + return $this->configurationPool->getByProductType($this->item->getProductType())->getOptions($this->item); + } + + /** + * @return \Magento\Catalog\Model\Product + */ + protected function getProductForThumbnail() + { + return $this->getProduct(); + } + + /** + * @return \Magento\Catalog\Model\Product + */ + protected function getProduct() + { + return $this->item->getProduct(); + } + + /** + * Get item configure url + * + * @return string + */ + protected function getConfigureUrl() + { + return $this->urlBuilder->getUrl( + 'checkout/cart/configure', + ['id' => $this->item->getId(), 'product_id' => $this->item->getProduct()->getId()] + ); + } + + /** + * Check Product has URL + * + * @return bool + */ + protected function hasProductUrl() + { + if ($this->item->getRedirectUrl()) { + return true; + } + + $product = $this->item->getProduct(); + $option = $this->item->getOptionByCode('product_type'); + if ($option) { + $product = $option->getProduct(); + } + + if ($product->isVisibleInSiteVisibility()) { + return true; + } else { + if ($product->hasUrlDataObject()) { + $data = $product->getUrlDataObject(); + if (in_array($data->getVisibility(), $product->getVisibleInSiteVisibilities())) { + return true; + } + } + } + + return false; + } + + /** + * Retrieve URL to item Product + * + * @return string + */ + protected function getProductUrl() + { + if ($this->item->getRedirectUrl()) { + return $this->item->getRedirectUrl(); + } + + $product = $this->item->getProduct(); + $option = $this->item->getOptionByCode('product_type'); + if ($option) { + $product = $option->getProduct(); + } + + return $product->getUrlModel()->getUrl($product); + } +} diff --git a/app/code/Magento/Checkout/CustomerData/ItemInterface.php b/app/code/Magento/Checkout/CustomerData/ItemInterface.php new file mode 100644 index 0000000000000..200c8888bf0b2 --- /dev/null +++ b/app/code/Magento/Checkout/CustomerData/ItemInterface.php @@ -0,0 +1,23 @@ +objectManager = $objectManager; + $this->defaultItemId = $defaultItemId; + $this->itemMap = $itemMap; + } + + /** + * {@inheritdoc} + */ + public function getItemData(Item $item) + { + return $this->get($item->getProductType())->getItemData($item); + } + + /** + * Get section source by name + * + * @param string $type + * @return ItemInterface + * @throws LocalizedException + */ + protected function get($type) + { + $itemId = isset($this->itemMap[$type]) ? $this->itemMap[$type] : $this->defaultItemId; + $item = $this->objectManager->get($itemId); + + if (!$item instanceof ItemInterface) { + throw new LocalizedException( + __('%1 doesn\'t extend \Magento\Checkout\CustomerData\ItemInterface', $type) + ); + } + return $item; + } +} diff --git a/app/code/Magento/Checkout/CustomerData/ItemPoolInterface.php b/app/code/Magento/Checkout/CustomerData/ItemPoolInterface.php new file mode 100644 index 0000000000000..2c15acb572cd8 --- /dev/null +++ b/app/code/Magento/Checkout/CustomerData/ItemPoolInterface.php @@ -0,0 +1,23 @@ +agreementsProviders as $agreementsProvider) { $requiredAgreements = array_merge($requiredAgreements, $agreementsProvider->getRequiredAgreementIds()); diff --git a/app/code/Magento/Checkout/Model/CompositeConfigProvider.php b/app/code/Magento/Checkout/Model/CompositeConfigProvider.php new file mode 100644 index 0000000000000..de31d67a03ada --- /dev/null +++ b/app/code/Magento/Checkout/Model/CompositeConfigProvider.php @@ -0,0 +1,35 @@ +configProviders = $configProviders; + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + $config = []; + foreach ($this->configProviders as $configProvider) { + $config = array_merge_recursive($config, $configProvider->getConfig()); + } + return $config; + } +} diff --git a/app/code/Magento/Checkout/Model/ConfigProviderInterface.php b/app/code/Magento/Checkout/Model/ConfigProviderInterface.php new file mode 100644 index 0000000000000..715a339635e88 --- /dev/null +++ b/app/code/Magento/Checkout/Model/ConfigProviderInterface.php @@ -0,0 +1,17 @@ +checkoutHelper = $checkoutHelper; + $this->checkoutSession = $checkoutSession; + $this->customerRepository = $customerRepository; + $this->customerSession = $customerSession; + $this->customerUrlManager = $customerUrlManager; + $this->httpContext = $httpContext; + $this->currencyManager = $currencyManager; + $this->quoteRepository = $quoteRepository; + $this->quoteItemRepository = $quoteItemRepository; + $this->shippingMethodManager = $shippingMethodManager; + $this->configurationPool = $configurationPool; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->localeFormat = $localeFormat; + $this->addressMapper = $addressMapper; + $this->addressConfig = $addressConfig; + $this->formKey = $formKey; + $this->imageHelper = $imageHelper; + $this->viewConfig = $viewConfig; + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + return [ + 'formKey' => $this->formKey->getFormKey(), + 'customerData' => $this->getCustomerData(), + 'quoteData' => $this->getQuoteData(), + 'quoteItemData' => $this->getQuoteItemData(), + 'isCustomerLoggedIn' => $this->isCustomerLoggedIn(), + 'selectedShippingMethod' => $this->getSelectedShippingMethod(), + 'storeCode' => $this->getStoreCode(), + 'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed(), + 'isCustomerLoginRequired' => $this->isCustomerLoginRequired(), + 'registerUrl' => $this->getRegisterUrl(), + 'customerAddressCount' => $this->getCustomerAddressCount(), + 'forgotPasswordUrl' => $this->getForgotPasswordUrl(), + 'staticBaseUrl' => $this->getStaticBaseUrl(), + 'priceFormat' => $this->localeFormat->getPriceFormat( + null, + $this->checkoutSession->getQuote()->getQuoteCurrencyCode() + ), + 'basePriceFormat' => $this->localeFormat->getPriceFormat( + null, + $this->currencyManager->getDefaultCurrency() + ) + ]; + } + + /** + * Retrieve customer data + * + * @return array + */ + private function getCustomerData() + { + $customerData = []; + if ($this->isCustomerLoggedIn()) { + $customer = $this->customerRepository->getById($this->customerSession->getCustomerId()); + $customerData = $customer->__toArray(); + foreach ($customer->getAddresses() as $key => $address) { + $customerData['addresses'][$key]['inline'] = $this->getCustomerAddressInline($address); + } + } + return $customerData; + } + + /** + * Set additional customer address data + * + * @param \Magento\Customer\Api\Data\AddressInterface $address + * @return string + */ + private function getCustomerAddressInline($address) + { + $builtOutputAddressData = $this->addressMapper->toFlatArray($address); + return $this->addressConfig + ->getFormatByCode(\Magento\Customer\Model\Address\Config::DEFAULT_ADDRESS_FORMAT) + ->getRenderer() + ->renderArray($builtOutputAddressData); + } + + /** + * Retrieve number of customer addresses + * + * @return int + */ + private function getCustomerAddressCount() + { + $customerAddressCount = 0; + if ($this->isCustomerLoggedIn()) { + $customer = $this->customerRepository->getById($this->customerSession->getCustomerId()); + $addresses = $customer->getAddresses(); + $customerAddressCount = count($addresses); + } + return $customerAddressCount; + } + + /** + * Retrieve quote data + * + * @return array + */ + private function getQuoteData() + { + $quoteData = []; + if ($this->checkoutSession->getQuote()->getId()) { + $quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId()); + // the following condition is a legacy logic left here for compatibility + if (!$quote->getCustomer()->getId()) { + $this->quoteRepository->save($this->checkoutSession->getQuote()->setCheckoutMethod('guest')); + } else { + $this->quoteRepository->save($this->checkoutSession->getQuote()->setCheckoutMethod(null)); + } + + $quoteData = $quote->toArray(); + $quoteData['is_virtual'] = $quote->getIsVirtual(); + + if (!$quote->getCustomer()->getId()) { + /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */ + $quoteIdMask = $this->quoteIdMaskFactory->create(); + $quoteData['entity_id'] = $quoteIdMask->load( + $this->checkoutSession->getQuote()->getId(), + 'quote_id' + )->getMaskedId(); + } + + } + return $quoteData; + } + + /** + * Retrieve quote item data + * + * @return array + */ + private function getQuoteItemData() + { + $quoteItemData = []; + $quoteId = $this->checkoutSession->getQuote()->getId(); + if ($quoteId) { + $quoteItems = $this->quoteItemRepository->getList($quoteId); + foreach ($quoteItems as $index => $quoteItem) { + $quoteItemData[$index] = $quoteItem->toArray(); + $quoteItemData[$index]['options'] = $this->getFormattedOptionValue($quoteItem); + $thumbnailSize = $this->viewConfig->getViewConfig()->getVarValue( + 'Magento_Catalog', + 'product_thumbnail_image_size' + ); + $quoteItemData[$index]['thumbnail'] = (string) $this->imageHelper->init( + $quoteItem->getProduct(), + 'thumbnail' + )->resize($thumbnailSize); + } + } + return $quoteItemData; + } + + /** + * Retrieve formatted item options view + * + * @param \Magento\Quote\Api\Data\CartItemInterface $item + * @return array + */ + protected function getFormattedOptionValue($item) + { + $optionsData = []; + $options = $this->configurationPool->getByProductType($item->getProductType())->getOptions($item); + foreach ($options as $index => $optionValue) { + /* @var $helper \Magento\Catalog\Helper\Product\Configuration */ + $helper = $this->configurationPool->getByProductType('default'); + $params = [ + 'max_length' => 55, + 'cut_replacer' => ' ...' + ]; + $option = $helper->getFormattedOptionValue($optionValue, $params); + $optionsData[$index] = $option; + $optionsData[$index]['label'] = $optionValue['label']; + } + return $optionsData; + } + + /** + * Retrieve customer registration URL + * + * @return string + */ + public function getRegisterUrl() + { + return $this->customerUrlManager->getRegisterUrl(); + } + + /** + * Retrieve selected shipping method + * + * @return string + */ + private function getSelectedShippingMethod() + { + // Shipping method ID contains carrier code and shipping method code + $shippingMethodId = ''; + try { + $quoteId = $this->checkoutSession->getQuote()->getId(); + $shippingMethod = $this->shippingMethodManager->get($quoteId); + if ($shippingMethod) { + $shippingMethodId = $shippingMethod->getCarrierCode() . '_' . $shippingMethod->getMethodCode(); + } + } catch (\Exception $exception) { + $shippingMethodId = ''; + } + return $shippingMethodId; + } + + /** + * Retrieve store code + * + * @return string + */ + private function getStoreCode() + { + return $this->checkoutSession->getQuote()->getStore()->getCode(); + } + + /** + * Check if guest checkout is allowed + * + * @return bool + */ + private function isGuestCheckoutAllowed() + { + return $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote()); + } + + /** + * Check if customer is logged in + * + * @return bool + */ + private function isCustomerLoggedIn() + { + return (bool)$this->httpContext->getValue(CustomerContext::CONTEXT_AUTH); + } + + /** + * Check if customer must be logged in to proceed with checkout + * + * @return bool + */ + private function isCustomerLoginRequired() + { + return $this->checkoutHelper->isCustomerMustBeLogged(); + } + + /** + * Return forgot password URL + * + * @return string + */ + private function getForgotPasswordUrl() + { + return $this->customerUrlManager->getForgotPasswordUrl(); + } + + /** + * Return base static url. + * + * @return string + */ + protected function getStaticBaseUrl() + { + return $this->checkoutSession->getQuote()->getStore()->getBaseUrl(UrlInterface::URL_TYPE_STATIC); + } +} diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index da634e082756d..27733a64629c6 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -7,6 +7,7 @@ use Magento\Customer\Api\Data\CustomerInterface; use Magento\Quote\Model\Quote; +use Magento\Quote\Model\QuoteIdMaskFactory; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -81,6 +82,16 @@ class Session extends \Magento\Framework\Session\SessionManager */ protected $customerRepository; + /** + * @param QuoteIdMaskFactory + */ + protected $quoteIdMaskFactory; + + /** + * @param bool + */ + protected $isQuoteMasked; + /** * @param \Magento\Framework\App\Request\Http $request * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -98,6 +109,7 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository + * @param QuoteIdMaskFactory $quoteIdMaskFactory * @throws \Magento\Framework\Exception\SessionException * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -117,7 +129,8 @@ public function __construct( \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository + \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, + QuoteIdMaskFactory $quoteIdMaskFactory ) { $this->_orderFactory = $orderFactory; $this->_customerSession = $customerSession; @@ -126,6 +139,7 @@ public function __construct( $this->_eventManager = $eventManager; $this->_storeManager = $storeManager; $this->customerRepository = $customerRepository; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; parent::__construct( $request, $sidResolver, @@ -229,18 +243,26 @@ public function getQuote() } } - if ($this->getQuoteId()) { - if ($this->_customer) { - $quote->setCustomer($this->_customer); - } elseif ($this->_customerSession->isLoggedIn()) { - $quote->setCustomer($this->customerRepository->getById($this->_customerSession->getCustomerId())); - } + if ($this->_customer) { + $quote->setCustomer($this->_customer); + } elseif ($this->_customerSession->isLoggedIn()) { + $quote->setCustomer($this->customerRepository->getById($this->_customerSession->getCustomerId())); } $quote->setStore($this->_storeManager->getStore()); $this->_quote = $quote; } + if (!$this->isQuoteMasked() && !$this->_customerSession->isLoggedIn() && $this->getQuoteId()) { + $quoteId = $this->getQuoteId(); + /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */ + $quoteIdMask = $this->quoteIdMaskFactory->create()->load($quoteId, 'quote_id'); + if ($quoteIdMask->getMaskedId() === null) { + $quoteIdMask->setQuoteId($quoteId)->save(); + } + $this->setIsQuoteMasked(true); + } + $remoteAddress = $this->_remoteAddress->getRemoteAddress(); if ($remoteAddress) { $this->_quote->setRemoteIp($remoteAddress); @@ -466,4 +488,21 @@ public function restoreQuote() } return false; } + + /** + * @param $isQuoteMasked bool + * @return void + */ + protected function setIsQuoteMasked($isQuoteMasked) + { + $this->isQuoteMasked = $isQuoteMasked; + } + + /** + * @return bool|null + */ + protected function isQuoteMasked() + { + return $this->isQuoteMasked; + } } diff --git a/app/code/Magento/Checkout/Model/Sidebar.php b/app/code/Magento/Checkout/Model/Sidebar.php index 225c5c7323bc4..ee924310021e4 100644 --- a/app/code/Magento/Checkout/Model/Sidebar.php +++ b/app/code/Magento/Checkout/Model/Sidebar.php @@ -60,15 +60,7 @@ public function getResponseData($error = '') if (empty($error)) { $response = [ 'success' => true, - 'data' => [ - 'summary_qty' => $this->getSummaryQty(), - 'summary_text' => $this->getSummaryText(), - 'subtotal' => $this->getSubtotalHtml(), - ], ]; - if (!$this->getSummaryQty()) { - $response['cleanup'] = true; - } } else { $response = [ 'success' => false, diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 3e746159a8dd0..ff24c18f2be28 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -460,7 +460,7 @@ public function saveBilling($data, $customerAddressId) /** * Billing address using options */ - $usingCase = isset($data['use_for_shipping']) ? (int)$data['use_for_shipping'] : self::NOT_USE_FOR_SHIPPING; + $usingCase = isset($data['use_for_shipping']) ? (bool)$data['use_for_shipping'] : self::NOT_USE_FOR_SHIPPING; switch ($usingCase) { case self::NOT_USE_FOR_SHIPPING: @@ -951,8 +951,6 @@ public function saveOrder() $this->getQuote()->getId() )->setLastSuccessQuoteId( $this->getQuote()->getId() - )->setLastOrderId( - $order->getIncrementId() )->clearHelperData(); if ($order) { diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Sidebar/TotalsTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Sidebar/TotalsTest.php deleted file mode 100644 index 41229c291e9af..0000000000000 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Sidebar/TotalsTest.php +++ /dev/null @@ -1,69 +0,0 @@ -quote = $this->getMockBuilder('Magento\Quote\Model\Quote') - ->disableOriginalConstructor() - ->setMethods(['getTotals', '__wakeup']) - ->getMock(); - - $checkoutSession = $this->getMockBuilder('\Magento\Checkout\Model\Session') - ->disableOriginalConstructor() - ->setMethods(['getQuote', '__wakeup']) - ->getMock(); - - $checkoutSession->expects($this->once()) - ->method('getQuote') - ->will($this->returnValue($this->quote)); - - $this->totalsObj = $objectManager->getObject( - 'Magento\Checkout\Block\Cart\Sidebar\Totals', - ['checkoutSession' => $checkoutSession] - ); - } - - public function testGetSubtotal() - { - $subtotal = new Object(['value' => self::SUBTOTAL]); - $totals = ['subtotal' => $subtotal]; - $this->quote->expects($this->once()) - ->method('getTotals') - ->will($this->returnValue($totals)); - - $this->assertEquals(self::SUBTOTAL, $this->totalsObj->getSubtotal()); - } - - public function testGetSubtotalZero() - { - $totals = []; - $this->quote->expects($this->once()) - ->method('getTotals') - ->will($this->returnValue($totals)); - - $this->assertEquals(0, $this->totalsObj->getSubtotal()); - } -} diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php index c7003960224a8..d212eec3a5a7e 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php @@ -15,103 +15,6 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } - public function testDeserializeRenders() - { - $childBlock = $this->getMock('Magento\Framework\View\Element\AbstractBlock', [], [], '', false); - /** @var $layout \Magento\Framework\View\LayoutInterface */ - $layout = $this->getMock( - 'Magento\Framework\View\Layout', - ['createBlock', 'getChildName', 'setChild'], - [], - '', - false - ); - - $rendererList = $this->_objectManager->getObject( - 'Magento\Checkout\Block\Cart\Sidebar', - [ - 'context' => $this->_objectManager->getObject( - 'Magento\Backend\Block\Template\Context', - ['layout' => $layout] - ) - ] - ); - $layout->expects( - $this->at(0) - )->method( - 'createBlock' - )->with( - 'Magento\Framework\View\Element\RendererList' - )->will( - $this->returnValue($rendererList) - ); - $layout->expects( - $this->at(4) - )->method( - 'createBlock' - )->with( - 'some-block', - '.some-template', - ['data' => ['template' => 'some-type']] - )->will( - $this->returnValue($childBlock) - ); - $layout->expects( - $this->at(5) - )->method( - 'getChildName' - )->with( - null, - 'some-template' - )->will( - $this->returnValue(false) - ); - $layout->expects($this->at(6))->method('setChild')->with(null, null, 'some-template'); - - /** @var $block \Magento\Checkout\Block\Cart\Sidebar */ - $block = $this->_objectManager->getObject( - 'Magento\Checkout\Block\Cart\Sidebar', - [ - 'context' => $this->_objectManager->getObject( - 'Magento\Backend\Block\Template\Context', - ['layout' => $layout] - ) - ] - ); - - $block->deserializeRenders('some-template|some-block|some-type'); - } - - public function testGetIdentities() - { - /** @var $block \Magento\Checkout\Block\Cart\Sidebar */ - $block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\Sidebar'); - - /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMock( - 'Magento\Catalog\Model\Product', - ['__wakeup', 'getIdentities'], - [], - '', - false - ); - $identities = [0 => 1, 1 => 2, 2 => 3]; - $product->expects($this->exactly(2)) - ->method('getIdentities') - ->will($this->returnValue($identities)); - - /** @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); - $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); - - /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quote */ - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $quote->expects($this->once())->method('getAllVisibleItems')->will($this->returnValue([$item])); - - $block->setData('custom_quote', $quote); - $this->assertEquals($product->getIdentities(), $block->getIdentities()); - } - public function testGetTotalsHtml() { $totalsHtml = "$134.36"; @@ -142,9 +45,9 @@ public function testGetTotalsHtml() ->method('getLayout') ->will($this->returnValue($layoutMock)); - /** @var \Magento\Checkout\Block\Cart\SideBar $sidebarBlock */ + /** @var \Magento\Checkout\Block\Cart\Sidebar $sidebarBlock */ $sidebarBlock = $this->_objectManager->getObject( - 'Magento\Checkout\Block\Cart\SideBar', + 'Magento\Checkout\Block\Cart\Sidebar', ['context' => $contextMock] ); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/ProgressTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/ProgressTest.php deleted file mode 100644 index 99813f6d48b09..0000000000000 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/ProgressTest.php +++ /dev/null @@ -1,96 +0,0 @@ -checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->taxHelper = $this->getMock('Magento\Tax\Helper\Data', [], [], '', false); - - $objectManagerHelper = new ObjectManagerHelper($this); - $this->model = $objectManagerHelper->getObject( - 'Magento\Checkout\Block\Onepage\Progress', - ['resourceSession' => $this->checkoutSession, 'taxData' => $this->taxHelper] - ); - $this->shippingAddress = $this->getMock( - 'Magento\Quote\Model\Quote\Address', - ['getShippingRateByCode', '__wakeup'], - [], - '', - false - ); - $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); - $quote->expects($this->any())->method('getShippingAddress')->will($this->returnValue($this->shippingAddress)); - $quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); - $this->checkoutSession->expects($this->any())->method('getQuote')->will($this->returnValue($quote)); - } - - /** - * Test getShippingRate method - */ - public function testGetShippingRate() - { - $rate = $this->getMock('Magento\Quote\Model\Quote\Address\Rate', ['__wakeup'], [], '', false); - $this->shippingAddress->setShippingMethod(self::SHIPPING_METHOD); - $this->shippingAddress->expects($this->once()) - ->method('getShippingRateByCode') - ->with(self::SHIPPING_METHOD) - ->will($this->returnValue($rate)); - - $this->assertEquals($rate, $this->model->getShippingRate()); - } -} diff --git a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php new file mode 100644 index 0000000000000..a5a38f3982c19 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php @@ -0,0 +1,138 @@ +getMock('\Magento\Framework\View\Element\Template\Context', [], [], '', false); + $directoryHelperMock = $this->getMock('\Magento\Directory\Helper\Data', [], [], '', false); + $configCacheTypeMock = $this->getMock('\Magento\Framework\App\Cache\Type\Config', [], [], '', false); + $customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $resourceSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); + $addressConfigMock = $this->getMock('\Magento\Customer\Model\Address\Config', [], [], '', false); + $httpContextMock = $this->getMock('\Magento\Framework\App\Http\Context', [], [], '', false); + $addressMapperMock = $this->getMock('\Magento\Customer\Model\Address\Mapper', [], [], '', false); + $this->formKeyMock = $this->getMock('\Magento\Framework\Data\Form\FormKey', [], [], '', false); + $this->configProviderMock = $this->getMock( + '\Magento\Checkout\Model\CompositeConfigProvider', + [], + [], + '', + false + ); + $countryCollectionFactoryMock = $this->getMock( + 'Magento\Directory\Model\Resource\Country\CollectionFactory', + ['create'], + [], + '', + false + ); + $regionCollectionFactoryMock = $this->getMock( + 'Magento\Directory\Model\Resource\Region\CollectionFactory', + ['create'], + [], + '', + false + ); + $customerRepositoryMock = $this->getMock( + '\Magento\Customer\Api\CustomerRepositoryInterface', + [], + [], + '', + false + ); + + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $contextMock->expects($this->once())->method('getStoreManager')->willReturn($this->storeManagerMock); + $this->layoutProcessorMock = $this->getMock( + '\Magento\Checkout\Block\Checkout\LayoutProcessorInterface', + [], + [], + '', + false + ); + + $this->model = new \Magento\Checkout\Block\Onepage( + $contextMock, + $directoryHelperMock, + $configCacheTypeMock, + $customerSessionMock, + $resourceSessionMock, + $countryCollectionFactoryMock, + $regionCollectionFactoryMock, + $customerRepositoryMock, + $addressConfigMock, + $httpContextMock, + $addressMapperMock, + $this->formKeyMock, + $this->configProviderMock, + [$this->layoutProcessorMock] + ); + } + + public function testGetBaseUrl() + { + $baseUrl = 'http://magento.com'; + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + + $storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); + $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); + + $this->assertEquals($baseUrl, $this->model->getBaseUrl()); + } + + public function testGetCheckoutConfig() + { + $checkoutConfig = ['checkout', 'config']; + $this->configProviderMock->expects($this->once())->method('getConfig')->willReturn($checkoutConfig); + + $this->assertEquals($checkoutConfig, $this->model->getCheckoutConfig()); + } + + public function testGetFormKey() + { + $formKey = 'form_key'; + $this->formKeyMock->expects($this->once())->method('getFormKey')->willReturn($formKey); + + $this->assertEquals($formKey, $this->model->getFormKey()); + } + + public function testGetJsLayout() + { + $processedLayout = ['layout' => ['processed' => true]]; + $jsonLayout = '{"layout":{"processed":true}}'; + $this->layoutProcessorMock->expects($this->once())->method('process')->with([])->willReturn($processedLayout); + + $this->assertEquals($jsonLayout, $this->model->getJsLayout()); + } +} diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php index 43b5fb8657ded..fc2199407275c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php @@ -131,12 +131,6 @@ public function setUp() */ public function testExecuteWithMessages() { - $layout = $this->getMockBuilder('Magento\Framework\View\Layout') - ->disableOriginalConstructor() - ->getMock(); - $layout->expects($this->once()) - ->method('initMessages'); - $title = $this->getMockBuilder('Magento\Framework\View\Page\Title') ->disableOriginalConstructor() ->getMock(); @@ -154,9 +148,7 @@ public function testExecuteWithMessages() $page = $this->getMockBuilder('Magento\Framework\View\Result\Page') ->disableOriginalConstructor() ->getMock(); - $page->expects($this->once()) - ->method('getLayout') - ->willReturn($layout); + $page->expects($this->once()) ->method('getConfig') ->willReturn($config); diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/IndexTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/IndexTest.php index e5142f4ef2e3c..f3a3f246ec1ee 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/IndexTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/IndexTest.php @@ -191,8 +191,6 @@ public function testRegenerateSessionIdOnExecute() //Expected outcomes $this->sessionMock->expects($this->once())->method('regenerateId'); - $this->layoutMock->expects($this->once()) - ->method('initMessages'); $this->assertSame($this->resultPageMock, $this->model->execute()); } diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php deleted file mode 100755 index f1a5b1c882dac..0000000000000 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php +++ /dev/null @@ -1,316 +0,0 @@ -scopeConfig = $this->getMock('Magento\Framework\App\Config', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getPost', 'isPost'], [], '', false); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->quote = $this->getMock( - 'Magento\Quote\Model\Quote', - ['__wakeup', 'getHasError', 'hasItems', 'validateMinimumAmount', 'isVirtual', 'getStoreId'], - [], - '', - false - ); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->onePage = $this->getMock('Magento\Checkout\Model\Type\Onepage', [], [], '', false); - - $this->response->expects($this->any()) - ->method('setHeader') - ->will($this->returnSelf()); - $this->onePage->expects($this->any()) - ->method('getQuote') - ->willReturn($this->quote); - - //Object Manager mock initialization - $valueMap = [ - ['Magento\Checkout\Model\Type\Onepage', $this->onePage], - ['Magento\Checkout\Model\Session', $this->checkoutSession], - ]; - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); - $this->objectManagerMock->expects($this->any()) - ->method('get') - ->will($this->returnValueMap($valueMap)); - $this->layoutFactory = $this->getMock('Magento\Framework\View\LayoutFactory', ['create'], [], '', false); - - //Context mock initialization - $context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); - $context->expects($this->once()) - ->method('getObjectManager') - ->will($this->returnValue($this->objectManagerMock)); - $context->expects($this->once()) - ->method('getRequest') - ->will($this->returnValue($this->request)); - $context->expects($this->once()) - ->method('getResponse') - ->will($this->returnValue($this->response)); - $context->expects($this->once()) - ->method('getEventManager') - ->will($this->returnValue($this->eventManager)); - - $this->resultRaw = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') - ->disableOriginalConstructor() - ->getMock(); - $resultRawFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $resultRawFactory->expects($this->any()) - ->method('create') - ->willReturn($this->resultRaw); - - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') - ->disableOriginalConstructor() - ->setMethods(['setData']) - ->getMock(); - $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $resultJsonFactory->expects($this->any()) - ->method('create') - ->willReturn($this->resultJson); - - $this->controller = $objectManager->getObject( - 'Magento\Checkout\Controller\Onepage\SaveBilling', - [ - 'context' => $context, - 'scopeConfig' => $this->scopeConfig, - 'layoutFactory' => $this->layoutFactory, - 'resultRawFactory' => $resultRawFactory, - 'resultJsonFactory' => $resultJsonFactory - ] - ); - } - - /** - * Test execute - * - * @return void - */ - public function testExecute() - { - $this->request->expects($this->once()) - ->method('isPost') - ->willReturn(false); - $this->resultRaw->expects($this->once()) - ->method('setStatusHeader') - ->with(403, '1.1', 'Session Expired') - ->willReturn($this->resultRaw); - $this->resultRaw->expects($this->once()) - ->method('setHeader') - ->with('Login-Required', 'true', false) - ->willReturn($this->resultRaw); - $this->assertSame($this->resultRaw, $this->controller->execute()); - } - - /** - * Test validate minimum amount - * - * @return void - */ - public function testValidateMinimumAmount() - { - $expectedResult = [ - 'goto_section' => 'shipping_method', - 'update_section' => [ - 'name' => 'shipping-method', - 'html' => null, - ], - 'allow_sections' => ['shipping'], - 'duplicateBillingInfo' => 'true', - 'update_progress' => [ - 'html' => 'some_html', - ], - ]; - $this->quote->expects($this->once()) - ->method('hasItems') - ->willReturn(true); - $this->quote->expects($this->once()) - ->method('getHasError') - ->willReturn(false); - $this->quote->expects($this->exactly(2)) - ->method('validateMinimumAmount') - ->willReturn(true); - - $data = ['use_for_shipping' => 1]; - $this->request->expects($this->once()) - ->method('isPost') - ->willReturn(true); - $this->request->expects($this->any()) - ->method('getPost') - ->willReturn($data); - - $layout = $this->getMock( - 'Magento\Framework\View\Layout', - ['getUpdate', 'generateXml', 'generateElements', 'getOutput', 'getBlock'], - [], - '', - false - ); - $this->layoutFactory->expects($this->any()) - ->method('create') - ->willReturn($layout); - - $block = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') - ->disableOriginalConstructor() - ->setMethods(['setAttribute', 'toHtml']) - ->getMockForAbstractClass(); - $block->expects($this->any()) - ->method('setAttribute') - ->willReturnSelf(); - $block->expects($this->any()) - ->method('toHtml') - ->willReturn('some_html'); - - $update = $this->getMock('Magento\Framework\View\Model\Layout\Merge', ['load'], [], '', false); - $layout->expects($this->any()) - ->method('getUpdate') - ->willReturn($update); - $update->expects($this->any()) - ->method('load'); - $layout->expects($this->any()) - ->method('getBlock') - ->willReturn($block); - - $this->resultJson->expects($this->once()) - ->method('setData') - ->with($expectedResult) - ->willReturnSelf(); - - $this->assertSame($this->resultJson, $this->controller->execute()); - } - - /** - * Test validate minimum amount negative - * - * @return void - */ - public function testValidateMinimumAmountNegative() - { - $errorMessage = 'error_message'; - $expectedResult = [ - 'error' => -1, - 'message' => $errorMessage, - ]; - - $this->scopeConfig->expects($this->once()) - ->method('getValue') - ->willReturn($errorMessage); - $this->quote->expects($this->at(0)) - ->method('hasItems') - ->willReturn(true); - $this->quote->expects($this->at(1)) - ->method('getHasError') - ->willReturn(false); - $this->quote->expects($this->at(2)) - ->method('validateMinimumAmount') - ->willReturn(true); - $this->quote->expects($this->at(3)) - ->method('validateMinimumAmount') - ->willReturn(false); - - $data = ['use_for_shipping' => 1]; - $this->request->expects($this->once()) - ->method('isPost') - ->willReturn(true); - $this->request->expects($this->any()) - ->method('getPost') - ->willReturn($data); - - $this->resultJson->expects($this->once()) - ->method('setData') - ->with($expectedResult) - ->willReturnSelf(); - - $this->assertSame($this->resultJson, $this->controller->execute()); - } -} diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveOrderTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveOrderTest.php deleted file mode 100644 index cef6ff863cc8d..0000000000000 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveOrderTest.php +++ /dev/null @@ -1,322 +0,0 @@ -getMockBuilder('Magento\Framework\App\Action\Context') - ->disableOriginalConstructor() - ->getMock(); - $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface') - ->disableOriginalConstructor() - ->setMethods(['getPost']) - ->getMockForAbstractClass(); - $this->responseMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $this->formKeyValidatorMock = $this->getMockBuilder('Magento\Framework\Data\Form\FormKey\Validator') - ->disableOriginalConstructor() - ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory') - ->disableOriginalConstructor() - ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') - ->disableOriginalConstructor() - ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') - ->disableOriginalConstructor() - ->getMock(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $this->onepageMock = $this->getMockBuilder('Magento\Checkout\Model\Type\Onepage') - ->disableOriginalConstructor() - ->getMock(); - $this->agreementsValidatorMock = $this->getMockBuilder('Magento\Checkout\Model\Agreements\AgreementsValidator') - ->disableOriginalConstructor() - ->getMock(); - $this->quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') - ->disableOriginalConstructor() - ->getMock(); - - $contextMock->expects($this->once()) - ->method('getRequest') - ->willReturn($this->requestMock); - $contextMock->expects($this->once()) - ->method('getResponse') - ->willReturn($this->responseMock); - $contextMock->expects($this->once()) - ->method('getObjectManager') - ->willReturn($this->objectManagerMock); - $contextMock->expects($this->once()) - ->method('getResultRedirectFactory') - ->willReturn($this->resultRedirectFactoryMock); - $contextMock->expects($this->once()) - ->method('getEventManager') - ->willReturn($this->eventManagerMock); - - $this->controller = $helper->getObject( - 'Magento\Checkout\Controller\Onepage\SaveOrder', - [ - 'context' => $contextMock, - 'formKeyValidator' => $this->formKeyValidatorMock, - 'resultRawFactory' => $this->resultRawFactoryMock, - 'resultJsonFactory' => $this->resultJsonFactoryMock, - ] - ); - } - - /** - * Test method execution _expireAjax (call hasItems === false) - * - * @return void - */ - protected function expireAjaxFlowHasItemsFalse() - { - $this->onepageMock->expects($this->atLeastOnce()) - ->method('getQuote') - ->willReturn($this->quoteMock); - - $this->quoteMock->expects($this->once()) - ->method('hasItems') - ->willReturn(false); - $this->quoteMock->expects($this->never()) - ->method('getHasError') - ->willReturn(true); - $this->quoteMock->expects($this->never()) - ->method('validateMinimumAmount') - ->willReturn(false); - - $this->requestMock->expects($this->never()) - ->method('getActionName'); - } - - /** - * Test for execute method - * - * @return void - */ - public function testExecuteWithSuccessOrderSave() - { - $testData = $this->getExecuteWithSuccessOrderSaveTestData(); - - - $redirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect') - ->disableOriginalConstructor() - ->getMock(); - $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') - ->disableOriginalConstructor() - ->getMock(); - $checkoutMock = $this->getMockBuilder('Magento\Checkout\Model\Session') - ->disableOriginalConstructor() - ->setMethods(['getRedirectUrl']) - ->getMock(); - $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') - ->disableOriginalConstructor() - ->getMock(); - - $redirectMock->expects($this->never()) - ->method('setPath') - ->with('*/*/') - ->willReturn('redirect'); - - $this->formKeyValidatorMock->expects($this->once()) - ->method('validate') - ->with($this->requestMock) - ->willReturn(true); - - $this->resultRedirectFactoryMock->expects($this->never()) - ->method('create') - ->willReturn($redirectMock); - - $this->objectManagerMock->expects($this->atLeastOnce()) - ->method('get') - ->willReturnMap($testData['objectManager.get']); - - // call _expireAjax method - $this->expireAjaxFlowHasItemsFalse(); - - $this->requestMock->expects($this->atLeastOnce()) - ->method('getPost') - ->willReturnMap($testData['request.getPost']); - - $this->agreementsValidatorMock->expects($this->once()) - ->method('isValid') - ->with($testData['agreementsValidator.isValid']) - ->willReturn(true); - - $this->quoteMock->expects($this->atLeastOnce()) - ->method('getPayment') - ->willReturn($paymentMock); - - $paymentMock->expects($this->once()) - ->method('setQuote') - ->with($this->quoteMock); - $paymentMock->expects($this->once()) - ->method('importData') - ->with($testData['payment.importData']); - - $this->onepageMock->expects($this->once()) - ->method('saveOrder'); - $this->onepageMock->expects($this->once()) - ->method('getCheckout') - ->willReturn($checkoutMock); - - $checkoutMock->expects($this->once()) - ->method('getRedirectUrl') - ->willReturn(null); - - $this->eventManagerMock->expects($this->once()) - ->method('dispatch') - ->withConsecutive( - $this->equalTo('checkout_controller_onepage_saveOrder'), - $this->countOf(2) - ); - - $this->resultJsonFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($resultJsonMock); - - $resultJsonMock->expects($this->once()) - ->method('setData') - ->with($testData['resultJson.setData']) - ->willReturnSelf(); - - $this->assertEquals($resultJsonMock, $this->controller->execute()); - } - - /** - * Get data for test testExecuteWithSuccessOrderSave - * - * @return array - */ - protected function getExecuteWithSuccessOrderSaveTestData() - { - $data = [ - 'payment-key-1' => 'payment-value-1', - 'checks' => [ - \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, - \Magento\Payment\Model\Method\AbstractMethod::CHECK_ZERO_TOTAL, - ] - ]; - $testKey = 'test-key-1'; - - return [ - 'resultJson.setData' => [ - 'success' => 1, - 'error' => false - ], - 'request.getPost' => [ - [ - 'agreement', - [], - [ - $testKey => 'test-value-1' - ] - ], - [ - 'payment', - [], - $data - ], - ], - 'payment.importData' => $data, - 'agreementsValidator.isValid' => [$testKey], - 'objectManager.get' => [ - ['Magento\Checkout\Model\Type\Onepage', $this->onepageMock], - ['Magento\Checkout\Model\Agreements\AgreementsValidator', $this->agreementsValidatorMock], - ] - ]; - } -} diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php deleted file mode 100644 index 480e9fe957d80..0000000000000 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php +++ /dev/null @@ -1,294 +0,0 @@ -scopeConfig = $this->getMock('Magento\Framework\App\Config', [], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getPost', 'isPost'], [], '', false); - $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->quote = $this->getMock( - 'Magento\Quote\Model\Quote', - ['__wakeup', 'getHasError', 'hasItems', 'validateMinimumAmount', 'isVirtual', 'getStoreId'], - [], - '', - false - ); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); - $this->onePage = $this->getMock('Magento\Checkout\Model\Type\Onepage', [], [], '', false); - - $this->response->expects($this->any()) - ->method('setHeader') - ->will($this->returnSelf()); - $this->onePage->expects($this->any()) - ->method('getQuote') - ->willReturn($this->quote); - - //Object Manager mock initialization - $valueMap = [ - ['Magento\Checkout\Model\Type\Onepage', $this->onePage], - ['Magento\Checkout\Model\Session', $this->checkoutSession], - ]; - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); - $this->objectManagerMock->expects($this->any()) - ->method('get') - ->will($this->returnValueMap($valueMap)); - $this->layoutFactory = $this->getMock('Magento\Framework\View\LayoutFactory', ['create'], [], '', false); - - //Context mock initialization - $context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); - $context->expects($this->once()) - ->method('getObjectManager') - ->will($this->returnValue($this->objectManagerMock)); - $context->expects($this->once()) - ->method('getRequest') - ->will($this->returnValue($this->request)); - $context->expects($this->once()) - ->method('getResponse') - ->will($this->returnValue($this->response)); - $context->expects($this->once()) - ->method('getEventManager') - ->will($this->returnValue($this->eventManager)); - - $this->resultRaw = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') - ->disableOriginalConstructor() - ->getMock(); - $resultRawFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $resultRawFactory->expects($this->any()) - ->method('create') - ->willReturn($this->resultRaw); - - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') - ->disableOriginalConstructor() - ->setMethods(['setData']) - ->getMock(); - $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $resultJsonFactory->expects($this->any()) - ->method('create') - ->willReturn($this->resultJson); - - $this->controller = $objectManager->getObject( - 'Magento\Checkout\Controller\Onepage\SaveShipping', - [ - 'context' => $context, - 'scopeConfig' => $this->scopeConfig, - 'layoutFactory' => $this->layoutFactory, - 'resultRawFactory' => $resultRawFactory, - 'resultJsonFactory' => $resultJsonFactory - ] - ); - } - - public function testExecute() - { - $this->request->expects($this->once()) - ->method('isPost') - ->willReturn(false); - $this->resultRaw->expects($this->once()) - ->method('setStatusHeader') - ->with(403, '1.1', 'Session Expired') - ->willReturn($this->resultRaw); - $this->resultRaw->expects($this->once()) - ->method('setHeader') - ->with('Login-Required', 'true', false) - ->willReturn($this->resultRaw); - $this->assertSame($this->resultRaw, $this->controller->execute()); - } - - public function testValidateMinimumAmount() - { - $expectedResult = [ - 'goto_section' => 'shipping_method', - 'update_section' => [ - 'name' => 'shipping-method', - 'html' => null, - ], - 'update_progress' => [ - 'html' => 'some_html', - ], - ]; - $this->quote->expects($this->once()) - ->method('hasItems') - ->willReturn(true); - $this->quote->expects($this->once()) - ->method('getHasError') - ->willReturn(false); - $this->quote->expects($this->exactly(2)) - ->method('validateMinimumAmount') - ->willReturn(true); - - $data = ['use_for_shipping' => 1]; - $this->request->expects($this->once()) - ->method('isPost') - ->willReturn(true); - $this->request->expects($this->any()) - ->method('getPost') - ->willReturn($data); - - $layout = $this->getMock( - 'Magento\Framework\View\Layout', - ['getUpdate', 'generateXml', 'generateElements', 'getOutput', 'getBlock'], - [], - '', - false - ); - $this->layoutFactory->expects($this->any()) - ->method('create') - ->willReturn($layout); - - $block = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock') - ->disableOriginalConstructor() - ->setMethods(['setAttribute', 'toHtml']) - ->getMockForAbstractClass(); - $block->expects($this->any()) - ->method('setAttribute') - ->willReturnSelf(); - $block->expects($this->any()) - ->method('toHtml') - ->willReturn('some_html'); - - $update = $this->getMock('Magento\Framework\View\Model\Layout\Merge', [], [], '', false); - $layout->expects($this->any()) - ->method('getUpdate') - ->willReturn($update); - $update->expects($this->any()) - ->method('load'); - $layout->expects($this->any()) - ->method('getBlock') - ->willReturn($block); - - $this->resultJson->expects($this->once()) - ->method('setData') - ->with($expectedResult) - ->willReturnSelf(); - - $this->assertSame($this->resultJson, $this->controller->execute()); - } - - public function testValidateMinimumAmountNegative() - { - $errorMessage = 'error_message'; - $expectedResult = [ - 'error' => -1, - 'message' => $errorMessage, - ]; - - $this->scopeConfig->expects($this->once()) - ->method('getValue') - ->willReturn($errorMessage); - $this->quote->expects($this->at(0)) - ->method('hasItems') - ->willReturn(true); - $this->quote->expects($this->at(1)) - ->method('getHasError') - ->willReturn(false); - $this->quote->expects($this->at(2)) - ->method('validateMinimumAmount') - ->willReturn(true); - $this->quote->expects($this->at(3)) - ->method('validateMinimumAmount') - ->willReturn(false); - - $data = ['use_for_shipping' => 1]; - $this->request->expects($this->once()) - ->method('isPost') - ->willReturn(true); - $this->request->expects($this->any()) - ->method('getPost') - ->willReturn($data); - - $this->resultJson->expects($this->once()) - ->method('setData') - ->with($expectedResult) - ->willReturnSelf(); - - $this->assertSame($this->resultJson, $this->controller->execute()); - } -} diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php index 900693acec908..d2cf39386d297 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php @@ -94,34 +94,6 @@ public function testExecute() ] ); - $pageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') - ->disableOriginalConstructor() - ->getMock(); - - $this->resultPageFactoryMock->expects($this->once()) - ->method('create') - ->with(false, []) - ->willReturn($pageMock); - - $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') - ->getMock(); - - $pageMock->expects($this->once()) - ->method('getLayout') - ->willReturn($layoutMock); - - $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') - ->getMock(); - - $layoutMock->expects($this->once()) - ->method('getBlock') - ->with('minicart.content') - ->willReturn($blockMock); - - $blockMock->expects($this->once()) - ->method('toHtml') - ->willReturn('block html'); - $this->jsonHelperMock->expects($this->once()) ->method('jsonEncode') ->with( @@ -132,7 +104,6 @@ public function testExecute() 'summary_text' => __(' items'), 'subtotal' => 0, ], - 'content' => 'block html', ] ) ->willReturn('json encoded'); diff --git a/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php b/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php index 177846e4a1078..377365e9294d2 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php @@ -38,19 +38,19 @@ public function setUp() */ public function testGetLastRealOrder($orderId, $incrementId, $orderMock) { - $orderFactory = $this->getMockBuilder( - 'Magento\Sales\Model\OrderFactory' - )->disableOriginalConstructor()->setMethods( - ['create'] - )->getMock(); + $orderFactory = $this->getMockBuilder('Magento\Sales\Model\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $orderFactory->expects($this->once())->method('create')->will($this->returnValue($orderMock)); - $messageCollectionFactory = $this->getMockBuilder( - 'Magento\Framework\Message\CollectionFactory' - )->disableOriginalConstructor()->getMock(); - $quoteRepository = $this->getMockBuilder( - 'Magento\Quote\Model\QuoteRepository' - )->disableOriginalConstructor()->getMock(); + $messageCollectionFactory = $this->getMockBuilder('Magento\Framework\Message\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $quoteRepository = $this->getMockBuilder('Magento\Quote\Model\QuoteRepository') + ->disableOriginalConstructor() + ->getMock(); $appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false); $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); @@ -284,7 +284,7 @@ public function testReplaceQuote() ->disableOriginalConstructor() ->setMethods(['getWebsiteId', '__wakeup']) ->getMock(); - $store->expects($this->exactly(2)) + $store->expects($this->any()) ->method('getWebsiteId') ->will($this->returnValue($websiteId)); @@ -304,19 +304,34 @@ public function testReplaceQuote() ->disableOriginalConstructor() ->setMethods(['setData', 'getData']) ->getMock(); - $storage->expects($this->once()) - ->method('setData') - ->with('quote_id_' . $websiteId, $replaceQuoteId); - $storage->expects($this->once()) + + $storage->expects($this->any()) ->method('getData') - ->with('quote_id_' . $websiteId) - ->will($this->returnValue($replaceQuoteId));; + ->willReturn($replaceQuoteId); + $storage->expects($this->any()) + ->method('setData'); + + $quoteIdMaskMock = $this->getMock( + '\Magento\Quote\Model\QuoteIdMask', + ['getMaskedId', 'load', 'setQuoteId', 'save'], + [], + '', + false + ); + $quoteIdMaskMock->expects($this->once())->method('load')->with($replaceQuoteId, 'quote_id')->willReturnSelf(); + $quoteIdMaskMock->expects($this->once())->method('getMaskedId')->willReturn(null); + $quoteIdMaskMock->expects($this->once())->method('setQuoteId')->with($replaceQuoteId)->willReturnSelf(); + $quoteIdMaskMock->expects($this->once())->method('save'); + + $quoteIdMaskFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteIdMaskFactory', ['create'], [], '', false); + $quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock); $session = $this->_helper->getObject( 'Magento\Checkout\Model\Session', [ 'storeManager' => $storeManager, - 'storage' => $storage + 'storage' => $storage, + 'quoteIdMaskFactory' => $quoteIdMaskFactoryMock ] ); diff --git a/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php index c928db0923da8..3f0eef0833341 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php @@ -36,94 +36,32 @@ protected function setUp() /** * @param string $error - * @param float $summaryQty - * @param array $totals * @param array $result * * @dataProvider dataProviderGetResponseData */ - public function testGetResponseData($error, $summaryQty, $totals, $result) + public function testGetResponseData($error, $result) { - $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote') - ->disableOriginalConstructor() - ->getMock(); - $quoteMock->expects($this->any()) - ->method('getTotals') - ->willReturn($totals); - - $this->cartMock->expects($this->any()) - ->method('getSummaryQty') - ->willReturn($summaryQty); - $this->cartMock->expects($this->any()) - ->method('getQuote') - ->willReturn($quoteMock); - - $this->checkoutHelperMock->expects($this->any()) - ->method('formatPrice') - ->willReturnArgument(0); - $this->assertEquals($result, $this->sidebar->getResponseData($error)); } public function dataProviderGetResponseData() { - $totalMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address\Total') - ->disableOriginalConstructor() - ->setMethods(['getValue']) - ->getMock(); - $totalMock->expects($this->any()) - ->method('getValue') - ->willReturn(12.34); - return [ [ '', - 0, - [], - [ - 'success' => true, - 'data' => [ - 'summary_qty' => 0, - 'summary_text' => __(' items'), - 'subtotal' => 0, - ], - 'cleanup' => true, - ], + ['success' => true], ], [ '', - 1, - [ - 'subtotal' => $this->getMock('NonexistentClass'), - ], - [ - 'success' => true, - 'data' => [ - 'summary_qty' => 1, - 'summary_text' => __(' item'), - 'subtotal' => 0, - ], - ], + ['success' => true], ], [ '', - 2, - [ - 'subtotal' => $totalMock, - ], - [ - 'success' => true, - 'data' => [ - 'summary_qty' => 2, - 'summary_text' => __(' items'), - 'subtotal' => 12.34, - ], - ], + ['success' => true], ], [ 'Error', - 0, - [], [ 'success' => false, 'error_message' => 'Error', diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 40e8b4b1e2cd4..67fb91166e7a5 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,32 +3,32 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-payment": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-gift-message": "0.74.0-beta9", - "magento/module-wishlist": "0.74.0-beta9", - "magento/module-page-cache": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-msrp": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-ui": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-gift-message": "0.74.0-beta11", + "magento/module-wishlist": "0.74.0-beta11", + "magento/module-page-cache": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-msrp": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.74.0-beta9" + "magento/module-cookie": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Checkout/etc/frontend/di.xml b/app/code/Magento/Checkout/etc/frontend/di.xml index 0662312df5438..3399782763bea 100644 --- a/app/code/Magento/Checkout/etc/frontend/di.xml +++ b/app/code/Magento/Checkout/etc/frontend/di.xml @@ -5,7 +5,8 @@ * See COPYING.txt for license details. */ --> - + @@ -17,4 +18,32 @@ + + + + Magento\Checkout\CustomerData\Cart + + + + + + + Magento\Checkout\CustomerData\DefaultItem + + + + + + Magento\Checkout\Model\DefaultConfigProvider + + + + + + + Magento\Checkout\Block\Checkout\LayoutProcessor + + + diff --git a/app/code/Magento/Checkout/etc/frontend/sections.xml b/app/code/Magento/Checkout/etc/frontend/sections.xml new file mode 100644 index 0000000000000..5d0a50865b02a --- /dev/null +++ b/app/code/Magento/Checkout/etc/frontend/sections.xml @@ -0,0 +1,40 @@ + + + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml index 9b690c5b43fbd..d0aeb1702d330 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml @@ -13,7 +13,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml index de03dc7e9c9e1..9a3fb49073337 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml @@ -9,6 +9,27 @@ + + + + + + + + + uiComponent + + Magento_Checkout/minicart/item/price + priceSidebar + + + + + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index d165e98b8ef0a..95b2d0a739b4b 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -7,10 +7,40 @@ --> - - - - + + + + + + + + defaultRenderer + defaultRenderer + defaultRenderer + + + + + uiComponent + + defaultRenderer + Magento_Checkout/minicart/item/default + + + + Magento_Catalog/js/view/image + + Magento_Catalog/product/image + itemImage + + + + + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml index e0374276fc3bd..5630e0e9c06dd 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml @@ -8,7 +8,30 @@ - + + + + + + + + + + + uiComponent + + Magento_Checkout/minicart/subtotal/totals + + + + + + + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml index 0d49bdbebbf44..d72d04fe0e3cf 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml @@ -6,33 +6,320 @@ */ --> - - - - - - - - - - - - - - - - - - - - - + + + + + + Magento_Ui/js/form/element/abstract + + checkoutProvider + ui/form/field + ui/form/element/input + + + + + + Magento_Checkout/js/view/onepage + + + Magento_Checkout/js/view/progress + progress + + + Magento_Tax/js/view/checkout/shipping_method/price + shipping + + + + + 0 + Magento_Ui/js/view/errors + errors + + + uiComponent + steps + + + Magento_Checkout/js/view/authentication + 1 + + + uiComponent + before + + + + + + + + Magento_Checkout/js/view/billing-address + checkoutProvider + 2 + + + uiComponent + additional-fieldsets + + + + + false + + + Magento_Ui/js/form/element/region + + ui/form/field + ui/form/element/select + billingAddress.region + + + true + + + + ${ $.provider }:${ $.parentScope }.country_id + country_id + + + + + Magento_Ui/js/form/element/post-code + + true + + + + + 0 + + + + + 0 + + + + 115 + + + + Magento_Ui/js/form/element/abstract + + ui/form/field + ui/form/element/email + customerDetails + + Email + customerDetails.email + checkoutProvider + 45 + + true + true + + + + Magento_Ui/js/form/element/abstract + + ui/form/field + ui/form/element/checkbox + + Save in address book + checkoutProvider + billingAddress.save_in_address_book + + + + + uiComponent + additional-field-choice + + + + + + + + Magento_Checkout/js/view/shipping-address + checkoutProvider + 3 + + + uiComponent + before-fields + + + + + + uiComponent + additional-fieldsets + + + + + false + + + Magento_Ui/js/form/element/region + + ui/form/field + ui/form/element/select + shippingAddress.region + + + true + + + + :<%= parentScope %>.country_id]]> + country_id + + + + + Magento_Ui/js/form/element/post-code + + true + + + + + 0 + + + + + 0 + + + + 115 + + + Magento_Ui/js/form/element/abstract + + ui/form/field + ui/form/element/checkbox + + Save in address book + checkoutProvider + shippingAddress.save_in_address_book + + + + + + + Magento_Checkout/js/view/shipping-method + 4 + + + + + + uiComponent + afterSelect + + + + + + + + Magento_Checkout/js/view/payment + 5 + + + uiComponent + beforeMethods + + + + + + + uiComponent + afterMethods + + + + + + + + Magento_Checkout/js/view/review + 6 + + + Magento_Checkout/js/view/columns + + Magento_Checkout/js/view/review/item/columns/name + Magento_Checkout/js/view/review/item/columns/price + Magento_Checkout/js/view/review/item/columns/qty + Magento_Checkout/js/view/review/item/columns/subtotal + + + + Magento_Checkout/js/view/itemsBefore + + + + + + Magento_Checkout/js/view/itemsAfter + + + + + + Magento_Checkout/js/view/beforePlaceOrder + + + + + + Magento_Checkout/js/view/totals + + + Magento_Checkout/js/view/subtotal + + + Magento_Checkout/js/view/discount + + + + + Magento_Checkout/js/view/review/actions + + + Magento_Checkout/js/view/review/actions/default + + true + + + + + + + + + + + + + uiComponent + + + + - - - diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml deleted file mode 100644 index 2f665bbc1562b..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_progress.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_progress.xml deleted file mode 100644 index c5cb17bda6006..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_progress.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml deleted file mode 100644 index 8965d3d498b05..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_shippingmethod.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_shippingmethod.xml deleted file mode 100644 index b364a3c42104a..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_shippingmethod.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/Checkout/view/frontend/layout/default.xml b/app/code/Magento/Checkout/view/frontend/layout/default.xml index 8fff222718790..2ac27890ca18a 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/default.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/default.xml @@ -15,17 +15,47 @@ - - - - - - - - - - - + + + + + + Magento_Checkout/js/view/minicart + + Magento_Checkout/minicart/content + + + + uiComponent + + subtotalContainer + + + + uiComponent + + Magento_Checkout/minicart/subtotal + + + + + + uiComponent + + extraInfo + + + + uiComponent + + promotion + + + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/requirejs-config.js b/app/code/Magento/Checkout/view/frontend/requirejs-config.js index be64c6f3cc385..e8a9923521254 100644 --- a/app/code/Magento/Checkout/view/frontend/requirejs-config.js +++ b/app/code/Magento/Checkout/view/frontend/requirejs-config.js @@ -7,7 +7,6 @@ var config = { map: { '*': { discountCode: 'Magento_Checkout/js/discount-codes', - orderOverview: 'Magento_Checkout/js/overview', shoppingCart: 'Magento_Checkout/js/shopping-cart', regionUpdater: 'Magento_Checkout/js/region-updater', opcOrderReview: 'Magento_Checkout/js/opc-order-review', @@ -16,4 +15,4 @@ var config = { paymentAuthentication: 'Magento_Checkout/js/payment-authentication' } } -}; \ No newline at end of file +}; diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml index 9082c7696e4e1..d515d34169278 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml @@ -9,21 +9,24 @@ /** @var $block \Magento\Checkout\Block\Cart\Sidebar */ ?> -getSummaryCount() ?> -
- +
+ - - - - + + - getSummaryText($_cartQty); ?> + + + + getIsNeedToDisplaySideBar()): ?> -
-
- getChildHtml('minicart_content') ?> +
+
+ diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart/content.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart/content.phtml deleted file mode 100644 index ac59b9dce84a0..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart/content.phtml +++ /dev/null @@ -1,87 +0,0 @@ - - -getSummaryCount() ?> -
- - - - -
-
- - - getAllowCartLink()): ?> -
- - getSummaryText($_cartQty); ?> -
- isPossibleOnepageCheckout() ?> - - getChildHtml('subtotal'); ?> - - getChildHtml('minicart_info') ?> -
-
- - - getChildHtml('extra_actions') ?> - -
-
- - - getRecentItems() ?> - - -
-
    - - getItemHtml($_item) ?> - -
-
- - - - - getCartEmptyMessage()): ?> -

getCartEmptyMessage(); ?>

- - - - getAllowCartLink()): ?> -
-
- - - -
-
- - -
- getChildHtml('cart_promotion') ?> -
-
diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart/totals.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart/totals.phtml deleted file mode 100644 index 9872565b7bd6b..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart/totals.phtml +++ /dev/null @@ -1,12 +0,0 @@ - - -
- helper('Magento\Checkout\Helper\Data')->formatPrice($block->getSubtotal()) ?> -
diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml index b3e8bcd4d6792..9fe14c75f86a8 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -/** @var $block \Magento\Checkout\Block\Cart\EmptyCart */ +/** @var $block \Magento\Checkout\Block\Cart */ ?>
getChildHtml('checkout_cart_empty_widget'); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/sidebar/default.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/sidebar/default.phtml deleted file mode 100644 index 5a5d1cba87399..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/sidebar/default.phtml +++ /dev/null @@ -1,119 +0,0 @@ - -getItem(); -$product = $_item->getProduct(); -/** @var \Magento\Msrp\Helper\Data $helper */ -$helper = $this->helper('Magento\Msrp\Helper\Data'); -$canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinimalPriceLessMsrp($product); -$imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\Image') -?> -
  • -
    - hasProductUrl()): ?> - - init($block->getProductForThumbnail(), 'mini_cart_product_thumbnail')->toHtml() ?> - - - - init($block->getProductForThumbnail(), 'mini_cart_product_thumbnail')->toHtml() ?> - - - -
    - - hasProductUrl()): ?> - escapeHtml($block->getProductName()) ?> - - escapeHtml($block->getProductName()) ?> - - - - getOptionList()):?> -
    - - -
    - -
    - -
    escapeHtml($_option['label']) ?>
    -
    - - - - - -
    - -
    -
    -
    - - - -
    - - -
    - - -
    - - - getSidebarItemPriceHtml($_item); ?> - - -
    - - - -
    -
    - -
    - isVisibleInSiteVisibility()):?> -
    - - - -
    - -
    - - - -
    -
    -
    -
    -
  • diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/subtotal.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/subtotal.phtml deleted file mode 100644 index 291a8a762fe89..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/subtotal.phtml +++ /dev/null @@ -1,13 +0,0 @@ - -
    - - - - getTotalsHtml() ?> -
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage.phtml index 7f7f77ee09239..7e8fe0c43edb0 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage.phtml @@ -3,45 +3,26 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - -/** @var \Magento\Checkout\Block\Onepage\Payment $_paymentBlock */ -$_paymentBlock = $block->getLayout()->getBlock('checkout.onepage.payment'); ?> - -
    -
      + + -
    + } + + + +
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml index 3e4d340bada9d..951f7355804ec 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml @@ -7,6 +7,10 @@ // @codingStandardsIgnoreFile /** @var \Magento\Checkout\Block\Onepage\Billing $block */ +/** + * @deprecated + * @removeCandidate + */ ?>
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/link.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/link.phtml index baae876a32b83..25d144d746d4a 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/link.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/link.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?> isPossibleOnepageCheckout()):?> - helper('Magento\Checkout\Helper\Data')->isCustomerMustBeLogged()): ?> - - - - - - -
    -
    -
    -
    - - -
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml index be458572d7769..2c334689a2c65 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?>
    getBlockHtml('formkey') ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml index 7a4278f9e21bf..6f80ee1744db2 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?> -
    -
    - -
    -
    -
    - getCheckout()->getStepData('billing', 'is_show')): ?> - isStepComplete('billing')): ?> -
    - - - - -
    -
    -
    getBilling()->format('html') ?>
    -
    - -
    - -
    - - - - getCheckout()->getStepData('shipping', 'is_show')): ?> - isStepComplete('shipping')): ?> -
    - - - - -
    -
    -
    getShipping()->format('html') ?>
    -
    - -
    - -
    - - - - getCheckout()->getStepData('shipping_method', 'is_show')): ?> - isStepComplete('shipping_method')): ?> -
    - - - - -
    -
    - getShippingMethod()): ?> - escapeHtml($block->getShippingDescription()) ?> - - getShippingPriceHtml($block->getShippingRate()) ?> - - - - -
    - -
    - -
    - - - - getCheckout()->getStepData('payment', 'is_show')): ?> - isStepComplete('payment')): ?> -
    - - - - -
    -
    - getPaymentHtml() ?> -
    - -
    - -
    - - -
    -
    -
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review.phtml deleted file mode 100644 index a1818f0249657..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review.phtml +++ /dev/null @@ -1,9 +0,0 @@ - -
    - getChildHtml('info') ?> -
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml index 144229da4d503..b2c80c18c3410 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml @@ -3,6 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +/** + * @deprecated + * @removeCandidate + */ ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml index 7583840f76aec..410eb15288344 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml @@ -7,6 +7,11 @@ // @codingStandardsIgnoreFile /** @var $block \Magento\Checkout\Block\Onepage\Review\Info */ + +/** + * @deprecated + * @removeCandidate + */ ?> getChildHtml('items_before'); ?>
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml index f1b01382b20ab..1c341f5cf30a2 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml @@ -8,6 +8,11 @@ /** @var $block Magento\Checkout\Block\Cart\Item\Renderer */ +/** + * @deprecated + * @removeCandidate + */ + $_item = $block->getItem(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml index 0fb50a1c75440..84dadaa0d45cf 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml @@ -8,6 +8,11 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ +/** + * @deprecated + * @removeCandidate + */ + $_item = $block->getItem(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml index 170dbe599c537..5f354f7f7634d 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml @@ -8,6 +8,11 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ +/** + * @deprecated + * @removeCandidate + */ + $_item = $block->getItem(); ?> helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml index 6eeb99706cf0e..4c29e0507fa79 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml @@ -8,6 +8,11 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ +/** + * @deprecated + * @removeCandidate + */ + $_item = $block->getItem(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml index 5b50c3cd384b3..b77c3a972fc9e 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml @@ -8,6 +8,11 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ +/** + * @deprecated + * @removeCandidate + */ + $_item = $block->getItem(); ?> helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml index e51e2164efc26..9213b53700f1d 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml @@ -9,6 +9,11 @@ /** * @see \Magento\Checkout\Block\Cart\Totals */ + +/** + * @deprecated + * @removeCandidate + */ ?> getTotals()): ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml index 9e45f27fabdb9..6848faef6f2b9 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml index 4b44618818d24..d4b9d858d0e4c 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?>
    diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml index f05f97fb6f343..da4b581b633b3 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?> getQuote()->isVirtual()): ?> helper('Magento\GiftMessage\Helper\Message')->getInline('onepage_checkout', $block->getQuote(), $block->getDontDisplayContainer()) ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml index 12ca6679daf48..257d8bab74f12 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml @@ -6,6 +6,10 @@ // @codingStandardsIgnoreFile +/** + * @deprecated + * @removeCandidate + */ ?> getShippingRates(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/check-email-availability.js b/app/code/Magento/Checkout/view/frontend/web/js/action/check-email-availability.js new file mode 100644 index 0000000000000..f25cd3f00ac28 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/check-email-availability.js @@ -0,0 +1,36 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true*/ +/*global define*/ +define( + [ + 'mage/storage', + '../model/url-builder', + 'Magento_Customer/js/model/customer' + ], + function(storage, urlBuilder, customer) { + "use strict"; + return function(deferred) { + storage.post( + urlBuilder.createUrl('/customers/isEmailAvailable', {}), + JSON.stringify({ + customerEmail: customer.customerData.email + }) + ).done( + function (isEmailAvailable) { + if (isEmailAvailable) { + deferred.resolve(); + } else { + deferred.reject(); + } + } + ).fail( + function () { + deferred.reject(); + } + ); + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/place-order.js b/app/code/Magento/Checkout/view/frontend/web/js/action/place-order.js new file mode 100644 index 0000000000000..ee6bf6d67d339 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/place-order.js @@ -0,0 +1,51 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + '../model/quote', + '../model/url-builder', + '../model/payment-service', + 'mage/storage', + 'mage/url', + 'Magento_Ui/js/model/errorlist', + 'Magento_Customer/js/model/customer', + 'underscore' + ], + function(quote, urlBuilder, paymentService, storage, url, errorList, customer, _) { + "use strict"; + return function(customParams, callback) { + var payload; + customParams = customParams || { + cartId: quote.getQuoteId(), + paymentMethod: paymentService.getSelectedPaymentData() + }; + /** + * Checkout for guest and registered customer. + */ + var serviceUrl; + if (quote.getCheckoutMethod()() === 'guest') { + serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/order', {quoteId: quote.getQuoteId()}); + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/order', {}); + } + payload = customParams; + storage.put( + serviceUrl, JSON.stringify(payload) + ).done( + function() { + if (!_.isFunction(callback) || callback()) { + window.location.replace(url.build('checkout/onepage/success/')); + } + } + ).fail( + function(response) { + var error = JSON.parse(response.responseText); + errorList.add(error); + } + ); + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js new file mode 100644 index 0000000000000..635f6797f4075 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js @@ -0,0 +1,89 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true*/ +/*global define, alert*/ +define( + [ + '../model/quote', + '../model/addresslist', + '../model/step-navigator', + './select-shipping-address', + 'uiRegistry', + '../model/url-builder', + 'mage/storage', + '../model/payment-service', + 'underscore' + ], + function (quote, addressList, navigator, selectShippingAddress, registry, urlBuilder, storage, paymentService, _) { + "use strict"; + var actionCallback; + var result = function (billingAddress, useForShipping, additionalData) { + var copyBillingToShipping = function() { + var shippingAddressSource = registry.get('checkoutProvider'), + shippingAddress = shippingAddressSource.get('shippingAddress'); + for (var property in billingAddress) { + if (billingAddress.hasOwnProperty(property) && shippingAddress.hasOwnProperty(property)) { + if (typeof billingAddress[property] === 'string') { + shippingAddressSource.set('shippingAddress.' + property, billingAddress[property]); + } else { + shippingAddressSource.set('shippingAddress.' + property, _.clone(billingAddress[property])); + } + } + } + }; + additionalData = additionalData || {}; + quote.setBillingAddress(billingAddress); + if (useForShipping() === '1' && !quote.isVirtual()) { + if (!billingAddress.customerAddressId) { + copyBillingToShipping(); + } + selectShippingAddress(billingAddress, useForShipping, additionalData); + } else if (quote.isVirtual()) { + var serviceUrl; + if (quote.getCheckoutMethod()() === 'guest') { + serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/addresses', {quoteId: quote.getQuoteId()}); + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/addresses', {}); + } + storage.post( + serviceUrl, + JSON.stringify({ + billingAddress: quote.getBillingAddress()(), + additionalData: {extensionAttributes : additionalData}, + checkoutMethod: quote.getCheckoutMethod()() + }) + ).done( + function (result) { + paymentService.setPaymentMethods(result.payment_methods); + quote.setFormattedBillingAddress(result.formatted_billing_address); + quote.setTotals(result.totals); + navigator.setCurrent('billingAddress').goNext(); + if (typeof actionCallback == 'function') { + actionCallback(true); + } + } + ).fail( + function (response) { + var error = JSON.parse(response.responseText); + errorList.add(error); + quote.setBillingAddress(null); + if (typeof actionCallback == 'function') { + actionCallback(false); + } + } + ); + } else { + navigator.setCurrent('billingAddress').goNext(); + if (addressList.isBillingSameAsShipping) { + copyBillingToShipping(); + } + } + }; + result.setActionCallback = function (value) { + actionCallback = value; + }; + return result; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js new file mode 100644 index 0000000000000..1c7b36b9178be --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js @@ -0,0 +1,99 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + '../model/quote', + '../model/url-builder', + '../model/step-navigator', + '../model/payment-service', + 'Magento_Ui/js/model/errorlist', + 'mage/storage', + 'underscore' + ], + function(quote, urlBuilder, navigator, service, errorList, storage, _) { + "use strict"; + return function (methodData, methodInfo, callbacks) { + var paymentMethodData = { + "cartId": quote.getQuoteId(), + "paymentMethod": methodData + }; + + var shippingMethodCode = quote.getSelectedShippingMethod()().slice(0).split("_"), + shippingMethodData = { + "shippingCarrierCode" : shippingMethodCode.shift(), + "shippingMethodCode" : shippingMethodCode.join('_') + }, + serviceUrl; + if (quote.getCheckoutMethod()() === 'guest') { + serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/collect-totals', {quoteId: quote.getQuoteId()}); + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/collect-totals', {}); + } + + if (quote.isVirtual()) { + return storage.put( + serviceUrl, + JSON.stringify(paymentMethodData) + ).done( + function (response) { + var proceed = true; + _.each(callbacks, function(callback) { + proceed = proceed && callback(); + }); + if (proceed) { + quote.setPaymentMethod(methodData.method); + service.setSelectedPaymentData(methodData); + service.setSelectedPaymentInfo(methodInfo); + quote.setTotals(response); + navigator.setCurrent('paymentMethod').goNext(); + } + } + ).error( + function (response) { + var error = JSON.parse(response.responseText); + errorList.add(error); + quote.setPaymentMethod(null); + } + ); + } else { + if (!_.isEmpty(quote.getShippingCustomOptions()())) { + shippingMethodData = _.extend( + shippingMethodData, + { + additionalData: { + extension_attributes: quote.getShippingCustomOptions()() + } + } + ); + } + return storage.put( + serviceUrl, + JSON.stringify(_.extend(paymentMethodData, shippingMethodData)) + ).done( + function (response) { + var proceed = true; + _.each(callbacks, function(callback) { + proceed = proceed && callback(); + }); + if (proceed) { + quote.setPaymentMethod(methodData.method); + service.setSelectedPaymentData(methodData); + service.setSelectedPaymentInfo(methodInfo); + quote.setTotals(response); + navigator.setCurrent('paymentMethod').goNext(); + } + } + ).error( + function (response) { + var error = JSON.parse(response.responseText); + errorList.add(error); + quote.setPaymentMethod(null); + } + ); + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js new file mode 100644 index 0000000000000..c9f87d1594b7a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js @@ -0,0 +1,72 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + '../model/quote', + '../model/addresslist', + '../model/url-builder', + '../model/step-navigator', + '../model/shipping-service', + '../model/payment-service', + 'mage/storage', + 'Magento_Ui/js/model/errorlist' + ], + function(quote, addressList, urlBuilder, navigator, shippingService, paymentService, storage, errorList) { + "use strict"; + var actionCallback; + var result = function(shippingAddress, sameAsBilling, additionalData) { + var serviceUrl; + if (quote.getCheckoutMethod()() === 'guest') { + serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/addresses', {quoteId: quote.getQuoteId()}); + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/addresses', {}); + } + + errorList.clear(); + additionalData = additionalData || {}; + shippingAddress['same_as_billing'] = (sameAsBilling) ? 1 : 0; + quote.setShippingAddress(shippingAddress); + + storage.post( + serviceUrl, + JSON.stringify({ + shippingAddress: quote.getShippingAddress()(), + billingAddress: quote.getBillingAddress()(), + additionalData: {extensionAttributes : additionalData}, + checkoutMethod: quote.getCheckoutMethod()() + }) + ).done( + function(result) { + shippingService.setShippingRates(result.shipping_methods); + paymentService.setPaymentMethods(result.payment_methods); + quote.setFormattedBillingAddress(result.formatted_billing_address); + quote.setFormattedShippingAddress(result.formatted_shipping_address); + quote.setTotals(result.totals); + navigator.setCurrent('shippingAddress').goNext(); + if (typeof actionCallback == 'function') { + actionCallback(true); + } + } + ).fail( + function(response) { + var error = JSON.parse(response.responseText); + errorList.add(error); + quote.setShippingAddress(null); + quote.setBillingAddress(null); + quote.setFormattedBillingAddress(null); + quote.setFormattedShippingAddress(null); + if (typeof actionCallback == 'function') { + actionCallback(false); + } + } + ); + }; + result.setActionCallback = function (value) { + actionCallback = value; + }; + return result; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-method.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-method.js new file mode 100644 index 0000000000000..f00e2e86670c8 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-method.js @@ -0,0 +1,40 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define,alert*/ +define( + [ + '../model/quote', + '../model/url-builder', + '../model/step-navigator', + 'Magento_Checkout/js/model/shipping-service', + 'mage/translate', + 'ko' + ], + function (quote, urlBuilder, navigator, shippingService, $t, ko) { + "use strict"; + return function (code, customOptions, callbacks) { + if (!code) { + alert($t('Please specify a shipping method')); + return; + } + + var proceed = true; + _.each(callbacks, function (callback) { + proceed = proceed && callback(); + }); + + if (proceed) { + var shippingMethodCode = code.split("_"), + shippingRate = shippingService.getRateByCode(shippingMethodCode)[0]; + + quote.setShippingMethod(shippingMethodCode); + quote.setSelectedShippingMethod(code); + quote.setShippingCustomOptions(customOptions); + quote.setCollectedTotals('shipping', shippingRate.amount); + navigator.setCurrent('shippingMethod').goNext(); + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/addresslist.js b/app/code/Magento/Checkout/view/frontend/web/js/model/addresslist.js new file mode 100644 index 0000000000000..62bc28d252763 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/addresslist.js @@ -0,0 +1,29 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true*/ +/*global define*/ +define(['jquery'], function($) { + "use strict"; + var addresses = []; + return { + add: function (address) { + addresses.push(address); + }, + getAddressById: function(id) { + var address = null; + $.each(addresses, function(key, item) { + if (id === item.customerAddressId) { + address = item; + return false; + } + }); + return address; + }, + getAddresses: function() { + return addresses.slice(0); + }, + isBillingSameAsShipping: false + }; +}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/item.js b/app/code/Magento/Checkout/view/frontend/web/js/model/item.js new file mode 100644 index 0000000000000..d1927d19e9288 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/item.js @@ -0,0 +1,9 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([], function() { + +}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/payment-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/payment-service.js new file mode 100644 index 0000000000000..9b6fc75a216c5 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/payment-service.js @@ -0,0 +1,68 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'ko', + 'jquery', + 'Magento_Checkout/js/model/quote' + ], + function (ko, $, quote) { + return { + paymentMethods: ko.observableArray([]), + availablePaymentMethods: ko.observableArray([]), + selectedPaymentData: ko.observableArray(), + selectedPaymentInfo: ko.observableArray([]), + setPaymentMethods: function(methods) { + this.paymentMethods(methods); + }, + getAvailablePaymentMethods: function () { + var methods = [], + self = this; + $.each(this.paymentMethods(), function (key, method) { + if (self.isFreeMethodActive() && ( + quote.getCalculatedTotal() <= 0 && method['code'] == 'free' + || quote.getCalculatedTotal() > 0 && method['code'] != 'free' + ) || !self.isFreeMethodActive() + ) { + methods.push(method); + } + }); + return methods; + }, + isFreeMethodActive: function () { + var isAvailable = false; + $.each(this.paymentMethods(), function (key, method) { + if (method['code'] == 'free') { + isAvailable = true; + } + }); + return isAvailable; + }, + setSelectedPaymentData: function(data) { + this.selectedPaymentData(data); + }, + getSelectedPaymentData: function () { + return this.selectedPaymentData(); + }, + setSelectedPaymentInfo: function(data) { + this.selectedPaymentInfo(data); + }, + getSelectedPaymentInfo: function () { + return this.selectedPaymentInfo(); + }, + getTitleByCode: function(code) { + var methodTitle = ''; + $.each(this.getAvailablePaymentMethods(), function (key, entity) { + if (entity['code'] == code) { + methodTitle = entity['title']; + } + }); + return methodTitle; + } + } + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/quote.js b/app/code/Magento/Checkout/view/frontend/web/js/model/quote.js new file mode 100644 index 0000000000000..650a8b053f7a2 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/quote.js @@ -0,0 +1,124 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + ['ko'], + function(ko) { + var billingAddress = ko.observable(null); + var shippingAddress = ko.observable(null); + var shippingMethod = ko.observable(null); + var paymentMethod = ko.observable(null); + var quoteData = window.checkoutConfig.quoteData; + var basePriceFormat = window.checkoutConfig.basePriceFormat; + var priceFormat = window.checkoutConfig.priceFormat; + var selectedShippingMethod = ko.observable(window.checkoutConfig.selectedShippingMethod); + var storeCode = window.checkoutConfig.storeCode; + var totals = ko.observable({}); + var checkoutMethod = ko.observable(null); + var shippingCustomOptions = ko.observable(null); + var formattedShippingAddress = ko.observable(null); + var formattedBillingAddress = ko.observable(null); + var collectedTotals = ko.observable({}); + return { + getQuoteId: function() { + return quoteData.entity_id; + }, + isVirtual: function() { + return !!Number(quoteData.is_virtual); + }, + getPriceFormat: function() { + return priceFormat; + }, + getBasePriceFormat: function() { + return basePriceFormat; + }, + getItems: function() { + return window.checkoutConfig.quoteItemData; + }, + getTotals: function() { + return totals + }, + setTotals: function(totalsData) { + if (_.isObject(totalsData.extension_attributes)) { + _.each(totalsData.extension_attributes, function(element, index) { + totalsData[index] = element; + }); + } + totals(totalsData); + this.setCollectedTotals('subtotal_with_discount', parseFloat(totalsData.subtotal_with_discount)); + }, + setBillingAddress: function (address) { + billingAddress(address); + }, + getBillingAddress: function() { + return billingAddress; + }, + setShippingAddress: function (address) { + shippingAddress(address); + }, + getShippingAddress: function() { + return shippingAddress; + }, + setFormattedBillingAddress: function (address) { + formattedBillingAddress(address); + }, + getFormattedBillingAddress: function() { + return formattedBillingAddress; + }, + setFormattedShippingAddress: function (address) { + formattedShippingAddress(address); + }, + getFormattedShippingAddress: function() { + return formattedShippingAddress; + }, + setPaymentMethod: function(paymentMethodCode) { + paymentMethod(paymentMethodCode); + }, + getPaymentMethod: function() { + return paymentMethod; + }, + setShippingMethod: function(shippingMethodCode) { + shippingMethod(shippingMethodCode); + }, + getShippingMethod: function() { + return shippingMethod; + }, + getSelectedShippingMethod: function() { + return selectedShippingMethod; + }, + setSelectedShippingMethod: function(shippingMethod) { + selectedShippingMethod(shippingMethod); + }, + getStoreCode: function() { + return storeCode; + }, + getCheckoutMethod: function() { + return checkoutMethod; + }, + setCheckoutMethod: function(method) { + checkoutMethod(method); + }, + setShippingCustomOptions: function(customOptions) { + shippingCustomOptions(customOptions); + }, + getShippingCustomOptions: function() { + return shippingCustomOptions; + }, + setCollectedTotals: function(code, value) { + var totals = collectedTotals(); + totals[code] = value; + collectedTotals(totals); + }, + getCalculatedTotal: function() { + var total = 0.; + _.each(collectedTotals(), function(value) { + total += value; + }); + return total; + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-service.js new file mode 100644 index 0000000000000..8bb0366111a7a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-service.js @@ -0,0 +1,63 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + ['ko', 'jquery'], + function (ko, $) { + "use strict"; + var rates = ko.observable([]); + return { + shippingRates: ko.observableArray([]), + setShippingRates: function(ratesData) { + var self = this; + rates(ratesData); + self.shippingRates([]); + $.each(ratesData, function (key, entity) { + var rateEntity = {}; + rateEntity.items = []; + if (!ratesData.hasOwnProperty(entity.carrier_code)) { + rateEntity['carrier_code'] = entity.carrier_code; + rateEntity['carrier_title'] = entity.carrier_title; + } + rateEntity.items.push(entity); + self.shippingRates.push(rateEntity); + }); + + }, + getSippingRates: function() { + return this.shippingRates; + }, + getTitleByCode: function(methodCodeParts) { + var shippingMethodTitle = '', shippingMethodCode, carrierCode, methodCode; + if (!methodCodeParts) { + return shippingMethodTitle; + } + shippingMethodCode = methodCodeParts.slice(0); + carrierCode = shippingMethodCode.shift(); + methodCode = shippingMethodCode.join('_'); + $.each(rates(), function (key, entity) { + if (entity['carrier_code'] === carrierCode && entity['method_code'] === methodCode) { + shippingMethodTitle = entity['carrier_title'] + " - " + entity['method_title']; + } + }); + return shippingMethodTitle; + }, + getRateByCode : function(methodCodeParts) { + var shippingRates = [], + shippingMethodCode = methodCodeParts.slice(0), + carrierCode = shippingMethodCode.shift(), + methodCode = shippingMethodCode.join('_'); + if (methodCodeParts) { + $.each(rates(), function (key, entity) { + if (entity['carrier_code'] === carrierCode && entity['method_code'] === methodCode) { + shippingRates.push(entity); + } + }); + } + return shippingRates; + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/step-loader.js b/app/code/Magento/Checkout/view/frontend/web/js/model/step-loader.js new file mode 100644 index 0000000000000..179fee0461342 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/step-loader.js @@ -0,0 +1,23 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define(['jquery'], function($) { + return { + registerLoader: function() { + $(document).bind('ajaxSend', function() { + $('#checkout').trigger("processStart"); + }); + + $(document).bind('ajaxComplete', function() { + $('#checkout').trigger("processStop"); + }); + + $(document).bind('ajaxError', function() { + $('#checkout').trigger("processStop"); + }); + } + }; +}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js new file mode 100644 index 0000000000000..44a48fa893285 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js @@ -0,0 +1,205 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'jquery', + 'ko', + 'Magento_Customer/js/model/customer', + 'Magento_Ui/js/model/errorlist' + ], + function($, ko, customer, errorList) { + var customerIsLoggedIn = customer.isLoggedIn()(); + var defaultStepClass = 'section'; + var allowedStepClass = 'allow'; + var activeStepClass = 'active'; + return { + currentStep: null, + steps: [ + { + name: 'authentication', + isVisible: ko.observable(!customerIsLoggedIn), + isEnabled: true, + number: ko.observable(1), + classAttributes: ko.observable(defaultStepClass) + }, + { + name: 'billingAddress', + isVisible: ko.observable(customerIsLoggedIn), + isEnabled: true, + number: ko.observable(2), + classAttributes: ko.observable(defaultStepClass) + }, + { + name: 'shippingAddress', + isVisible: ko.observable(false), + isEnabled: true, + number: ko.observable(3), + classAttributes: ko.observable(defaultStepClass) + }, + { + name: 'shippingMethod', + isVisible: ko.observable(false), + isEnabled: true, + number: ko.observable(4), + classAttributes: ko.observable(defaultStepClass) + }, + { + name: 'paymentMethod', + isVisible: ko.observable(false), + isEnabled: true, + number: ko.observable(5), + classAttributes: ko.observable(defaultStepClass) + }, + { + name: 'review', + isVisible: ko.observable(false), + isEnabled: true, + number: ko.observable(6), + classAttributes: ko.observable(defaultStepClass) + } + ], + setCurrent: function(step) { + this.currentStep = step; + return this; + }, + getCurrentStep: function() { + if (!this.currentStep) { + alert('Current step not set.'); + return; + } + var self = this; + var currentStep = null; + $.each(this.steps, function(key, step) { + if (self.currentStep == step.name) { + currentStep = step; + } + }); + return currentStep; + }, + goNext: function() { + var currentStep = this.getCurrentStep(); + var nextStepOrder = currentStep.number() + 1; + var nextStep = null; + $.each(this.steps, function(key, item) { + if (nextStepOrder == item.number()) { + nextStep = item; + return false; + } + }); + if (nextStep) { + this.toStep(nextStep.name); + } + }, + goBack: function() { + var currentStep = this.getCurrentStep(); + var prevStepOrder = currentStep.number() - 1; + var previousStep = null; + $.each(this.steps, function(key, item) { + if (prevStepOrder == item.number()) { + previousStep = item; + return false; + } + }); + if (previousStep) { + this.toStep(previousStep.name); + } + }, + getStepClassAttributes: function(name) { + return this.findStepByName(name).classAttributes; + }, + setStepClassAttributes: function(name) { + var stepClass = defaultStepClass; + var step = this.findStepByName(name); + if (step.isVisible()) { + stepClass += ' ' + activeStepClass; + } + if (this.isStepAvailable(step.name)) { + stepClass += ' ' + allowedStepClass; + } + step.classAttributes(stepClass); + }, + updateStepsClassAttributes: function() { + var self = this; + $.each(this.steps, function(key, step) { + var stepClass = defaultStepClass; + if (step.isVisible()) { + stepClass += ' ' + activeStepClass; + } + if (self.isStepAvailable(step.name)) { + stepClass += ' ' + allowedStepClass; + } + step.classAttributes(stepClass); + }); + }, + isStepAvailable: function(name) { + var visibleStep = this.getCurrentVisibleStep(); + var step = this.findStepByName(name); + return (step.number() < visibleStep.number()); + }, + goToStep: function(name) { + if (this.isStepAvailable(name)) { + this.toStep(name); + } + }, + toStep: function(name) { + if (name) { + $.each(this.steps, function(key, step) { + step.isVisible(false); + }); + this.findStepByName(name).isVisible(true); + this.updateStepsClassAttributes(); + errorList.clear(); + } + }, + findStepByName: function(name) { + var step = null; + $.each(this.steps, function(key, currentStep) { + if (name == currentStep.name) { + step = currentStep; + return false; + } + }); + return step; + }, + isStepVisible: function(step) { + this.setStepClassAttributes(step); + return this.findStepByName(step).isVisible; + }, + setStepVisible: function(step, flag) { + this.findStepByName(step).isVisible(flag); + }, + getCurrentVisibleStep: function() { + var step = null; + $.each(this.steps, function(key, currentStep) { + if (currentStep.isVisible()) { + step = currentStep; + return false; + } + }); + return step; + }, + setStepEnabled: function(step, flag) { + this.findStepByName(step).isEnabled = flag; + this.refreshStepsNumbers(); + }, + refreshStepsNumbers: function() { + var numb = 1; + $.each(this.steps, function(key, item) { + if (item.isEnabled) { + item.number(numb); + numb++; + } else { + item.number(null); + } + }); + }, + getStepNumber: function(name) { + return this.findStepByName(name).number; + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/url-builder.js b/app/code/Magento/Checkout/view/frontend/web/js/model/url-builder.js new file mode 100644 index 0000000000000..979dc09304f50 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/url-builder.js @@ -0,0 +1,38 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + ['jquery'], + function($) { + return { + method: "rest", + storeCode: window.checkoutConfig.storeCode, + version: 'V1', + serviceUrl: ':method/:storeCode/:version', + + createUrl: function(url, params) { + var completeUrl = this.serviceUrl + url; + return this.bindParams(completeUrl, params); + }, + bindParams: function(url, params) { + params.method = this.method; + params.storeCode = this.storeCode; + params.version = this.version; + + var urlParts = url.split("/"); + urlParts = urlParts.filter(Boolean); + + $.each(urlParts, function(key, part) { + part = part.replace(':', ''); + if (params[part] != undefined) { + urlParts[key] = params[part]; + } + }); + return urlParts.join('/'); + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js index cd5121ef50fd6..8977f0a7dd66b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js @@ -6,6 +6,10 @@ */ /*jshint browser:true jquery:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ "jquery", "jquery/ui", diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js index bdc635d337b1b..899f38b32e120 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js @@ -6,6 +6,10 @@ */ /*jshint browser:true jquery:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ "jquery", "accordion", diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js index cda76773ef3c4..a837566f0e712 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js @@ -6,6 +6,10 @@ */ /*jshint browser:true jquery:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ "jquery", "jquery/ui", diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js index e67d89012ee71..c590c9835a37c 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js @@ -6,6 +6,10 @@ */ /*jshint browser:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ 'jquery', 'mage/template', diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js index 53784918992f1..067fb59f19905 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js @@ -6,6 +6,10 @@ */ /*jshint browser:true jquery:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ "jquery", "jquery/ui", diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js index f21ea11589f64..074ee318a67c3 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js @@ -6,6 +6,10 @@ */ /*jshint browser:true jquery:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ "jquery", "jquery/ui", diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js index ac833eb7df2a1..0cad0456668bd 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js @@ -4,6 +4,10 @@ */ /*jshint browser:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ 'jquery', 'mage/template', diff --git a/app/code/Magento/Checkout/view/frontend/web/js/overview.js b/app/code/Magento/Checkout/view/frontend/web/js/overview.js deleted file mode 100644 index 94f918b73e643..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/overview.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @category checkout multi-shipping review order overview - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint jquery:true*/ -/*global alert*/ -define([ - "jquery", - "jquery/ui", - "mage/translate" -], function($){ - "use strict"; - - $.widget('mage.orderOverview', { - options: { - opacity: 0.5, // CSS opacity for the 'Place Order' button when it's clicked and then disabled. - pleaseWaitLoader: 'span.please-wait', // 'Submitting order information...' Ajax loader. - placeOrderSubmit: 'button[type="submit"]' // The 'Place Order' button. - }, - - /** - * Bind a submit handler to the form. - * @private - */ - _create: function() { - this.element.on('submit', $.proxy(this._showLoader, this)); - }, - - /** - * Show the Ajax loader. Disable the submit button (i.e. Place Order). - * @return {Boolean} - * @private - */ - _showLoader: function() { - if (!this.element.validation('isValid')) { - return false; - } - this.element.find(this.options.pleaseWaitLoader).show().end() - .find(this.options.placeOrderSubmit).prop('disabled', true).css('opacity', this.options.opacity); - return true; - } - }); - - return $.mage.orderOverview; -}); \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js b/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js index 0ceea91923493..3f0cfc7b7f274 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js @@ -3,6 +3,10 @@ * See COPYING.txt for license details. */ /*jshint jquery:true*/ +/** + * @deprecated + * @removeCandidate + */ define([ "jquery", "jquery/ui" diff --git a/app/code/Magento/Checkout/view/frontend/web/js/payment.js b/app/code/Magento/Checkout/view/frontend/web/js/payment.js index 4d6dadc7c7110..f306e375d47fd 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/payment.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/payment.js @@ -4,6 +4,10 @@ */ /*jshint browser:true*/ /*global alert*/ +/** + * @deprecated + * @removeCandidate + */ define([ 'jquery', 'mage/template', diff --git a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js index 31e16ff05c81b..2455c3932eaba 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -117,12 +117,6 @@ define([ * @private */ _updateItemQtyAfter: function(elem, response) { - if ($.type(response.data) === 'object') { - this._refreshQty(response.data.summary_qty, response.data.summary_text); - this._refreshSubtotal(response.data.subtotal); - this._refreshShowcart(response.data.summary_qty, response.data.summary_text); - this._refreshItemQty(elem, response.data.summary_qty); - } this._hideItemButton(elem); }, @@ -141,16 +135,7 @@ define([ * @private */ _removeItemAfter: function(elem, response) { - if ($.type(response.data) === 'object') { - this._refreshShowcart(response.data.summary_qty, response.data.summary_text); - } - $(this.options.minicart.content).html($.trim(response.content)); - if (response.cleanup === true) { - $(this.options.showcart.parent).addClass('empty'); - } - this._initContent(); }, - /** * @param url - ajax url * @param data - post data for ajax call @@ -185,44 +170,6 @@ define([ console.log(JSON.stringify(error)); }); }, - - _refreshItemQty: function(elem, qty) { - if (qty != undefined) { - var itemId = elem.data('cart-item'); - $('#cart-item-' + itemId + '-qty').data('item-qty', qty); - } - }, - - _refreshQty: function(qty, text) { - if (qty != undefined && text != undefined) { - var self = this; - $(this.options.minicart.qty).fadeOut('slow', function() { - $(self.options.minicart.qty).html('' + qty + '' + text); - }).fadeIn(); - } - }, - - _refreshSubtotal: function(val) { - if (val != undefined) { - var self = this; - $(this.options.minicart.subtotal).fadeOut('slow', function() { - $(self.options.minicart.subtotal).replaceWith(val); - }).fadeIn(); - } - }, - - _refreshShowcart: function(qty, text) { - if (qty != undefined && text != undefined) { - var self = this; - $(this.options.showcart.qty).fadeOut('slow', function() { - $(self.options.showcart.qty).text(qty); - }).fadeIn(); - $(this.options.showcart.label).fadeOut('slow', function() { - $(self.options.showcart.label).text(text); - }).fadeIn(); - } - }, - /** * Calculate height of minicart list * diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/authentication.js b/app/code/Magento/Checkout/view/frontend/web/js/view/authentication.js new file mode 100644 index 0000000000000..44018161f3eea --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/authentication.js @@ -0,0 +1,73 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + "jquery", + 'ko', + 'Magento_Ui/js/form/form', + 'Magento_Customer/js/action/login', + 'Magento_Customer/js/model/customer', + 'Magento_Checkout/js/model/step-navigator', + '../model/quote', + 'mage/validation' + ], + function($, ko, Component, login, customer, navigator, quote) { + "use strict"; + var stepName = 'authentication'; + return Component.extend({ + stepNumber: navigator.getStepNumber(stepName), + isGuestCheckoutAllowed: window.checkoutConfig.isGuestCheckoutAllowed, + isCustomerLoginRequired: window.checkoutConfig.isCustomerLoginRequired, + registerUrl: window.checkoutConfig.registerUrl, + forgotPasswordUrl: window.checkoutConfig.forgotPasswordUrl, + username: '', + password: '', + isVisible: navigator.isStepVisible(stepName), + defaults: { + template: 'Magento_Checkout/authentication' + }, + login: function(loginForm) { + var loginData = {}; + var formDataArray = $(loginForm).serializeArray(); + var loginFormSelector = 'form[data-role=login]'; + formDataArray.forEach(function (entry) { + loginData[entry.name] = entry.value; + }); + if($(loginFormSelector).validation() && $(loginFormSelector).validation('isValid')) { + login(loginData); + } + }, + stepClassAttributes: function() { + return navigator.getStepClassAttributes(stepName); + }, + isActive: function() { + if (customer.isLoggedIn()()) { + navigator.setStepEnabled(stepName, false); + } + return !customer.isLoggedIn()(); + }, + isChecked: function() { + if (!isGuestCheckoutAllowed) { + return 'register'; + } + return false; + }, + setCheckoutMethod: function() { + quote.setCheckoutMethod('guest'); + $('[name="customerDetails.password"]').hide(); + $('[name="customerDetails.confirm_password"]').hide(); + $('[name*=".save_in_address_book"]').hide(); + navigator.setCurrent('authentication').goNext(); + }, + navigateToCurrentStep: function() { + if (!navigator.isStepVisible(stepName)()) { + navigator.goToStep(stepName); + } + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js b/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js new file mode 100644 index 0000000000000..b84bed5619b32 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js @@ -0,0 +1,17 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + ['uiComponent'], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/iterator', + displayArea: 'beforePlaceOrder' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js new file mode 100644 index 0000000000000..ebb20378def25 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -0,0 +1,133 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true*/ +/*global define*/ +define( + [ + "jquery", + 'Magento_Ui/js/form/form', + 'ko', + 'Magento_Customer/js/model/customer', + '../action/select-billing-address', + '../model/step-navigator', + '../model/quote', + '../model/addresslist' + ], + function ($, Component, ko, customer, selectBillingAddress, navigator, quote, addressList) { + "use strict"; + var stepName = 'billingAddress'; + var newAddressSelected = ko.observable(false); + var billingFormSelector = '#co-billing-form'; + + return Component.extend({ + defaults: { + template: 'Magento_Checkout/billing-address' + }, + initObservable: function () { + this._super().observe('useForShipping'); + return this; + }, + stepClassAttributes: function() { + return navigator.getStepClassAttributes(stepName); + }, + stepNumber: navigator.getStepNumber(stepName), + billingAddresses: function() { + var newAddress = { + getAddressInline: function() { + return $.mage.__('New address'); + }, + customerAddressId: null + }, + addresses = addressList.getAddresses(); + addresses.push(newAddress); + return addresses; + }, + selectedBillingAddressId: ko.observable( + addressList.getAddresses().length ? addressList.getAddresses()[0].customerAddressId : null + ), + isVisible: navigator.isStepVisible(stepName), + useForShipping: "1", + quoteIsVirtual: quote.isVirtual(), + billingAddressesOptionsText: function(item) { + return item.getAddressInline(); + }, + checkUseForShipping: function(useForShipping) { + var additionalData = {}; + if (useForShipping() instanceof Object) { + additionalData = useForShipping().getAdditionalData(); + useForShipping('1'); + } + return additionalData; + }, + submitBillingAddress: function() { + var additionalData = this.checkUseForShipping(this.useForShipping); + if (this.selectedBillingAddressId()) { + selectBillingAddress( + addressList.getAddressById(this.selectedBillingAddressId()), + this.useForShipping, + additionalData + ); + } else { + this.validate(); + if (!this.source.get('params.invalid')) { + var addressData = this.source.get('billingAddress'); + /** + * All the the input fields that are not a part of the address (e. g. CAPTCHA) but need to be + * submitted in the same request must have data-scope attribute set + */ + var additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray(); + additionalFields.forEach(function (field) { + additionalData[field.name] = field.value; + }); + if (quote.getCheckoutMethod()() && !customer.isLoggedIn()()) { + addressData.email = this.source.get('customerDetails.email'); + } + if($(billingFormSelector).validation() && $(billingFormSelector).validation('isValid')) { + selectBillingAddress(addressData, this.useForShipping, additionalData); + } + } + } + }, + navigateToCurrentStep: function() { + if (!navigator.isStepVisible(stepName)()) { + navigator.goToStep(stepName); + } + }, + isNewAddressSelected: function() { + if (!this.customerAddressCount) { + return true; + } + return newAddressSelected(); + }, + onAddressChange: function (value) { + value() === null ? newAddressSelected(true) : newAddressSelected(false); + }, + validate: function() { + var fields = $(billingFormSelector).find('input, select'); + + this.source.set('params.invalid', false); + fields.trigger('change'); + this.source.trigger('billingAddress.data.validate'); + if (!customer.isLoggedIn()()) { + this.source.trigger('customerDetails.data.validate'); + } + this.validateAdditionalAddressFields(); + }, + validateAdditionalAddressFields: function() { + $(billingFormSelector).validation(); + $(billingFormSelector + ' input[data-scope="additionalAddressData"]').each(function(key, item) { + $(item).valid(); + }); + }, + isCustomerLoggedIn: customer.isLoggedIn(), + customerAddressCount: window.checkoutConfig.customerAddressCount, + hideExtraFields: function() { + if (!quote.getCheckoutMethod()() && customer.isLoggedIn()()) { + $('[name="customerDetails.email"]').hide(); + } + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/columns.js b/app/code/Magento/Checkout/view/frontend/web/js/view/columns.js new file mode 100644 index 0000000000000..85a2097532024 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/columns.js @@ -0,0 +1,20 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/iterator', + displayArea: 'columns' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/discount.js b/app/code/Magento/Checkout/view/frontend/web/js/view/discount.js new file mode 100644 index 0000000000000..f2a959dfcdb51 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/discount.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component, quote, priceUtils) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/discount', + displayArea: 'totals' + }, + colspan: 3, + style: '', + fieldName: 'Discount', + totals: quote.getTotals(), + getPureValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().discount_amount; + } + return price; + }, + getValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().discount_amount; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/itemsAfter.js b/app/code/Magento/Checkout/view/frontend/web/js/view/itemsAfter.js new file mode 100644 index 0000000000000..ee96966658f05 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/itemsAfter.js @@ -0,0 +1,20 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/iterator', + displayArea: 'itemsAfter' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/itemsBefore.js b/app/code/Magento/Checkout/view/frontend/web/js/view/itemsBefore.js new file mode 100644 index 0000000000000..9d2e10ce0a87a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/itemsBefore.js @@ -0,0 +1,20 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/iterator', + displayArea: 'itemsBefore' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js new file mode 100644 index 0000000000000..322718862d97e --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js @@ -0,0 +1,77 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data', + 'jquery', + 'ko' +], function (Component, customerData, $, ko) { + 'use strict'; + + var sidebarInitialized = false; + + function initSidebar() { + var minicart = $("[data-block='minicart']"); + minicart.trigger('contentUpdated'); + if (sidebarInitialized) { + return false; + } + sidebarInitialized = true; + minicart.mage('sidebar', { + "targetElement": "div.block.block-minicart", + "url": { + "checkout": window.checkout.checkoutUrl, + "update": window.checkout.updateItemQtyUrl, + "remove": window.checkout.removeItemUrl + }, + "button": { + "checkout": "#top-cart-btn-checkout", + "remove": "#mini-cart a.action.delete", + "close": "#btn-minicart-close" + }, + "showcart": { + "parent": "span.counter", + "qty": "span.counter-number", + "label": "span.counter-label" + }, + "minicart": { + "list": "#mini-cart", + "content": "#minicart-content-wrapper", + "qty": "div.items-total", + "subtotal": "div.subtotal span.price" + }, + "item": { + "qty": ":input.cart-item-qty", + "button": ":button.update-cart-item" + }, + "confirmMessage": $.mage.__( + 'Are you sure you would like to remove this item from the shopping cart?' + ) + }); + } + + return Component.extend({ + shoppingCartUrl: window.checkout.shoppingCartUrl, + initialize: function () { + this._super(); + this.cart = customerData.get('cart'); + this.cart.subscribe(function () { + sidebarInitialized = false; + }); + }, + initSidebar: ko.observable(initSidebar), + closeSidebar: function(element) { + var minicart = $('[data-block="minicart"]'); + minicart.on('click', '[data-action="close"]', function(event) { + event.stopPropagation(); + minicart.find('[data-role="dropdownDialog"]').dropdownDialog("close"); + }); + return true; + }, + getItemRenderer: function (productType) { + return this.itemRenderer[productType] || 'defaultRenderer'; + } + }); +}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/onepage.js b/app/code/Magento/Checkout/view/frontend/web/js/view/onepage.js new file mode 100644 index 0000000000000..1d8f713edc4c8 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/onepage.js @@ -0,0 +1,18 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true jquery:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + return Component.extend({ + defaults: { + template: 'Magento_Checkout/onepage' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js new file mode 100644 index 0000000000000..21d555cdd7b2a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js @@ -0,0 +1,160 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'jquery', + 'uiComponent', + '../model/quote', + '../action/select-payment-method', + 'Magento_Checkout/js/model/step-navigator', + 'Magento_Checkout/js/model/payment-service', + 'mage/translate', + 'mageUtils' + ], + function ($, Component, quote, selectPaymentMethod, navigator, paymentService, $t, utils) { + var stepName = 'paymentMethod'; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/payment', + activeMethod: '' + }, + stepClassAttributes: function() { + return navigator.getStepClassAttributes(stepName); + }, + stepNumber: navigator.getStepNumber(stepName), + isVisible: navigator.isStepVisible(stepName), + paymentForm: '#co-payment-form', + initObservable: function () { + this._super() + .observe('activeMethod'); + return this; + }, + quoteHasShippingMethod: function() { + return quote.isVirtual() || quote.getShippingMethod(); + }, + setPaymentMethod: function() { + if (!this.activeMethod()) { + alert($t('Please specify payment method.')); + return; + } + + if (this.isFormValid()) { + selectPaymentMethod( + this.getPaymentMethodData(), + this.getPaymentMethodInfo(), + this.getPaymentMethodCallbacks() + ); + } + }, + getPaymentMethodData: function() { + var data = { + "method": this.activeMethod(), + "po_number": null, + "cc_owner": null, + "cc_number": null, + "cc_type": null, + "cc_exp_year": null, + "cc_exp_month": null, + "additional_data": null + }; + utils.extend(data, this.getActiveMethodView().getData()); + + _.each(this.getAdditionalMethods(), function(elem) { + if (elem.isActive()) { + utils.extend(data, elem.getData()); + } + }); + + return data; + }, + getPaymentMethodInfo: function() { + var info = this.getActiveMethodView().getInfo(); + + _.each(this.getAdditionalMethods(), function(elem) { + if (elem.isActive()) { + info = _.union(info, elem.getInfo()); + } + }); + + return info; + }, + getPaymentMethodCallbacks: function() { + var callbacks = [this.getActiveMethodView().afterSave.bind(this.getActiveMethodView())]; + + _.each(this.getAdditionalMethods(), function(elem) { + if (elem.isActive()) { + callbacks = _.union(callbacks, [elem.afterSave.bind(elem)]); + } + }); + + return callbacks; + }, + getAvailableViews: function () { + var sortedElems = [], + self = this; + + _.each(this.getAvailableMethods(), function (originElem) { + var method = self.getMethodViewByCode(originElem.code); + if (method && method.isAvailable()) { + sortedElems.push(method); + } + }); + + if (sortedElems.length == 1) { + this.activeMethod(sortedElems[0].getCode()); + } + + return sortedElems; + }, + getAvailableMethods: function() { + return paymentService.getAvailablePaymentMethods(); + }, + getAvailableCodes: function() { + return _.pluck(this.getAvailableMethods(), 'code'); + }, + getMethodViewByCode: function(code) { + return _.find(this.getRegion('paymentMethods')(), function(elem) { + return elem.getCode() == code; + }); + }, + getActiveMethodView: function() { + return this.getMethodViewByCode(this.activeMethod()); + }, + backToShippingMethod: function() { + navigator.setCurrent(stepName).goBack(); + }, + navigateToCurrentStep: function() { + if (!navigator.isStepVisible(stepName)()) { + navigator.goToStep(stepName); + } + }, + isMethodActive: function(code) { + return this.activeMethod() === code; + }, + isFormValid: function() { + $(this.paymentForm).validation(); + return $(this.paymentForm).validation('isValid'); + }, + getFormKey: function() { + return window.checkoutConfig.formKey; + }, + getAdditionalMethods: function() { + var methods = []; + _.each(this.getRegion('beforeMethods')(), function(elem) { + methods = _.union(methods, elem.elems()); + }); + _.each(this.getRegion('afterMethods')(), function(elem) { + methods = _.union(methods, elem.elems()); + }); + return methods; + }, + getMethodControlAdditionalClass: function() { + return this.getAvailableViews().length == 1 ? ' hidden' : ''; + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/generic.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/generic.js new file mode 100644 index 0000000000000..64833500f70a1 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/generic.js @@ -0,0 +1,30 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + return Component.extend({ + getCode: function() { + return this.index; + }, + isActive: function(parent) { + return false; + }, + getData: function() { + return {}; + }, + getInfo: function() { + return []; + }, + afterSave: function() { + return true; + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/method-info.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/method-info.js new file mode 100644 index 0000000000000..c653d3f54111d --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/method-info.js @@ -0,0 +1,40 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Checkout/js/view/payment/generic', + '../../model/payment-service' + ], + function (generic, paymentService) { + return generic.extend({ + defaults: { + titleTemplate: 'Magento_Checkout/payment/generic-title', + displayArea: 'paymentMethods', + isEnabled: true + }, + initObservable: function () { + this._super() + .observe('isEnabled'); + return this; + }, + getMethod: function() { + var paymentMethods = _.indexBy(paymentService.getAvailablePaymentMethods(), 'code'); + + return paymentMethods[this.getCode()]; + }, + isAvailable: function() { + return this.getMethod() != null; + }, + getTitle: function() { + return this.isAvailable() ? this.getMethod()['title'] : ''; + }, + isActive: function(parent) { + return this.isAvailable() && parent.isMethodActive(this.getCode()); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment/virtual.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/virtual.js new file mode 100644 index 0000000000000..ec20c4d42179a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment/virtual.js @@ -0,0 +1,50 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true*/ +/*global define*/ +define( + [ + 'ko', + 'Magento_Checkout/js/view/payment/generic', + 'Magento_Checkout/js/model/quote' + ], + function (ko, generic, quote) { + return generic.extend({ + defaults: { + isChecked: false + }, + isAvailable: function() { + return false; + }, + isOn: function() { + return false; + }, + getBalance: function() { + return 0; + }, + initObservable: function () { + this._super() + .observe('isChecked'); + + var self = this; + this.isChecked.subscribe( + function(isChecked) { + if (isChecked) { + quote.setCollectedTotals(self.getCode(), -parseFloat(self.getBalance())); + } else { + quote.setCollectedTotals(self.getCode(), 0); + } + } + ); + this.isChecked(this.isOn()); + + return this; + }, + isActive: function() { + return this.isChecked(); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/progress.js b/app/code/Magento/Checkout/view/frontend/web/js/view/progress.js new file mode 100644 index 0000000000000..1017f9f160eea --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/progress.js @@ -0,0 +1,102 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'ko', + 'uiComponent', + 'Magento_Checkout/js/model/step-navigator', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/shipping-service', + 'Magento_Checkout/js/model/payment-service' + ], + function (ko, Component, navigator, quote, shippingService, paymentService) { + var className = ko.observable(); + return Component.extend({ + defaults: { + template: 'Magento_Checkout/progress' + }, + getClassName: function() + { + className('opc-block-progress'); + if(quote.getBillingAddress()() && (quote.getShippingAddress()()) || quote.isVirtual()) { + className('opc-block-progress active') + } + if (quote.getPaymentMethod()()) { + className('opc-block-progress order-review-step') + } + return className() + }, + + isShowStep: function (stepName) { + switch(stepName){ + case 'shippingAddress': + if (quote.isVirtual()) { + return false + } + return navigator.findStepByName(stepName).isEnabled; + break; + case 'shippingMethod': + if (quote.isVirtual()) { + return false + } + return navigator.findStepByName(stepName).isEnabled; + break; + default: + return navigator.findStepByName(stepName).isEnabled; + } + }, + isStepComplete: function(stepName) { + switch(stepName){ + case 'billingAddress': + return quote.getFormattedBillingAddress()|| false; + break; + case 'shippingAddress': + return quote.getFormattedShippingAddress()||false; + break; + case 'shippingMethod': + return quote.getShippingMethod()||false; + break; + case 'paymentMethod': + return quote.getPaymentMethod()||false; + break; + default: + return false; + } + }, + getBillingAddress: function() { + return quote.getFormattedBillingAddress()(); + }, + getShippingAddress: function() { + return quote.getFormattedShippingAddress(); + }, + getShippingMethod: function() { + return quote.getShippingMethod() + }, + getPaymentMethod: function() { + return quote.getPaymentMethod(); + }, + getPaymentMethodTitle: function() { + var code = this.getPaymentMethod()(); + return paymentService.getTitleByCode(code) + }, + getPaymentMethodInfo: function() { + return paymentService.getSelectedPaymentInfo() + }, + goToStep: function(stepName) { + navigator.goToStep(stepName); + }, + getShippingMethodTitle: function() { + var code = this.getShippingMethod()(); + return shippingService.getTitleByCode(code) + }, + getShippingRates: function() { + var code = this.getShippingMethod()(); + return shippingService.getRateByCode(code) + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review.js new file mode 100644 index 0000000000000..c2c9c58333f9f --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review.js @@ -0,0 +1,62 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true jquery:true*/ +/*global define*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'mage/url', + 'Magento_Checkout/js/model/step-navigator', + 'Magento_Checkout/js/action/place-order', + 'underscore' + ], + function (Component, quote, url, navigator, orderAction, _) { + "use strict"; + var stepName = 'review'; + var itemsBefore = []; + var itemsAfter = []; + var beforePlaceOrder = {}; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review' + }, + stepClassAttributes: function() { + return navigator.getStepClassAttributes(stepName); + }, + stepNumber: navigator.getStepNumber(stepName), + quoteHasPaymentMethod: quote.getPaymentMethod(), + itemsBefore: itemsBefore, + itemsAfter: itemsAfter, + beforePlaceOrder: beforePlaceOrder, + getItems: function() { + return quote.getTotals()().items; + }, + getColHeaders: function() { + return ['name', 'price', 'qty', 'subtotal']; + }, + isVisible: navigator.isStepVisible(stepName), + cartUrl: url.build('checkout/cart/'), + placeOrder: function(callback) { + var component, + isValid = false; + if (_.isEmpty(this.beforePlaceOrder)) { + orderAction(null, callback); + } else { + for (component in this.beforePlaceOrder) { + if (this.beforePlaceOrder.hasOwnProperty(component) && !this.beforePlaceOrder[component].validate()) { + isValid = true; + } + } + if (isValid) { + orderAction(this.beforePlaceOrder[component].getSubmitParams(), callback); + } + } + }, + // get recalculated totals when all data set + getTotals: quote.getTotals() + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js new file mode 100644 index 0000000000000..e160151929985 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js @@ -0,0 +1,35 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote' + ], + function (Component, quote) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/actions', + displayArea: 'actions' + }, + getActiveView: function() { + var view = this.getViewByCode(quote.getPaymentMethod()()); + return view ? view : this.getDefaultView(); + }, + getViewByCode: function(code) { + return _.find(this.elems(), function(elem) { + return elem.index == code && !elem.isDefault; + }); + }, + getDefaultView: function() { + return _.find(this.elems(), function(elem) { + return elem.isDefault; + }); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js new file mode 100644 index 0000000000000..7bc2a6af282f2 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js @@ -0,0 +1,21 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/actions/default' + }, + placeOrder: function(parent) { + return parent.placeOrder.bind(parent); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/column.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/column.js new file mode 100644 index 0000000000000..3c80b6595f9ef --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/column.js @@ -0,0 +1,44 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent', + '../../../model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component, quote, priceUtils) { + "use strict"; + var ownClass = ''; + var columnTitle = ''; + return Component.extend({ + defaults: { + headerClass: null, + ownClass: ownClass, + columnTitle: columnTitle, + template: 'Magento_Checkout/review/item/column' + }, + getClass: function() { + return 'col ' + this.ownClass; + }, + getHeaderClass: function() { + if (this.headerClass) { + return this.headerClass; + } + return 'col ' + this.ownClass; + }, + getColName: function() { + return this.columnTitle; + }, + getValue: function(quoteItem) { + return quoteItem.name; + }, + getFormattedPrice: function (price) { + return priceUtils.formatPrice(price, quote.getPriceFormat()); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/name.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/name.js new file mode 100644 index 0000000000000..7e04d856621c6 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/name.js @@ -0,0 +1,24 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + '../column' + ], + function (column) { + "use strict"; + return column.extend({ + defaults: { + ownClass: 'name', + columnTitle: 'Product Name', + template: 'Magento_Checkout/review/item/columns/name' + }, + getValue: function(quoteItem) { + return quoteItem.name; + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/price.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/price.js new file mode 100644 index 0000000000000..0066f8cce1c0c --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/price.js @@ -0,0 +1,24 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + '../column' + ], + function (column) { + "use strict"; + return column.extend({ + defaults: { + ownClass: 'price', + columnTitle: 'Price', + template: 'Magento_Checkout/review/item/columns/price' + }, + getValue: function(quoteItem) { + return this.getFormattedPrice(quoteItem.price); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/qty.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/qty.js new file mode 100644 index 0000000000000..c3352464d34e2 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/qty.js @@ -0,0 +1,24 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + '../column' + ], + function (column) { + "use strict"; + return column.extend({ + defaults: { + ownClass: 'qty', + columnTitle: 'Qty', + template: 'Magento_Checkout/review/item/columns/qty' + }, + getValue: function(quoteItem) { + return quoteItem.qty; + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/subtotal.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/subtotal.js new file mode 100644 index 0000000000000..f08fb4830a0db --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/item/columns/subtotal.js @@ -0,0 +1,24 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + '../column' + ], + function (column) { + "use strict"; + return column.extend({ + defaults: { + ownClass: 'subtotal', + columnTitle: 'Subtotal', + template: 'Magento_Checkout/review/item/columns/price' + }, + getValue: function(quoteItem) { + return this.getFormattedPrice(quoteItem.row_total); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address.js new file mode 100644 index 0000000000000..17b75243a4ee6 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address.js @@ -0,0 +1,149 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + "jquery", + 'Magento_Ui/js/form/form', + 'ko', + 'Magento_Checkout/js/action/select-shipping-address', + 'Magento_Customer/js/model/customer', + '../model/quote', + 'Magento_Checkout/js/model/step-navigator', + '../model/addresslist', + 'underscore' + ], + function($, Component, ko, selectShippingAddress, customer, quote, navigator, addressList, _) { + 'use strict'; + var stepName = 'shippingAddress'; + var newAddressSelected = ko.observable(false); + return Component.extend({ + defaults: { + template: 'Magento_Checkout/shipping-address', + visible: true, + formVisible: customer.getShippingAddressList().length === 0 + }, + stepClassAttributes: function() { + return navigator.getStepClassAttributes(stepName); + }, + stepNumber: navigator.getStepNumber(stepName), + addresses: function() { + var newAddress = { + getAddressInline: function() { + return $.mage.__('New address'); + }, + customerAddressId: null + }, + addresses = addressList.getAddresses(); + addresses.push(newAddress); + return addresses; + }, + selectedAddressId: ko.observable( + addressList.getAddresses().length ? addressList.getAddresses()[0].customerAddressId : null + ), + sameAsBilling: ko.observable(null), + quoteHasBillingAddress: quote.getBillingAddress(), + isVisible: navigator.isStepVisible(stepName), + initObservable: function () { + this._super() + .observe('visible'); + return this; + }, + isActive: function() { + if (quote.isVirtual()) { + navigator.setStepEnabled(stepName, false); + } + return !quote.isVirtual(); + }, + selectShippingAddress: function() { + var additionalData = {}; + var billingAddress = quote.getBillingAddress()(); + if (!billingAddress.customerAddressId || !this.visible()) { + /** + * All the the input fields that are not a part of the address but need to be submitted + * in the same request must have data-scope attribute set + */ + var additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray(); + additionalFields.forEach(function (field) { + additionalData[field.name] = field.value; + }); + } + if (!newAddressSelected()) { + selectShippingAddress( + addressList.getAddressById(this.selectedAddressId()), + this.sameAsBilling(), + additionalData + ); + } else { + if (this.visible()) { + this.validate(); + } + if (!this.source.get('params.invalid')) { + var addressData = this.source.get('shippingAddress'); + selectShippingAddress(addressData, this.sameAsBilling(), additionalData); + } + } + }, + sameAsBillingClick: function() { + addressList.isBillingSameAsShipping = !addressList.isBillingSameAsShipping; + if (this.sameAsBilling()) { + var billingAddress = quote.getBillingAddress()(); + if (billingAddress.customerAddressId) { + this.selectedAddressId(billingAddress.customerAddressId); + newAddressSelected(false); + } else { + // copy billing address data to shipping address form if customer uses new address for billing + var shippingAddress = this.source.get('shippingAddress'); + for (var property in billingAddress) { + if (billingAddress.hasOwnProperty(property) && shippingAddress.hasOwnProperty(property)) { + if (typeof billingAddress[property] === 'string') { + this.source.set('shippingAddress.' + property, billingAddress[property]); + } else { + this.source.set('shippingAddress.' + property, _.clone(billingAddress[property])); + } + } + } + this.selectedAddressId(null); + newAddressSelected(true); + } + } + return true; + }, + onAddressChange: function() { + var billingAddress = quote.getBillingAddress(); + if (this.selectedAddressId() !== billingAddress().customerAddressId) { + this.sameAsBilling(false); + } + if (this.selectedAddressId() === null) { + newAddressSelected(true); + } else { + newAddressSelected(false); + } + }, + // Checkout step navigation + backToBilling: function() { + navigator.setCurrent(stepName).goBack(); + }, + navigateToCurrentStep: function() { + if (!navigator.isStepVisible(stepName)()) { + navigator.goToStep(stepName); + } + }, + isNewAddressSelected: function() { + if (!this.customerAddressCount) { + newAddressSelected(true); + return true; + } + return newAddressSelected(); + }, + validate: function() { + this.source.set('params.invalid', false); + this.source.trigger('shippingAddress.data.validate'); + }, + isCustomerLoggedIn: customer.isLoggedIn(), + customerAddressCount: window.checkoutConfig.customerAddressCount + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-method.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-method.js new file mode 100644 index 0000000000000..29f4ebbca2a04 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-method.js @@ -0,0 +1,87 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'jquery', + 'underscore', + 'uiComponent', + '../model/quote', + '../model/shipping-service', + '../action/select-shipping-method', + 'Magento_Catalog/js/price-utils', + 'Magento_Checkout/js/model/step-navigator' + ], + function ($, _, Component, quote, shippingService, selectShippingMethod, priceUtils, navigator) { + var stepName = 'shippingMethod'; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/shipping-method' + }, + stepClassAttributes: function() { + return navigator.getStepClassAttributes(stepName); + }, + stepNumber: navigator.getStepNumber(stepName), + rates: shippingService.getSippingRates(), + // Checkout step navigation + isVisible: navigator.isStepVisible(stepName), + quoteHasShippingAddress: function() { + return quote.isVirtual() || quote.getShippingAddress(); + }, + + selectedMethod: quote.getSelectedShippingMethod(), + verifySelectedMethodCode: function (data) { + if (this.selectedMethod() == data) { + return data; + } + return false; + }, + + setShippingMethod: function (form) { + var item, + customOptions = {}; + for (item in this.elems()) { + if ('submit' in this.elems()[item]) { + customOptions = _.extend(customOptions, this.elems()[item].submit()); + } + } + form = $(form); + var code = form.find("input[name='shipping_method']:checked").val(); + selectShippingMethod(code, customOptions, this.getAfterSelectCallbacks()); + }, + getAfterSelectCallbacks: function() { + var callbacks = []; + _.each(this.getAdditionalMethods(), function(view) { + if (typeof view.afterSelect === 'function') { + callbacks.push(view.afterSelect); + } + }); + return callbacks; + }, + getAdditionalMethods: function() { + var methods = []; + _.each(this.getRegion('afterSelect')(), function(elem) { + methods = _.union(methods, elem.elems()); + }); + return methods; + }, + isActive: function() { + if (quote.isVirtual()) { + navigator.setStepEnabled(stepName, false); + } + return !quote.isVirtual(); + }, + backToShippingAddress: function () { + navigator.setCurrent(stepName).goBack(); + }, + navigateToCurrentStep: function() { + if (!navigator.isStepVisible(stepName)()) { + navigator.goToStep(stepName); + } + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/subtotal.js b/app/code/Magento/Checkout/view/frontend/web/js/view/subtotal.js new file mode 100644 index 0000000000000..227129562f0e5 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/subtotal.js @@ -0,0 +1,17 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + ['uiComponent'], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/iterator', + displayArea: 'totals' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/totals.js b/app/code/Magento/Checkout/view/frontend/web/js/view/totals.js new file mode 100644 index 0000000000000..caca53e801396 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/totals.js @@ -0,0 +1,20 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Checkout/review/totals', + displayArea: 'totals' + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/template/authentication.html b/app/code/Magento/Checkout/view/frontend/web/template/authentication.html new file mode 100644 index 0000000000000..c54065bab2510 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/authentication.html @@ -0,0 +1,95 @@ + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html b/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html new file mode 100644 index 0000000000000..baed4c7b53edb --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html @@ -0,0 +1,57 @@ + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/minicart/content.html b/app/code/Magento/Checkout/view/frontend/web/template/minicart/content.html new file mode 100644 index 0000000000000..82475d90a2523 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/minicart/content.html @@ -0,0 +1,100 @@ + +
    + + + + + + +
    + +
    + + + +
    + + + + + + + +
    + + + + + + + + + + + + +
    +
    + +
    +
    +
    + + + + + +
    +
      + + + +
    +
    + + + + + + + +

    + + + + +
    +
    + + + +
    +
    + + +
    + + + +
    +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html b/app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html new file mode 100644 index 0000000000000..a846c85deb4e7 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html @@ -0,0 +1,111 @@ + +
  • +
    + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    + + +
    + +
    + +
    +
    + + + + + + +
    + +
    +
    +
    + + +
    + + +
    + + +
    + + + + + + + +
    + + + +
    +
    + +
    + +
    + + + +
    + +
    + + + +
    +
    +
    +
    +
  • diff --git a/app/code/Magento/Checkout/view/frontend/web/template/minicart/item/price.html b/app/code/Magento/Checkout/view/frontend/web/template/minicart/item/price.html new file mode 100644 index 0000000000000..04f634288554c --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/minicart/item/price.html @@ -0,0 +1,10 @@ + +
    + + +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/minicart/subtotal.html b/app/code/Magento/Checkout/view/frontend/web/template/minicart/subtotal.html new file mode 100644 index 0000000000000..7f075dc088224 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/minicart/subtotal.html @@ -0,0 +1,15 @@ + +
    + + + + + + + +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/minicart/subtotal/totals.html b/app/code/Magento/Checkout/view/frontend/web/template/minicart/subtotal/totals.html new file mode 100644 index 0000000000000..3fdc88f0593ef --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/minicart/subtotal/totals.html @@ -0,0 +1,9 @@ + +
    + +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/onepage.html b/app/code/Magento/Checkout/view/frontend/web/template/onepage.html new file mode 100644 index 0000000000000..b05de11162116 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/onepage.html @@ -0,0 +1,22 @@ + + + + + +
    +
      + + + +
    +
    +
    + + + +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/payment.html b/app/code/Magento/Checkout/view/frontend/web/template/payment.html new file mode 100644 index 0000000000000..af29231586341 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/payment.html @@ -0,0 +1,62 @@ + + diff --git a/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php b/app/code/Magento/Checkout/view/frontend/web/template/payment/generic-title.html similarity index 58% rename from dev/tools/Magento/Tools/Dependency/generate/bootstrap.php rename to app/code/Magento/Checkout/view/frontend/web/template/payment/generic-title.html index ead28a5725181..b88c8342c009d 100644 --- a/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php +++ b/app/code/Magento/Checkout/view/frontend/web/template/payment/generic-title.html @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/template/progress.html b/app/code/Magento/Checkout/view/frontend/web/template/progress.html new file mode 100644 index 0000000000000..af506619bda95 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/progress.html @@ -0,0 +1,146 @@ + +
    +
    + +
    +
    +
    + + +
    + + + +
    +
    +
    +
    + + +
    + + + + + +
    + + + +
    +
    +
    +
    + + +
    + +
    + + + + + +
    + + + +
    +
    + + + + + + + + + + + + + + + +
    + + +
    + +
    + + + + + +
    + + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    +
    + + +
    + +
    + + +
    +
    +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review.html b/app/code/Magento/Checkout/view/frontend/web/template/review.html new file mode 100644 index 0000000000000..2258e50fd37a2 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review.html @@ -0,0 +1,63 @@ + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/actions.html b/app/code/Magento/Checkout/view/frontend/web/template/review/actions.html new file mode 100644 index 0000000000000..d2734bb266a90 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/actions.html @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/actions/default.html b/app/code/Magento/Checkout/view/frontend/web/template/review/actions/default.html new file mode 100644 index 0000000000000..b0d2a0282444a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/actions/default.html @@ -0,0 +1,21 @@ + +
    +
    + +
    +
    + + + + +
    +
    diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/discount.html b/app/code/Magento/Checkout/view/frontend/web/template/review/discount.html new file mode 100644 index 0000000000000..3123b421025ed --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/discount.html @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/item/column.html b/app/code/Magento/Checkout/view/frontend/web/template/review/item/column.html new file mode 100644 index 0000000000000..c32d4991c36b0 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/item/column.html @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/name.html b/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/name.html new file mode 100644 index 0000000000000..54f6daf92fd94 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/name.html @@ -0,0 +1,25 @@ + + + + + + + +
    + +
    + +
    + + +
    + + +
    + + \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/price.html b/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/price.html new file mode 100644 index 0000000000000..25e9e79a35d89 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/price.html @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/qty.html b/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/qty.html new file mode 100644 index 0000000000000..cc5e4d63f7890 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/item/columns/qty.html @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/iterator.html b/app/code/Magento/Checkout/view/frontend/web/template/review/iterator.html new file mode 100644 index 0000000000000..3e2032f2c631a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/iterator.html @@ -0,0 +1,10 @@ + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/review/totals.html b/app/code/Magento/Checkout/view/frontend/web/template/review/totals.html new file mode 100644 index 0000000000000..3e2032f2c631a --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/review/totals.html @@ -0,0 +1,10 @@ + + + + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address.html new file mode 100644 index 0000000000000..acd04e1fca45c --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address.html @@ -0,0 +1,62 @@ + +
  • +
    + +

    +
    +
    +
    + + + + +
    + +
    + +
    +
    + +
    + + + +
    + +
    + + +
    +
    +
    + +
    +
    +
    +
    +
    +
  • diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-method.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-method.html new file mode 100644 index 0000000000000..3bb9342bc5722 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-method.html @@ -0,0 +1,94 @@ + + diff --git a/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php b/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php index 3d528c2a3969d..670b7683b0c03 100644 --- a/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php +++ b/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php @@ -5,12 +5,55 @@ */ namespace Magento\CheckoutAgreements\Api; +/** + * Interface CheckoutAgreementsRepositoryInterface + * @api + */ interface CheckoutAgreementsRepositoryInterface { + /** + * Return data object for specified checkout agreement ID and store. + * + * @param int $id + * @param int $storeId + * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface + */ + public function get($id, $storeId = null); + /** * Lists active checkout agreements. * * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface[] */ public function getList(); + + /** + * Create/Update new checkout agreements with data object values + * + * @param \Magento\CheckoutAgreements\Api\Data\AgreementInterface $data + * @param int $storeId + * @return \Magento\CheckoutAgreements\Api\Data\AgreementInterface + * @throws \Magento\Framework\Exception\CouldNotSaveException If there is a problem with the input + * @throws \Magento\Framework\Exception\NoSuchEntityException If a ID is sent but the entity does not exist + */ + public function save(\Magento\CheckoutAgreements\Api\Data\AgreementInterface $data, $storeId = null); + + /** + * Delete checkout agreement + * + * @param \Magento\CheckoutAgreements\Api\Data\AgreementInterface $data + * @return bool + * @throws \Magento\Framework\Exception\CouldNotDeleteException If there is a problem with the input + */ + public function delete(\Magento\CheckoutAgreements\Api\Data\AgreementInterface $data); + + /** + * Delete checkout agreement by id + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException If a ID is sent but the entity does not exist + * @throws \Magento\Framework\Exception\CouldNotDeleteException If there is a problem with the input + */ + public function deleteById($id); } diff --git a/app/code/Magento/CheckoutAgreements/Block/Checkout/LayoutProcessor.php b/app/code/Magento/CheckoutAgreements/Block/Checkout/LayoutProcessor.php new file mode 100644 index 0000000000000..b13012ae47336 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/Block/Checkout/LayoutProcessor.php @@ -0,0 +1,67 @@ +checkoutAgreementsRepository = $checkoutAgreementsRepository; + $this->escaper = $escaper; + } + + /** + * {@inheritdoc} + */ + public function process($jsLayout) + { + $form = []; + $agreementsList = $this->checkoutAgreementsRepository->getList(); + foreach ($agreementsList as $agreement) { + $name = $agreement->getAgreementId(); + $form[$name] = [ + 'component' => 'Magento_Ui/js/form/element/abstract', + 'config' => [ + 'customScope' => 'checkoutAgreements', + 'customEntry' => 'checkoutAgreements.' . $name, + 'template' => 'Magento_CheckoutAgreements/form/element/agreement' + ], + 'agreementConfiguration' => [ + 'content' => $agreement->getIsHtml() + ? $agreement->getContent() + : nl2br($this->escaper->escapeHtml($agreement->getContent())), + 'height' => $agreement->getContentHeight(), + 'checkboxText' => $agreement->getCheckboxText() + ], + 'dataScope' => $name, + 'provider' => 'checkoutProvider', + 'validation' => ['checked' => true], + 'customEntry' => null, + 'visible' => true + ]; + } + $result['components']['checkout']['children']['steps']['children']['review']['children'] + ['beforePlaceOrder']['children']['checkoutAgreements']['children'] = $form; + + return array_merge_recursive($jsLayout, $result); + } +} diff --git a/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php b/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php new file mode 100644 index 0000000000000..8a14acbb404b0 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php @@ -0,0 +1,41 @@ +scopeConfiguration = $scopeConfiguration; + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + if ($this->scopeConfiguration->isSetFlag(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE)) { + return ['checkoutAgreementsEnabled' => true]; + } else { + return []; + } + } +} diff --git a/app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php b/app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php index 892e1599241f3..eae3f09c667a9 100644 --- a/app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php +++ b/app/code/Magento/CheckoutAgreements/Model/CheckoutAgreementsRepository.php @@ -14,9 +14,14 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\ScopeInterface; use Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface; +use Magento\CheckoutAgreements\Model\Resource\Agreement as AgreementResource; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Store\Model\Store; /** * Checkout agreement repository. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CheckoutAgreementsRepository implements CheckoutAgreementsRepositoryInterface { @@ -41,21 +46,37 @@ class CheckoutAgreementsRepository implements CheckoutAgreementsRepositoryInterf */ private $scopeConfig; + /** + * @var AgreementResource + */ + private $resourceModel; + + /** + * @var AgreementFactory + */ + private $agreementFactory; + /** * Constructs a checkout agreement data object. * * @param AgreementCollectionFactory $collectionFactory Collection factory. * @param \Magento\Store\Model\StoreManagerInterface $storeManager Store manager. * @param ScopeConfigInterface $scopeConfig Scope config. + * @param AgreementResource $agreementResource + * @param AgreementFactory $agreementFactory */ public function __construct( AgreementCollectionFactory $collectionFactory, StoreManagerInterface $storeManager, - ScopeConfigInterface $scopeConfig + ScopeConfigInterface $scopeConfig, + AgreementResource $agreementResource, + AgreementFactory $agreementFactory ) { $this->collectionFactory = $collectionFactory; $this->storeManager = $storeManager; $this->scopeConfig = $scopeConfig; + $this->resourceModel = $agreementResource; + $this->agreementFactory = $agreementFactory; } /** @@ -81,4 +102,67 @@ public function getList() return $agreementDataObjects; } + + /** + * {@inheritdoc} + */ + public function save(\Magento\CheckoutAgreements\Api\Data\AgreementInterface $data, $storeId = null) + { + $id = $data->getAgreementId(); + + if ($id) { + $data = $this->get($id, $storeId)->addData($data->getData()); + } + if ($storeId === null) { + $storeId = $this->storeManager->getStore()->getId(); + } + $data->setStores($storeId); + try { + $this->resourceModel->save($data); + } catch (\Exception $e) { + throw new \Magento\Framework\Exception\CouldNotSaveException( + __('Unable to save checkout agreement %1', $data->getAgreementId()) + ); + } + return $data; + } + + /** + * {@inheritdoc} + */ + public function delete(\Magento\CheckoutAgreements\Api\Data\AgreementInterface $data) + { + try { + $this->resourceModel->delete($data); + } catch (\Exception $e) { + throw new \Magento\Framework\Exception\CouldNotDeleteException( + __('Unable to remove checkout agreement %1', $data->getAgreementId()) + ); + } + return true; + } + + /** + * {@inheritdoc} + */ + public function deleteById($id) + { + $model = $this->get($id); + $this->delete($model); + return true; + } + + /** + * {@inheritdoc} + */ + public function get($id, $storeId = null) + { + /** @var AgreementFactory $agreement */ + $agreement = $this->agreementFactory->create(); + $this->resourceModel->load($agreement, $id); + if (!$agreement->getId()) { + throw new NoSuchEntityException(__('Checkout agreement with specified ID "%1" not found.', $id)); + } + return $agreement; + } } diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php index 1751b99c5c632..9d27e3e471e23 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php @@ -36,6 +36,26 @@ class CheckoutAgreementsRepositoryTest extends \PHPUnit_Framework_TestCase */ private $objectManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $resourceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $agrFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $agreementMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $storeMock; + protected function setUp() { $this->objectManager = new ObjectManager($this); @@ -49,10 +69,24 @@ protected function setUp() ); $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->resourceMock = $this->getMock('Magento\CheckoutAgreements\Model\Resource\Agreement', [], [], '', false); + $this->agrFactoryMock = $this->getMock( + 'Magento\CheckoutAgreements\Model\AgreementFactory', + ['create'], + [], + '', + false + ); + $methods = ['addData', 'getData', 'setStores', 'getAgreementId', 'getId']; + $this->agreementMock = + $this->getMock('\Magento\CheckoutAgreements\Model\Agreement', $methods, [], '', false); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $this->model = new \Magento\CheckoutAgreements\Model\CheckoutAgreementsRepository( $this->factoryMock, $this->storeManagerMock, - $this->scopeConfigMock + $this->scopeConfigMock, + $this->resourceMock, + $this->agrFactoryMock ); } @@ -73,14 +107,6 @@ public function testGetListReturnsTheListOfActiveCheckoutAgreements() ->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null) ->will($this->returnValue(true)); - $agreementDataObject = $this->getMock( - 'Magento\CheckoutAgreements\Model\Agreement', - [], - [], - '', - false - ); - $storeId = 1; $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId)); @@ -88,12 +114,92 @@ public function testGetListReturnsTheListOfActiveCheckoutAgreements() $collectionMock = $this->objectManager->getCollectionMock( 'Magento\CheckoutAgreements\Model\Resource\Agreement\Collection', - [$agreementDataObject] + [$this->agreementMock] ); $this->factoryMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock)); $collectionMock->expects($this->once())->method('addStoreFilter')->with($storeId); $collectionMock->expects($this->once())->method('addFieldToFilter')->with('is_active', 1); - $this->assertEquals([$agreementDataObject], $this->model->getList()); + $this->assertEquals([$this->agreementMock], $this->model->getList()); + } + + public function testSave() + { + $this->agreementMock->expects($this->once())->method('getAgreementId')->willReturn(null); + $this->agrFactoryMock->expects($this->never())->method('create'); + $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn('storeId'); + $this->agreementMock->expects($this->once())->method('setStores'); + $this->resourceMock->expects($this->once())->method('save')->with($this->agreementMock); + $this->model->save($this->agreementMock); + } + + public function testUpdate() + { + $agreementId = 1; + $this->agreementMock->expects($this->once())->method('getAgreementId')->willReturn($agreementId); + $this->agrFactoryMock->expects($this->once())->method('create')->willReturn($this->agreementMock); + $this->resourceMock + ->expects($this->once()) + ->method('load') + ->with($this->agreementMock, $agreementId); + $this->storeManagerMock->expects($this->never())->method('getStore'); + $this->agreementMock->expects($this->once())->method('setStores'); + $this->agreementMock->expects($this->once())->method('getId')->willReturn($agreementId); + $this->agreementMock->expects($this->any())->method('getData')->willReturn(['data']); + $this->agreementMock + ->expects($this->once()) + ->method('addData')->with(['data']) + ->willReturn($this->agreementMock); + $this->resourceMock->expects($this->once())->method('save')->with($this->agreementMock); + $this->assertEquals($this->agreementMock, $this->model->save($this->agreementMock, 1)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testSaveWithException() + { + $this->agreementMock->expects($this->exactly(2))->method('getAgreementId')->willReturn(null); + $this->agrFactoryMock->expects($this->never())->method('create'); + $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn('storeId'); + $this->agreementMock->expects($this->once())->method('setStores'); + $this->resourceMock + ->expects($this->once()) + ->method('save') + ->with($this->agreementMock)->willThrowException(new \Exception()); + $this->model->save($this->agreementMock); + } + + public function testDeleteById() + { + $agreementId = 1; + $this->agrFactoryMock->expects($this->once())->method('create')->willReturn($this->agreementMock); + $this->resourceMock + ->expects($this->once()) + ->method('load') + ->with($this->agreementMock, $agreementId) + ->willReturn($this->agreementMock); + $this->agreementMock->expects($this->once())->method('getId')->willReturn($agreementId); + $this->resourceMock->expects($this->once())->method('delete'); + $this->assertTrue($this->model->deleteById(1)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteByIdWithException() + { + $agreementId = 1; + $this->agrFactoryMock->expects($this->once())->method('create')->willReturn($this->agreementMock); + $this->resourceMock + ->expects($this->once()) + ->method('load') + ->with($this->agreementMock, $agreementId) + ->willReturn($this->agreementMock); + $this->agreementMock->expects($this->once())->method('getId')->willReturn($agreementId); + $this->resourceMock->expects($this->once())->method('delete')->willThrowException(new \Exception()); + $this->assertTrue($this->model->deleteById(1)); } } diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index 32e5394223e2c..23d8730eca731 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -3,14 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CheckoutAgreements/etc/frontend/di.xml b/app/code/Magento/CheckoutAgreements/etc/frontend/di.xml new file mode 100644 index 0000000000000..f3e65ef5a342a --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/etc/frontend/di.xml @@ -0,0 +1,23 @@ + + + + + + + Magento\CheckoutAgreements\Block\Checkout\LayoutProcessor + + + + + + + Magento\CheckoutAgreements\Model\AgreementsConfigProvider + + + + diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/CheckoutAgreements/view/frontend/layout/checkout_onepage_index.xml new file mode 100644 index 0000000000000..b80bfc39aef43 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/layout/checkout_onepage_index.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + Magento_CheckoutAgreements/js/view/checkoutAgreements + checkoutAgreements + checkoutAgreements + checkoutProvider + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/layout/checkout_onepage_review.xml b/app/code/Magento/CheckoutAgreements/view/frontend/layout/checkout_onepage_review.xml deleted file mode 100644 index 7d3d015fd01ec..0000000000000 --- a/app/code/Magento/CheckoutAgreements/view/frontend/layout/checkout_onepage_review.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkoutAgreements.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkoutAgreements.js new file mode 100644 index 0000000000000..094136c756467 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkoutAgreements.js @@ -0,0 +1,32 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + ['Magento_Ui/js/form/form', 'Magento_Checkout/js/view/review', 'underscore'], + function (Component, review, _) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_CheckoutAgreements/checkout/review/agreements' + }, + initialize: function() { + this._super(); + if (window.checkoutConfig.checkoutAgreementsEnabled) { + review.prototype.beforePlaceOrder.checkoutAgreements = this; + } + }, + validate: function() { + this.source.set('params.invalid', false); + this.source.trigger('checkoutAgreements.data.validate'); + return this.source.get('params.invalid'); + }, + getSubmitParams: function() { + return { + agreements: _.keys(this.source.get('checkoutAgreements')) + }; + } + }); + } +); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/review/agreements.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/review/agreements.html new file mode 100644 index 0000000000000..7de21298dcc66 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/review/agreements.html @@ -0,0 +1,11 @@ + +
      + + + +
    diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/form/element/agreement.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/form/element/agreement.html new file mode 100644 index 0000000000000..0f029cfe2f3b4 --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/form/element/agreement.html @@ -0,0 +1,18 @@ + +
  • +
    +
    + + +
    + +
    + +
  • diff --git a/app/code/Magento/Cms/Block/Block.php b/app/code/Magento/Cms/Block/Block.php index 707dbbe40d754..de7dbc8a54a73 100644 --- a/app/code/Magento/Cms/Block/Block.php +++ b/app/code/Magento/Cms/Block/Block.php @@ -11,7 +11,7 @@ /** * Cms block content block */ -class Block extends \Magento\Framework\View\Element\AbstractBlock implements \Magento\Framework\View\Block\IdentityInterface +class Block extends \Magento\Framework\View\Element\AbstractBlock implements \Magento\Framework\Object\IdentityInterface { /** * @var \Magento\Cms\Model\Template\FilterProvider diff --git a/app/code/Magento/Cms/Block/Page.php b/app/code/Magento/Cms/Block/Page.php index 9b28ef8015ea1..211cac3afecae 100644 --- a/app/code/Magento/Cms/Block/Page.php +++ b/app/code/Magento/Cms/Block/Page.php @@ -11,7 +11,7 @@ * Cms page content block */ class Page extends \Magento\Framework\View\Element\AbstractBlock implements - \Magento\Framework\View\Block\IdentityInterface + \Magento\Framework\Object\IdentityInterface { /** * @var \Magento\Cms\Model\Template\FilterProvider @@ -154,7 +154,6 @@ protected function _addBreadcrumbs(\Magento\Cms\Model\Page $page) protected function _toHtml() { $html = $this->_filterProvider->getPageFilter()->filter($this->getPage()->getContent()); - $html = $this->getLayout()->renderElement('messages') . $html; return $html; } diff --git a/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassStatus.php b/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassStatus.php new file mode 100755 index 0000000000000..9a13e9c0b91ca --- /dev/null +++ b/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassStatus.php @@ -0,0 +1,142 @@ +getRequest()->getParam('selected'); + $excluded = $this->getRequest()->getParam('excluded'); + + if (isset($excluded)) { + if (!empty($excluded)) { + $this->excludedSetStatus($excluded); + } else { + $this->setStatusAll(); + } + } elseif (!empty($selected)) { + $this->selectedSetStatus($selected); + } else { + $this->messageManager->addError(__('Please select item(s).')); + } + + return $this->getDefaultResult(); + } + + /** + * {@inheritdoc} + * + * @return \Magento\Backend\Model\View\Result\Redirect + */ + public function getDefaultResult() + { + $resultRedirect = $this->resultRedirectFactory->create(); + return $resultRedirect->setPath(static::REDIRECT_URL); + } + + /** + * Set status to all + * + * @return void + * @throws \Exception + */ + protected function setStatusAll() + { + /** @var AbstractCollection $collection */ + $collection = $this->_objectManager->get($this->collection); + $this->setStatus($collection); + } + + /** + * Set status to all but the not selected + * + * @param array $excluded + * @return void + * @throws \Exception + */ + protected function excludedSetStatus(array $excluded) + { + /** @var AbstractCollection $collection */ + $collection = $this->_objectManager->get($this->collection); + $collection->addFieldToFilter(static::ID_FIELD, ['nin' => $excluded]); + $this->setStatus($collection); + } + + /** + * Set status to selected items + * + * @param array $selected + * @return void + * @throws \Exception + */ + protected function selectedSetStatus(array $selected) + { + /** @var AbstractCollection $collection */ + $collection = $this->_objectManager->get($this->collection); + $collection->addFieldToFilter(static::ID_FIELD, ['in' => $selected]); + $this->setStatus($collection); + } + + /** + * Set status to collection items + * + * @param AbstractCollection $collection + * @return void + */ + protected function setStatus(AbstractCollection $collection) + { + foreach ($collection->getAllIds() as $id) { + /** @var \Magento\Framework\Model\AbstractModel $model */ + $model = $this->_objectManager->get($this->model); + $model->load($id); + $model->setIsActive($this->status); + $model->save(); + } + } +} diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php new file mode 100644 index 0000000000000..ef56988a592c7 --- /dev/null +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php @@ -0,0 +1,40 @@ +setContentHeading($contentHeading); } - /* @TODO: Move catalog and checkout storage types to appropriate modules */ - $messageBlock = $resultPage->getLayout()->getMessagesBlock(); - $messageBlock->addStorageType($this->messageManager->getDefaultGroup()); - $messageBlock->addMessages($this->messageManager->getMessages(true)); - return $resultPage; } diff --git a/app/code/Magento/Cms/Model/Block/DataProvider.php b/app/code/Magento/Cms/Model/Block/DataProvider.php index 71994a060b081..61c11908668df 100644 --- a/app/code/Magento/Cms/Model/Block/DataProvider.php +++ b/app/code/Magento/Cms/Model/Block/DataProvider.php @@ -14,6 +14,13 @@ */ class DataProvider implements DataProviderInterface { + /** + * Data Provider name + * + * @var string + */ + protected $name; + /** * @var string */ @@ -42,6 +49,7 @@ class DataProvider implements DataProviderInterface protected $data = []; /** + * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $collectionFactory @@ -49,12 +57,14 @@ class DataProvider implements DataProviderInterface * @param array $data */ public function __construct( + $name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, array $meta = [], array $data = [] ) { + $this->name = $name; $this->primaryFieldName = $primaryFieldName; $this->requestFieldName = $requestFieldName; $this->collection = $collectionFactory->create(); @@ -63,53 +73,73 @@ public function __construct( } /** - * @return array + * Get Data Provider name + * + * @return string */ - public function getMeta() + public function getName() { - return $this->meta; + return $this->name; } /** - * @param string $fieldSetName - * @param string $fieldName - * @return array + * Get primary field name + * + * @return string */ - public function getFieldMetaInfo($fieldSetName, $fieldName) + public function getPrimaryFieldName() { - return isset($this->meta[$fieldSetName]['fields'][$fieldName]) - ? $this->meta[$fieldSetName]['fields'][$fieldName] - : []; + return $this->primaryFieldName; } /** - * Get data + * Get field name in request * + * @return string + */ + public function getRequestFieldName() + { + return $this->requestFieldName; + } + + /** * @return array */ - public function getData() + public function getMeta() { - return $this->collection->toArray(); + return $this->meta; } /** - * Get field name in request + * Get field Set meta info * - * @return string + * @param string $fieldSetName + * @return array */ - public function getRequestFieldName() + public function getFieldSetMetaInfo($fieldSetName) { - return $this->requestFieldName; + return isset($this->meta[$fieldSetName]) ? $this->meta[$fieldSetName] : []; } /** - * Get primary field name - * - * @return string + * @param string $fieldSetName + * @return array */ - public function getPrimaryFieldName() + public function getFieldsMetaInfo($fieldSetName) { - return $this->primaryFieldName; + return isset($this->meta[$fieldSetName]['fields']) ? $this->meta[$fieldSetName]['fields'] : []; + } + + /** + * @param string $fieldSetName + * @param string $fieldName + * @return array + */ + public function getFieldMetaInfo($fieldSetName, $fieldName) + { + return isset($this->meta[$fieldSetName]['fields'][$fieldName]) + ? $this->meta[$fieldSetName]['fields'][$fieldName] + : []; } /** @@ -179,6 +209,16 @@ public function removeAllFields() $this->collection->removeAllFieldsFromSelect(); } + /** + * Get data + * + * @return array + */ + public function getData() + { + return $this->collection->toArray(); + } + /** * Retrieve count of loaded items * @@ -209,13 +249,4 @@ public function setConfigData($config) { $this->data['config'] = $config; } - - /** - * @param string $fieldSetName - * @return array - */ - public function getFieldsMetaInfo($fieldSetName) - { - return isset($this->meta[$fieldSetName]['fields']) ? $this->meta[$fieldSetName]['fields'] : []; - } } diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index 4797ffbe28c84..cc3bbf6750caa 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -15,11 +15,22 @@ class DataProvider implements DataProviderInterface { /** + * Data Provider name + * + * @var string + */ + protected $name; + + /** + * Data Provider Primary Identifier name + * * @var string */ protected $primaryFieldName; /** + * Data Provider Request Parameter Identifier name + * * @var string */ protected $requestFieldName; @@ -47,6 +58,7 @@ class DataProvider implements DataProviderInterface protected $data = []; /** + * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $collectionFactory @@ -54,12 +66,14 @@ class DataProvider implements DataProviderInterface * @param array $data */ public function __construct( + $name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, array $meta = [], array $data = [] ) { + $this->name = $name; $this->primaryFieldName = $primaryFieldName; $this->requestFieldName = $requestFieldName; @@ -70,53 +84,73 @@ public function __construct( } /** - * @return array + * Get Data Provider name + * + * @return string */ - public function getMeta() + public function getName() { - return $this->meta; + return $this->name; } /** - * Get data + * Get primary field name * + * @return string + */ + public function getPrimaryFieldName() + { + return $this->primaryFieldName; + } + + /** + * Get field name in request + * + * @return string + */ + public function getRequestFieldName() + { + return $this->requestFieldName; + } + + /** * @return array */ - public function getData() + public function getMeta() { - return $this->collection->toArray(); + return $this->meta; } /** + * Get field Set meta info + * * @param string $fieldSetName - * @param string $fieldName * @return array */ - public function getFieldMetaInfo($fieldSetName, $fieldName) + public function getFieldSetMetaInfo($fieldSetName) { - return isset($this->meta[$fieldSetName]['fields'][$fieldName]) - ? $this->meta[$fieldSetName]['fields'][$fieldName] - : []; + return isset($this->meta[$fieldSetName]) ? $this->meta[$fieldSetName] : []; } /** - * Get field name in request - * - * @return string + * @param string $fieldSetName + * @return array */ - public function getRequestFieldName() + public function getFieldsMetaInfo($fieldSetName) { - return $this->requestFieldName; + return isset($this->meta[$fieldSetName]['fields']) ? $this->meta[$fieldSetName]['fields'] : []; } /** - * Get primary field name - * - * @return string + * @param string $fieldSetName + * @param string $fieldName + * @return array */ - public function getPrimaryFieldName() + public function getFieldMetaInfo($fieldSetName, $fieldName) { - return $this->primaryFieldName; + return isset($this->meta[$fieldSetName]['fields'][$fieldName]) + ? $this->meta[$fieldSetName]['fields'][$fieldName] + : []; } /** @@ -186,6 +220,16 @@ public function removeAllFields() $this->collection->removeAllFieldsFromSelect(); } + /** + * Get data + * + * @return array + */ + public function getData() + { + return $this->collection->toArray(); + } + /** * Retrieve count of loaded items * @@ -216,13 +260,4 @@ public function setConfigData($config) { $this->data['config'] = $config; } - - /** - * @param string $fieldSetName - * @return array - */ - public function getFieldsMetaInfo($fieldSetName) - { - return isset($this->meta[$fieldSetName]['fields']) ? $this->meta[$fieldSetName]['fields'] : []; - } } diff --git a/app/code/Magento/Cms/Model/Page/Source/IsActive.php b/app/code/Magento/Cms/Model/Page/Source/IsActive.php index 7c9d153e5a5a5..81ec863288e3d 100644 --- a/app/code/Magento/Cms/Model/Page/Source/IsActive.php +++ b/app/code/Magento/Cms/Model/Page/Source/IsActive.php @@ -34,10 +34,10 @@ public function __construct(\Magento\Cms\Model\Page $cmsPage) */ public function toOptionArray() { - $options = []; + $options[] = ['label' => '', 'value' => '']; $availableOptions = $this->cmsPage->getAvailableStatuses(); foreach ($availableOptions as $key => $value) { - $options[$key] = [ + $options[] = [ 'label' => $value, 'value' => $key, ]; diff --git a/app/code/Magento/Cms/Model/Page/Source/PageLayout.php b/app/code/Magento/Cms/Model/Page/Source/PageLayout.php index 32e8878dbe5b2..071e071a7aa74 100644 --- a/app/code/Magento/Cms/Model/Page/Source/PageLayout.php +++ b/app/code/Magento/Cms/Model/Page/Source/PageLayout.php @@ -43,10 +43,10 @@ public function toOptionArray() if ($this->options !== null) { return $this->options; } - $options = []; + $options[] = ['label' => '', 'value' => '']; $configOptions = $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions(); foreach ($configOptions as $key => $value) { - $options[$key] = [ + $options[] = [ 'label' => $value, 'value' => $key, ]; diff --git a/app/code/Magento/Cms/Model/Page/Source/Theme.php b/app/code/Magento/Cms/Model/Page/Source/Theme.php new file mode 100644 index 0000000000000..dc0568a2b4c54 --- /dev/null +++ b/app/code/Magento/Cms/Model/Page/Source/Theme.php @@ -0,0 +1,42 @@ +themeList = $themeList; + } + + /** + * Get options + * + * @return array + */ + public function toOptionArray() + { + $options[] = ['label' => '', 'value' => '']; + return $options + $this->themeList->getLabels(); + + } +} diff --git a/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php b/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php index 4b7e6861eec6c..3d34d2dfe449b 100644 --- a/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php @@ -242,7 +242,6 @@ public function testPrepareResultPage( $layoutUpdateXml = 'layoutUpdateXml'; $contentHeading = 'contentHeading'; $escapedContentHeading = 'escapedContentHeading'; - $defaultGroup = 'defaultGroup'; $pageLoadResultCollection = [ null, $this->pageMock, @@ -347,23 +346,6 @@ public function testPrepareResultPage( ->method('setContentHeading') ->with($escapedContentHeading) ->willReturnSelf(); - $this->layoutMock->expects($this->any()) - ->method('getMessagesBlock') - ->willReturn($this->messagesBlockMock); - $this->messageManagerMock->expects($this->any()) - ->method('getDefaultGroup') - ->willReturn($defaultGroup); - $this->messagesBlockMock->expects($this->any()) - ->method('addStorageType') - ->with($defaultGroup); - $this->messageManagerMock->expects($this->any()) - ->method('getMessages') - ->with(true) - ->willReturn($this->messageCollectionMock); - $this->messagesBlockMock->expects($this->any()) - ->method('addMessages') - ->with($this->messageCollectionMock) - ->willReturnSelf(); if ($expectedResult) { $expectedResult = $this->resultPageMock; diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php index f06f1346e7b96..22a3e421ff3f3 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php @@ -165,7 +165,7 @@ protected function setUp() $this->_storageCollectionFactoryMock = $this->getMock( 'Magento\Cms\Model\Wysiwyg\Images\Storage\CollectionFactory', - [], + ['create'], [], '', false diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php new file mode 100644 index 0000000000000..a3a2fbda293c0 --- /dev/null +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -0,0 +1,60 @@ +getMockBuilder('Magento\Framework\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + $inputUrl = 'href/url/for/edit/action'; + + /** @var \Magento\Cms\Ui\Component\Listing\Column\PageActions $model */ + $model = $objectManager->getObject( + 'Magento\Cms\Ui\Component\Listing\Column\PageActions', + [ + 'urlBuilder' => $urlBuilderMock, + 'url' => $inputUrl + ] + ); + + // Define test input and expectations + $items = ['data' => ['items' => [['page_id' => 1]]]]; + $fullUrl = 'full-url-including-base.com/href/url/for/edit/action'; + $name = 'item_name'; + + $editArray = [ + 'href' => $fullUrl, + 'label' => __('Edit'), + 'hidden' => true + ]; + $expectedItems = [ + [ + 'page_id' => 1, + $name => ['edit' => $editArray] + ] + ]; + + // Configure mocks and object data + $urlBuilderMock->expects($this->once()) + ->method('getUrl') + ->with($inputUrl, ['page_id' => 1]) + ->willReturn($fullUrl); + + $model->setName($name); + $model->prepareDataSource($items); + // Run test + $this->assertEquals( + $expectedItems, + $items['data']['items'] + ); + } +} diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php index ecdf19a805f4c..d93cc635d9e8b 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -46,21 +46,24 @@ public function __construct( } /** - * @param array $items - * @return array + * Prepare Data Source + * + * @param array $dataSource + * @return void */ - public function prepareItems(array & $items) + public function prepareDataSource(array & $dataSource) { - foreach ($items as & $item) { - if (isset($item['block_id'])) { - $item[$this->getData('name')] = [ - 'edit' => [ - 'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['block_id' => $item['block_id']]), - 'label' => __('Edit'), - ] - ]; + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['block_id'])) { + $item[$this->getData('name')] = [ + 'edit' => [ + 'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['block_id' => $item['block_id']]), + 'label' => __('Edit'), + ] + ]; + } } } - return $items; } } diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php index 2a8140c0923cf..59edfeded291c 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -16,31 +16,27 @@ */ class PageActions extends Column { - /** - * Url path - */ - const URL_PATH = 'cms/page/edit'; + /** Url path */ + const CMS_URL_PATH = 'cms/page/edit'; - /** - * @var UrlBuilder - */ + /** @var UrlBuilder */ protected $actionUrlBuilder; - /** - * @var UrlInterface - */ + /** @var UrlInterface */ protected $urlBuilder; + /** @var string */ + private $url; + /** - * Constructor - * * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param UrlBuilder $actionUrlBuilder * @param UrlInterface $urlBuilder * @param array $components * @param array $data + * @param string $url */ public function __construct( ContextInterface $context, @@ -48,39 +44,43 @@ public function __construct( UrlBuilder $actionUrlBuilder, UrlInterface $urlBuilder, array $components = [], - array $data = [] + array $data = [], + $url = self::CMS_URL_PATH ) { $this->urlBuilder = $urlBuilder; $this->actionUrlBuilder = $actionUrlBuilder; + $this->url = $url; parent::__construct($context, $uiComponentFactory, $components, $data); } /** - * @param array $items - * @return array + * Prepare Data Source + * + * @param array $dataSource + * @return void */ - public function prepareItems(array & $items) + public function prepareDataSource(array & $dataSource) { - foreach ($items as & $item) { - if (isset($item['page_id'])) { - $item[$this->getData('name')]['edit'] = [ - 'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['page_id' => $item['page_id']]), - 'label' => __('Edit'), - 'hidden' => true - ]; - } - if (isset($item['identifier'])) { - $item[$this->getData('name')]['preview'] = [ - 'href' => $this->actionUrlBuilder->getUrl( - $item['identifier'], - isset($item['_first_store_id']) ? $item['_first_store_id'] : null, - isset($item['store_code']) ? $item['store_code'] : null - ), - 'label' => __('Preview') - ]; + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['page_id'])) { + $item[$this->getData('name')]['edit'] = [ + 'href' => $this->urlBuilder->getUrl($this->url, ['page_id' => $item['page_id']]), + 'label' => __('Edit'), + 'hidden' => true + ]; + } + if (isset($item['identifier'])) { + $item[$this->getData('name')]['preview'] = [ + 'href' => $this->actionUrlBuilder->getUrl( + $item['identifier'], + isset($item['_first_store_id']) ? $item['_first_store_id'] : null, + isset($item['store_code']) ? $item['store_code'] : null + ), + 'label' => __('Preview') + ]; + } } } - - return $items; } } diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 675fe457cd0c2..262a606f618f6 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-email": "0.74.0-beta9", - "magento/module-ui": "0.74.0-beta9", - "magento/module-variable": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-email": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", + "magento/module-variable": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml index da8c5b01d5ea6..44f4c1deea217 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml @@ -6,15 +6,9 @@ */ --> - - Magento\Framework\View\Element\UiComponent\Context - cms_block_listing - - - cms_block_listing.cms_block_listing_data_source - + cms_block_listing.cms_block_listing_data_source cms_block_listing.cms_block_listing_data_source cms_block_columns @@ -27,20 +21,43 @@ + + + Magento\Cms\Model\Block\DataProvider + cms_block_listing_data_source + block_id + id + + + + + + + + + Magento_Ui/js/grid/provider + + + ui/grid/toolbar - + - Magento_Ui/js/grid/controls/view + Magento_Ui/js/grid/controls/bookmarks/bookmarks dataGridActions + + + + cms_block_listing + - + @@ -48,12 +65,22 @@ dataGridActions - + dataGridFilters - params.filters + filters + + cms_block_listing.cms_block_listing.listing_top.bookmarks + current.filters + + + cms_block_listing.cms_block_listing.listing_top.listing_filters + + cms_block_listing.cms_block_listing.listing_top.bookmarks:current.columns.${ $.index }.visible + + @@ -61,6 +88,9 @@ block_id ID + + cms_block_listing.cms_block_listing.listing_top.listing_filters + @@ -134,6 +164,9 @@ creation_time Created + + cms_block_listing.cms_block_listing.listing_top.listing_filters + @@ -142,6 +175,7 @@ from From From + MM/dd/YYYY @@ -151,6 +185,7 @@ to To To + MM/dd/YYYY @@ -160,6 +195,9 @@ update_time Modified + + cms_block_listing.cms_block_listing.listing_top.listing_filters + @@ -168,6 +206,7 @@ from From From + MM/dd/YYYY @@ -177,6 +216,7 @@ to To To + MM/dd/YYYY @@ -201,6 +241,10 @@ + + cms_block_listing.cms_block_listing.listing_top.bookmarks + current.paging + bottom @@ -227,29 +271,7 @@ - - - - Magento\Cms\Model\Block\DataProvider - block_id - id - - - - CMS Page - - - - - - - Magento_Ui/js/grid/provider - - - mui/index/render - - - + @@ -257,6 +279,11 @@ actions edit cms_block_listing.cms_block_listing.listing_top.columns_controls + + cms_block_listing.cms_block_listing.listing_top.bookmarks + columns.${ $.index } + current.${ $.storageConfig.root} + diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml index 3e67e0ef1235c..b8f4b086bbf15 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml @@ -6,15 +6,9 @@ */ --> - - Magento\Framework\View\Element\UiComponent\Context - cms_page_listing - - - cms_page_listing.cms_page_listing_data_source - + cms_page_listing.cms_page_listing_data_source cms_page_listing.cms_page_listing_data_source cms_page_columns @@ -30,13 +24,12 @@ Magento\Cms\Model\Page\DataProvider + cms_page_listing_data_source block_id id - - - - CMS Block - + + + @@ -44,9 +37,6 @@ Magento_Ui/js/grid/provider - - mui/index/render - @@ -55,14 +45,19 @@ ui/grid/toolbar - + - Magento_Ui/js/grid/controls/view + Magento_Ui/js/grid/controls/bookmarks/bookmarks dataGridActions + + + + cms_page_listing + - + @@ -75,7 +70,17 @@ dataGridFilters - params.filters + filters + + cms_page_listing.cms_page_listing.listing_top.bookmarks + current.filters + + + cms_page_listing.cms_page_listing.listing_top.listing_filters + + cms_page_listing.cms_page_listing.listing_top.bookmarks:current.columns.${ $.index }.visible + + @@ -83,6 +88,9 @@ page_id ID + + cms_page_listing.cms_page_listing.listing_top.listing_filters + @@ -157,7 +165,7 @@ 1 - Enabled + Published @@ -168,6 +176,9 @@ creation_time Created + + cms_page_listing.cms_page_listing.listing_top.listing_filters + @@ -176,6 +187,7 @@ from from From + MM/dd/YYYY @@ -185,6 +197,7 @@ to to To + MM/dd/YYYY @@ -194,6 +207,9 @@ update_time Modified + + cms_page_listing.cms_page_listing.listing_top.listing_filters + @@ -202,6 +218,7 @@ from from From + MM/dd/YYYY @@ -211,6 +228,7 @@ to to To + MM/dd/YYYY @@ -227,6 +245,16 @@ Delete cms/page/massDelete + + disable + Disable + cms/page/massDisable + + + enable + Enable + cms/page/massEnable + page_id @@ -235,6 +263,10 @@ + + cms_page_listing.cms_page_listing.listing_top.bookmarks + current.paging + bottom @@ -261,7 +293,7 @@ - + @@ -269,6 +301,11 @@ actions edit cms_page_listing.cms_page_listing.listing_top.columns_controls + + cms_page_listing.cms_page_listing.listing_top.bookmarks + columns.${ $.index } + current.${ $.storageConfig.root} + @@ -383,6 +420,88 @@ + + + + Magento_Ui/js/grid/columns/date + + + date + left + Custom design from + MMM d, y + false + + + + + + + Magento_Ui/js/grid/columns/date + + + date + left + Custom design to + MMM d, y + false + + + + + + Magento\Cms\Model\Page\Source\Theme + + Magento_Ui/js/grid/columns/select + + + select + left + Custom Theme + false + + + + + + Magento\Cms\Model\Page\Source\PageLayout + + Magento_Ui/js/grid/columns/select + + + select + left + Custom Layout + false + + + + + + + Magento_Ui/js/grid/columns/sortable + + + text + left + Meta Keywords + false + + + + + + + Magento_Ui/js/grid/columns/sortable + + + text + left + Meta Description + false + + + diff --git a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php index b50d1f4935012..1c47586a63eda 100644 --- a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php +++ b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php @@ -5,6 +5,8 @@ */ namespace Magento\CmsUrlRewrite\Model; +use Magento\Cms\Api\Data\PageInterface; + class CmsPageUrlPathGenerator { /** @var \Magento\Framework\Filter\FilterManager */ @@ -17,11 +19,12 @@ public function __construct( } /** - * @param \Magento\Cms\Model\Page $cmsPage + * @param PageInterface $cmsPage * * @return string + * @api */ - public function getUrlPath($cmsPage) + public function getUrlPath(PageInterface $cmsPage) { return $cmsPage->getIdentifier(); } @@ -29,10 +32,11 @@ public function getUrlPath($cmsPage) /** * Get canonical product url path * - * @param \Magento\Cms\Model\Page $cmsPage + * @param PageInterface $cmsPage * @return string + * @api */ - public function getCanonicalUrlPath($cmsPage) + public function getCanonicalUrlPath(PageInterface $cmsPage) { return 'cms/page/view/page_id/' . $cmsPage->getId(); } @@ -40,10 +44,11 @@ public function getCanonicalUrlPath($cmsPage) /** * Generate CMS page url key based on url_key entered by merchant or page title * - * @param \Magento\Cms\Model\Page $cmsPage + * @param PageInterface $cmsPage * @return string + * @api */ - public function generateUrlKey($cmsPage) + public function generateUrlKey(PageInterface $cmsPage) { $urlKey = $cmsPage->getIdentifier(); return $this->filterManager->translitUrl($urlKey === '' || $urlKey === null ? $cmsPage->getTitle() : $urlKey); diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index d98ca20d523fb..2796f0badc61a 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-url-rewrite": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-url-rewrite": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php b/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php index abcf35b66fb6f..255b15177f97a 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php @@ -86,7 +86,7 @@ protected function _getHeaderHtml($element) $html = '
    '; } - $html .= '
    ' . + $html .= '
    ' . ''; @@ -171,7 +171,7 @@ protected function _getFieldsetCss() /** @var \Magento\Config\Model\Config\Structure\Element\Group $group */ $group = $this->getGroup(); $configCss = $group->getFieldsetCss(); - return 'config collapseable' . ($configCss ? ' ' . $configCss : ''); + return 'config admin__collapsible-block' . ($configCss ? ' ' . $configCss : ''); } /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php index 75fb6c199f21e..af53ce1458b67 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php +++ b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php @@ -10,7 +10,8 @@ namespace Magento\Config\Model\Config\Backend; -class Encrypted extends \Magento\Framework\App\Config\Value implements \Magento\Framework\App\Config\Data\ProcessorInterface +class Encrypted extends \Magento\Framework\App\Config\Value implements + \Magento\Framework\App\Config\Data\ProcessorInterface { /** * @var \Magento\Framework\Encryption\EncryptorInterface @@ -58,7 +59,9 @@ public function __sleep() public function __wakeup() { parent::__wakeup(); - $this->_encryptor = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\Encryption\EncryptorInterface'); + $this->_encryptor = \Magento\Framework\App\ObjectManager::getInstance()->get( + 'Magento\Framework\Encryption\EncryptorInterface' + ); } /** @@ -81,16 +84,13 @@ protected function _afterLoad() */ public function beforeSave() { + $this->_dataSaveAllowed = false; $value = (string)$this->getValue(); - // don't change value, if an obscured value came - if (preg_match('/^\*+$/', $this->getValue())) { - $value = $this->getOldValue(); - } - if (!empty($value)) { + // don't save value, if an obscured value was received. This indicates that data was not changed. + if (!preg_match('/^\*+$/', $value) && !empty($value)) { + $this->_dataSaveAllowed = true; $encrypted = $this->_encryptor->encrypt($value); - if ($encrypted) { - $this->setValue($encrypted); - } + $this->setValue($encrypted); } } diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php index 10ef9f1e7c4f9..a52ebaec811c1 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php @@ -10,10 +10,15 @@ class FormTest extends \PHPUnit_Framework_TestCase { + /** + * @var \PHPUnit_Framework_MockObject_MockBuilder + */ + protected $_objectBuilder; + /** * @var \Magento\Config\Block\System\Config\Form */ - protected $_object; + protected $object; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -166,17 +171,49 @@ protected function setUp() 'context' => $context, ]; - $this->_object = $helper->getObject('Magento\Config\Block\System\Config\Form', $data); - $this->_object->setData('scope_id', 1); + $objectArguments = $helper->getConstructArguments('Magento\Config\Block\System\Config\Form', $data); + $this->_objectBuilder = $this->getMockBuilder('Magento\Config\Block\System\Config\Form') + ->setConstructorArgs($objectArguments) + ->setMethods(['something']); + $this->object = $helper->getObject('Magento\Config\Block\System\Config\Form', $data); + $this->object->setData('scope_id', 1); } - public function testInitFormWithoutSection() + /** + * @param bool $sectionIsVisible + * @dataProvider initFormDataProvider + */ + public function testInitForm($sectionIsVisible) { + /** @var \Magento\Config\Block\System\Config\Form | \PHPUnit_Framework_MockObject_MockObject $object */ + $object = $this->_objectBuilder->setMethods(['_initGroup'])->getMock(); + $object->setData('scope_id', 1); $this->_formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_formMock)); - $this->_formMock->expects($this->once())->method('setParent')->with($this->_object); + $this->_formMock->expects($this->once())->method('setParent')->with($object); $this->_formMock->expects($this->once())->method('setBaseUrl')->with('base_url'); $this->_urlModelMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('base_url')); + $sectionMock = $this->getMockBuilder('\Magento\Config\Model\Config\Structure\Element\Section') + ->disableOriginalConstructor() + ->getMock(); + if ($sectionIsVisible) { + $sectionMock->expects($this->once()) + ->method('isVisible') + ->willReturn(true); + $sectionMock->expects($this->once()) + ->method('getChildren') + ->willReturn([ + $this->getMock( + 'Magento\Config\Model\Config\Structure\Element\Group', + [], + [], + '', + false, + false + ) + ]); + } + $this->_systemConfigMock->expects( $this->once() )->method( @@ -184,21 +221,43 @@ public function testInitFormWithoutSection() )->with( 'section_code' )->will( - $this->returnValue(null) + $this->returnValue($sectionIsVisible ? $sectionMock : null) ); - $this->_object->initForm(); - $this->assertEquals($this->_formMock, $this->_object->getForm()); + if ($sectionIsVisible) { + $object->expects($this->once()) + ->method('_initGroup'); + } else { + $object->expects($this->never()) + ->method('_initGroup'); + } + + + $object->initForm(); + $this->assertEquals($this->_formMock, $object->getForm()); + } + + public function initFormDataProvider() + { + return [ + [false], + [true] + ]; } /** - * @return void + * @param bool $shouldCloneFields + * @param array $prefixes + * @param int $callNum + * @dataProvider initGroupDataProvider * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testInitGroup() + public function testInitGroup($shouldCloneFields, $prefixes, $callNum) { + /** @var \Magento\Config\Block\System\Config\Form | \PHPUnit_Framework_MockObject_MockObject $object */ + $object = $this->_objectBuilder->setMethods(['initFields'])->getMock(); $this->_formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_formMock)); - $this->_formMock->expects($this->once())->method('setParent')->with($this->_object); + $this->_formMock->expects($this->once())->method('setParent')->with($object); $this->_formMock->expects($this->once())->method('setBaseUrl')->with('base_url'); $this->_urlModelMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('base_url')); @@ -227,8 +286,6 @@ public function testInitGroup() false ); - $cloneModelMock->expects($this->once())->method('getPrefixes')->will($this->returnValue([])); - $groupMock = $this->getMock( 'Magento\Config\Model\Config\Structure\Element\Group', [], @@ -243,8 +300,7 @@ public function testInitGroup() $groupMock->expects($this->once())->method('getComment')->will($this->returnValue('comment')); $groupMock->expects($this->once())->method('isExpanded')->will($this->returnValue(false)); $groupMock->expects($this->once())->method('populateFieldset'); - $groupMock->expects($this->once())->method('shouldCloneFields')->will($this->returnValue(true)); - $groupMock->expects($this->once())->method('getCloneModel')->will($this->returnValue($cloneModelMock)); + $groupMock->expects($this->once())->method('shouldCloneFields')->will($this->returnValue($shouldCloneFields)); $groupMock->expects($this->once())->method('getData')->will($this->returnValue('some group data')); $groupMock->expects( $this->once() @@ -300,9 +356,40 @@ public function testInitGroup() )->will( $this->returnValue($formFieldsetMock) ); - $this->_object->initForm(); + + if ($shouldCloneFields) { + $cloneModelMock->expects($this->once())->method('getPrefixes')->will($this->returnValue($prefixes)); + + $groupMock->expects($this->once())->method('getCloneModel')->will($this->returnValue($cloneModelMock)); + } + + if ($shouldCloneFields && $prefixes) { + $object->expects($this->exactly($callNum)) + ->method('initFields') + ->with( + $formFieldsetMock, + $groupMock, + $sectionMock, + $prefixes[0]['field'], + $prefixes[0]['label'] + ); + } else { + $object->expects($this->exactly($callNum)) + ->method('initFields') + ->with($formFieldsetMock, $groupMock, $sectionMock); + } + + $object->initForm(); } + public function initGroupDataProvider() + { + return [ + [true, [['field' => 'field', 'label' => 'label']], 1], + [true, [], 0], + [false, [['field' => 'field', 'label' => 'label']], 1], + ]; + } /** * @dataProvider initFieldsDataProvider * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -460,7 +547,7 @@ public function testInitFields($backendConfigValue, $configValue, $configPath, $ $fieldMock->expects($this->once())->method('populateInput'); - $this->_object->initFields($fieldsetMock, $groupMock, $sectionMock, $fieldPrefix, $labelPrefix); + $this->object->initFields($fieldsetMock, $groupMock, $sectionMock, $fieldPrefix, $labelPrefix); } /** diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php index 1440247dc3d96..54a9bf0ba8b2e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php @@ -87,37 +87,24 @@ public function testProcessValue() * @covers \Magento\Config\Model\Config\Backend\Encrypted::beforeSave * @dataProvider beforeSaveDataProvider * - * @param $value - * @param $valueToSave + * @param string $value + * @param string $expectedValue + * @param int $encryptMethodCall */ - public function testBeforeSave($value, $valueToSave) + public function testBeforeSave($value, $expectedValue, $encryptMethodCall) { $this->_resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); $this->_resourceMock->expects($this->any())->method('commit')->will($this->returnSelf()); - - $this->_configMock->expects( - $this->any() - )->method( - 'getValue' - )->with( - 'some/path' - )->will( - $this->returnValue('oldValue') - ); - $this->_encryptorMock->expects( - $this->once() - )->method( - 'encrypt' - )->with( - $valueToSave - )->will( - $this->returnValue('encrypted') - ); + $this->_encryptorMock->expects($this->exactly($encryptMethodCall)) + ->method('encrypt') + ->with($value) + ->will($this->returnValue('encrypted')); $this->_model->setValue($value); $this->_model->setPath('some/path'); $this->_model->beforeSave(); - $this->assertEquals($this->_model->getValue(), 'encrypted'); + + $this->assertEquals($expectedValue, $this->_model->getValue()); } /** @@ -125,6 +112,6 @@ public function testBeforeSave($value, $valueToSave) */ public function beforeSaveDataProvider() { - return [['****', 'oldValue'], ['newValue', 'newValue']]; + return [['someValue', 'encrypted', 1], ['****', '****', 0]]; } } diff --git a/app/code/Magento/Config/composer.json b/app/code/Magento/Config/composer.json index aef7a083c5a81..c7deb8913204c 100644 --- a/app/code/Magento/Config/composer.json +++ b/app/code/Magento/Config/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/framework": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-cron": "0.74.0-beta9", - "magento/module-email": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-cron": "0.74.0-beta11", + "magento/module-email": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml b/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml index 089f5a6eb8cfe..c85f9314837ff 100644 --- a/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml +++ b/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml @@ -14,7 +14,7 @@ $_colspan = $block->isAddAfter() ? 2 : 1; ?>
    - +
    getColumns() as $columnName => $column): ?> diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index 92dc50b930568..0e26c67930ce0 100644 --- a/app/code/Magento/ConfigurableImportExport/composer.json +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-catalog-import-export": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-import-export": "0.74.0-beta9", - "magento/module-configurable-product": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-catalog-import-export": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-import-export": "0.74.0-beta11", + "magento/module-configurable-product": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php b/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php index 3588a1ca6a708..66e05cf340d40 100644 --- a/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php @@ -6,6 +6,10 @@ */ namespace Magento\ConfigurableProduct\Api; +/** + * Interface ConfigurableProductManagementInterface + * @api + */ interface ConfigurableProductManagementInterface { /** diff --git a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php index 84fbb287ce22e..01814c8861c22 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php @@ -7,7 +7,7 @@ use Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; use Magento\Checkout\Block\Cart\Item\Renderer; -use Magento\Framework\View\Block\IdentityInterface; +use Magento\Framework\Object\IdentityInterface; /** * Shopping cart item render block for configurable products. diff --git a/app/code/Magento/ConfigurableProduct/CustomerData/ConfigurableItem.php b/app/code/Magento/ConfigurableProduct/CustomerData/ConfigurableItem.php new file mode 100644 index 0000000000000..cd20c3931db3a --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/CustomerData/ConfigurableItem.php @@ -0,0 +1,82 @@ +_scopeConfig = $scopeConfig; + } + + /** + * {@inheritdoc} + */ + protected function getProductForThumbnail() + { + /** + * Show parent product thumbnail if it must be always shown according to the related setting in system config + * or if child thumbnail is not available + */ + $config = $this->_scopeConfig->getValue( + \Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::CONFIG_THUMBNAIL_SOURCE, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + $product = $config == ThumbnailSource::OPTION_USE_PARENT_IMAGE + || (!$this->getChildProduct()->getThumbnail() || $this->getChildProduct()->getThumbnail() == 'no_selection') + ? $this->getProduct() + : $this->getChildProduct(); + + return $product; + } + + /** + * Get item configurable child product + * + * @return \Magento\Catalog\Model\Product + */ + protected function getChildProduct() + { + if ($option = $this->item->getOptionByCode('simple_product')) { + return $option->getProduct(); + } + return $this->getProduct(); + } +} diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php index 34b66ecb320dc..5bf9e0b3106d3 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php @@ -207,4 +207,57 @@ public function testGetListNotConfigurableProduct() $this->model->getList($productSku); } + + /** + * @param int $attributeId + * @param string $label + * @param array $optionValues + * @param string $msg + * @dataProvider validateOptionDataProvider + * @throws \Magento\Framework\Exception\InputException + */ + public function testValidateNewOptionData($attributeId, $label, $optionValues, $msg) + { + $this->setExpectedException('Magento\Framework\Exception\InputException', $msg); + $optionValueMock = $this->getMock('\Magento\ConfigurableProduct\Api\Data\OptionValueInterface'); + $optionValuesMock = []; + if (!empty($optionValues)) { + $optionValueMock->expects($this->any()) + ->method('getValueIndex') + ->willReturn($optionValues['v']); + $optionValueMock->expects($this->any()) + ->method('getPricingValue') + ->willReturn($optionValues['p']); + $optionValueMock->expects($this->any()) + ->method('getIsPercent') + ->willReturn($optionValues['r']); + $optionValuesMock = [$optionValueMock]; + } + + $optionMock = $this->getMock('\Magento\ConfigurableProduct\Api\Data\OptionInterface'); + $optionMock->expects($this->any()) + ->method('getAttributeId') + ->willReturn($attributeId); + $optionMock->expects($this->any()) + ->method('getLabel') + ->willReturn($label); + $optionMock->expects($this->any()) + ->method('getValues') + ->willReturn($optionValuesMock); + + $this->model->validateNewOptionData($optionMock); + } + + public function validateOptionDataProvider() + { + return [ + [null, '', ['v' => null, 'p' => null, 'r' => null], 'One or more input exceptions have occurred.'], + [1, 'Label', [], 'Option values are not specified.'], + [null, 'Label', ['v' => 1, 'p' => 1, 'r' => 1], 'Option attribute ID is not specified.'], + [1, '', ['v' => 1, 'p' => 1, 'r' => 1], 'Option label is not specified.'], + [1, 'Label', ['v' => null, 'p' => 1, 'r' => 1], 'Value index is not specified for an option.'], + [1, 'Label', ['v' => 1, 'p' => null, 'r' => 1], 'Price is not specified for an option.'], + [1, 'Label', ['v' => 1, 'p' => 1, 'r' => null], 'Percent/absolute is not specified for an option.'], + ]; + } } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AfterProductLoadTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AfterProductLoadTest.php index af3e73f0b855e..0b56ba5abe068 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AfterProductLoadTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AfterProductLoadTest.php @@ -37,9 +37,13 @@ class AfterProductLoadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->optionValueFactory = $this->getMockBuilder( - '\Magento\ConfigurableProduct\Api\Data\OptionValueInterfaceFactory' - )->disableOriginalConstructor()->getMock(); + $this->optionValueFactory = $this->getMock( + '\Magento\ConfigurableProduct\Api\Data\OptionValueInterfaceFactory', + ['create'], + [], + '', + false + ); $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') ->disableOriginalConstructor() ->getMock(); @@ -54,6 +58,7 @@ protected function setUp() ->method('getTypeInstance') ->willReturn($this->configurableProductTypeInstanceMock); $this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory') + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AroundProductRepositorySaveTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AroundProductRepositorySaveTest.php index 6e750f9e13fce..417cd7a48b07b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AroundProductRepositorySaveTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AroundProductRepositorySaveTest.php @@ -66,9 +66,13 @@ protected function setUp() $this->productOptionRepositoryMock = $this->getMock( 'Magento\ConfigurableProduct\Api\OptionRepositoryInterface' ); - $this->configurableTypeFactoryMock = $this->getMockBuilder( - '\Magento\ConfigurableProduct\Model\Resource\Product\Type\ConfigurableFactory' - )->disableOriginalConstructor()->getMock(); + $this->configurableTypeFactoryMock = $this->getMock( + '\Magento\ConfigurableProduct\Model\Resource\Product\Type\ConfigurableFactory', + ['create'], + [], + '', + false + ); $this->priceDataMock = $this->getMockBuilder( '\Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Price\Data' )->disableOriginalConstructor()->getMock(); @@ -85,6 +89,7 @@ protected function setUp() }; $this->productFactoryMock = $this->getMockBuilder('\Magento\Catalog\Model\ProductFactory') + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index fda291b3460d3..68679f3c1943f 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,26 +3,27 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-catalog-rule": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-msrp": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-catalog-rule": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-webapi": "0.74.0-beta9" + "magento/module-webapi": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ConfigurableProduct/etc/frontend/di.xml b/app/code/Magento/ConfigurableProduct/etc/frontend/di.xml new file mode 100644 index 0000000000000..27a999c47887d --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/etc/frontend/di.xml @@ -0,0 +1,17 @@ + + + + + + + Magento\ConfigurableProduct\CustomerData\ConfigurableItem + + + + diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-js-template.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-js-template.phtml index 253b53dca5986..2865b30b77107 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-js-template.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-js-template.phtml @@ -21,9 +21,9 @@ -
    +
    - + <%- data.attribute.label %>
    diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-template.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-template.phtml index 420096d462a60..9a50b287313e9 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-template.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/attribute-template.phtml @@ -38,9 +38,9 @@ $id = $block->escapeHtml($attribute['attribute_id']); * @TODO refactor collapsable and remove this
    */?> -
    +
    - + escapeHtml($attribute['label']); ?>
    diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml index 804195c9776f9..cf9f3ffa35a77 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/config.phtml @@ -11,9 +11,9 @@ use Magento\ConfigurableProduct\Model\Product\Type\Configurable; ?>
    -
    +
    - +
    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 8f4713df58ef5..b7beb5d05ede6 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 @@ -21,7 +21,7 @@ $productByUsedAttributes = $block->getAssociatedProducts();
    -
    +
    diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/product/product.css b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/product/product.css index 4af99352c7abc..79550544efa59 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/product/product.css +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/product/product.css @@ -25,10 +25,6 @@ width: 43%; } -#configurable-attributes-container { - margin-bottom: 23px; -} - #configurable-attributes-container .col-include { width: 80px; } @@ -62,9 +58,9 @@ #configurable-attributes-container .field-pricing-value .pricing-value { width: 100%; - padding: 4px; + padding: 4px 10px; border-right: none; - border-radius: 4px 0 0 4px; + border-radius: 1px 0 0 1px; } /* "Generate Variations" button */ @@ -73,6 +69,7 @@ } #product-variations-matrix > .title { + margin-top: 2rem; margin-bottom: 10px; } diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml deleted file mode 100644 index 9daf17b510201..0000000000000 --- a/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/Contact/Block/ContactForm.php b/app/code/Magento/Contact/Block/ContactForm.php new file mode 100644 index 0000000000000..907bccb5a494b --- /dev/null +++ b/app/code/Magento/Contact/Block/ContactForm.php @@ -0,0 +1,24 @@ +_isScopePrivate = true; + } +} diff --git a/app/code/Magento/Contact/Controller/Index/Index.php b/app/code/Magento/Contact/Controller/Index/Index.php index 80f3698a42332..b6e6e3f0ffaa0 100644 --- a/app/code/Magento/Contact/Controller/Index/Index.php +++ b/app/code/Magento/Contact/Controller/Index/Index.php @@ -19,7 +19,6 @@ public function execute() $this->_view->getLayout() ->getBlock('contactForm') ->setFormAction($this->_url->getUrl('*/*/post', ['_secure' => true])); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Contact/Test/Unit/Block/ContactFormTest.php b/app/code/Magento/Contact/Test/Unit/Block/ContactFormTest.php new file mode 100644 index 0000000000000..446279ee14ef7 --- /dev/null +++ b/app/code/Magento/Contact/Test/Unit/Block/ContactFormTest.php @@ -0,0 +1,44 @@ +contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->contactForm = new ContactForm( + $this->contextMock + ); + } + + /** + * @return void + */ + public function testScope() + { + $this->assertTrue($this->contactForm->isScopePrivate()); + } +} diff --git a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php index 4c24b4368fb66..bb59c0e78c742 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php @@ -106,13 +106,10 @@ public function testExecute() $this->_view->expects($this->once()) ->method('loadLayout'); - $this->_view->expects($this->exactly(2)) + $this->_view->expects($this->exactly(1)) ->method('getLayout') ->will($this->returnValue($layout)); - $layout->expects($this->once()) - ->method('initMessages'); - $this->_view->expects($this->once()) ->method('renderLayout'); diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index c9b93b799a1ad..d91e84ade98de 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.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Contact/view/frontend/layout/contact_index_index.xml b/app/code/Magento/Contact/view/frontend/layout/contact_index_index.xml index e5e4b57692094..843206e4e00d5 100644 --- a/app/code/Magento/Contact/view/frontend/layout/contact_index_index.xml +++ b/app/code/Magento/Contact/view/frontend/layout/contact_index_index.xml @@ -11,7 +11,7 @@ - + diff --git a/app/code/Magento/Cookie/composer.json b/app/code/Magento/Cookie/composer.json index dd6a97e978c27..91e406224ed81 100644 --- a/app/code/Magento/Cookie/composer.json +++ b/app/code/Magento/Cookie/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-backend": "0.74.0-beta9" + "magento/module-backend": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Cron/Console/Command/CronCommand.php b/app/code/Magento/Cron/Console/Command/CronCommand.php new file mode 100644 index 0000000000000..8d99bd045366b --- /dev/null +++ b/app/code/Magento/Cron/Console/Command/CronCommand.php @@ -0,0 +1,101 @@ +objectManager = $objectManagerFactory->create($params); + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $options = [ + new InputOption( + self::INPUT_KEY_GROUP, + null, + InputOption::VALUE_REQUIRED, + 'Run jobs only from specified group', + 'default' + ), + new InputOption( + Cli::INPUT_KEY_BOOTSTRAP, + null, + InputOption::VALUE_REQUIRED, + 'Add or override parameters of the bootstrap' + ), + ]; + $this->setName('cron:run') + ->setDescription('Runs jobs by schedule') + ->setDefinition($options); + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $params[self::INPUT_KEY_GROUP] = $input->getOption(self::INPUT_KEY_GROUP); + $params[Observer::STANDALONE_PROCESS_STARTED] = '0'; + $bootstrap = $input->getOption(Cli::INPUT_KEY_BOOTSTRAP); + if ($bootstrap) { + $bootstrapProcessor = new ComplexParameter(Cli::INPUT_KEY_BOOTSTRAP); + $bootstrapOptionValues = $bootstrapProcessor->getFromString( + '--' . Cli::INPUT_KEY_BOOTSTRAP . '=' . $bootstrap + ); + $bootstrapOptionValue = $bootstrapOptionValues[Observer::STANDALONE_PROCESS_STARTED]; + if ($bootstrapOptionValue) { + $params[Observer::STANDALONE_PROCESS_STARTED] = $bootstrapOptionValue; + } + } + /** @var \Magento\Framework\App\Cron $cronObserver */ + $cronObserver = $this->objectManager->create('Magento\Framework\App\Cron', ['parameters' => $params]); + $cronObserver->launch(); + $output->writeln('' . 'Ran jobs by schedule.' . ''); + } +} diff --git a/app/code/Magento/Cron/Model/Observer.php b/app/code/Magento/Cron/Model/Observer.php index 800e1e732710d..275ad3635eaa4 100644 --- a/app/code/Magento/Cron/Model/Observer.php +++ b/app/code/Magento/Cron/Model/Observer.php @@ -9,7 +9,7 @@ */ namespace Magento\Cron\Model; -use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Console\CLI; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -23,6 +23,12 @@ class Observer const CACHE_KEY_LAST_HISTORY_CLEANUP_AT = 'cron_last_history_cleanup_at'; + /** + * Flag for internal communication between processes for running + * all jobs in a group in parallel as a separate process + */ + const STANDALONE_PROCESS_STARTED = 'standaloneProcessStarted'; + /**#@-*/ /**#@+ @@ -143,18 +149,17 @@ public function dispatch($observer) if ($this->_request->getParam('group') !== null && $this->_request->getParam('group') != $groupId) { continue; } - if (($this->_request->getParam('standaloneProcessStarted') !== '1') && ( + if (($this->_request->getParam(self::STANDALONE_PROCESS_STARTED) !== '1') && ( $this->_scopeConfig->getValue( 'system/cron/' . $groupId . '/use_separate_process', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) == 1 )) { $this->_shell->execute( - 'php -f %s -- --group=%s --standaloneProcessStarted=%s', + 'php %s cron:run --group=' . $groupId . ' --' . CLI::INPUT_KEY_BOOTSTRAP . '=' + . self::STANDALONE_PROCESS_STARTED . '=1', [ - BP . '/' . DirectoryList::PUB . '/cron.php', - $groupId, - '1' + BP . '/bin/magento' ] ); continue; diff --git a/app/code/Magento/Cron/README.md b/app/code/Magento/Cron/README.md index 0e9e37ff8db79..445666301ade4 100644 --- a/app/code/Magento/Cron/README.md +++ b/app/code/Magento/Cron/README.md @@ -1,2 +1,2 @@ -Cron is a module that enables scheduling of jobs. Other modules can add cron jobs by including crontab.xml in their etc directory. The script dev/shell/cron.sh should be run periodically to trigger the Cron module to run its scheduled jobs. +Cron is a module that enables scheduling of jobs. Other modules can add cron jobs by including crontab.xml in their etc directory. The command "bin/magento cron:run" should be run periodically to trigger the Cron module to run its scheduled jobs. This module also allows administrators to tune cron options in Magento Admin. \ No newline at end of file diff --git a/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php b/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php new file mode 100644 index 0000000000000..396846acd8dee --- /dev/null +++ b/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php @@ -0,0 +1,26 @@ +getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false); + $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + $cron = $this->getMock('Magento\Framework\App\Cron', [], [], '', false); + $objectManager->expects($this->once())->method('create')->willReturn($cron); + $cron->expects($this->once())->method('launch'); + $objectManagerFactory->expects($this->once())->method('create')->willReturn($objectManager); + $commandTester = new CommandTester(new CronCommand($objectManagerFactory)); + $commandTester->execute([]); + $expectedMsg = 'Ran jobs by schedule.' . PHP_EOL; + $this->assertEquals($expectedMsg, $commandTester->getDisplay()); + } +} diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index 5b7fa97e3580b..95babbef256e0 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.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index 6680200ebc040..2be7e453defaf 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -29,4 +29,11 @@ shellBackground + + + + Magento\Cron\Console\Command\CronCommand + + + diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 92343d7bdcca0..159a89a2dc847 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.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-page-cache": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-page-cache": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CurrencySymbol/view/adminhtml/layout/adminhtml_system_currencysymbol_index.xml b/app/code/Magento/CurrencySymbol/view/adminhtml/layout/adminhtml_system_currencysymbol_index.xml index d66ae1fb23a2f..72d6afb67e40d 100644 --- a/app/code/Magento/CurrencySymbol/view/adminhtml/layout/adminhtml_system_currencysymbol_index.xml +++ b/app/code/Magento/CurrencySymbol/view/adminhtml/layout/adminhtml_system_currencysymbol_index.xml @@ -6,6 +6,7 @@ */ --> + diff --git a/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml b/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml index 2d61bf600ff4f..8e47b51aecb40 100644 --- a/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml +++ b/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml @@ -17,33 +17,32 @@
    - -
    - - - - - - - - - getCurrencySymbolsData() as $code => $data): ?> - - - - - - -
    - - -
    - name="custom_currency_symbol[]"> - value="1" name="inherit_custom_currency_symbol[]"> - -
    -
    -
    +
    + getCurrencySymbolsData() as $code => $data): ?> +
    + +
    + + name="custom_currency_symbol[]"> +
    + + value="1" + name="inherit_custom_currency_symbol[]"> + +
    +
    +
    + +
    getChildHtml()):?>
    getChildHtml();?> diff --git a/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml b/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml new file mode 100644 index 0000000000000..0be4fef69c4b1 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml @@ -0,0 +1,19 @@ + + diff --git a/app/code/Magento/Customer/view/frontend/templates/js/section-config.phtml b/app/code/Magento/Customer/view/frontend/templates/js/section-config.phtml new file mode 100644 index 0000000000000..cfe27cbbbde2f --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/js/section-config.phtml @@ -0,0 +1,22 @@ + + diff --git a/app/code/Magento/Customer/view/frontend/web/js/action/login.js b/app/code/Magento/Customer/view/frontend/web/js/action/login.js new file mode 100644 index 0000000000000..11dcaeec5cb4b --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/action/login.js @@ -0,0 +1,36 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + 'jquery', + 'mage/storage', + 'Magento_Ui/js/model/errorlist', + 'Magento_Customer/js/model/customer' + ], + function($, storage, errorlist, customer) { + "use strict"; + return function(loginData, redirectUrl) { + return storage.post( + 'customer/ajax/login', + JSON.stringify(loginData) + ).done(function (response) { + if (response.errors) { + customer.increaseFailedLoginAttempt(); + errorlist.add(response); + } else { + if (redirectUrl) { + window.location.href = redirectUrl; + } else { + location.reload(); + } + } + }).fail(function () { + customer.increaseFailedLoginAttempt(); + errorlist.add({'message': 'Could not authenticate. Please try again later'}); + }); + }; + } +); diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js new file mode 100644 index 0000000000000..e459e07201fe3 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -0,0 +1,151 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'underscore', + 'ko', + 'Magento_Customer/js/section-config', + 'jquery/jquery-storageapi', + 'jquery/jquery-cookie' +], function ($, _, ko, sectionConfig) { + 'use strict'; + + //TODO: remove global change, in this case made for initNamespaceStorage + $.cookieStorage.setConf({path:'/'}); + + var options; + var storage = $.initNamespaceStorage('mage-cache-storage').localStorage; + var storageInvalidation = $.initNamespaceStorage('mage-cache-storage-section-invalidation').localStorage; + + var invalidateCacheBySessionTimeOut = function(options) { + if (new Date($.localStorage.get('mage-cache-timeout')) < new Date()) { + storage.removeAll(); + var date = new Date(Date.now() + parseInt(options.cookieLifeTime, 10) * 1000); + $.localStorage.set('mage-cache-timeout', date); + } + }; + + var invalidateCacheByCloseCookieSession = function() { + if (!$.cookieStorage.isSet('mage-cache-sessid')) { + $.cookieStorage.set('mage-cache-sessid', true); + storage.removeAll(); + } + }; + + var dataProvider = { + getFromStorage: function (sectionNames) { + var result = {}; + _.each(sectionNames, function (sectionName) { + result[sectionName] = storage.get(sectionName); + }); + return result; + }, + getFromServer: function (sectionNames) { + var parameters = _.isArray(sectionNames) ? {sections: sectionNames.join(',')} : []; + return $.getJSON(options.sectionLoadUrl, parameters).fail(function(jqXHR) { + throw new Error(jqXHR.responseJSON.message); + }); + } + }; + + + ko.extenders.disposableCustomerData = function(target, sectionName) { + storage.remove(sectionName); + target.subscribe(function(newValue) { + setTimeout(function(){ + storage.remove(sectionName); + }, 3000); + }); + return target; + }; + + var buffer = { + data: {}, + bind: function (sectionName) { + this.data[sectionName] = ko.observable({}); + }, + get: function (sectionName) { + if (!this.data[sectionName]) { + this.bind(sectionName); + } + return this.data[sectionName]; + }, + keys: function () { + return _.keys(this.data); + }, + notify: function (sectionName, sectionData) { + if (!this.data[sectionName]) { + this.bind(sectionName); + } + this.data[sectionName](sectionData); + }, + update: function (sections) { + _.each(sections, function (sectionData, sectionName) { + storage.set(sectionName, sectionData); + storageInvalidation.remove(sectionName); + buffer.notify(sectionName, sectionData); + }); + }, + remove: function (sections) { + _.each(sections, function (sectionName) { + storage.remove(sectionName); + storageInvalidation.set(sectionName, true); + }); + } + }; + + var customerData = { + init: function() { + if (_.isEmpty(storage.keys())) { + this.reload(); + } else { + _.each(dataProvider.getFromStorage(storage.keys()), function (sectionData, sectionName) { + buffer.notify(sectionName, sectionData); + }); + if (!_.isEmpty(storageInvalidation.keys())) { + this.reload(storageInvalidation.keys()); + } + } + }, + get: function (sectionName) { + return buffer.get(sectionName); + }, + reload: function (sectionNames) { + return dataProvider.getFromServer(sectionNames).done(function (sections) { + buffer.update(sections); + }); + }, + invalidate: function (sectionNames) { + buffer.remove(_.contains(sectionNames, '*') ? buffer.keys() : sectionNames); + }, + 'Magento_Customer/js/customer-data': function (settings) { + options = settings; + invalidateCacheBySessionTimeOut(settings); + invalidateCacheByCloseCookieSession(); + customerData.init(); + } + }; + + /** Events listener **/ + $(document).on('ajaxComplete', function (event, xhr, settings) { + if (settings.type.match(/post/i)) { + var sections = sectionConfig.getAffectedSections(settings.url); + if (sections) { + customerData.invalidate(sections); + customerData.reload(sections); + } + } + }); + $(document).on('submit', function (event) { + if (event.target.method.match(/post/i)) { + var sections = sectionConfig.getAffectedSections(event.target.action); + if (sections) { + customerData.invalidate(sections); + } + } + }); + + return customerData; +}); diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/customer.js b/app/code/Magento/Customer/view/frontend/web/js/model/customer.js new file mode 100644 index 0000000000000..28a43254db2ef --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/model/customer.js @@ -0,0 +1,118 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + 'jquery', + 'ko', + 'underscore', + 'mage/storage', + 'Magento_Checkout/js/model/addresslist', + './customer/address' + ], + function($, ko, _, storage, addressList, address) { + "use strict"; + var isLoggedIn = ko.observable(window.isCustomerLoggedIn), + failedLoginAttempts = ko.observable(0), + customerData = {}; + + if (isLoggedIn()) { + customerData = window.customerData; + if (Object.keys(customerData).length) { + $.each(customerData.addresses, function (key, item) { + addressList.add(new address(item)); + }); + } + } else { + customerData = {}; + } + return { + customerData: customerData, + customerDetails: {}, + isLoggedIn: function() { + return isLoggedIn; + }, + setIsLoggedIn: function (flag) { + isLoggedIn(flag); + }, + getFailedLoginAttempts: function() { + return failedLoginAttempts; + }, + increaseFailedLoginAttempt: function() { + var oldAttempts = failedLoginAttempts(); + failedLoginAttempts(++oldAttempts); + }, + getBillingAddressList: function () { + return addressList.getAddresses(); + }, + getShippingAddressList: function () { + return addressList.getAddresses(); + }, + setDetails: function (fieldName, value) { + if (fieldName) { + this.customerDetails[fieldName] = value; + } + }, + getDetails: function (fieldName) { + if (fieldName) { + if (this.customerDetails.hasOwnProperty(fieldName)) { + return this.customerDetails[fieldName]; + } + return undefined; + } else { + return this.customerDetails; + } + }, + addCustomerAddress: function (address) { + var fields = [ + 'customer_id', 'country_id', 'street', 'company', 'telephone', 'fax', 'postcode', 'city', + 'firstname', 'lastname', 'middlename', 'prefix', 'suffix', 'vat_id', 'default_billing', + 'default_shipping' + ], + customerAddress = {}, + hasAddress = 0, + existingAddress; + + if (!this.customerData.addresses) { + this.customerData.addresses = []; + } + + customerAddress = _.pick(address, fields); + if (address.hasOwnProperty('region_id')) { + customerAddress.region = { + region_id: address.region_id, + region: address.region + }; + } + for (existingAddress in this.customerData.addresses) { + if (this.customerData.addresses.hasOwnProperty(existingAddress)) { + if (_.isEqual(this.customerData.addresses[existingAddress], customerAddress)) { + hasAddress = existingAddress; + break; + } + } + } + if (hasAddress === 0) { + return this.customerData.addresses.push(customerAddress) - 1; + } + return hasAddress; + }, + setAddressAsDefaultBilling: function (addressId) { + if (this.customerData.addresses[addressId]) { + this.customerData.addresses[addressId].default_billing = 1; + return true; + } + return false; + }, + setAddressAsDefaultShipping: function (addressId) { + if (this.customerData.addresses[addressId]) { + this.customerData.addresses[addressId].default_shipping = 1; + return true; + } + return false; + } + }; + } +); diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js new file mode 100644 index 0000000000000..104655e0f2224 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js @@ -0,0 +1,35 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([], function() { + return function (addressData) { + return { + customerAddressId: addressData.id, + email: addressData.email, + countryId: addressData.country_id, + regionId: addressData.region.region_id, + regionCode: addressData.region.region_code, + region: addressData.region.region, + customerId: addressData.customer_id, + street: addressData.street, + company: addressData.company, + telephone: addressData.telephone, + fax: addressData.fax, + postcode: addressData.postcode, + city: addressData.city, + firstname: addressData.firstname, + lastname: addressData.lastname, + middlename: addressData.middlename, + prefix: addressData.prefix, + suffix: addressData.suffix, + vatId: addressData.vat_id, + sameAsBilling: null, + getAddressInline: function() { + return addressData.inline; + } + } + } +}); diff --git a/app/code/Magento/Customer/view/frontend/web/js/section-config.js b/app/code/Magento/Customer/view/frontend/web/js/section-config.js new file mode 100644 index 0000000000000..5fb2b8f15c0e3 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/section-config.js @@ -0,0 +1,35 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define(['underscore'], function (_) { + 'use strict'; + + var baseUrls, sections; + + var canonize = function(url){ + var route = url; + for (var key in baseUrls) { + route = url.replace(baseUrls[key], ''); + if (route != url) { + break; + } + } + return route.replace(/^\/?index.php\/?/, '').toLowerCase(); + }; + + return { + getAffectedSections: function (url) { + var route = canonize(url); + var actions = _.find(sections, function(val, section){ + return (route.indexOf(section) === 0); + }); + + return _.union(_.toArray(actions), _.toArray(sections['*'])); + }, + 'Magento_Customer/js/section-config': function(options) { + baseUrls = options.baseUrls; + sections = options.sections; + } + }; +}); diff --git a/app/code/Magento/Customer/view/frontend/web/js/view/customer.js b/app/code/Magento/Customer/view/frontend/web/js/view/customer.js new file mode 100644 index 0000000000000..81eb787418068 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/view/customer.js @@ -0,0 +1,18 @@ +/** +* Copyright © 2015 Magento. All rights reserved. +* See COPYING.txt for license details. +*/ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data' +], function (Component, customerData) { + 'use strict'; + + return Component.extend({ + initialize: function () { + this._super(); + + this.customer = customerData.get('customer'); + } + }); +}); diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index d90332410af15..450c7f38eb42a 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-import-export": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-import-export": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index e80d4066fa76e..f71feb4dc42d7 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-translation": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-translation": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Developer/Console/Command/CssDeployCommand.php b/app/code/Magento/Developer/Console/Command/CssDeployCommand.php index cb9a34ae543ca..ffa326bc08b2f 100644 --- a/app/code/Magento/Developer/Console/Command/CssDeployCommand.php +++ b/app/code/Magento/Developer/Console/Command/CssDeployCommand.php @@ -20,6 +20,7 @@ use Magento\Framework\View\Asset\SourceFileGeneratorPool; use Magento\Framework\View\Asset\PreProcessor\ChainFactoryInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Validator\Locale; /** * Class CssDeployCommand - collects, processes and publishes source files like LESS or SASS @@ -92,6 +93,11 @@ class CssDeployCommand extends Command */ private $filesystem; + /** + * @var Locale + */ + private $validator; + /** * Inject dependencies * @@ -103,6 +109,7 @@ class CssDeployCommand extends Command * @param SourceFileGeneratorPool $sourceFileGeneratorPoll * @param ChainFactoryInterface $chainFactory * @param Filesystem $filesystem + * @param Locale $validator */ public function __construct( ObjectManagerInterface $objectManager, @@ -112,7 +119,8 @@ public function __construct( Source $assetSource, SourceFileGeneratorPool $sourceFileGeneratorPoll, ChainFactoryInterface $chainFactory, - Filesystem $filesystem + Filesystem $filesystem, + Locale $validator ) { $this->state = $state; $this->objectManager = $objectManager; @@ -122,6 +130,7 @@ public function __construct( $this->assetSource = $assetSource; $this->chainFactory = $chainFactory; $this->filesystem = $filesystem; + $this->validator = $validator; parent::__construct(); } @@ -132,12 +141,12 @@ public function __construct( protected function configure() { $this->setName('dev:css:deploy') - ->setDescription('Collects, processes and publishes source files like LESS or SASS') + ->setDescription('Collects, processes and publishes source LESS files') ->setDefinition([ new InputArgument( self::TYPE_ARGUMENT, InputArgument::REQUIRED, - 'Type of dynamic stylesheet language: [less|sass]' + 'Type of dynamic stylesheet language: [less]' ), new InputArgument( self::FILE_ARGUMENT, @@ -180,9 +189,9 @@ protected function execute(InputInterface $input, OutputInterface $output) { $locale = $input->getOption(self::LOCALE_OPTION); - if (!preg_match('/^[a-z]{2}_[A-Z]{2}$/', $locale)) { + if (!$this->validator->isValid($locale)) { throw new \InvalidArgumentException( - $locale . ' argument has invalid value format' + $locale . ' argument has invalid value, please run info:language:list for list of available locales' ); } diff --git a/app/code/Magento/Developer/Console/Command/XmlConverterCommand.php b/app/code/Magento/Developer/Console/Command/XmlConverterCommand.php new file mode 100644 index 0000000000000..9b10eaf044639 --- /dev/null +++ b/app/code/Magento/Developer/Console/Command/XmlConverterCommand.php @@ -0,0 +1,139 @@ +formatter = $formatter; + $this->domFactory = $domFactory; + $this->xsltProcessorFactory = $xsltProcessorFactory; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('dev:xml:convert') + ->setDescription('Converts XML file using XSL style sheets') + ->setDefinition([ + new InputArgument( + self::XML_FILE_ARGUMENT, + InputArgument::REQUIRED, + 'Path to XML file that going to be transformed' + ), + new InputArgument( + self::PROCESSOR_ARGUMENT, + InputArgument::REQUIRED, + 'Path to XSL style sheet that going to be applied to XML file' + ), + new InputOption( + self::OVERWRITE_OPTION, + '-o', + InputOption::VALUE_NONE, + 'Overwrite XML file' + ), + + ]); + + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + $domXml = $this->domFactory->create(); + $domXsl = $this->domFactory->create(); + $xsltProcessor = $this->xsltProcessorFactory->create(); + + $xmlFile = $input->getArgument(self::XML_FILE_ARGUMENT); + $domXml->preserveWhiteSpace = true; + $domXml->load($xmlFile); + + $domXsl->preserveWhiteSpace = true; + $domXsl->load($input->getArgument(self::PROCESSOR_ARGUMENT)); + + $xsltProcessor->registerPHPFunctions(); + $xsltProcessor->importStylesheet($domXsl); + $transformedDoc = $xsltProcessor->transformToXml($domXml); + $result = $this->formatter->format($transformedDoc); + + if ($input->getOption(self::OVERWRITE_OPTION)) { + file_put_contents($input->getArgument(self::XML_FILE_ARGUMENT), $result); + $output->writeln("You saved converted XML into $xmlFile"); + } else { + $output->write($result); + } + + return; + } catch (\Exception $exception) { + $errorMessage = $exception->getMessage(); + $output->writeln("$errorMessage"); + return; + } + } +} diff --git a/dev/tools/Magento/Tools/Layout/Formatter.php b/app/code/Magento/Developer/Model/Tools/Formatter.php similarity index 97% rename from dev/tools/Magento/Tools/Layout/Formatter.php rename to app/code/Magento/Developer/Model/Tools/Formatter.php index a016e32f203b5..94e3624401c68 100644 --- a/dev/tools/Magento/Tools/Layout/Formatter.php +++ b/app/code/Magento/Developer/Model/Tools/Formatter.php @@ -3,7 +3,8 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Layout; + +namespace Magento\Developer\Model\Tools; class Formatter { diff --git a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChain.php b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChain.php index 9703008ff7daf..7ef5b31ba966c 100644 --- a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChain.php +++ b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChain.php @@ -15,6 +15,7 @@ class DeveloperChain extends Chain * @param string $origContent * @param string $origContentType * @param null $origAssetPath + * @codeCoverageIgnore */ public function __construct( LocalInterface $asset, diff --git a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChainFactory.php b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChainFactory.php index dff0dc015aa08..c9e33d9c5e405 100644 --- a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChainFactory.php +++ b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChainFactory.php @@ -13,12 +13,17 @@ class DeveloperChainFactory implements ChainFactoryInterface { + /** + * Name of entity to create + */ + const ENTITY_NAME = 'Magento\Developer\Model\View\Asset\PreProcessor\DeveloperChain'; + /** * Object manager * * @var ObjectManagerInterface */ - private $_objectManager; + private $objectManager; /** * @var ChainFactory @@ -40,7 +45,7 @@ public function __construct( ChainFactory $chainFactory, ScopeConfigInterface $scopeConfig ) { - $this->_objectManager = $objectManager; + $this->objectManager = $objectManager; $this->chainFactory = $chainFactory; $this->scopeConfig = $scopeConfig; } @@ -51,8 +56,8 @@ public function __construct( public function create(array $arguments = []) { if (WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH)) { - return $this->_objectManager->create( - 'Magento\Developer\Model\View\Asset\PreProcessor\DeveloperChain', + return $this->objectManager->create( + self::ENTITY_NAME, $arguments ); } diff --git a/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php b/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php index bba4643f4e745..e055e2a528642 100644 --- a/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php +++ b/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php @@ -10,8 +10,6 @@ /** * Factory class for \Magento\Framework\View\Page\Config\RendererInterface - * - * todo work with interfaces instead of abstractions */ class RendererFactory extends \Magento\Framework\View\Page\Config\RendererFactory { diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/CssDeployCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/CssDeployCommandTest.php index e740800579f63..cad79e9253b0b 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/CssDeployCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/CssDeployCommandTest.php @@ -16,6 +16,7 @@ use Magento\Framework\View\Asset\PreProcessor\ChainFactoryInterface; use Magento\Developer\Console\Command\CssDeployCommand; use Symfony\Component\Console\Tester\CommandTester; +use Magento\Framework\Validator\Locale; class CssDeployCommandTest extends \PHPUnit_Framework_TestCase { @@ -64,6 +65,11 @@ class CssDeployCommandTest extends \PHPUnit_Framework_TestCase */ private $filesystem; + /** + * @var Locale|\PHPUnit_Framework_MockObject_MockObject + */ + private $validator; + public function setUp() { $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); @@ -82,6 +88,7 @@ public function setUp() 'Magento\Framework\View\Asset\PreProcessor\ChainFactoryInterface' ); $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->validator = $this->getMock('Magento\Framework\Validator\Locale', [], [], '', false); $this->command = new CssDeployCommand( $this->objectManager, @@ -91,7 +98,8 @@ public function setUp() $this->assetSource, $this->sourceFileGeneratorPool, $this->chainFactory, - $this->filesystem + $this->filesystem, + $this->validator ); } @@ -128,6 +136,8 @@ public function testExecute() $this->getMock('\Magento\Framework\Filesystem\Directory\WriteInterface', [], [], '', false) ); + $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true); + $commandTester = new CommandTester($this->command); $commandTester->execute( [ @@ -149,7 +159,7 @@ public function testExecuteWithoutParameters() /** * @expectedException \InvalidArgumentException - * @expectedExceptionMessage WRONG_LOCALE argument has invalid value format + * @expectedExceptionMessage WRONG_LOCALE argument has invalid value, please run info:language:list */ public function testExecuteWithWrongFormat() { diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php new file mode 100644 index 0000000000000..f3546a29e5391 --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php @@ -0,0 +1,88 @@ +formatter = $this->getMock('Magento\Developer\Model\Tools\Formatter', [], [], '', false); + $this->domFactory = $this->getMock('Magento\Framework\DomDocument\DomDocumentFactory', [], [], '', false); + $this->xsltProcessorFactory = $this->getMock( + 'Magento\Framework\XsltProcessor\XsltProcessorFactory', + [], + [], + '', + false + ); + + $this->command = new XmlConverterCommand($this->formatter, $this->domFactory, $this->xsltProcessorFactory); + } + + public function testExecute() + { + $domXml = $this->getMock('DOMDocument', [], [], '', false); + $domXsl = clone $domXml; + $domXml->expects($this->once())->method('load')->with('file.xml'); + $domXsl->expects($this->once())->method('load')->with('file.xsl'); + + $this->domFactory->expects($this->at(0))->method('create')->willReturn($domXml); + $this->domFactory->expects($this->at(1))->method('create')->willReturn($domXsl); + + $xsltProcessor = $this->getMock('XSLTProcessor', [], [], '', false); + $xsltProcessor->expects($this->once())->method('transformToXml')->with($domXml)->willReturn('XML'); + + $this->xsltProcessorFactory->expects($this->once())->method('create')->willReturn($xsltProcessor); + + $this->formatter->expects($this->once())->method('format')->with('XML')->willReturn('result'); + + $commandTester = new CommandTester($this->command); + $commandTester->execute( + [ + XmlConverterCommand::XML_FILE_ARGUMENT => 'file.xml', + XmlConverterCommand::PROCESSOR_ARGUMENT => 'file.xsl' + ] + ); + $this->assertContains('result', $commandTester->getDisplay()); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Not enough arguments + */ + public function testWrongParameter() + { + $commandTester = new CommandTester($this->command); + $commandTester->execute([]); + } +} diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/DeveloperChainFactoryTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/DeveloperChainFactoryTest.php new file mode 100644 index 0000000000000..686e6024a8174 --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/DeveloperChainFactoryTest.php @@ -0,0 +1,88 @@ +objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->configMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->chainFactoryMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\ChainFactory') + ->disableOriginalConstructor() + ->getMock(); + + // Set up System Under Test + $sutArgs = [ + 'objectManager' => $this->objectManagerMock, + 'chainFactory' => $this->chainFactoryMock, + 'scopeConfig' => $this->configMock + ]; + $this->model = $objectManager->getObject( + 'Magento\Developer\Model\View\Asset\PreProcessor\DeveloperChainFactory', + $sutArgs + ); + } + + public function testCreateClientCompilation() + { + $this->configMock->expects($this->once()) + ->method('getValue') + ->with(WorkflowType::CONFIG_NAME_PATH) + ->willReturn(WorkflowType::CLIENT_SIDE_COMPILATION); + $instanceMock = $this->getMockBuilder(DeveloperChainFactory::ENTITY_NAME) + ->disableOriginalConstructor() + ->getMock(); + $createArgs = [1, 2, 3]; + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with(DeveloperChainFactory::ENTITY_NAME, $createArgs) + ->willReturn($instanceMock); + $this->chainFactoryMock->expects($this->never())->method('create'); + + $this->assertSame($instanceMock, $this->model->create($createArgs)); + } + + public function testCreateNoClientCompilation() + { + $this->configMock->expects($this->once()) + ->method('getValue') + ->with(WorkflowType::CONFIG_NAME_PATH) + ->willReturn(''); + $instanceMock = $this->getMockBuilder(DeveloperChainFactory::ENTITY_NAME) + ->disableOriginalConstructor() + ->getMock(); + $createArgs = [1, 2, 3]; + $this->chainFactoryMock->expects($this->once()) + ->method('create') + ->with($createArgs) + ->willReturn($instanceMock); + $this->objectManagerMock->expects($this->never())->method('create'); + + $this->assertSame($instanceMock, $this->model->create($createArgs)); + } +} diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php new file mode 100644 index 0000000000000..2c315905a8532 --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php @@ -0,0 +1,89 @@ +getMockBuilder('Magento\Framework\View\Page\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->assetCollectionMock = $this->getMockBuilder('Magento\Framework\View\Asset\GroupedCollection') + ->disableOriginalConstructor() + ->getMock(); + $pageConfigMock->expects($this->once()) + ->method('getAssetCollection') + ->willReturn($this->assetCollectionMock); + $this->assetRepo = $this->getMockBuilder('Magento\Framework\View\Asset\Repository') + ->disableOriginalConstructor() + ->getMock(); + $overriddenMocks = [ + 'assetRepo' => $this->assetRepo, + 'pageConfig' => $pageConfigMock + ]; + + $mocks = $objectManager->getConstructArguments( + 'Magento\Developer\Model\View\Page\Config\ClientSideLessCompilation\Renderer', + $overriddenMocks + ); + $this->model = $this->getMock( + 'Magento\Developer\Model\View\Page\Config\ClientSideLessCompilation\Renderer', + ['renderAssetGroup'], + $mocks + ); + } + + /** + * Test calls renderAssets as a way to execute renderLessJsScripts code + */ + public function testRenderLessJsScripts() + { + // Stubs for renderAssets + $propertyGroups = [ + $this->getMockBuilder('Magento\Framework\View\Asset\PropertyGroup') + ->disableOriginalConstructor() + ->getMock() + ]; + $this->assetCollectionMock->expects($this->once())->method('getGroups')->willReturn($propertyGroups); + + // Stubs for renderLessJsScripts code + $lessConfigFile = $this->getMockBuilder('Magento\Framework\View\Asset\File') + ->disableOriginalConstructor() + ->getMock(); + $lessMinFile = $this->getMockBuilder('Magento\Framework\View\Asset\File') + ->disableOriginalConstructor() + ->getMock(); + $lessConfigUrl = 'less/config/url.css'; + $lessMinUrl = 'less/min/url.css'; + $lessConfigFile->expects($this->once())->method('getUrl')->willReturn($lessConfigUrl); + $lessMinFile->expects($this->once())->method('getUrl')->willReturn($lessMinUrl); + + $assetMap = [ + ['less/config.less.js', [], $lessConfigFile], + ['less/less.min.js', [], $lessMinFile] + ]; + $this->assetRepo->expects($this->exactly(2))->method('createAsset')->will($this->returnValueMap($assetMap)); + + $resultGroups = "\n\n"; + + // Call method + $this->assertSame($resultGroups, $this->model->renderAssets(['js' => ''])); + } +} diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php new file mode 100644 index 0000000000000..cd0679d318198 --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php @@ -0,0 +1,56 @@ +getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $configMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + + $rendererMock = $this->getMockBuilder('Magento\Framework\View\Page\Config\RendererInterface') + ->disableOriginalConstructor() + ->getMock(); + $createArgs = [1,2,3]; + $objectManagerMock->expects($this->once()) + ->method('create') + ->with(self::RENDERER_INSTANCE_NAME, $createArgs) + ->willReturn($rendererMock); + $configMock->expects($this->once()) + ->method('getValue') + ->with(WorkflowType::CONFIG_NAME_PATH, ScopeInterface::SCOPE_STORE) + ->willReturn(self::RENDERER_TYPE); + + // Set up System Under Test + $rendererTypes = [ + self::RENDERER_TYPE => self::RENDERER_INSTANCE_NAME + ]; + $sutArgs = [ + 'objectManager' => $objectManagerMock, + 'scopeConfig' => $configMock, + 'rendererTypes' => $rendererTypes + ]; + + $model = $objectManager->getObject('Magento\Developer\Model\View\Page\Config\RendererFactory', $sutArgs); + + // Test + $this->assertSame($rendererMock, $model->create($createArgs)); + } +} diff --git a/app/code/Magento/Developer/composer.json b/app/code/Magento/Developer/composer.json index 9522c13f257a4..cfb7ec9bb5bc3 100644 --- a/app/code/Magento/Developer/composer.json +++ b/app/code/Magento/Developer/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml index d793eb340a284..fce702c138268 100644 --- a/app/code/Magento/Developer/etc/di.xml +++ b/app/code/Magento/Developer/etc/di.xml @@ -28,6 +28,7 @@ Magento\Developer\Console\Command\DevTestsRunCommand Magento\Developer\Console\Command\CssDeployCommand + Magento\Developer\Console\Command\XmlConverterCommand diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index 63c970d557c09..669e3bb00acf3 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Directory/Model/Country.php b/app/code/Magento/Directory/Model/Country.php index 4da7c58e06f0a..65c1590086e70 100644 --- a/app/code/Magento/Directory/Model/Country.php +++ b/app/code/Magento/Directory/Model/Country.php @@ -73,6 +73,8 @@ protected function _construct() } /** + * Load country by code + * * @param string $code * @return $this */ @@ -83,6 +85,8 @@ public function loadByCode($code) } /** + * Get regions + * * @return \Magento\Directory\Model\Resource\Region\Collection */ public function getRegions() @@ -152,7 +156,7 @@ public function formatAddress(\Magento\Framework\Object $address, $html = false) } /** - * Retrieve formats for + * Retrieve country formats * * @return \Magento\Directory\Model\Resource\Country\Format\Collection */ @@ -172,7 +176,7 @@ public function getFormats() } /** - * Retrieve format + * Retrieve country format * * @param string $type * @return \Magento\Directory\Model\Country\Format|null @@ -190,6 +194,8 @@ public function getFormat($type) } /** + * Get country name + * * @return string */ public function getName() diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index 31ab3bf266dd2..bcab343e24002 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -123,6 +123,8 @@ public function getCode() } /** + * Get currency code + * * @return string */ public function getCurrencyCode() diff --git a/app/code/Magento/Directory/Model/Region.php b/app/code/Magento/Directory/Model/Region.php index 32b0f6e6134f0..1e401a7ce7456 100644 --- a/app/code/Magento/Directory/Model/Region.php +++ b/app/code/Magento/Directory/Model/Region.php @@ -48,6 +48,8 @@ public function getName() } /** + * Load region by code + * * @param string $code * @param string $countryId * @return $this @@ -61,6 +63,8 @@ public function loadByCode($code, $countryId) } /** + * Load region by name + * * @param string $name * @param string $countryId * @return $this diff --git a/app/code/Magento/Directory/Model/Resource/Country/Collection.php b/app/code/Magento/Directory/Model/Resource/Country/Collection.php index b35c86a727a60..c16496c3e14ca 100644 --- a/app/code/Magento/Directory/Model/Resource/Country/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Country/Collection.php @@ -224,6 +224,9 @@ public function toOptionArray($emptyLabel = ' ') if ($this->helperData->isRegionRequired($value)) { $option['is_region_required'] = true; } + if ($this->helperData->isZipCodeOptional($value)) { + $option['is_zipcode_optional'] = true; + } $options[] = $option; } diff --git a/app/code/Magento/Directory/Model/Resource/Region/Collection.php b/app/code/Magento/Directory/Model/Resource/Region/Collection.php index 6474d480eaaad..c41af5db80819 100644 --- a/app/code/Magento/Directory/Model/Resource/Region/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Region/Collection.php @@ -192,7 +192,10 @@ public function toOptionArray() ['title' => 'default_name', 'country_id' => 'country_id'] ); if (count($options) > 0) { - array_unshift($options, ['title ' => null, 'value' => null, 'label' => __('--Please select--')]); + array_unshift( + $options, + ['title ' => null, 'value' => null, 'label' => __('Please select region, state or province')] + ); } return $options; } diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index 28bc09fbf4493..67ecd0f8ad703 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.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Directory/etc/frontend/sections.xml b/app/code/Magento/Directory/etc/frontend/sections.xml new file mode 100644 index 0000000000000..2af7dde3b1a98 --- /dev/null +++ b/app/code/Magento/Directory/etc/frontend/sections.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php b/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php index 3a0d8053e4f8d..12b8458cecaec 100644 --- a/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php +++ b/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php @@ -7,31 +7,19 @@ use Magento\Downloadable\Api\Data\LinkInterface; +/** + * Interface LinkRepositoryInterface + * @package Magento\Downloadable\Api + */ interface LinkRepositoryInterface { - /** - * List of samples for downloadable product - * - * @param string $sku - * @return \Magento\Downloadable\Api\Data\SampleInterface[] - */ - public function getSamples($sku); - - /** - * List of samples for downloadable product - * - * @param \Magento\Catalog\Api\Data\ProductInterface $product - * @return \Magento\Downloadable\Api\Data\SampleInterface[] - */ - public function getSamplesByProduct(\Magento\Catalog\Api\Data\ProductInterface $product); - /** * List of links with associated samples * * @param string $sku * @return \Magento\Downloadable\Api\Data\LinkInterface[] */ - public function getLinks($sku); + public function getList($sku); /** * List of links with associated samples diff --git a/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php b/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php index 9a52cea8819f4..8aa184795bb3f 100644 --- a/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php +++ b/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php @@ -7,8 +7,28 @@ use Magento\Downloadable\Api\Data\SampleInterface; +/** + * Interface SampleRepositoryInterface + * @api + */ interface SampleRepositoryInterface { + /** + * List of samples for downloadable product + * + * @param string $sku + * @return \Magento\Downloadable\Api\Data\SampleInterface[] + */ + public function getList($sku); + + /** + * List of links with associated samples + * + * @param \Magento\Catalog\Api\Data\ProductInterface $product + * @return \Magento\Downloadable\Api\Data\SampleInterface[] + */ + public function getSamplesByProduct(\Magento\Catalog\Api\Data\ProductInterface $product); + /** * Update downloadable sample of the given product * diff --git a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php index 878f896575ae3..699e44fe150db 100644 --- a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php @@ -68,7 +68,10 @@ public function __construct( */ public function getLinks() { - return $this->_downloadProdConfig->getLinks($this->getItem()); + if (!$this->getItem()) { + return []; + } + return $this->_downloadableProductConfiguration->getLinks($this->getItem()); } /** @@ -78,6 +81,26 @@ public function getLinks() */ public function getLinksTitle() { - return $this->_downloadProdConfig->getLinksTitle($this->getProduct()); + return $this->_downloadableProductConfiguration->getLinksTitle($this->getProduct()); + } + + /** + * Get list of all options for product + * + * @return array + */ + public function getOptionList() + { + return $this->_downloadableProductConfiguration->getOptions($this->getItem()); + } + + /** + * Get list of all options for product + * @param \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item + * @return array + */ + public function getOption($item) + { + return $this->_downloadableProductConfiguration->getOptions($item); } } diff --git a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php index bfb80edb76793..3e8fb6d11aed2 100644 --- a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php +++ b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php @@ -50,7 +50,6 @@ public function __construct( $this->_linksFactory = $linksFactory; $this->_itemsFactory = $itemsFactory; parent::__construct($context, $data); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Downloadable/Controller/Customer/Products.php b/app/code/Magento/Downloadable/Controller/Customer/Products.php index 33c4360bb9fb5..7c1118713fd2f 100644 --- a/app/code/Magento/Downloadable/Controller/Customer/Products.php +++ b/app/code/Magento/Downloadable/Controller/Customer/Products.php @@ -52,7 +52,6 @@ public function dispatch(RequestInterface $request) public function execute() { $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($block = $this->_view->getLayout()->getBlock('downloadable_customer_products_list')) { $block->setRefererUrl($this->_redirect->getRefererUrl()); } diff --git a/app/code/Magento/Downloadable/Model/LinkRepository.php b/app/code/Magento/Downloadable/Model/LinkRepository.php index bca06682ba718..6f047f4b0a837 100644 --- a/app/code/Magento/Downloadable/Model/LinkRepository.php +++ b/app/code/Magento/Downloadable/Model/LinkRepository.php @@ -22,21 +22,11 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac */ protected $productRepository; - /** - * @var \Magento\Downloadable\Model\Product\Type - */ - protected $downloadableType; - /** * @var \Magento\Downloadable\Api\Data\LinkInterfaceFactory */ protected $linkDataObjectFactory; - /** - * @var \Magento\Downloadable\Api\Data\SampleInterfaceFactory - */ - protected $sampleDataObjectFactory; - /** * @var \Magento\Downloadable\Model\LinkFactory */ @@ -61,7 +51,6 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Downloadable\Model\Product\Type $downloadableType * @param \Magento\Downloadable\Api\Data\LinkInterfaceFactory $linkDataObjectFactory - * @param \Magento\Downloadable\Api\Data\SampleInterfaceFactory $sampleDataObjectFactory * @param LinkFactory $linkFactory * @param Link\ContentValidator $contentValidator * @param EncoderInterface $jsonEncoder @@ -71,7 +60,6 @@ public function __construct( \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Downloadable\Model\Product\Type $downloadableType, \Magento\Downloadable\Api\Data\LinkInterfaceFactory $linkDataObjectFactory, - \Magento\Downloadable\Api\Data\SampleInterfaceFactory $sampleDataObjectFactory, LinkFactory $linkFactory, Link\ContentValidator $contentValidator, EncoderInterface $jsonEncoder, @@ -80,7 +68,6 @@ public function __construct( $this->productRepository = $productRepository; $this->downloadableType = $downloadableType; $this->linkDataObjectFactory = $linkDataObjectFactory; - $this->sampleDataObjectFactory = $sampleDataObjectFactory; $this->linkFactory = $linkFactory; $this->contentValidator = $contentValidator; $this->jsonEncoder = $jsonEncoder; @@ -90,7 +77,7 @@ public function __construct( /** * {@inheritdoc} */ - public function getLinks($sku) + public function getList($sku) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->productRepository->get($sku); @@ -134,10 +121,10 @@ protected function buildLink($resourceData) } /** - * Subroutine for buildLink and buildSample + * Subroutine for build link * - * @param \Magento\Downloadable\Model\Link|\Magento\Downloadable\Model\Sample $resourceData - * @param \Magento\Downloadable\Api\Data\LinkInterface|\Magento\Downloadable\Api\Data\SampleInterface $dataObject + * @param \Magento\Downloadable\Model\Link $resourceData + * @param \Magento\Downloadable\Api\Data\LinkInterface $dataObject * @return null */ protected function setBasicFields($resourceData, $dataObject) @@ -156,43 +143,6 @@ protected function setBasicFields($resourceData, $dataObject) $dataObject->setSampleUrl($resourceData->getSampleUrl()); } - /** - * {@inheritdoc} - */ - public function getSamples($sku) - { - $product = $this->productRepository->get($sku); - return $this->getSamplesByProduct($product); - } - - /** - * @param \Magento\Catalog\Api\Data\ProductInterface $product - * @return array - */ - public function getSamplesByProduct(\Magento\Catalog\Api\Data\ProductInterface $product) - { - $sampleList = []; - $samples = $this->downloadableType->getSamples($product); - /** @var \Magento\Downloadable\Model\Sample $sample */ - foreach ($samples as $sample) { - $sampleList[] = $this->buildSample($sample); - } - return $sampleList; - } - - /** - * Build a sample data object - * - * @param \Magento\Downloadable\Model\Sample $resourceData - * @return \Magento\Downloadable\Model\Sample - */ - protected function buildSample($resourceData) - { - $sample = $this->sampleDataObjectFactory->create(); - $this->setBasicFields($resourceData, $sample); - return $sample; - } - /** * {@inheritdoc} * @SuppressWarnings(PHPMD.CyclomaticComplexity) diff --git a/app/code/Magento/Downloadable/Model/Plugin/AfterProductLoad.php b/app/code/Magento/Downloadable/Model/Plugin/AfterProductLoad.php index 83466a0fa080f..d8af61297efab 100644 --- a/app/code/Magento/Downloadable/Model/Plugin/AfterProductLoad.php +++ b/app/code/Magento/Downloadable/Model/Plugin/AfterProductLoad.php @@ -14,6 +14,11 @@ class AfterProductLoad */ protected $linkRepository; + /** + * @var \Magento\Downloadable\Api\SampleRepositoryInterface + */ + protected $sampleRepository; + /** * @var \Magento\Catalog\Api\Data\ProductExtensionFactory */ @@ -21,13 +26,16 @@ class AfterProductLoad /** * @param \Magento\Downloadable\Api\LinkRepositoryInterface $linkRepository + * @param \Magento\Downloadable\Api\SampleRepositoryInterface $sampleRepository * @param \Magento\Catalog\Api\Data\ProductExtensionFactory $productExtensionFactory */ public function __construct( \Magento\Downloadable\Api\LinkRepositoryInterface $linkRepository, + \Magento\Downloadable\Api\SampleRepositoryInterface $sampleRepository, \Magento\Catalog\Api\Data\ProductExtensionFactory $productExtensionFactory ) { $this->linkRepository = $linkRepository; + $this->sampleRepository = $sampleRepository; $this->productExtensionFactory = $productExtensionFactory; } @@ -41,16 +49,13 @@ public function afterLoad( if ($product->getTypeId() != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { return $product; } - - $productExtension = $product->getExtensionAttributes(); - if ($productExtension === null) { - $productExtension = $this->productExtensionFactory->create(); - } + $productExtension = $product->getExtensionAttributes() + ?: $this->productExtensionFactory->create(); $links = $this->linkRepository->getLinksByProduct($product); if ($links !== null) { $productExtension->setDownloadableProductLinks($links); } - $samples = $this->linkRepository->getSamplesByProduct($product); + $samples = $this->sampleRepository->getSamplesByProduct($product); if ($samples !== null) { $productExtension->setDownloadableProductSamples($samples); } diff --git a/app/code/Magento/Downloadable/Model/SampleRepository.php b/app/code/Magento/Downloadable/Model/SampleRepository.php index f357e6a5d8541..71d76e05f40a7 100644 --- a/app/code/Magento/Downloadable/Model/SampleRepository.php +++ b/app/code/Magento/Downloadable/Model/SampleRepository.php @@ -6,7 +6,8 @@ namespace Magento\Downloadable\Model; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Downloadable\Model\SampleFactory; +use Magento\Downloadable\Api\Data\SampleInterfaceFactory; +use Magento\Downloadable\Model\Product\Type; use Magento\Downloadable\Api\Data\File\ContentUploaderInterface; use Magento\Downloadable\Api\Data\SampleInterface; use Magento\Downloadable\Model\Sample\ContentValidator; @@ -16,7 +17,6 @@ /** * Class SampleRepository - * @package Magento\Downloadable\Model * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInterface @@ -27,14 +27,19 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte protected $productRepository; /** - * @var \Magento\Downloadable\Model\Product\Type + * @var ContentValidator + */ + protected $contentValidator; + + /** + * @var Type */ protected $downloadableType; /** - * @var ContentValidator + * @var SampleInterfaceFactory */ - protected $contentValidator; + protected $sampleDataObjectFactory; /** * @var ContentUploaderInterface @@ -48,7 +53,8 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte /** * @param ProductRepositoryInterface $productRepository - * @param \Magento\Downloadable\Model\Product\Type $downloadableType + * @param Type $downloadableType + * @param SampleInterfaceFactory $sampleDataObjectFactory * @param ContentValidator $contentValidator * @param ContentUploaderInterface $fileContentUploader * @param EncoderInterface $jsonEncoder @@ -56,7 +62,8 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte */ public function __construct( ProductRepositoryInterface $productRepository, - \Magento\Downloadable\Model\Product\Type $downloadableType, + Type $downloadableType, + SampleInterfaceFactory $sampleDataObjectFactory, ContentValidator $contentValidator, ContentUploaderInterface $fileContentUploader, EncoderInterface $jsonEncoder, @@ -68,6 +75,71 @@ public function __construct( $this->fileContentUploader = $fileContentUploader; $this->jsonEncoder = $jsonEncoder; $this->sampleFactory = $sampleFactory; + $this->downloadableType = $downloadableType; + $this->sampleDataObjectFactory = $sampleDataObjectFactory; + } + + /** + * {@inheritdoc} + */ + public function getList($sku) + { + /** @var \Magento\Catalog\Model\Product $product */ + $product = $this->productRepository->get($sku); + return $this->getSamplesByProduct($product); + } + + /** + * Build a sample data object + * + * @param \Magento\Downloadable\Model\Sample $resourceData + * @return \Magento\Downloadable\Model\Sample + */ + protected function buildSample($resourceData) + { + $sample = $this->sampleDataObjectFactory->create(); + $this->setBasicFields($resourceData, $sample); + return $sample; + } + + /** + * Subroutine for buildLink and buildSample + * + * @param \Magento\Downloadable\Model\Link|\Magento\Downloadable\Model\Sample $resourceData + * @param \Magento\Downloadable\Api\Data\LinkInterface|\Magento\Downloadable\Api\Data\SampleInterface $dataObject + * @return null + */ + protected function setBasicFields($resourceData, $dataObject) + { + $dataObject->setId($resourceData->getId()); + $storeTitle = $resourceData->getStoreTitle(); + $title = $resourceData->getTitle(); + if (!empty($storeTitle)) { + $dataObject->setTitle($storeTitle); + } else { + $dataObject->setTitle($title); + } + $dataObject->setSortOrder($resourceData->getSortOrder()); + $dataObject->setSampleType($resourceData->getSampleType()); + $dataObject->setSampleFile($resourceData->getSampleFile()); + $dataObject->setSampleUrl($resourceData->getSampleUrl()); + } + + /** + * List of links with associated samples + * + * @param \Magento\Catalog\Api\Data\ProductInterface $product + * @return \Magento\Downloadable\Api\Data\SampleInterface[] + */ + public function getSamplesByProduct(\Magento\Catalog\Api\Data\ProductInterface $product) + { + $sampleList = []; + $samples = $this->downloadableType->getSamples($product); + /** @var \Magento\Downloadable\Model\Sample $sample */ + foreach ($samples as $sample) { + $sampleList[] = $this->buildSample($sample); + } + return $sampleList; } /** @@ -77,7 +149,6 @@ public function __construct( * @param \Magento\Downloadable\Api\Data\SampleInterface $sample * @param bool $isGlobalScopeContent * @return int - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function save( $sku, @@ -90,7 +161,7 @@ public function save( if ($sampleId) { return $this->updateSample($product, $sample, $isGlobalScopeContent); } else { - if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { + if ($product->getTypeId() !== Type::TYPE_DOWNLOADABLE) { throw new InputException(__('Product type of the product must be \'downloadable\'.')); } if (!$this->contentValidator->isValid($sample)) { diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php index d4ec184847edc..e030603fd6f3a 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php @@ -49,10 +49,6 @@ class LinkRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $linkDataObjectFactory; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $sampleDataObjectFactory; /** * @var LinkRepository @@ -119,7 +115,6 @@ protected function setUp() $this->repositoryMock, $this->productTypeMock, $this->linkDataObjectFactory, - $this->sampleDataObjectFactory, $this->linkFactoryMock, $this->contentValidatorMock, $this->jsonEncoderMock, @@ -487,7 +482,7 @@ public function testDeleteThrowsExceptionIfLinkIdIsNotValid() $this->service->delete($linkId); } - public function testGetLinks() + public function testGetList() { $productSku = 'downloadable_sku'; @@ -540,58 +535,7 @@ public function testGetLinks() $this->setLinkAssertions($linkMock, $linkData); $this->linkDataObjectFactory->expects($this->once())->method('create')->willReturn($linkInterfaceMock); - $this->assertEquals([$linkInterfaceMock], $this->service->getLinks($productSku)); - } - - public function testGetSamples() - { - $productSku = 'downloadable_sku'; - - $sampleData = [ - 'id' => 324, - 'store_title' => 'rock melody sample', - 'title' => 'just melody sample', - 'sort_order' => 21, - 'sample_type' => 'file', - 'sample_url' => null, - 'sample_file' => '/r/o/rock.melody.ogg' - ]; - - $sampleMock = $this->getMock( - '\Magento\Downloadable\Model\Sample', - [ - 'getId', - 'getStoreTitle', - 'getTitle', - 'getSampleType', - 'getSampleFile', - 'getSampleUrl', - 'getSortOrder', - 'getData', - '__wakeup' - ], - [], - '', - false - ); - - $sampleInterfaceMock = $this->getMock('\Magento\Downloadable\Api\Data\SampleInterface'); - - $this->repositoryMock->expects($this->once()) - ->method('get') - ->with($productSku) - ->will($this->returnValue($this->productMock)); - - $this->productTypeMock->expects($this->once()) - ->method('getSamples') - ->with($this->productMock) - ->will($this->returnValue([$sampleMock])); - - $this->setSampleAssertions($sampleMock, $sampleData); - - $this->sampleDataObjectFactory->expects($this->once())->method('create')->willReturn($sampleInterfaceMock); - - $this->assertEquals([$sampleInterfaceMock], $this->service->getSamples($productSku)); + $this->assertEquals([$linkInterfaceMock], $this->service->getList($productSku)); } protected function setLinkAssertions($resource, $inputData) @@ -622,21 +566,4 @@ protected function setLinkAssertions($resource, $inputData) $resource->expects($this->any())->method('getLinkUrl') ->will($this->returnValue($inputData['link_url'])); } - - protected function setSampleAssertions($resource, $inputData) - { - $resource->expects($this->any())->method('getId')->will($this->returnValue($inputData['id'])); - $resource->expects($this->any())->method('getStoreTitle') - ->will($this->returnValue($inputData['store_title'])); - $resource->expects($this->any())->method('getTitle') - ->will($this->returnValue($inputData['title'])); - $resource->expects($this->any())->method('getSortOrder') - ->will($this->returnValue($inputData['sort_order'])); - $resource->expects($this->any())->method('getSampleType') - ->will($this->returnValue($inputData['sample_type'])); - $resource->expects($this->any())->method('getSampleFile') - ->will($this->returnValue($inputData['sample_file'])); - $resource->expects($this->any())->method('getSampleUrl') - ->will($this->returnValue($inputData['sample_url'])); - } } diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Plugin/AfterProductLoadTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Plugin/AfterProductLoadTest.php index 36f21e6fb5f28..3ddb4ad86405f 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Plugin/AfterProductLoadTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Plugin/AfterProductLoadTest.php @@ -36,20 +36,28 @@ class AfterProductLoadTest extends \PHPUnit_Framework_TestCase */ protected $productExtensionFactory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sampleRepositoryMock; + protected function setUp() { $this->linkRepositoryMock = $this->getMock('\Magento\Downloadable\Api\LinkRepositoryInterface'); + $this->sampleRepositoryMock = $this->getMock('Magento\Downloadable\Api\SampleRepositoryInterface'); $this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory') + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->model = new \Magento\Downloadable\Model\Plugin\AfterProductLoad( $this->linkRepositoryMock, + $this->sampleRepositoryMock, $this->productExtensionFactory ); - $this->productMock = $this->getMockBuilder('\Magento\Catalog\Model\Product') + $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') ->disableOriginalConstructor() ->getMock(); - $this->productExtensionMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtension') + $this->productExtensionMock = $this->getMockBuilder('Magento\Catalog\Api\Data\ProductExtension') ->setMethods(['setDownloadableProductLinks', 'setDownloadableProductSamples'])->getMock(); } @@ -63,13 +71,13 @@ public function testAfterLoad() ->method('create') ->willReturn($this->productExtensionMock); - $linkMock = $this->getMock('\Magento\Downloadable\Api\Data\LinkInterface'); + $linkMock = $this->getMock('Magento\Downloadable\Api\Data\LinkInterface'); $this->linkRepositoryMock->expects($this->once()) ->method('getLinksByProduct') ->with($this->productMock) ->willReturn([$linkMock]); - $sampleMock = $this->getMock('\Magento\Downloadable\Api\Data\SampleInterface'); - $this->linkRepositoryMock->expects($this->once()) + $sampleMock = $this->getMock('Magento\Downloadable\Api\Data\SampleInterface'); + $this->sampleRepositoryMock->expects($this->once()) ->method('getSamplesByProduct') ->with($this->productMock) ->willReturn([$sampleMock]); @@ -104,13 +112,13 @@ public function testAfterLoadWithExistingExtensionAttributes() $this->productExtensionFactory->expects($this->never()) ->method('create'); - $linkMock = $this->getMock('\Magento\Downloadable\Api\Data\LinkInterface'); + $linkMock = $this->getMock('Magento\Downloadable\Api\Data\LinkInterface'); $this->linkRepositoryMock->expects($this->once()) ->method('getLinksByProduct') ->with($this->productMock) ->willReturn([$linkMock]); - $sampleMock = $this->getMock('\Magento\Downloadable\Api\Data\SampleInterface'); - $this->linkRepositoryMock->expects($this->once()) + $sampleMock = $this->getMock('Magento\Downloadable\Api\Data\SampleInterface'); + $this->sampleRepositoryMock->expects($this->once()) ->method('getSamplesByProduct') ->with($this->productMock) ->willReturn([$sampleMock]); @@ -143,12 +151,12 @@ public function testAfterLoadOnlyLinks() ->method('create') ->willReturn($this->productExtensionMock); - $linkMock = $this->getMock('\Magento\Downloadable\Api\Data\LinkInterface'); + $linkMock = $this->getMock('Magento\Downloadable\Api\Data\LinkInterface'); $this->linkRepositoryMock->expects($this->once()) ->method('getLinksByProduct') ->with($this->productMock) ->willReturn([$linkMock]); - $this->linkRepositoryMock->expects($this->once()) + $this->sampleRepositoryMock->expects($this->once()) ->method('getSamplesByProduct') ->with($this->productMock) ->willReturn(null); @@ -183,8 +191,8 @@ public function testAfterLoadOnlySamples() ->method('getLinksByProduct') ->with($this->productMock) ->willReturn(null); - $sampleMock = $this->getMock('\Magento\Downloadable\Api\Data\SampleInterface'); - $this->linkRepositoryMock->expects($this->once()) + $sampleMock = $this->getMock('Magento\Downloadable\Api\Data\SampleInterface'); + $this->sampleRepositoryMock->expects($this->once()) ->method('getSamplesByProduct') ->with($this->productMock) ->willReturn([$sampleMock]); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php index 7e25af50c3f6b..672599aa0e770 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php @@ -50,6 +50,11 @@ class SampleRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $service; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sampleDataObjectFactory; + protected function setUp() { $this->productMock = $this->getMock( @@ -81,10 +86,23 @@ protected function setUp() '', false ); + $this->productTypeMock = $this->getMockBuilder('\Magento\Downloadable\Model\Product\Type') + ->disableOriginalConstructor() + ->getMock(); + $this->sampleDataObjectFactory = $this->getMockBuilder('\Magento\Downloadable\Api\Data\SampleInterfaceFactory') + ->setMethods( + [ + 'create', + ] + ) + ->disableOriginalConstructor() + ->getMock(); + $this->service = new \Magento\Downloadable\Model\SampleRepository( $this->repositoryMock, $this->productTypeMock, + $this->sampleDataObjectFactory, $this->contentValidatorMock, $this->contentUploaderMock, $this->jsonEncoderMock, @@ -371,4 +389,77 @@ public function testDeleteThrowsExceptionIfSampleIdIsNotValid() $this->service->delete($sampleId); } + + + public function testGetList() + { + $productSku = 'downloadable_sku'; + + $sampleData = [ + 'id' => 324, + 'store_title' => 'rock melody sample', + 'title' => 'just melody sample', + 'sort_order' => 21, + 'sample_type' => 'file', + 'sample_url' => null, + 'sample_file' => '/r/o/rock.melody.ogg' + ]; + + $sampleMock = $this->getMock( + '\Magento\Downloadable\Model\Sample', + [ + 'getId', + 'getStoreTitle', + 'getTitle', + 'getSampleType', + 'getSampleFile', + 'getSampleUrl', + 'getSortOrder', + 'getData', + '__wakeup' + ], + [], + '', + false + ); + + $sampleInterfaceMock = $this->getMock('\Magento\Downloadable\Api\Data\SampleInterface'); + + $this->repositoryMock->expects($this->once()) + ->method('get') + ->with($productSku) + ->will($this->returnValue($this->productMock)); + + $this->productTypeMock->expects($this->once()) + ->method('getSamples') + ->with($this->productMock) + ->will($this->returnValue([$sampleMock])); + + $this->setSampleAssertions($sampleMock, $sampleData); + + $this->sampleDataObjectFactory->expects($this->once())->method('create')->willReturn($sampleInterfaceMock); + + $this->assertEquals([$sampleInterfaceMock], $this->service->getList($productSku)); + } + + /** + * @param $resource + * @param $inputData + */ + protected function setSampleAssertions($resource, $inputData) + { + $resource->expects($this->any())->method('getId')->will($this->returnValue($inputData['id'])); + $resource->expects($this->any())->method('getStoreTitle') + ->will($this->returnValue($inputData['store_title'])); + $resource->expects($this->any())->method('getTitle') + ->will($this->returnValue($inputData['title'])); + $resource->expects($this->any())->method('getSortOrder') + ->will($this->returnValue($inputData['sort_order'])); + $resource->expects($this->any())->method('getSampleType') + ->will($this->returnValue($inputData['sample_type'])); + $resource->expects($this->any())->method('getSampleFile') + ->will($this->returnValue($inputData['sample_file'])); + $resource->expects($this->any())->method('getSampleUrl') + ->will($this->returnValue($inputData['sample_url'])); + } } diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index eb211bd458be9..885adac58def9 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-wishlist": "0.74.0-beta9", - "magento/module-gift-message": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-msrp": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-wishlist": "0.74.0-beta11", + "magento/module-gift-message": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-msrp": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Downloadable/etc/frontend/di.xml b/app/code/Magento/Downloadable/etc/frontend/di.xml index 18f35c2987fcd..71ef98a6f3476 100644 --- a/app/code/Magento/Downloadable/etc/frontend/di.xml +++ b/app/code/Magento/Downloadable/etc/frontend/di.xml @@ -14,4 +14,11 @@ + + + + Magento\Downloadable\Helper\Catalog\Product\Configuration + + + diff --git a/app/code/Magento/Downloadable/etc/frontend/events.xml b/app/code/Magento/Downloadable/etc/frontend/events.xml index 774a2f574da76..ac54f059a3749 100644 --- a/app/code/Magento/Downloadable/etc/frontend/events.xml +++ b/app/code/Magento/Downloadable/etc/frontend/events.xml @@ -12,7 +12,7 @@ - + diff --git a/app/code/Magento/Downloadable/etc/webapi.xml b/app/code/Magento/Downloadable/etc/webapi.xml index 7f597119f9e74..4b1f86ead0eaa 100644 --- a/app/code/Magento/Downloadable/etc/webapi.xml +++ b/app/code/Magento/Downloadable/etc/webapi.xml @@ -8,13 +8,13 @@ - + - + diff --git a/app/code/Magento/Downloadable/etc/webapi_rest/di.xml b/app/code/Magento/Downloadable/etc/webapi_rest/di.xml new file mode 100644 index 0000000000000..489aed0bf3f01 --- /dev/null +++ b/app/code/Magento/Downloadable/etc/webapi_rest/di.xml @@ -0,0 +1,16 @@ + + + + + + + Magento\Downloadable\Helper\Catalog\Product\Configuration + + + + diff --git a/app/code/Magento/Downloadable/etc/webapi_soap/di.xml b/app/code/Magento/Downloadable/etc/webapi_soap/di.xml new file mode 100644 index 0000000000000..489aed0bf3f01 --- /dev/null +++ b/app/code/Magento/Downloadable/etc/webapi_soap/di.xml @@ -0,0 +1,16 @@ + + + + + + + Magento\Downloadable\Helper\Catalog\Product\Configuration + + + + diff --git a/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml index c30585da4f2d7..7a152eff590fc 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml @@ -11,7 +11,7 @@ - + diff --git a/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml deleted file mode 100644 index f7191a8e7250f..0000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/Downloadable/view/frontend/layout/downloadable_customer_products.xml b/app/code/Magento/Downloadable/view/frontend/layout/downloadable_customer_products.xml index d0e2704cf388d..a4715c36a4184 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/downloadable_customer_products.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/downloadable_customer_products.xml @@ -9,7 +9,7 @@ - + diff --git a/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php b/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php index 9519950004b42..4edcecdb0fff9 100644 --- a/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php +++ b/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php @@ -6,6 +6,10 @@ */ namespace Magento\Eav\Api; +/** + * Interface AttributeGroupRepositoryInterface + * @api + */ interface AttributeGroupRepositoryInterface { /** diff --git a/app/code/Magento/Eav/Api/AttributeManagementInterface.php b/app/code/Magento/Eav/Api/AttributeManagementInterface.php index d311c8fdbceef..07e2474c54f56 100644 --- a/app/code/Magento/Eav/Api/AttributeManagementInterface.php +++ b/app/code/Magento/Eav/Api/AttributeManagementInterface.php @@ -6,6 +6,10 @@ */ namespace Magento\Eav\Api; +/** + * Interface AttributeManagementInterface + * @api + */ interface AttributeManagementInterface { /** diff --git a/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php b/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php index f7eae770ac527..d8b306cca79e4 100644 --- a/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php +++ b/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php @@ -7,6 +7,7 @@ /** * Interface AttributeOptionManagementInterface + * @api */ interface AttributeOptionManagementInterface { diff --git a/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php b/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php index 2cfca10832ee0..ebf0c4b784ddc 100644 --- a/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php +++ b/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php @@ -6,6 +6,10 @@ */ namespace Magento\Eav\Api; +/** + * Interface AttributeRepositoryInterface + * @api + */ interface AttributeRepositoryInterface { /** diff --git a/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php b/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php index 23b34f148b443..102fcb2c6cbb3 100644 --- a/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php +++ b/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php @@ -6,6 +6,10 @@ */ namespace Magento\Eav\Api; +/** + * Interface AttributeSetManagementInterface + * @api + */ interface AttributeSetManagementInterface { /** diff --git a/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php b/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php index 986cbcbc03b28..323ddc2fd6ea6 100644 --- a/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php +++ b/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php @@ -6,6 +6,10 @@ */ namespace Magento\Eav\Api; +/** + * Interface AttributeSetRepositoryInterface + * @api + */ interface AttributeSetRepositoryInterface { /** diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php index 597b4f563dd27..0bff79e95a10f 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php @@ -32,9 +32,9 @@ abstract class AbstractMain extends \Magento\Backend\Block\Widget\Form\Generic protected $_eavData = null; /** - * @var \Magento\Eav\Model\Entity\Attribute\Config + * @var \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker */ - protected $_attributeConfig; + protected $propertyLocker; /** * @var \Magento\Config\Model\Config\Source\YesnoFactory @@ -53,7 +53,7 @@ abstract class AbstractMain extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Eav\Helper\Data $eavData * @param \Magento\Config\Model\Config\Source\YesnoFactory $yesnoFactory * @param \Magento\Eav\Model\Adminhtml\System\Config\Source\InputtypeFactory $inputTypeFactory - * @param \Magento\Eav\Model\Entity\Attribute\Config $attributeConfig + * @param \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker $propertyLocker * @param array $data */ public function __construct( @@ -63,13 +63,13 @@ public function __construct( \Magento\Eav\Helper\Data $eavData, \Magento\Config\Model\Config\Source\YesnoFactory $yesnoFactory, \Magento\Eav\Model\Adminhtml\System\Config\Source\InputtypeFactory $inputTypeFactory, - \Magento\Eav\Model\Entity\Attribute\Config $attributeConfig, + \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker $propertyLocker, array $data = [] ) { $this->_eavData = $eavData; $this->_yesnoFactory = $yesnoFactory; $this->_inputTypeFactory = $inputTypeFactory; - $this->_attributeConfig = $attributeConfig; + $this->propertyLocker = $propertyLocker; parent::__construct($context, $registry, $formFactory, $data); } @@ -257,6 +257,7 @@ protected function _prepareForm() } } + $this->propertyLocker->lock($form); $this->setForm($form); return parent::_prepareForm(); @@ -277,27 +278,6 @@ protected function _initFormValues() return parent::_initFormValues(); } - /** - * This method is called before rendering HTML - * - * @return $this - */ - protected function _beforeToHtml() - { - parent::_beforeToHtml(); - $attributeObject = $this->getAttributeObject(); - if ($attributeObject->getId()) { - $form = $this->getForm(); - foreach ($this->_attributeConfig->getLockedFields($attributeObject) as $field) { - if ($element = $form->getElement($field)) { - $element->setDisabled(1); - $element->setReadonly(1); - } - } - } - return $this; - } - /** * Processing block html after rendering * Adding js block to the end of this block diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/PropertyLocker.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/PropertyLocker.php new file mode 100644 index 0000000000000..ccaab44afee61 --- /dev/null +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/PropertyLocker.php @@ -0,0 +1,57 @@ + + */ +class PropertyLocker +{ + /** + * @var Config + */ + private $attributeConfig; + + /** + * @var Registry + */ + protected $registry; + + /** + * @param Registry $registry + * @param Config $attributeConfig + */ + public function __construct( + Registry $registry, + Config $attributeConfig + ) { + $this->registry = $registry; + $this->attributeConfig = $attributeConfig; + } + + /** + * @param \Magento\Framework\Data\Form $form + * @return void + */ + public function lock(\Magento\Framework\Data\Form $form) + { + /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attributeObject */ + $attributeObject = $this->registry->registry('entity_attribute'); + if ($attributeObject->getId()) { + foreach ($this->attributeConfig->getLockedFields($attributeObject) as $field) { + if ($element = $form->getElement($field)) { + $element->setDisabled(1); + $element->setReadonly(1); + } + } + } + } +} diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Image.php b/app/code/Magento/Eav/Model/Attribute/Data/Image.php index 4110ddba02cf4..67bfa7294b284 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Image.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Image.php @@ -28,10 +28,6 @@ protected function _validateByRules($value) $imageProp = @getimagesize($value['tmp_name']); - if (!is_uploaded_file($value['tmp_name']) || !$imageProp) { - return [__('"%1" is not a valid file', $label)]; - } - $allowImageTypes = [1 => 'gif', 2 => 'jpg', 3 => 'png']; if (!isset($allowImageTypes[$imageProp[2]])) { diff --git a/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php b/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php index ef78fbcde2310..2a5063d0d00c3 100644 --- a/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php +++ b/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php @@ -20,6 +20,11 @@ class EavCustomAttributeTypeLocator implements CustomAttributeTypeLocatorInterfa */ private $attributeRepository; + /** + * @var \Magento\Framework\Stdlib\String + */ + private $stringUtility; + /** * @var array */ @@ -33,15 +38,16 @@ class EavCustomAttributeTypeLocator implements CustomAttributeTypeLocatorInterfa /** * Initialize EavCustomAttributeTypeLocator * - * @param AttributeRepositoryInterface $attributeRepository - * @param array $serviceEntityTypeMap + * @param AttributeRepositoryInterface $attributeRepository Attribute repository service + * @param \Magento\Framework\Stdlib\String $stringUtility + * @param array $serviceEntityTypeMap Service Entity Map *
          * [
          *      'ServiceInterfaceA' => 'EavEntityType1',
          *      'ServiceInterfaceB' => 'EavEntityType2'
          * ]
          * 
    - * @param array $serviceBackendModelDataInterfaceMap + * @param array $serviceBackendModelDataInterfaceMap Backend Model and DataInterface map for a service *
          * [
          *      'ServiceInterfaceA' => ['BackendType1' => 'ServiceDataInterface1'],
    @@ -54,16 +60,19 @@ class EavCustomAttributeTypeLocator implements CustomAttributeTypeLocatorInterfa
          */
         public function __construct(
             AttributeRepositoryInterface $attributeRepository,
    +        \Magento\Framework\Stdlib\String $stringUtility,
             array $serviceEntityTypeMap = [],
             array $serviceBackendModelDataInterfaceMap = []
         ) {
             $this->attributeRepository = $attributeRepository;
    +        $this->stringUtility = $stringUtility;
             $this->serviceEntityTypeMap = $serviceEntityTypeMap;
             $this->serviceBackendModelDataInterfaceMap = $serviceBackendModelDataInterfaceMap;
         }
     
         /**
          * {@inheritdoc}
    +     * @SuppressWarnings(PHPMD.NPathComplexity)
          */
         public function getType($attributeCode, $serviceClass)
         {
    @@ -74,13 +83,21 @@ public function getType($attributeCode, $serviceClass)
             }
     
             try {
    -            $backendModel = $this->attributeRepository
    -                ->get($this->serviceEntityTypeMap[$serviceClass], $attributeCode)
    -                ->getBackendModel();
    +            $attribute = $this->attributeRepository->get($this->serviceEntityTypeMap[$serviceClass], $attributeCode);
    +            $backendModel = $attribute->getBackendModel();
             } catch (NoSuchEntityException $e) {
                 return null;
             }
     
    +        //If empty backend model, check if it can be derived
    +        if (empty($backendModel)) {
    +            $backendModelClass = sprintf(
    +                'Magento\Eav\Model\Attribute\Data\%s',
    +                $this->stringUtility->upperCaseWords($attribute->getFrontendInput())
    +            );
    +            $backendModel = class_exists($backendModelClass) ? $backendModelClass : null;
    +        }
    +
             $dataInterface = isset($this->serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel])
                 ? $this->serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel]
                 : null;
    diff --git a/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php b/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php
    new file mode 100644
    index 0000000000000..cf0615c42a7d0
    --- /dev/null
    +++ b/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php
    @@ -0,0 +1,71 @@
    +attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute')
    +            ->setMethods(['getId'])
    +            ->disableOriginalConstructor()
    +            ->getMock();
    +
    +        $registryMock = $this->getMockBuilder('\Magento\Framework\Registry')
    +            ->setMethods(['registry'])
    +            ->disableOriginalConstructor()
    +            ->getMock();
    +        $registryMock->expects($this->atLeastOnce())->method('registry')->willReturn($this->attributeMock);
    +
    +        $this->attributeConfigMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Config')
    +            ->setMethods(['getLockedFields'])
    +            ->disableOriginalConstructor()
    +            ->getMock();
    +
    +        $this->formMock = $this->getMockBuilder('Magento\Framework\Data\Form')
    +            ->setMethods(['getElement'])
    +            ->disableOriginalConstructor()
    +            ->getMock();
    +
    +        $this->object = new PropertyLocker($registryMock, $this->attributeConfigMock);
    +    }
    +
    +    /**
    +     * @covers \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker::lock
    +     */
    +    public function testLock()
    +    {
    +        $lockedFields = [
    +            'is_searchable' => 'is_searchable',
    +            'is_filterable' => 'is_filterable'
    +        ];
    +        $this->attributeMock->expects($this->once())->method('getId')->willReturn(1);
    +        $this->attributeConfigMock->expects($this->once())->method('getLockedFields')->willReturn($lockedFields);
    +
    +        $elementMock = $this->getMockBuilder('\Magento\Framework\Data\Form\Element\AbstractElement')
    +            ->setMethods(['setDisabled', 'setReadonly'])
    +            ->disableOriginalConstructor()
    +            ->getMockForAbstractClass();
    +        $elementMock->expects($this->exactly(2))->method('setDisabled');
    +        $elementMock->expects($this->exactly(2))->method('setReadonly');
    +        $this->formMock->expects($this->exactly(2))->method('getElement')->willReturn($elementMock);
    +        $this->object->lock($this->formMock);
    +    }
    +}
    diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
    index 41dc92df72f0f..a429c5323e09d 100644
    --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
    +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
    @@ -183,7 +183,7 @@ public function testSaveThrowExceptionIfCannotSaveGroup()
         {
             $attributeSetId = 42;
             $groupId = 20;
    -        $groupMock = $this->getMock('\Magento\Eav\Api\Data\AttributeGroupInterface');
    +        $groupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
             $existingGroupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
             $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface');
             $groupMock->expects($this->any())->method('getAttributeSetId')->willReturn($attributeSetId);
    @@ -195,6 +195,9 @@ public function testSaveThrowExceptionIfCannotSaveGroup()
             $this->groupResourceMock->expects($this->once())->method('load')->with($existingGroupMock, $groupId);
             $existingGroupMock->expects($this->any())->method('getId')->willReturn($groupId);
             $existingGroupMock->expects($this->once())->method('getAttributeSetId')->willReturn($attributeSetId);
    +        $this->groupResourceMock->expects($this->once())
    +            ->method('save')
    +            ->will($this->throwException(new \Exception()));
             $this->model->save($groupMock);
         }
     
    @@ -211,7 +214,7 @@ public function testSaveThrowExceptionIfGroupDoesNotBelongToProvidedSet()
         {
             $attributeSetId = 42;
             $groupId = 20;
    -        $groupMock = $this->getMock('\Magento\Eav\Api\Data\AttributeGroupInterface');
    +        $groupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
             $existingGroupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
             $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface');
             $groupMock->expects($this->any())->method('getAttributeSetId')->willReturn($attributeSetId);
    @@ -238,7 +241,7 @@ public function testSaveThrowExceptionIfProvidedGroupDoesNotExist()
         {
             $attributeSetId = 42;
             $groupId = 20;
    -        $groupMock = $this->getMock('\Magento\Eav\Api\Data\AttributeGroupInterface');
    +        $groupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
             $existingGroupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
             $attributeSetMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetInterface');
             $groupMock->expects($this->any())->method('getAttributeSetId')->willReturn($attributeSetId);
    diff --git a/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php b/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php
    index 3a51c481a9be3..6631603e1ab61 100644
    --- a/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php
    +++ b/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php
    @@ -11,6 +11,9 @@
     use Magento\Eav\Api\AttributeRepositoryInterface;
     use Magento\Eav\Model\EavCustomAttributeTypeLocator;
     
    +/**
    + * Unit test class for \Magento\Eav\Model\EavCustomAttributeTypeLocator
    + */
     class EavCustomAttributeTypeLocatorTest extends \PHPUnit_Framework_TestCase
     {
         /**
    @@ -40,6 +43,7 @@ protected function setUp()
          * @param string $attributeCode
          * @param string $serviceClass
          * @param array $attributeRepositoryResponse
    +     * @param \Magento\Framework\Stdlib\String $stringUtility,
          * @param array $serviceEntityTypeMapData
          * @param array $serviceBackendModelDataInterfaceMapData
          * @param string $expected
    @@ -49,6 +53,7 @@ public function testGetType(
             $attributeCode,
             $serviceClass,
             $attributeRepositoryResponse,
    +        $stringUtility,
             $serviceEntityTypeMapData,
             $serviceBackendModelDataInterfaceMapData,
             $expected
    @@ -61,6 +66,7 @@ public function testGetType(
     
             $this->eavCustomAttributeTypeLocator = new EavCustomAttributeTypeLocator(
                 $this->attributeRepository,
    +            $stringUtility,
                 $serviceEntityTypeMapData,
                 $serviceBackendModelDataInterfaceMapData
             );
    @@ -70,6 +76,10 @@ public function testGetType(
             $this->assertEquals($expected, $type, 'Expected: ' . $expected . 'but got: ' . $type);
         }
     
    +    /**
    +     * @return array
    +     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
    +     */
         public function getTypeDataProvider()
         {
             $serviceInterface = 'Magento\Catalog\Api\Data\ProductInterface';
    @@ -94,7 +104,7 @@ public function getTypeDataProvider()
     
             $attributeNoBackendModel = $this->getMock(
                 'Magento\Catalog\Model\Resource\Eav\Attribute',
    -            ['getBackendModel'],
    +            ['getBackendModel', 'getFrontendInput'],
                 [],
                 '',
                 false
    @@ -104,11 +114,18 @@ public function getTypeDataProvider()
                 ->method('getBackendModel')
                 ->willReturn(null);
     
    +        $attributeNoBackendModel->expects($this->any())
    +            ->method('getFrontendInput')
    +            ->willReturn('image');
    +
    +        $stringUtility = new \Magento\Framework\Stdlib\String();
    +
             return [
                 [
                     'attributeCode' => 'media_galley',
                     'serviceClass' => $serviceInterface,
                     'attributeRepositoryResponse' => $attribute,
    +                'stringUtility' => $stringUtility,
                     'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType],
                     'serviceBackendModelDataInterfaceMapData' => $serviceBackendModelDataInterfaceMapData,
                     'expected' => $mediaAttributeDataInterface
    @@ -117,6 +134,7 @@ public function getTypeDataProvider()
                     'attributeCode' => null,
                     'serviceClass' => $serviceInterface,
                     'attributeRepositoryResponse' => $attribute,
    +                'stringUtility' => $stringUtility,
                     'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType],
                     'serviceBackendModelDataInterfaceMapData' => $serviceBackendModelDataInterfaceMapData,
                     'expected' => null
    @@ -125,6 +143,7 @@ public function getTypeDataProvider()
                     'attributeCode' => 'media_galley',
                     'serviceClass' => null,
                     'attributeRepositoryResponse' => $attribute,
    +                'stringUtility' => $stringUtility,
                     'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType],
                     'serviceBackendModelDataInterfaceMapData' => $serviceBackendModelDataInterfaceMapData,
                     'expected' => null
    @@ -133,6 +152,7 @@ public function getTypeDataProvider()
                     'attributeCode' => 'media_galley',
                     'serviceClass' => $serviceInterface,
                     'attributeRepositoryResponse' => $attributeNoBackendModel,
    +                'stringUtility' => $stringUtility,
                     'serviceEntityTypeMapData' => [],
                     'serviceBackendModelDataInterfaceMapData' => [],
                     'expected' => null
    @@ -141,16 +161,36 @@ public function getTypeDataProvider()
                     'attributeCode' => 'media_galley',
                     'serviceClass' => 'Magento\Catalog\Api\Data\ProductInterface',
                     'attributeRepositoryResponse' => $attribute,
    +                'stringUtility' => $stringUtility,
                     'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType],
                     'serviceBackendModelDataInterfaceMapData' => [],
                     'expected' => null
    +            ],
    +            [
    +                'attributeCode' => 'image',
    +                'serviceClass' => $serviceInterface,
    +                'attributeRepositoryResponse' => $attributeNoBackendModel,
    +                'stringUtility' => $stringUtility,
    +                'serviceEntityTypeMapData' => [$serviceInterface => 'image'],
    +                'serviceBackendModelDataInterfaceMapData' =>
    +                    [
    +                        $serviceInterface =>
    +                            [
    +                                'Magento\Eav\Model\Attribute\Data\Image' => $mediaAttributeDataInterface
    +                            ]
    +                    ],
    +                'expected' => $mediaAttributeDataInterface
                 ]
             ];
         }
     
         public function testGetAllServiceDataInterfaceEmpty()
         {
    -        $this->eavCustomAttributeTypeLocator = new EavCustomAttributeTypeLocator($this->attributeRepository);
    +        $stringUtility = new \Magento\Framework\Stdlib\String();
    +        $this->eavCustomAttributeTypeLocator = new EavCustomAttributeTypeLocator(
    +            $this->attributeRepository,
    +            $stringUtility
    +        );
             $this->assertEmpty($this->eavCustomAttributeTypeLocator->getAllServiceDataInterfaces());
         }
     
    @@ -161,8 +201,9 @@ public function testGetAllServiceDataInterface()
                 'ServiceB' => ['BackendB' => 'ServiceDataInterfaceB', 'BackendC' => 'ServiceDataInterfaceC'],
                 'ServiceC' => ['BackendD' => 'ServiceDataInterfaceD']
             ];
    +        $stringUtility = new \Magento\Framework\Stdlib\String();
             $this->eavCustomAttributeTypeLocator = new EavCustomAttributeTypeLocator(
    -            $this->attributeRepository, [], $serviceBackendModelDataInterfaceMapData
    +            $this->attributeRepository, $stringUtility, [], $serviceBackendModelDataInterfaceMapData
             );
             $this->assertEquals(
                 ['ServiceDataInterfaceA', 'ServiceDataInterfaceB', 'ServiceDataInterfaceC', 'ServiceDataInterfaceD'],
    diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json
    index c78cd9e34aa78..beb25eea2be2f 100644
    --- a/app/code/Magento/Eav/composer.json
    +++ b/app/code/Magento/Eav/composer.json
    @@ -3,16 +3,16 @@
         "description": "N/A",
         "require": {
             "php": "~5.5.0|~5.6.0",
    -        "magento/module-store": "0.74.0-beta9",
    -        "magento/module-backend": "0.74.0-beta9",
    -        "magento/module-catalog": "0.74.0-beta9",
    -        "magento/module-config": "0.74.0-beta9",
    -        "magento/module-media-storage": "0.74.0-beta9",
    -        "magento/framework": "0.74.0-beta9",
    +        "magento/module-store": "0.74.0-beta11",
    +        "magento/module-backend": "0.74.0-beta11",
    +        "magento/module-catalog": "0.74.0-beta11",
    +        "magento/module-config": "0.74.0-beta11",
    +        "magento/module-media-storage": "0.74.0-beta11",
    +        "magento/framework": "0.74.0-beta11",
             "magento/magento-composer-installer": "*"
         },
         "type": "magento2-module",
    -    "version": "0.74.0-beta9",
    +    "version": "0.74.0-beta11",
         "license": [
             "OSL-3.0",
             "AFL-3.0"
    diff --git a/app/code/Magento/Email/Model/Template/Config.php b/app/code/Magento/Email/Model/Template/Config.php
    index 0fdd709d51490..f8056d7c66f3b 100644
    --- a/app/code/Magento/Email/Model/Template/Config.php
    +++ b/app/code/Magento/Email/Model/Template/Config.php
    @@ -1,12 +1,13 @@
     action->setColumn($this->columnMock);
             $row = new \Magento\Framework\Object();
             $row->setId(1);
    -        $this->assertContains('action-select', $this->action->render($row));
    +        $this->assertContains('admin__control-select', $this->action->render($row));
         }
     }
    diff --git a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
    index c18cab16cf584..47d4e8e0929ac 100644
    --- a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
    +++ b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
    @@ -101,6 +101,7 @@ public function setUp()
                 ->disableOriginalConstructor()
                 ->getMock();
             $this->emailFilterFactory = $this->getMockBuilder('Magento\Email\Model\Template\FilterFactory')
    +            ->setMethods(['create'])
                 ->disableOriginalConstructor()
                 ->getMock();
             $this->emailConfig = $this->getMockBuilder('Magento\Email\Model\Template\Config')
    diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json
    index 1928629c4c9d5..09372575b5c83 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.5.0|~5.6.0",
    -        "magento/module-config": "0.74.0-beta9",
    -        "magento/module-store": "0.74.0-beta9",
    -        "magento/module-cms": "0.74.0-beta9",
    -        "magento/module-backend": "0.74.0-beta9",
    -        "magento/module-variable": "0.74.0-beta9",
    -        "magento/framework": "0.74.0-beta9",
    +        "magento/module-config": "0.74.0-beta11",
    +        "magento/module-store": "0.74.0-beta11",
    +        "magento/module-cms": "0.74.0-beta11",
    +        "magento/module-backend": "0.74.0-beta11",
    +        "magento/module-variable": "0.74.0-beta11",
    +        "magento/framework": "0.74.0-beta11",
             "magento/magento-composer-installer": "*"
         },
         "type": "magento2-module",
    -    "version": "0.74.0-beta9",
    +    "version": "0.74.0-beta11",
         "license": [
             "OSL-3.0",
             "AFL-3.0"
    diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json
    index 6023b3abb6fd5..e74e13897d205 100644
    --- a/app/code/Magento/Fedex/composer.json
    +++ b/app/code/Magento/Fedex/composer.json
    @@ -3,20 +3,20 @@
         "description": "N/A",
         "require": {
             "php": "~5.5.0|~5.6.0",
    -        "magento/module-store": "0.74.0-beta9",
    -        "magento/module-shipping": "0.74.0-beta9",
    -        "magento/module-directory": "0.74.0-beta9",
    -        "magento/module-catalog": "0.74.0-beta9",
    -        "magento/module-sales": "0.74.0-beta9",
    -        "magento/module-catalog-inventory": "0.74.0-beta9",
    -        "magento/module-quote": "0.74.0-beta9",
    -        "magento/module-config": "0.74.0-beta9",
    -        "magento/framework": "0.74.0-beta9",
    +        "magento/module-store": "0.74.0-beta11",
    +        "magento/module-shipping": "0.74.0-beta11",
    +        "magento/module-directory": "0.74.0-beta11",
    +        "magento/module-catalog": "0.74.0-beta11",
    +        "magento/module-sales": "0.74.0-beta11",
    +        "magento/module-catalog-inventory": "0.74.0-beta11",
    +        "magento/module-quote": "0.74.0-beta11",
    +        "magento/module-config": "0.74.0-beta11",
    +        "magento/framework": "0.74.0-beta11",
             "lib-libxml": "*",
             "magento/magento-composer-installer": "*"
         },
         "type": "magento2-module",
    -    "version": "0.74.0-beta9",
    +    "version": "0.74.0-beta11",
         "license": [
             "OSL-3.0",
             "AFL-3.0"
    diff --git a/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php b/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php
    index 7e34c18ed0d65..6cc1bc5ec088c 100644
    --- a/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php
    +++ b/app/code/Magento/GiftMessage/Api/CartRepositoryInterface.php
    @@ -5,6 +5,10 @@
      */
     namespace Magento\GiftMessage\Api;
     
    +/**
    + * Interface CartRepositoryInterface
    + * @api
    + */
     interface CartRepositoryInterface
     {
         /**
    diff --git a/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php b/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php
    index 3e2f771fad133..eacb52d5e1c09 100644
    --- a/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php
    +++ b/app/code/Magento/GiftMessage/Api/ItemRepositoryInterface.php
    @@ -5,6 +5,10 @@
      */
     namespace Magento\GiftMessage\Api;
     
    +/**
    + * Interface ItemRepositoryInterface
    + * @api
    + */
     interface ItemRepositoryInterface
     {
         /**
    diff --git a/app/code/Magento/GiftMessage/Api/OrderItemRepositoryInterface.php b/app/code/Magento/GiftMessage/Api/OrderItemRepositoryInterface.php
    index 4b94af3ce5f61..8e66c7922c939 100644
    --- a/app/code/Magento/GiftMessage/Api/OrderItemRepositoryInterface.php
    +++ b/app/code/Magento/GiftMessage/Api/OrderItemRepositoryInterface.php
    @@ -5,6 +5,10 @@
      */
     namespace Magento\GiftMessage\Api;
     
    +/**
    + * Interface OrderItemRepositoryInterface
    + * @api
    + */
     interface OrderItemRepositoryInterface
     {
         /**
    diff --git a/app/code/Magento/GiftMessage/Api/OrderRepositoryInterface.php b/app/code/Magento/GiftMessage/Api/OrderRepositoryInterface.php
    index 28f5b54dde526..564577e49b786 100644
    --- a/app/code/Magento/GiftMessage/Api/OrderRepositoryInterface.php
    +++ b/app/code/Magento/GiftMessage/Api/OrderRepositoryInterface.php
    @@ -5,6 +5,10 @@
      */
     namespace Magento\GiftMessage\Api;
     
    +/**
    + * Interface OrderRepositoryInterface
    + * @api
    + */
     interface OrderRepositoryInterface
     {
         /**
    diff --git a/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php b/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php
    new file mode 100644
    index 0000000000000..aac0982ecb604
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php
    @@ -0,0 +1,111 @@
    +scopeConfiguration = $context->getScopeConfig();
    +        $this->cartRepository = $cartRepository;
    +        $this->itemRepository = $itemRepository;
    +        $this->checkoutSession = $checkoutSession;
    +    }
    +
    +    /**
    +     * {@inheritdoc}
    +     */
    +    public function getConfig()
    +    {
    +        $configuration = [];
    +        $orderLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue(
    +            GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER,
    +            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
    +        );
    +        $itemLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue(
    +            GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS,
    +            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
    +        );
    +        if ($orderLevelGiftMessageConfiguration) {
    +            $orderMessages = $this->getOrderLevelGiftMessages();
    +            $configuration['isOrderLevelGiftOptionsEnabled'] = true;
    +            $configuration['giftMessage']['orderLevel'] = $orderMessages === null ? true : $orderMessages->getData();
    +        }
    +        if ($itemLevelGiftMessageConfiguration) {
    +            $itemMessages = $this->getItemLevelGiftMessages();
    +            $configuration['isItemLevelGiftOptionsEnabled'] = true;
    +            $configuration['giftMessage']['itemLevel'] = $itemMessages === null ? true : $itemMessages;
    +        }
    +        return $configuration;
    +    }
    +
    +    /**
    +     * Load already specified quote level gift message.
    +     *
    +     * @return \Magento\GiftMessage\Api\Data\MessageInterface|null
    +     */
    +    protected function getOrderLevelGiftMessages()
    +    {
    +        $cartId = $this->checkoutSession->getQuoteId();
    +        return $this->cartRepository->get($cartId);
    +    }
    +
    +    /**
    +     * Load already specified item level gift messages.
    +     *
    +     * @return \Magento\GiftMessage\Api\Data\MessageInterface[]|null
    +     */
    +    protected function getItemLevelGiftMessages()
    +    {
    +        $itemMessages = [];
    +        $cartId = $this->checkoutSession->getQuoteId();
    +        $items = $this->checkoutSession->getQuote()->getAllVisibleItems();
    +        foreach ($items as $item) {
    +            $itemId = $item->getId();
    +            $message = $this->itemRepository->get($cartId, $itemId);
    +            if ($message) {
    +                $itemMessages[$itemId] = $message->getData();
    +            }
    +        }
    +        return count($itemMessages) === 0 ? null : $itemMessages;
    +    }
    +}
    diff --git a/app/code/Magento/GiftMessage/Model/Plugin/TotalsDataProcessorPlugin.php b/app/code/Magento/GiftMessage/Model/Plugin/TotalsDataProcessorPlugin.php
    new file mode 100644
    index 0000000000000..9d26c0a38b413
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/Model/Plugin/TotalsDataProcessorPlugin.php
    @@ -0,0 +1,64 @@
    +cartRepository = $cartRepository;
    +        $this->itemRepositoryInterface = $itemRepository;
    +    }
    +
    +    /**
    +     * Set gift messages from additional data.
    +     *
    +     * @param \Magento\Quote\Model\Cart\TotalsAdditionalDataProcessor $subject
    +     * @param TotalsAdditionalDataInterface $additionalData
    +     * @param int $cartId
    +     * @return void
    +     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
    +     */
    +    public function beforeProcess(
    +        TotalsAdditionalDataProcessor $subject,
    +        TotalsAdditionalDataInterface $additionalData,
    +        $cartId
    +    ) {
    +        $giftMessages = $additionalData->getExtensionAttributes()->getGiftMessages();
    +        foreach ($giftMessages as $giftMessage) {
    +            /** @var \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage */
    +            $entityType = $giftMessage->getExtensionAttributes()->getEntityType();
    +            $entityId = $giftMessage->getExtensionAttributes()->getEntityId();
    +            if ($entityType === 'quote') {
    +                $this->cartRepository->save($cartId, $giftMessage);
    +            } elseif ($entityType === 'item') {
    +                $this->itemRepositoryInterface->save($cartId, $giftMessage, $entityId);
    +            }
    +        }
    +    }
    +}
    diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/SaveTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/SaveTest.php
    index be2afab9ebc2b..728bcf9f426b2 100644
    --- a/app/code/Magento/GiftMessage/Test/Unit/Model/SaveTest.php
    +++ b/app/code/Magento/GiftMessage/Test/Unit/Model/SaveTest.php
    @@ -21,7 +21,10 @@ class SaveTest extends \PHPUnit_Framework_TestCase
         protected function setUp()
         {
             $productRepositoryMock = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface', [], [], '', false);
    -        $this->messageFactoryMock = $this->getMock('\Magento\GiftMessage\Model\MessageFactory', [], [], '', false);
    +        $this->messageFactoryMock = $this->getMockBuilder('\Magento\GiftMessage\Model\MessageFactory')
    +            ->setMethods(['create'])
    +            ->disableOriginalConstructor()
    +            ->getMock();
             $sessionMock = $this->getMock('\Magento\Backend\Model\Session\Quote', [], [], '', false);
             $giftMessageHelperMock = $this->getMock('\Magento\GiftMessage\Helper\Message', [], [], '', false);
             $this->model = new \Magento\GiftMessage\Model\Save(
    diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json
    index acfedbcc2d066..77f37ba0ff15a 100644
    --- a/app/code/Magento/GiftMessage/composer.json
    +++ b/app/code/Magento/GiftMessage/composer.json
    @@ -3,20 +3,20 @@
         "description": "N/A",
         "require": {
             "php": "~5.5.0|~5.6.0",
    -        "magento/module-store": "0.74.0-beta9",
    -        "magento/module-catalog": "0.74.0-beta9",
    -        "magento/module-checkout": "0.74.0-beta9",
    -        "magento/module-multishipping": "0.74.0-beta9",
    -        "magento/module-sales": "0.74.0-beta9",
    -        "magento/module-backend": "0.74.0-beta9",
    -        "magento/module-customer": "0.74.0-beta9",
    -        "magento/module-eav": "0.74.0-beta9",
    -        "magento/module-quote": "0.74.0-beta9",
    -        "magento/framework": "0.74.0-beta9",
    +        "magento/module-store": "0.74.0-beta11",
    +        "magento/module-catalog": "0.74.0-beta11",
    +        "magento/module-checkout": "0.74.0-beta11",
    +        "magento/module-multishipping": "0.74.0-beta11",
    +        "magento/module-sales": "0.74.0-beta11",
    +        "magento/module-backend": "0.74.0-beta11",
    +        "magento/module-customer": "0.74.0-beta11",
    +        "magento/module-eav": "0.74.0-beta11",
    +        "magento/module-quote": "0.74.0-beta11",
    +        "magento/framework": "0.74.0-beta11",
             "magento/magento-composer-installer": "*"
         },
         "type": "magento2-module",
    -    "version": "0.74.0-beta9",
    +    "version": "0.74.0-beta11",
         "license": [
             "OSL-3.0",
             "AFL-3.0"
    diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml
    index d8ea087e62d73..6d3a903c68045 100644
    --- a/app/code/Magento/GiftMessage/etc/di.xml
    +++ b/app/code/Magento/GiftMessage/etc/di.xml
    @@ -26,4 +26,7 @@
             
             
         
    +    
    +        
    +    
     
    diff --git a/app/code/Magento/GiftMessage/etc/frontend/di.xml b/app/code/Magento/GiftMessage/etc/frontend/di.xml
    index 2db23d49ced7c..36f49a653bd33 100644
    --- a/app/code/Magento/GiftMessage/etc/frontend/di.xml
    +++ b/app/code/Magento/GiftMessage/etc/frontend/di.xml
    @@ -29,4 +29,11 @@
         
             
         
    +    
    +        
    +            
    +                Magento\GiftMessage\Model\GiftMessageConfigProvider
    +            
    +        
    +    
     
    diff --git a/app/code/Magento/GiftMessage/etc/service_data_attributes.xml b/app/code/Magento/GiftMessage/etc/service_data_attributes.xml
    index f02c0a717e169..bc8a926dfb86f 100644
    --- a/app/code/Magento/GiftMessage/etc/service_data_attributes.xml
    +++ b/app/code/Magento/GiftMessage/etc/service_data_attributes.xml
    @@ -12,4 +12,11 @@
         
             
         
    +    
    +        
    +        
    +    
    +    
    +        
    +    
     
    diff --git a/app/code/Magento/Centinel/etc/frontend/events.xml b/app/code/Magento/GiftMessage/etc/webapi_rest/events.xml
    similarity index 61%
    rename from app/code/Magento/Centinel/etc/frontend/events.xml
    rename to app/code/Magento/GiftMessage/etc/webapi_rest/events.xml
    index 24dcacbedddf5..b32770f734d73 100644
    --- a/app/code/Magento/Centinel/etc/frontend/events.xml
    +++ b/app/code/Magento/GiftMessage/etc/webapi_rest/events.xml
    @@ -6,7 +6,7 @@
      */
     -->
     
    -    
    -        
    +    
    +        
         
     
    diff --git a/app/code/Magento/GiftMessage/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/GiftMessage/view/frontend/layout/checkout_onepage_index.xml
    new file mode 100644
    index 0000000000000..fbaba91cb60ea
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/layout/checkout_onepage_index.xml
    @@ -0,0 +1,42 @@
    +
    +
    +
    +    
    +        
    +            
    +                
    +                    
    +                        
    +                            
    +                                
    +                                    
    +                                        
    +                                            
    +                                                
    +                                                    Magento_GiftMessage/js/view/gift-options
    +                                                    
    +                                                        
    +                                                            Magento_GiftMessage/js/view/order-level-gift-message
    +                                                        
    +                                                        
    +                                                            Magento_GiftMessage/js/view/item-level-gift-message
    +                                                        
    +                                                    
    +                                                
    +                                            
    +                                        
    +                                    
    +                                
    +                            
    +                        
    +                    
    +                
    +            
    +        
    +    
    +
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js
    new file mode 100644
    index 0000000000000..d5f0e072c7713
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js
    @@ -0,0 +1,59 @@
    +/**
    + * Copyright © 2015 Magento. All rights reserved.
    + * See COPYING.txt for license details.
    + */
    +/*global define*/
    +define(['underscore', './gift-options'],
    +    function(_, giftOptions) {
    +        "use strict";
    +        var itemLevelDefaultMessages, orderLevelDefaultMessage,
    +            isItemLevelGiftOptionsSelected = false,
    +            isOrderLevelGiftOptionsSelected = false,
    +            isGiftOptionsSelected = false;
    +        if (giftOptions.isItemLevelGiftOptionsEnabled() && _.isObject(window.checkoutConfig.giftMessage.itemLevel)) {
    +            itemLevelDefaultMessages = window.checkoutConfig.giftMessage.itemLevel;
    +            isItemLevelGiftOptionsSelected = true;
    +            isGiftOptionsSelected = true;
    +        }
    +        if (giftOptions.isOrderLevelGiftOptionsEnabled() && _.isObject(window.checkoutConfig.giftMessage.orderLevel)) {
    +            orderLevelDefaultMessage = window.checkoutConfig.giftMessage.orderLevel;
    +            isOrderLevelGiftOptionsSelected = true;
    +            isGiftOptionsSelected = true;
    +        }
    +        return {
    +            getDefaultMessageForItem: function(itemId) {
    +                if (_.isObject(itemLevelDefaultMessages) && itemLevelDefaultMessages.hasOwnProperty(itemId)) {
    +                    return {
    +                        from: itemLevelDefaultMessages[itemId].sender,
    +                        to: itemLevelDefaultMessages[itemId].recipient,
    +                        message: itemLevelDefaultMessages[itemId].message
    +                    };
    +                }
    +                return {
    +                    from: null, to: null, message: null
    +                };
    +            },
    +            getDefaultMessageForQuote: function() {
    +                if (orderLevelDefaultMessage) {
    +                    return {
    +                        from: orderLevelDefaultMessage.sender,
    +                        to: orderLevelDefaultMessage.recipient,
    +                        message: orderLevelDefaultMessage.message
    +                    };
    +                }
    +                return {
    +                    from: null, to: null, message: null
    +                };
    +            },
    +            isGiftOptionsSelected: function() {
    +                return isGiftOptionsSelected;
    +            },
    +            isItemLevelGiftOptionsSelected: function() {
    +                return isItemLevelGiftOptionsSelected;
    +            },
    +            isOrderLevelGiftOptionsSelected: function() {
    +                return isOrderLevelGiftOptionsSelected;
    +            }
    +        };
    +    }
    +);
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js
    new file mode 100644
    index 0000000000000..000bf4b508e32
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js
    @@ -0,0 +1,62 @@
    +/**
    + * Copyright © 2015 Magento. All rights reserved.
    + * See COPYING.txt for license details.
    + */
    +/*global define*/
    +define(['underscore'],
    +    function(_) {
    +        "use strict";
    +        var isOrderLevelGiftOptionsEnabled = window.checkoutConfig.isOrderLevelGiftOptionsEnabled || false,
    +            isItemLevelGiftOptionsEnabled = window.checkoutConfig.isItemLevelGiftOptionsEnabled || false;
    +        return {
    +            orderLevelGiftOptions: [],
    +            itemLevelGiftOptions: [],
    +            extraGiftOptions: [],
    +            isGiftOptionsAvailable: function() {
    +                var isAvailable = isOrderLevelGiftOptionsEnabled || isItemLevelGiftOptionsEnabled;
    +
    +                _.each(this.getExtraGiftOptions(), function(option){
    +                    if (typeof option.isAvailable() === 'function') {
    +                        isAvailable = isAvailable || option.isAvailable();
    +                    }
    +                });
    +
    +                return isAvailable;
    +            },
    +            isOrderLevelGiftOptionsEnabled: function() {
    +                return isOrderLevelGiftOptionsEnabled;
    +            },
    +            isItemLevelGiftOptionsEnabled: function() {
    +                return isItemLevelGiftOptionsEnabled;
    +            },
    +            getExtraGiftOptions: function() {
    +                return this.getGiftOptions(this.extraGiftOptions);
    +            },
    +            getOrderLevelGiftOptions: function() {
    +                return this.getGiftOptions(this.orderLevelGiftOptions);
    +            },
    +            getItemLevelGiftOptions: function() {
    +                return this.getGiftOptions(this.itemLevelGiftOptions);
    +            },
    +            getGiftOptions: function(options) {
    +                return _.map(
    +                    _.sortBy(options, function(giftOption){
    +                        return giftOption.sortOrder
    +                    }),
    +                    function(giftOption) {
    +                        return giftOption.option
    +                    }
    +                )
    +            },
    +            setExtraGiftOptions: function (giftOption, sortOrder) {
    +                this.extraGiftOptions.push({'option': giftOption, 'sortOrder': sortOrder});
    +            },
    +            addOrderLevelGiftOptions: function(giftOption, sortOrder) {
    +                this.orderLevelGiftOptions.push({'option': giftOption, 'sortOrder': sortOrder});
    +            },
    +            addItemLevelGiftOptions: function(giftOption, sortOrder) {
    +                this.itemLevelGiftOptions.push({'option': giftOption, 'sortOrder': sortOrder});
    +            }
    +        };
    +    }
    +);
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-options.js b/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-options.js
    new file mode 100644
    index 0000000000000..f216daa41a609
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-options.js
    @@ -0,0 +1,96 @@
    +/**
    + * Copyright © 2015 Magento. All rights reserved.
    + * See COPYING.txt for license details.
    + */
    +/*global define*/
    +define(['uiComponent', 'ko', '../model/gift-options', '../model/gift-message', 'Magento_Ui/js/model/errorlist'],
    +    function (Component, ko, giftOptions, giftMessage, errorList) {
    +        "use strict";
    +
    +        return Component.extend({
    +            defaults: {
    +                template: 'Magento_GiftMessage/gift-options',
    +                displayArea: 'shippingAdditional'
    +            },
    +            options: [],
    +            isGiftOptionsSelected: ko.observable(giftMessage.isGiftOptionsSelected()),
    +            isOrderLevelGiftOptionsSelected: ko.observable(giftMessage.isOrderLevelGiftOptionsSelected()),
    +            isItemLevelGiftOptionsSelected: ko.observable(giftMessage.isItemLevelGiftOptionsSelected()),
    +            isGiftOptionsAvailable: function() {
    +                return giftOptions.isGiftOptionsAvailable();
    +            },
    +            isOrderLevelGiftOptionsEnabled: function() {
    +                return giftOptions.isOrderLevelGiftOptionsEnabled();
    +            },
    +            isItemLevelGiftOptionsEnabled: function() {
    +                return giftOptions.isItemLevelGiftOptionsEnabled();
    +            },
    +            getOrderLevelGiftOptions: function() {
    +                return this.filterOptions(giftOptions.getOrderLevelGiftOptions());
    +            },
    +            getItemLevelGiftOptions: function() {
    +                return this.filterOptions(giftOptions.getItemLevelGiftOptions());
    +            },
    +            getExtraGiftOptions: function() {
    +                return this.filterOptions(giftOptions.getExtraGiftOptions());
    +            },
    +            filterOptions: function(options) {
    +                return _.filter(options, function(option) {
    +                        var result = true;
    +                        if (option.isDirectRendering !== 'undefined') {
    +                            result = !option.isDirectRendering;
    +                        }
    +                        return result;
    +                    }
    +                );
    +            },
    +            collectOptions: function(giftOption, additionalFlag) {
    +                if (!this.isAvailableForSubmiting(giftOption)) {
    +                    return false;
    +                }
    +                var self = this;
    +                if (giftOption.optionType === 'undefined') {
    +                    errorList.add('You should define type of your custom option');
    +                }
    +
    +                if (!this.options.hasOwnProperty(giftOption.optionType)) {
    +                    this.options[giftOption.optionType] = [];
    +                }
    +
    +                _.each(giftOption.submit(additionalFlag), function(optionItem) {
    +                    self.options[giftOption.optionType].push(optionItem);
    +                });
    +            },
    +            isAvailableForSubmiting: function(option) {
    +                return typeof option.isSubmit == 'undefined' || option.isSubmit ? true : false;
    +            },
    +            submit: function() {
    +                var self = this;
    +
    +                var removeOrder = giftOptions.isItemLevelGiftOptionsEnabled() && this.isOrderLevelGiftOptionsEnabled()
    +                    && (!this.isGiftOptionsSelected() || !this.isOrderLevelGiftOptionsSelected())
    +                    ? true
    +                    : false;
    +                _.each(giftOptions.getOrderLevelGiftOptions(), function(option) {
    +                    self.collectOptions(option, removeOrder);
    +                });
    +
    +                var removeItem = giftOptions.isItemLevelGiftOptionsEnabled() && this.isItemLevelGiftOptionsEnabled()
    +                && (!this.isGiftOptionsSelected() || !this.isItemLevelGiftOptionsSelected())
    +                    ? true
    +                    : false;
    +                _.each(giftOptions.getItemLevelGiftOptions(), function(option) {
    +                    self.collectOptions(option, removeItem);
    +                });
    +
    +                _.each(giftOptions.getExtraGiftOptions(), function(option) {
    +                    self.collectOptions(option);
    +                });
    +
    +                var result = this.options;
    +                this.options = [];
    +                return result;
    +            }
    +        });
    +    }
    +);
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/view/item-level-gift-message.js b/app/code/Magento/GiftMessage/view/frontend/web/js/view/item-level-gift-message.js
    new file mode 100644
    index 0000000000000..05ef405b1feaa
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/view/item-level-gift-message.js
    @@ -0,0 +1,77 @@
    +/**
    + * Copyright © 2015 Magento. All rights reserved.
    + * See COPYING.txt for license details.
    + */
    +/*global define*/
    +define(['uiComponent', 'ko', '../model/gift-options', 'Magento_Checkout/js/model/quote', '../model/gift-message'],
    +    function (Component, ko, giftOptions, quote, giftMessage) {
    +        "use strict";
    +        return Component.extend({
    +            defaults: {
    +                template: 'Magento_GiftMessage/item-level-gift-message',
    +                displayArea: 'itemLevelGiftMessage'
    +            },
    +            messages: {},
    +            quoteItems: [],
    +            quoteItemsCount: 0,
    +            imagePlaceholder: window.checkoutConfig.staticBaseUrl +
    +                '/frontend/Magento/blank/en_US/Magento_Catalog/images/product/placeholder/thumbnail.jpg',
    +            optionType: 'gift_messages',
    +            initialize: function() {
    +                var item,
    +                    that = this,
    +                    quoteItems = quote.getItems();
    +                quote.getShippingAddress().subscribe(function(shippingAddress) {
    +                    var name = shippingAddress.firstname + ' ' + shippingAddress.lastname;
    +                    for (item in quoteItems) {
    +                        if (quoteItems.hasOwnProperty(item)) {
    +                            if (quoteItems[item].is_virtual === '0') {
    +                                var itemId = quoteItems[item].item_id;
    +                                that.messages[itemId] = {
    +                                    from: ko.observable(giftMessage.getDefaultMessageForItem(itemId).from || name),
    +                                    to: ko.observable(giftMessage.getDefaultMessageForItem(itemId).to || name),
    +                                    message: ko.observable(giftMessage.getDefaultMessageForItem(itemId).message)
    +                                };
    +                                quoteItems[item].isItemLevelGiftMessageVisible = ko.observable(false);
    +                                that.quoteItems.push(quoteItems[item]);
    +                            }
    +                        }
    +                    }
    +                    that.quoteItemsCount = that.quoteItems.length;
    +                    this.dispose();
    +                });
    +                this._super();
    +                giftOptions.addItemLevelGiftOptions(this);
    +            },
    +            itemImages: ko.observableArray(),
    +            setItemLevelGiftMessageHidden: function(data, event) {
    +                event.preventDefault();
    +                if (data.hasOwnProperty('item_id')) {
    +                    this.isItemLevelGiftMessageVisible(!this.isItemLevelGiftMessageVisible());
    +                }
    +            },
    +            submit: function(remove) {
    +                remove = remove || false;
    +                var itemId,
    +                    giftMessages = [],
    +                    that = this;
    +                for (itemId in this.messages) {
    +                    if (that.messages.hasOwnProperty(itemId)) {
    +                        if (that.messages[itemId].message() !== null) {
    +                            giftMessages.push({
    +                                sender: remove ? null : that.messages[itemId].from(),
    +                                recipient: remove ? null : that.messages[itemId].to(),
    +                                message: remove ? null : that.messages[itemId].message(),
    +                                extension_attributes: {
    +                                    entity_id: itemId,
    +                                    entity_type: 'item'
    +                                }
    +                            });
    +                        }
    +                    }
    +                }
    +                return giftMessages;
    +            }
    +        });
    +    }
    +);
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/view/order-level-gift-message.js b/app/code/Magento/GiftMessage/view/frontend/web/js/view/order-level-gift-message.js
    new file mode 100644
    index 0000000000000..277f17a2b4277
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/view/order-level-gift-message.js
    @@ -0,0 +1,59 @@
    +/**
    + * Copyright © 2015 Magento. All rights reserved.
    + * See COPYING.txt for license details.
    + */
    +/*global define*/
    +define([
    +        'uiComponent',
    +        'ko',
    +        '../model/gift-options',
    +        'Magento_Checkout/js/model/quote',
    +        '../model/gift-message'
    +    ],
    +    function (Component, ko, giftOptions, quote, giftMessage) {
    +        "use strict";
    +        return Component.extend({
    +            defaults: {
    +                template: 'Magento_GiftMessage/order-level-gift-message',
    +                displayArea: 'orderLevelGiftMessage'
    +            },
    +            message: {},
    +            optionType: 'gift_messages',
    +            initialize: function() {
    +                var that = this;
    +                quote.getShippingAddress().subscribe(function(shippingAddress) {
    +                    var customerName = shippingAddress.firstname + ' ' + shippingAddress.lastname;
    +                    that.message = {
    +                        from: ko.observable(giftMessage.getDefaultMessageForQuote().from || customerName),
    +                        to: ko.observable(giftMessage.getDefaultMessageForQuote().to || customerName),
    +                        message: ko.observable(giftMessage.getDefaultMessageForQuote().message)
    +                    };
    +                    this.dispose();
    +                });
    +                this._super();
    +                giftOptions.addOrderLevelGiftOptions(this, 10);
    +            },
    +            isOrderLevelGiftMessageVisible: ko.observable(false),
    +            setOrderLevelGiftMessageVisible: function(data, event) {
    +                event.preventDefault();
    +                this.isOrderLevelGiftMessageVisible(!this.isOrderLevelGiftMessageVisible());
    +            },
    +            quoteId: quote.entity_id,
    +            submit: function(remove) {
    +                remove = remove || false;
    +                if (this.message.message() !== null) {
    +                    return [{
    +                        sender: remove ? null : this.message.from(),
    +                        recipient: remove ? null : this.message.to(),
    +                        message: remove ? null : this.message.message(),
    +                        extension_attributes: {
    +                            entity_id: this.quoteId,
    +                            entity_type: 'quote'
    +                        }
    +                    }];
    +                }
    +                return [];
    +            }
    +        });
    +    }
    +);
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/template/gift-options.html b/app/code/Magento/GiftMessage/view/frontend/web/template/gift-options.html
    new file mode 100644
    index 0000000000000..02b2c1d5f03c0
    --- /dev/null
    +++ b/app/code/Magento/GiftMessage/view/frontend/web/template/gift-options.html
    @@ -0,0 +1,42 @@
    +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + + +
    + +
    +
    + + +
    +
    + + + +
    + +
    + + + +
    +
    +
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/template/item-level-gift-message.html b/app/code/Magento/GiftMessage/view/frontend/web/template/item-level-gift-message.html new file mode 100644 index 0000000000000..68aedda15ecea --- /dev/null +++ b/app/code/Magento/GiftMessage/view/frontend/web/template/item-level-gift-message.html @@ -0,0 +1,76 @@ + +
      +
    1. +
      +
      + + + + + + +
      +
      + + + + + +
      + +
      +
      + + + + + +
      +
      +

      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      +
      +
    2. +
    diff --git a/app/code/Magento/GiftMessage/view/frontend/web/template/order-level-gift-message.html b/app/code/Magento/GiftMessage/view/frontend/web/template/order-level-gift-message.html new file mode 100644 index 0000000000000..3053c94ed655d --- /dev/null +++ b/app/code/Magento/GiftMessage/view/frontend/web/template/order-level-gift-message.html @@ -0,0 +1,49 @@ + + + +
    +
    +

    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 51c1820097317..1b9604a1c7ee1 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index d19ecafec1512..885f3f2fba0a2 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-cookie": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-cookie": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleOptimizer/Block/Code/Category.php b/app/code/Magento/GoogleOptimizer/Block/Code/Category.php index 5e611ec1be136..433e278db78a1 100644 --- a/app/code/Magento/GoogleOptimizer/Block/Code/Category.php +++ b/app/code/Magento/GoogleOptimizer/Block/Code/Category.php @@ -10,7 +10,7 @@ namespace Magento\GoogleOptimizer\Block\Code; -class Category extends \Magento\GoogleOptimizer\Block\AbstractCode implements \Magento\Framework\View\Block\IdentityInterface +class Category extends \Magento\GoogleOptimizer\Block\AbstractCode implements \Magento\Framework\Object\IdentityInterface { /** * @var string Entity name in registry diff --git a/app/code/Magento/GoogleOptimizer/Block/Code/Product.php b/app/code/Magento/GoogleOptimizer/Block/Code/Product.php index 371debd2a7274..7c40e57e15bfe 100644 --- a/app/code/Magento/GoogleOptimizer/Block/Code/Product.php +++ b/app/code/Magento/GoogleOptimizer/Block/Code/Product.php @@ -10,7 +10,7 @@ namespace Magento\GoogleOptimizer\Block\Code; -class Product extends \Magento\GoogleOptimizer\Block\AbstractCode implements \Magento\Framework\View\Block\IdentityInterface +class Product extends \Magento\GoogleOptimizer\Block\AbstractCode implements \Magento\Framework\Object\IdentityInterface { /** * @var Product name in registry diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 737507a9a0e68..a65d295e1332d 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-google-analytics": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-google-analytics": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 565d14828e38f..523d9bcc471f3 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleShopping/view/adminhtml/templates/types/edit/attributes.phtml b/app/code/Magento/GoogleShopping/view/adminhtml/templates/types/edit/attributes.phtml index 03790f402f19a..d40677511d741 100644 --- a/app/code/Magento/GoogleShopping/view/adminhtml/templates/types/edit/attributes.phtml +++ b/app/code/Magento/GoogleShopping/view/adminhtml/templates/types/edit/attributes.phtml @@ -93,7 +93,7 @@ gContentAttribute = new Gcontent.Attribute(attributesSelectTemplate);
    - +
    diff --git a/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/GroupedTest.php b/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/GroupedTest.php index c01fa58cb6a64..e18667c5843ee 100644 --- a/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/GroupedTest.php +++ b/app/code/Magento/GroupedImportExport/Test/Unit/Model/Import/Product/Type/GroupedTest.php @@ -72,7 +72,7 @@ protected function setUp() $this->attrCollectionFactory = $this->getMock( 'Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory', - [], + ['create'], [], '', false diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index e065f52b8b8d1..7367f56837d49 100644 --- a/app/code/Magento/GroupedImportExport/composer.json +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-import-export": "0.74.0-beta9", - "magento/module-catalog-import-export": "0.74.0-beta9", - "magento/module-grouped-product": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-import-export": "0.74.0-beta11", + "magento/module-catalog-import-export": "0.74.0-beta11", + "magento/module-grouped-product": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php index a6f28362cd08a..b9d8ced7264f5 100644 --- a/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php @@ -7,7 +7,7 @@ use Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; use Magento\Checkout\Block\Cart\Item\Renderer; -use Magento\Framework\View\Block\IdentityInterface; +use Magento\Framework\Object\IdentityInterface; /** * Shopping cart item render block diff --git a/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php b/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php index 468f642f05489..ec900cc06ea04 100644 --- a/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php @@ -5,7 +5,7 @@ */ namespace Magento\GroupedProduct\Block\Stockqty\Type; -use Magento\Framework\View\Block\IdentityInterface; +use Magento\Framework\Object\IdentityInterface; /** * Product stock qty block for grouped product type diff --git a/app/code/Magento/GroupedProduct/CustomerData/GroupedItem.php b/app/code/Magento/GroupedProduct/CustomerData/GroupedItem.php new file mode 100644 index 0000000000000..bb7d4f36978b7 --- /dev/null +++ b/app/code/Magento/GroupedProduct/CustomerData/GroupedItem.php @@ -0,0 +1,77 @@ +_scopeConfig = $scopeConfig; + } + + /** + * {@inheritdoc} + */ + protected function getProductForThumbnail() + { + /** + * Show grouped product thumbnail if it must be always shown according to the related setting in system config + * or if child product thumbnail is not available + */ + $config = $this->_scopeConfig->getValue( + \Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + $product = $config == ThumbnailSource::OPTION_USE_PARENT_IMAGE || + (!$this->getProduct()->getThumbnail() || $this->getProduct()->getThumbnail() == 'no_selection') + ? $this->getGroupedProduct() + : $this->getProduct(); + return $product; + } + + /** + * Get item grouped product + * + * @return \Magento\Catalog\Model\Product + */ + protected function getGroupedProduct() + { + $option = $this->item->getOptionByCode('product_type'); + if ($option) { + return $option->getProduct(); + } + return $this->getProduct(); + } +} diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index 5ee51f1ecbfb4..bebfa0435d69f 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -378,7 +378,7 @@ protected function _prepareProduct(\Magento\Framework\Object $buyRequest, $produ foreach ($associatedProducts as $subProduct) { $qty = $productsInfo[$subProduct->getId()]; - if (!is_numeric($qty)) { + if (!is_numeric($qty) || empty($qty)) { continue; } diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php index 4cf5af00c0294..aed377242d123 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php @@ -576,4 +576,26 @@ public function testPrepareForCartAdvancedWithProductsStrictTrue() $this->_model->prepareForCartAdvanced($buyRequest, $this->product) ); } + + public function testPrepareForCartAdvancedZeroQty() + { + $expectedMsg = "Please specify the quantity of product(s)."; + $associatedId = 9384; + $associatedProduct = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $associatedProduct->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($associatedId)); + + $buyRequest = new \Magento\Framework\Object(); + $buyRequest->setSuperGroup([$associatedId => 0]); + + $cached = true; + $this->product + ->expects($this->atLeastOnce()) + ->method('hasData') + ->will($this->returnValue($cached)); + $this->product + ->expects($this->atLeastOnce()) + ->method('getData') + ->will($this->returnValue([$associatedProduct])); + $this->assertEquals($expectedMsg, $this->_model->prepareForCartAdvanced($buyRequest, $this->product)); + } } diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 8eb6e0db7cb83..9d68c4d1b92b5 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/module-msrp": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/module-msrp": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedProduct/etc/frontend/di.xml b/app/code/Magento/GroupedProduct/etc/frontend/di.xml new file mode 100644 index 0000000000000..7732a1bdc4d37 --- /dev/null +++ b/app/code/Magento/GroupedProduct/etc/frontend/di.xml @@ -0,0 +1,17 @@ + + + + + + + Magento\GroupedProduct\CustomerData\GroupedItem + + + + diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml index 4849d6d6a970f..06ada7b210415 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/container.phtml @@ -7,9 +7,12 @@
    -
    +
    - + getTabLabel() ?>
    diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/list.phtml b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/list.phtml index de0a513ca8482..091b9941e00ad 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/list.phtml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/templates/product/grouped/list.phtml @@ -32,17 +32,20 @@
    -
    -
    - +
    +
    diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml deleted file mode 100644 index 6ba3f0539fc7d..0000000000000 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php index 0dfd086c2d0fe..c7d648b4d54e6 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php @@ -76,7 +76,7 @@ protected function _getDateFromToHtmlWithValue(Attribute $attribute, $value) $arguments = [ 'name' => $this->getFilterElementName($attribute->getAttributeCode()) . '[]', 'id' => $this->getFilterElementId($attribute->getAttributeCode()), - 'class' => 'input-text input-text-range-date', + 'class' => 'admin__control-text', 'date_format' => $this->_localeDate->getDateFormat( \IntlDateFormatter::SHORT ), @@ -94,17 +94,10 @@ protected function _getDateFromToHtmlWithValue(Attribute $attribute, $value) $toValue = $this->escapeHtml(next($value)); } - return '' . __( - 'From' - ) . ': ' . $dateBlock->setValue( - $fromValue - )->getHtml() . ' ' . __( - 'To' - ) . ': ' . $dateBlock->setId( - $dateBlock->getId() . '_to' - )->setValue( - $toValue - )->getHtml(); + return '' . __('From') . ': ' + . $dateBlock->setValue($fromValue)->getHtml() + . ' ' . __('To') . ': ' + . $dateBlock->setId($dateBlock->getId() . '_to')->setValue($toValue)->getHtml(); } /** @@ -182,7 +175,7 @@ protected function _getNumberFromToHtmlWithValue(Attribute $attribute, $value) $toValue = $this->escapeHtml(next($value)); } - return '' . __( + return '' . __( 'From' ) . ': ' . @@ -192,7 +185,7 @@ protected function _getNumberFromToHtmlWithValue(Attribute $attribute, $value) ' value="' . $fromValue . '"/> ' . - '' . + '' . __( 'To' ) . @@ -268,7 +261,7 @@ protected function _prepareColumns() 'sortable' => false, 'index' => 'attribute_id', 'header_css_class' => 'col-id', - 'column_css_class' => 'col-id' + 'column_css_class' => 'col-id data-grid-checkbox-cell' ] ); $this->addColumn( diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php index 4ed67c3b79911..c9581ad7e7471 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php @@ -190,9 +190,10 @@ abstract protected function _getHeaderColumns(); /** * Get entity collection * + * @param bool $resetCollection * @return \Magento\Framework\Data\Collection\Db */ - abstract protected function _getEntityCollection(); + abstract protected function _getEntityCollection($resetCollection = false); /** * Get attributes codes which are appropriate for export. diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index b3aaeec836d2a..54c06276c1bb0 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -279,7 +279,7 @@ public function getOperationResultMessages($validationResult) */ public static function getAttributeType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute) { - if ($attribute->usesSource()) { + if ($attribute->usesSource() && in_array($attribute->getFrontendInput(), array('select', 'multiselect'))) { return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select'; } elseif ($attribute->isStatic()) { return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar'; diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index ea8942afbfd38..950bf8059675c 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-indexer": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-indexer": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php b/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php index 36f9ec1dd5b27..8296069d60f50 100644 --- a/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php +++ b/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php @@ -49,6 +49,11 @@ public function __construct(ObjectManagerFactory $objectManagerFactory) $params[StoreManager::PARAM_RUN_CODE] = 'admin'; $params[StoreManager::PARAM_RUN_TYPE] = 'store'; $objectManager = $objectManagerFactory->create($params); + + + /** @var \Magento\Framework\App\State $appState */ + $appState = $objectManager->get('Magento\Framework\App\State'); + $appState->setAreaCode('adminmhtml'); //TODO: temporary fix. $this->collectionFactory = $objectManager->create('Magento\Indexer\Model\Indexer\CollectionFactory'); $this->indexerFactory = $objectManager->create('Magento\Indexer\Model\IndexerFactory'); parent::__construct(); diff --git a/app/code/Magento/Indexer/Model/ActionInterface.php b/app/code/Magento/Indexer/Model/ActionInterface.php index ce4ec5e404fb1..a26fcf1ff2925 100644 --- a/app/code/Magento/Indexer/Model/ActionInterface.php +++ b/app/code/Magento/Indexer/Model/ActionInterface.php @@ -5,6 +5,9 @@ */ namespace Magento\Indexer\Model; +/** + * @api + */ interface ActionInterface { /** diff --git a/app/code/Magento/Indexer/Model/Config/Reader.php b/app/code/Magento/Indexer/Model/Config/Reader.php index ee7628d5b43da..ad750c7204175 100644 --- a/app/code/Magento/Indexer/Model/Config/Reader.php +++ b/app/code/Magento/Indexer/Model/Config/Reader.php @@ -5,6 +5,9 @@ */ namespace Magento\Indexer\Model\Config; +/** + * @codeCoverageIgnore + */ class Reader extends \Magento\Framework\Config\Reader\Filesystem { /** diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerCommandCommonTestSetup.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerCommandCommonTestSetup.php index 323e8c9be7a45..77fdccf9bc594 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerCommandCommonTestSetup.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerCommandCommonTestSetup.php @@ -24,21 +24,36 @@ class IndexerCommandCommonTestSetup extends \PHPUnit_Framework_TestCase */ protected $objectManagerFactory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\ObjectManagerInterface + */ + protected $objectManager; + protected function setUp() { $this->objectManagerFactory = $this->getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false); - $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); - - $this->collectionFactory = $this->getMock( - 'Magento\Indexer\Model\Indexer\CollectionFactory', - [], - [], - '', - false - ); - $this->indexerFactory = $this->getMock('Magento\Indexer\Model\IndexerFactory', [], [], '', false); - - $objectManager + $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + + //TODO: temporary fix unit + $stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $stateMock->expects($this->once())->method('setAreaCode')->with('adminmhtml')->willReturnSelf(); + + $this->objectManager->expects($this->once()) + ->method('get') + ->with('Magento\Framework\App\State') + ->willReturn($stateMock); + $this->objectManagerFactory->expects($this->once())->method('create')->willReturn($this->objectManager); + + $this->collectionFactory = $this->getMockBuilder('Magento\Indexer\Model\Indexer\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->indexerFactory = $this->getMockBuilder('Magento\Indexer\Model\IndexerFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->objectManager ->expects($this->exactly(2)) ->method('create') ->will($this->returnValueMap([ @@ -46,6 +61,6 @@ protected function setUp() ['Magento\Indexer\Model\IndexerFactory', [], $this->indexerFactory], ])); - $this->objectManagerFactory->expects($this->once())->method('create')->willReturn($objectManager); + $this->objectManagerFactory->expects($this->once())->method('create')->willReturn($this->objectManager); } } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php index b35dd6e74c6a9..79e058df70375 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php @@ -89,7 +89,10 @@ public function testSyncData() */ public function testSyncDataException() { + $describeTable = ['column' => 'column']; $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); + $connectionMock->expects($this->any())->method('describeTable')->will($this->returnValue($describeTable)); + $connectionMock->expects($this->any())->method('select')->will($this->throwException(new \Exception())); $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); $connectionMock->expects($this->once())->method('rollback'); diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 0fec8e5cd2448..7cd1080c31432 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-page-cache": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-page-cache": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php b/app/code/Magento/Integration/Api/AdminTokenServiceInterface.php similarity index 95% rename from app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php rename to app/code/Magento/Integration/Api/AdminTokenServiceInterface.php index 8c6682349a09a..3c2999851a9db 100644 --- a/app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php +++ b/app/code/Magento/Integration/Api/AdminTokenServiceInterface.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Api; use Magento\Framework\Exception\AuthenticationException; use Magento\Framework\Exception\InputException; @@ -12,6 +12,8 @@ /** * Interface providing token generation for Admins + * + * @api */ interface AdminTokenServiceInterface { diff --git a/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php b/app/code/Magento/Integration/Api/AuthorizationServiceInterface.php similarity index 96% rename from app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php rename to app/code/Magento/Integration/Api/AuthorizationServiceInterface.php index 8602ed78b1f4a..e58adff8d9e63 100644 --- a/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php +++ b/app/code/Magento/Integration/Api/AuthorizationServiceInterface.php @@ -4,12 +4,14 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Api; use Magento\Framework\Exception\LocalizedException; /** * Interface for integration permissions management. + * + * @api */ interface AuthorizationServiceInterface { diff --git a/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php b/app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php similarity index 94% rename from app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php rename to app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php index 3069c59cd429e..245d39bc4a63e 100644 --- a/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php +++ b/app/code/Magento/Integration/Api/CustomerTokenServiceInterface.php @@ -4,12 +4,14 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Api; use Magento\Framework\Exception\AuthenticationException; /** * Interface providing token generation for Customers + * + * @api */ interface CustomerTokenServiceInterface { diff --git a/app/code/Magento/Integration/Service/V1/IntegrationInterface.php b/app/code/Magento/Integration/Api/IntegrationServiceInterface.php similarity index 95% rename from app/code/Magento/Integration/Service/V1/IntegrationInterface.php rename to app/code/Magento/Integration/Api/IntegrationServiceInterface.php index 04202a398ba29..4aba2c495040a 100644 --- a/app/code/Magento/Integration/Service/V1/IntegrationInterface.php +++ b/app/code/Magento/Integration/Api/IntegrationServiceInterface.php @@ -3,14 +3,16 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Api; use Magento\Integration\Model\Integration as IntegrationModel; /** * Integration Service Interface + * + * @api */ -interface IntegrationInterface +interface IntegrationServiceInterface { /** * Create a new Integration diff --git a/app/code/Magento/Integration/Service/V1/OauthInterface.php b/app/code/Magento/Integration/Api/OauthServiceInterface.php similarity index 97% rename from app/code/Magento/Integration/Service/V1/OauthInterface.php rename to app/code/Magento/Integration/Api/OauthServiceInterface.php index c742cf995c36c..2fd3fdbeebb70 100644 --- a/app/code/Magento/Integration/Service/V1/OauthInterface.php +++ b/app/code/Magento/Integration/Api/OauthServiceInterface.php @@ -3,14 +3,16 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Api; use Magento\Integration\Model\Oauth\Token as OauthTokenModel; /** * Integration oAuth Service Interface + * + * @api */ -interface OauthInterface +interface OauthServiceInterface { /** * Create a new consumer account. diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration.php b/app/code/Magento/Integration/Block/Adminhtml/Integration.php index a9cd175c21d03..0299e9168d559 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration.php @@ -7,6 +7,8 @@ /** * Integration block. + * + * @codeCoverageIgnore */ class Integration extends \Magento\Backend\Block\Widget\Grid\Container { diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php index f45074cdea60d..fd6f9feb361b3 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php @@ -31,7 +31,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements /** @var \Magento\Framework\Json\Encoder */ protected $encoder; - /** @var \Magento\Integration\Service\V1\Integration */ + /** @var \Magento\Integration\Api\IntegrationServiceInterface */ protected $integrationService; /** @@ -44,7 +44,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements * @param \Magento\Framework\Acl\Resource\ProviderInterface $resourceProvider * @param \Magento\Integration\Helper\Data $integrationData * @param \Magento\Framework\Json\Encoder $encoder - * @param \Magento\Integration\Service\V1\Integration $integrationService + * @param \Magento\Integration\Api\IntegrationServiceInterface $integrationService * @param array $data */ public function __construct( @@ -55,7 +55,7 @@ public function __construct( \Magento\Framework\Acl\Resource\ProviderInterface $resourceProvider, \Magento\Integration\Helper\Data $integrationData, \Magento\Framework\Json\Encoder $encoder, - \Magento\Integration\Service\V1\Integration $integrationService, + \Magento\Integration\Api\IntegrationServiceInterface $integrationService, array $data = [] ) { $this->_rootResource = $rootResource; @@ -67,8 +67,9 @@ public function __construct( } /** - * Set the selected resources, which is an array of resource ids. If everything is allowed, the - * array will contain just the root resource id, which is "Magento_Backend::all". + * Set the selected resources, which is an array of resource ids. + * + * If everything is allowed, the array will contain just the root resource id, which is "Magento_Backend::all". * * @return void */ @@ -101,6 +102,8 @@ public function canShowTab() /** * {@inheritdoc} + * + * @codeCoverageIgnore */ public function getTabLabel() { @@ -109,6 +112,8 @@ public function getTabLabel() /** * {@inheritdoc} + * + * @codeCoverageIgnore */ public function getTabTitle() { @@ -117,6 +122,8 @@ public function getTabTitle() /** * {@inheritdoc} + * + * @codeCoverageIgnore */ public function isHidden() { @@ -147,7 +154,9 @@ public function getResourcesTreeJson() } /** - * Return an array of selected resource ids. If everything is allowed then iterate through all + * Return an array of selected resource ids. + * + * If everything is allowed then iterate through all * available resources to generate a comprehensive array of all resource ids, rather than just * returning "Magento_Backend::all". * @@ -167,6 +176,7 @@ public function getSelectedResourcesJson() * Whether tree has any resources. * * @return bool + * @codeCoverageIgnore */ public function isTreeEmpty() { diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tabs.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tabs.php index d49af7a5927d7..95b8c4ef756cd 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tabs.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tabs.php @@ -9,6 +9,11 @@ use Magento\Backend\Block\Widget\Tabs as TabsWidget; +/** + * Integration activation tabs. + * + * @codeCoverageIgnore + */ class Tabs extends TabsWidget { /** diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php index 665d3dbb4fe8d..624d4766cb832 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php @@ -21,17 +21,20 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements * * @var \Magento\Framework\Acl\RootResource */ - protected $_rootResource; + protected $rootResource; /** * Acl resource provider * * @var \Magento\Framework\Acl\Resource\ProviderInterface */ - protected $_aclResourceProvider; + protected $aclResourceProvider; /** @var \Magento\Integration\Helper\Data */ - protected $_integrationData; + protected $integrationData; + + /** @var \Magento\Integration\Api\IntegrationServiceInterface */ + protected $integrationService; /** * Initialize dependencies. @@ -42,7 +45,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements * @param \Magento\Framework\Acl\RootResource $rootResource * @param \Magento\Framework\Acl\Resource\ProviderInterface $aclResourceProvider * @param \Magento\Integration\Helper\Data $integrationData - * @param \Magento\Integration\Service\V1\Integration $integrationService + * @param \Magento\Integration\Api\IntegrationServiceInterface $integrationService * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -54,12 +57,12 @@ public function __construct( \Magento\Framework\Acl\RootResource $rootResource, \Magento\Framework\Acl\Resource\ProviderInterface $aclResourceProvider, \Magento\Integration\Helper\Data $integrationData, - \Magento\Integration\Service\V1\Integration $integrationService, + \Magento\Integration\Api\IntegrationServiceInterface $integrationService, array $data = [] ) { - $this->_rootResource = $rootResource; - $this->_aclResourceProvider = $aclResourceProvider; - $this->_integrationData = $integrationData; + $this->rootResource = $rootResource; + $this->aclResourceProvider = $aclResourceProvider; + $this->integrationData = $integrationData; $this->integrationService = $integrationService; parent::__construct($context, $registry, $formFactory, $data); } @@ -68,6 +71,7 @@ public function __construct( * Get tab label * * @return \Magento\Framework\Phrase + * @codeCoverageIgnore */ public function getTabLabel() { @@ -78,6 +82,7 @@ public function getTabLabel() * Get tab title * * @return string + * @codeCoverageIgnore */ public function getTabTitle() { @@ -101,6 +106,7 @@ public function canShowTab() * Whether tab is visible * * @return bool + * @codeCoverageIgnore */ public function isHidden() { @@ -131,11 +137,11 @@ protected function _construct() /** * Check if everything is allowed * - * @return boolean + * @return bool */ public function isEverythingAllowed() { - return in_array($this->_rootResource->getId(), $this->getSelectedResources()); + return in_array($this->rootResource->getId(), $this->getSelectedResources()); } /** @@ -145,8 +151,8 @@ public function isEverythingAllowed() */ public function getTree() { - $resources = $this->_aclResourceProvider->getAclResources(); - $rootArray = $this->_integrationData->mapResources( + $resources = $this->aclResourceProvider->getAclResources(); + $rootArray = $this->integrationData->mapResources( isset($resources[1]['children']) ? $resources[1]['children'] : [] ); return $rootArray; diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tabs.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tabs.php index c9d5bca7ae9c5..b3ad6808e01cc 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tabs.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tabs.php @@ -11,6 +11,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs * Initialize integration edit page tabs * * @return void + * @codeCoverageIgnore */ protected function _construct() { diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Grid.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Grid.php index 8e3d490e3ff56..622ca36c22904 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Grid.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Grid.php @@ -9,6 +9,9 @@ use Magento\Backend\Block\Widget\Grid as BackendGrid; +/** + * @codeCoverageIgnore + */ class Grid extends BackendGrid { /** diff --git a/app/code/Magento/Integration/Controller/Adminhtml/Integration.php b/app/code/Magento/Integration/Controller/Adminhtml/Integration.php index 2cf3aae943982..b1db3f9779ef8 100644 --- a/app/code/Magento/Integration/Controller/Adminhtml/Integration.php +++ b/app/code/Magento/Integration/Controller/Adminhtml/Integration.php @@ -6,7 +6,7 @@ namespace Magento\Integration\Controller\Adminhtml; use Magento\Backend\App\Action; -use Magento\Integration\Service\V1\OauthInterface as IntegrationOauthService; +use Magento\Integration\Api\OauthServiceInterface as IntegrationOauthService; /** * Controller for integrations management. @@ -31,10 +31,10 @@ class Integration extends Action /** @var \Psr\Log\LoggerInterface */ protected $_logger; - /** @var \Magento\Integration\Service\V1\IntegrationInterface */ + /** @var \Magento\Integration\Api\IntegrationServiceInterface */ protected $_integrationService; - /** @var IntegrationOauthService */ + /** @var \Magento\Integration\Api\OauthServiceInterface */ protected $_oauthService; /** @var \Magento\Framework\Json\Helper\Data */ @@ -43,7 +43,7 @@ class Integration extends Action /** @var \Magento\Integration\Helper\Data */ protected $_integrationData; - /** @var \Magento\Integration\Model\Resource\Integration\Collection */ + /** @var \Magento\Integration\Model\Resource\Integration\Collection */ protected $_integrationCollection; /** @@ -55,8 +55,8 @@ class Integration extends Action * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $registry * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Integration\Service\V1\IntegrationInterface $integrationService - * @param IntegrationOauthService $oauthService + * @param \Magento\Integration\Api\IntegrationServiceInterface $integrationService + * @param \Magento\Integration\Api\OauthServiceInterface $oauthService * @param \Magento\Framework\Json\Helper\Data $jsonHelper * @param \Magento\Integration\Helper\Data $integrationData * @param \Magento\Framework\Escaper $escaper @@ -66,8 +66,8 @@ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $registry, \Psr\Log\LoggerInterface $logger, - \Magento\Integration\Service\V1\IntegrationInterface $integrationService, - IntegrationOauthService $oauthService, + \Magento\Integration\Api\IntegrationServiceInterface $integrationService, + \Magento\Integration\Api\OauthServiceInterface $oauthService, \Magento\Framework\Json\Helper\Data $jsonHelper, \Magento\Integration\Helper\Data $integrationData, \Magento\Framework\Escaper $escaper, diff --git a/app/code/Magento/Integration/Controller/Token/Access.php b/app/code/Magento/Integration/Controller/Token/Access.php index 23c5969de5d22..c9c5c7c3124b0 100644 --- a/app/code/Magento/Integration/Controller/Token/Access.php +++ b/app/code/Magento/Integration/Controller/Token/Access.php @@ -7,30 +7,30 @@ namespace Magento\Integration\Controller\Token; use Magento\Integration\Model\Integration as IntegrationModel; -use Magento\Integration\Service\V1\IntegrationInterface as IntegrationService; -use Magento\Integration\Service\V1\OauthInterface as IntegrationOauthService; +use Magento\Integration\Api\IntegrationServiceInterface as IntegrationService; +use Magento\Integration\Api\OauthServiceInterface as IntegrationOauthService; class Access extends \Magento\Framework\App\Action\Action { /** - * @var \Magento\Framework\Oauth\OauthInterface + * @var \Magento\Framework\Oauth\OauthInterface */ - protected $_oauthService; + protected $oauthService; /** - * @var IntegrationOauthService + * @var IntegrationOauthService */ - protected $_intOauthService; + protected $intOauthService; /** - * @var IntegrationService + * @var IntegrationService */ - protected $_integrationService; + protected $integrationService; /** - * @var \Magento\Framework\Oauth\Helper\Request + * @var \Magento\Framework\Oauth\Helper\Request */ - protected $_helper; + protected $helper; /** * @param \Magento\Framework\App\Action\Context $context @@ -47,10 +47,10 @@ public function __construct( \Magento\Framework\Oauth\Helper\Request $helper ) { parent::__construct($context); - $this->_oauthService = $oauthService; - $this->_intOauthService = $intOauthService; - $this->_integrationService = $integrationService; - $this->_helper = $helper; + $this->oauthService = $oauthService; + $this->intOauthService = $intOauthService; + $this->integrationService = $integrationService; + $this->helper = $helper; } /** @@ -61,20 +61,18 @@ public function __construct( public function execute() { try { - $requestUrl = $this->_helper->getRequestUrl($this->getRequest()); - $request = $this->_helper->prepareRequest($this->getRequest(), $requestUrl); + $requestUrl = $this->helper->getRequestUrl($this->getRequest()); + $request = $this->helper->prepareRequest($this->getRequest(), $requestUrl); // Request access token in exchange of a pre-authorized token - $response = $this->_oauthService->getAccessToken($request, $requestUrl, $this->getRequest()->getMethod()); + $response = $this->oauthService->getAccessToken($request, $requestUrl, $this->getRequest()->getMethod()); //After sending the access token, update the integration status to active; - $consumer = $this->_intOauthService->loadConsumerByKey($request['oauth_consumer_key']); - $this->_integrationService->findByConsumerId( - $consumer->getId() - )->setStatus( - IntegrationModel::STATUS_ACTIVE - )->save(); + $consumer = $this->intOauthService->loadConsumerByKey($request['oauth_consumer_key']); + $integration = $this->integrationService->findByConsumerId($consumer->getId()); + $integration->setStatus(IntegrationModel::STATUS_ACTIVE); + $integration->save(); } catch (\Exception $exception) { - $response = $this->_helper->prepareErrorResponse($exception, $this->getResponse()); + $response = $this->helper->prepareErrorResponse($exception, $this->getResponse()); } $this->getResponse()->setBody(http_build_query($response)); } diff --git a/app/code/Magento/Integration/Controller/Token/Request.php b/app/code/Magento/Integration/Controller/Token/Request.php index 652b43c8b153a..d1ee7d042969b 100644 --- a/app/code/Magento/Integration/Controller/Token/Request.php +++ b/app/code/Magento/Integration/Controller/Token/Request.php @@ -11,12 +11,12 @@ class Request extends \Magento\Framework\App\Action\Action /** * @var \Magento\Framework\Oauth\OauthInterface */ - protected $_oauthService; + protected $oauthService; /** * @var \Magento\Framework\Oauth\Helper\Request */ - protected $_helper; + protected $helper; /** * @param \Magento\Framework\App\Action\Context $context @@ -29,8 +29,8 @@ public function __construct( \Magento\Framework\Oauth\Helper\Request $helper ) { parent::__construct($context); - $this->_oauthService = $oauthService; - $this->_helper = $helper; + $this->oauthService = $oauthService; + $this->helper = $helper; } /** @@ -41,13 +41,13 @@ public function __construct( public function execute() { try { - $requestUrl = $this->_helper->getRequestUrl($this->getRequest()); - $request = $this->_helper->prepareRequest($this->getRequest(), $requestUrl); + $requestUrl = $this->helper->getRequestUrl($this->getRequest()); + $request = $this->helper->prepareRequest($this->getRequest(), $requestUrl); // Request request token - $response = $this->_oauthService->getRequestToken($request, $requestUrl, $this->getRequest()->getMethod()); + $response = $this->oauthService->getRequestToken($request, $requestUrl, $this->getRequest()->getMethod()); } catch (\Exception $exception) { - $response = $this->_helper->prepareErrorResponse($exception, $this->getResponse()); + $response = $this->helper->prepareErrorResponse($exception, $this->getResponse()); } $this->getResponse()->setBody(http_build_query($response)); } diff --git a/app/code/Magento/Integration/Service/V1/AdminTokenService.php b/app/code/Magento/Integration/Model/AdminTokenService.php similarity index 96% rename from app/code/Magento/Integration/Service/V1/AdminTokenService.php rename to app/code/Magento/Integration/Model/AdminTokenService.php index 7fb947eacd820..d201b5e2a072c 100644 --- a/app/code/Magento/Integration/Service/V1/AdminTokenService.php +++ b/app/code/Magento/Integration/Model/AdminTokenService.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Framework\Exception\AuthenticationException; use Magento\Framework\Exception\LocalizedException; @@ -18,7 +18,7 @@ * Class to handle token generation for Admins * */ -class AdminTokenService implements AdminTokenServiceInterface +class AdminTokenService implements \Magento\Integration\Api\AdminTokenServiceInterface { /** * Token Model diff --git a/app/code/Magento/Integration/Service/V1/AuthorizationService.php b/app/code/Magento/Integration/Model/AuthorizationService.php similarity index 97% rename from app/code/Magento/Integration/Service/V1/AuthorizationService.php rename to app/code/Magento/Integration/Model/AuthorizationService.php index 066caff3773b9..4eb1b5fb0151a 100644 --- a/app/code/Magento/Integration/Service/V1/AuthorizationService.php +++ b/app/code/Magento/Integration/Model/AuthorizationService.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Authorization\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; use Magento\Authorization\Model\Resource\Rules\CollectionFactory as RulesCollectionFactory; @@ -24,7 +24,7 @@ * @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AuthorizationService implements AuthorizationServiceInterface +class AuthorizationService implements \Magento\Integration\Api\AuthorizationServiceInterface { /** * @var AclBuilder diff --git a/app/code/Magento/Integration/Model/Config.php b/app/code/Magento/Integration/Model/Config.php index e6408d519a286..ca04dfc378f06 100644 --- a/app/code/Magento/Integration/Model/Config.php +++ b/app/code/Magento/Integration/Model/Config.php @@ -47,6 +47,7 @@ public function __construct(Cache\Type $configCacheType, Config\Reader $configRe * Return integrations loaded from cache if enabled or from files merged previously * * @return array + * @api */ public function getIntegrations() { diff --git a/app/code/Magento/Integration/Model/ConfigBasedIntegrationManager.php b/app/code/Magento/Integration/Model/ConfigBasedIntegrationManager.php index 35d07e676a6e3..06508732e91f5 100644 --- a/app/code/Magento/Integration/Model/ConfigBasedIntegrationManager.php +++ b/app/code/Magento/Integration/Model/ConfigBasedIntegrationManager.php @@ -16,7 +16,7 @@ class ConfigBasedIntegrationManager /** * Integration service * - * @var \Magento\Integration\Service\V1\IntegrationInterface + * @var \Magento\Integration\Api\IntegrationServiceInterface */ protected $_integrationService; @@ -29,11 +29,11 @@ class ConfigBasedIntegrationManager /** * @param Config $integrationConfig - * @param \Magento\Integration\Service\V1\IntegrationInterface $integrationService + * @param \Magento\Integration\Api\IntegrationServiceInterface $integrationService */ public function __construct( Config $integrationConfig, - \Magento\Integration\Service\V1\IntegrationInterface $integrationService + \Magento\Integration\Api\IntegrationServiceInterface $integrationService ) { $this->_integrationService = $integrationService; $this->_integrationConfig = $integrationConfig; diff --git a/app/code/Magento/Integration/Service/V1/CustomerTokenService.php b/app/code/Magento/Integration/Model/CustomerTokenService.php similarity index 95% rename from app/code/Magento/Integration/Service/V1/CustomerTokenService.php rename to app/code/Magento/Integration/Model/CustomerTokenService.php index 9a5af05e87ea1..4b991cf4870b8 100644 --- a/app/code/Magento/Integration/Service/V1/CustomerTokenService.php +++ b/app/code/Magento/Integration/Model/CustomerTokenService.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Customer\Api\AccountManagementInterface; use Magento\Framework\Exception\LocalizedException; @@ -13,7 +13,7 @@ use Magento\Integration\Model\Oauth\TokenFactory as TokenModelFactory; use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory; -class CustomerTokenService implements CustomerTokenServiceInterface +class CustomerTokenService implements \Magento\Integration\Api\CustomerTokenServiceInterface { /** * Token Model diff --git a/app/code/Magento/Integration/Model/Integration.php b/app/code/Magento/Integration/Model/Integration.php index ea6c8964ec3b3..24b082fd8ade7 100644 --- a/app/code/Magento/Integration/Model/Integration.php +++ b/app/code/Magento/Integration/Model/Integration.php @@ -147,6 +147,7 @@ public function loadActiveIntegrationByConsumerId($consumerId) * Get integration status. Cast to the type of STATUS_* constants in order to make strict comparison valid. * * @return int + * @api */ public function getStatus() { diff --git a/app/code/Magento/Integration/Model/IntegrationConfig.php b/app/code/Magento/Integration/Model/IntegrationConfig.php index 0e4c0aa77ef07..e1487cd1efffa 100644 --- a/app/code/Magento/Integration/Model/IntegrationConfig.php +++ b/app/code/Magento/Integration/Model/IntegrationConfig.php @@ -49,6 +49,7 @@ public function __construct(TypeIntegration $configCacheType, Reader $configRead * Return integrations loaded from cache if enabled or from files merged previously * * @return array + * @api */ public function getIntegrations() { diff --git a/app/code/Magento/Integration/Service/V1/Integration.php b/app/code/Magento/Integration/Model/IntegrationService.php similarity index 96% rename from app/code/Magento/Integration/Service/V1/Integration.php rename to app/code/Magento/Integration/Model/IntegrationService.php index 23cfdbf011d4d..c106e2b8dac75 100644 --- a/app/code/Magento/Integration/Service/V1/Integration.php +++ b/app/code/Magento/Integration/Model/IntegrationService.php @@ -3,11 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Integration\Model\Integration as IntegrationModel; use Magento\Integration\Model\IntegrationFactory; -use Magento\Integration\Service\V1\OauthInterface as IntegrationOauthService; +use Magento\Integration\Api\OauthServiceInterface as IntegrationOauthService; use Magento\Framework\Exception\IntegrationException; /** @@ -15,7 +15,7 @@ * * This service is used to interact with integrations. */ -class Integration implements \Magento\Integration\Service\V1\IntegrationInterface +class IntegrationService implements \Magento\Integration\Api\IntegrationServiceInterface { /** * @var IntegrationFactory diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Model/OauthService.php similarity index 98% rename from app/code/Magento/Integration/Service/V1/Oauth.php rename to app/code/Magento/Integration/Model/OauthService.php index 9f59d33da5b68..f51ddae465328 100644 --- a/app/code/Magento/Integration/Service/V1/Oauth.php +++ b/app/code/Magento/Integration/Model/OauthService.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Framework\Oauth\Helper\Oauth as OauthHelper; use Magento\Integration\Helper\Oauth\Data as IntegrationOauthHelper; @@ -19,7 +19,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Oauth implements OauthInterface +class OauthService implements \Magento\Integration\Api\OauthServiceInterface { /** * @var \Magento\Store\Model\StoreManagerInterface diff --git a/app/code/Magento/Integration/Model/Plugin/Service/V1/Integration.php b/app/code/Magento/Integration/Model/Plugin/Integration.php similarity index 77% rename from app/code/Magento/Integration/Model/Plugin/Service/V1/Integration.php rename to app/code/Magento/Integration/Model/Plugin/Integration.php index c197e0cf920f9..e12af6c0c20d9 100644 --- a/app/code/Magento/Integration/Model/Plugin/Service/V1/Integration.php +++ b/app/code/Magento/Integration/Model/Plugin/Integration.php @@ -4,19 +4,20 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Model\Plugin\Service\V1; +namespace Magento\Integration\Model\Plugin; use Magento\Authorization\Model\Acl\AclRetriever; use Magento\Authorization\Model\UserContextInterface; use Magento\Integration\Model\Integration as IntegrationModel; -use Magento\Integration\Service\V1\AuthorizationServiceInterface as IntegrationAuthorizationInterface; +use Magento\Integration\Api\AuthorizationServiceInterface; +use Magento\Integration\Api\IntegrationServiceInterface; /** - * Plugin for \Magento\Integration\Service\V1\Integration. + * Plugin for \Magento\Integration\Model\IntegrationService. */ class Integration { - /** @var IntegrationAuthorizationInterface */ + /** @var AuthorizationServiceInterface */ protected $integrationAuthorizationService; /** @var AclRetriever */ @@ -25,11 +26,11 @@ class Integration /** * Initialize dependencies. * - * @param IntegrationAuthorizationInterface $integrationAuthorizationService + * @param AuthorizationServiceInterface $integrationAuthorizationService * @param AclRetriever $aclRetriever */ public function __construct( - IntegrationAuthorizationInterface $integrationAuthorizationService, + AuthorizationServiceInterface $integrationAuthorizationService, AclRetriever $aclRetriever ) { $this->integrationAuthorizationService = $integrationAuthorizationService; @@ -39,13 +40,13 @@ public function __construct( /** * Persist API permissions. * - * @param \Magento\Integration\Service\V1\Integration $subject + * @param IntegrationServiceInterface $subject * @param IntegrationModel $integration * * @return IntegrationModel * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterCreate(\Magento\Integration\Service\V1\Integration $subject, $integration) + public function afterCreate(IntegrationServiceInterface $subject, $integration) { $this->_saveApiPermissions($integration); return $integration; @@ -54,13 +55,13 @@ public function afterCreate(\Magento\Integration\Service\V1\Integration $subject /** * Persist API permissions. * - * @param \Magento\Integration\Service\V1\Integration $subject + * @param IntegrationServiceInterface $subject * @param IntegrationModel $integration * * @return IntegrationModel * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterUpdate(\Magento\Integration\Service\V1\Integration $subject, $integration) + public function afterUpdate(IntegrationServiceInterface $subject, $integration) { $this->_saveApiPermissions($integration); return $integration; @@ -69,13 +70,13 @@ public function afterUpdate(\Magento\Integration\Service\V1\Integration $subject /** * Add API permissions to integration data. * - * @param \Magento\Integration\Service\V1\Integration $subject + * @param IntegrationServiceInterface $subject * @param IntegrationModel $integration * * @return IntegrationModel * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGet(\Magento\Integration\Service\V1\Integration $subject, $integration) + public function afterGet(IntegrationServiceInterface $subject, $integration) { $this->_addAllowedResources($integration); return $integration; @@ -126,13 +127,13 @@ protected function _saveApiPermissions(IntegrationModel $integration) /** * Process integration resource permissions after the integration is created * - * @param \Magento\Integration\Service\V1\Integration $subject + * @param IntegrationServiceInterface $subject * @param array $integrationData Data of integration deleted * * @return array $integrationData * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDelete(\Magento\Integration\Service\V1\Integration $subject, array $integrationData) + public function afterDelete(IntegrationServiceInterface $subject, array $integrationData) { //No check needed for integration data since it cannot be empty in the parent invocation - delete $integrationId = (int)$integrationData[IntegrationModel::ID]; diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php new file mode 100644 index 0000000000000..200e1909a5819 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php @@ -0,0 +1,49 @@ +objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->infoBlock = $this->objectManager->getObject( + 'Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info' + ); + } + + public function testGetTabLabelAndTitle() + { + $tabString = 'Integration Info'; + $this->assertEquals($tabString, $this->infoBlock->getTabLabel()); + $this->assertEquals($tabString, $this->infoBlock->getTabTitle()); + } + + public function testCanShowTab() + { + $this->assertTrue($this->infoBlock->canShowTab()); + } + + public function testIsHidden() + { + $this->assertFalse($this->infoBlock->isHidden()); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php new file mode 100644 index 0000000000000..b0b4da28c34e4 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php @@ -0,0 +1,203 @@ +objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + + $this->rootResource = $this->getMockBuilder('Magento\Framework\Acl\RootResource') + ->disableOriginalConstructor() + ->getMock(); + + $this->aclResourceProvider = $this->getMockBuilder('Magento\Framework\Acl\Resource\ProviderInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->integrationHelper = $this->getMockBuilder('Magento\Integration\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + + $this->integrationService = $this->getMockBuilder('Magento\Integration\Model\IntegrationService') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @param array $integrationData + * @param bool $expectedValue + * @dataProvider canShowTabProvider + */ + public function testCanShowTab($integrationData, $expectedValue) + { + $this->webapiBlock = $this->getWebapiBlock($integrationData); + $this->assertEquals($expectedValue, $this->webapiBlock->canShowTab()); + } + + public function canShowTabProvider() + { + return [ + 'null data' => [ + null, + true + ], + 'empty integration data' => [ + [], + true + ], + 'manual integration data' => [ + [Info::DATA_SETUP_TYPE => IntegrationModel::TYPE_MANUAL], + true + ], + 'config integration data' => [ + [Info::DATA_SETUP_TYPE => IntegrationModel::TYPE_CONFIG], + false + ], + ]; + } + + public function testIsHidden() + { + $this->webapiBlock = $this->getWebapiBlock(); + $this->assertFalse($this->webapiBlock->isHidden()); + } + + /** + * @param string $rootResourceId + * @param array $integrationData + * @param array $selectedResources + * @param bool $expectedValue + * @dataProvider isEverythingAllowedProvider + */ + public function testIsEverythingAllowed($rootResourceId, $integrationData, $selectedResources, $expectedValue) + { + $this->webapiBlock = $this->getWebapiBlock($integrationData, $selectedResources); + $this->rootResource->expects($this->once()) + ->method('getId') + ->will($this->returnValue($rootResourceId)); + $this->assertEquals($expectedValue, $this->webapiBlock->isEverythingAllowed()); + } + + public function isEverythingAllowedProvider() + { + return [ + 'root resource in array' => [ + 2, + ['integration_id' => 1], + [1, 2, 3], + true + ], + 'root resource not in array' => [ + 1, + ['integration_id' => 1], + [2, 3, 4], + false + ], + 'no integration data' => [ + 1, + [], + [], + false + ], + ]; + } + + public function testGetTree() + { + $this->webapiBlock = $this->getWebapiBlock(); + $resources = [ + 1 => [ 'children' => [1, 2, 3] ] + ]; + $this->aclResourceProvider->expects($this->once()) + ->method('getAclResources') + ->will($this->returnValue($resources)); + $rootArray = "rootArrayValue"; + $this->integrationHelper->expects($this->once()) + ->method('mapResources') + ->with([1, 2, 3]) + ->will($this->returnValue($rootArray)); + $this->assertEquals($rootArray, $this->webapiBlock->getTree()); + } + + /** + * @param array $integrationData + * @param array $selectedResources + * @return \Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Webapi + */ + private function getWebapiBlock($integrationData = [], array $selectedResources = []) + { + if ($integrationData) { + if (isset($integrationData['integration_id'])) { + $this->integrationService->expects($this->once()) + ->method('getSelectedResources') + ->with($integrationData['integration_id']) + ->will($this->returnValue($selectedResources)); + } + } + + $this->registry->expects($this->any()) + ->method('registry') + ->with(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION) + ->will($this->returnValue($integrationData)); + + return $this->objectManager->getObject( + 'Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Webapi', + [ + 'registry' => $this->registry, + 'rootResource' => $this->rootResource, + 'aclResourceProvider' => $this->aclResourceProvider, + 'integrationData' => $this->integrationHelper, + 'integrationService' => $this->integrationService, + ] + ); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php new file mode 100644 index 0000000000000..5f718df71a5cb --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/ButtonTest.php @@ -0,0 +1,70 @@ +escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); + $this->contextMock = $this->getMock('Magento\Backend\Block\Context', ['getEscaper'], [], '', false); + $this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock)); + + $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->buttonRenderer = $this->objectManagerHelper->getObject( + 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Button', + ['context' => $this->contextMock] + ); + } + + /** + * Test the basic render action. + */ + public function testRender() + { + $expectedResult = ''; + $column = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + ->disableOriginalConstructor() + ->setMethods(['getType', 'getId', 'getIndex']) + ->getMock(); + $column->expects($this->any()) + ->method('getType') + ->will($this->returnValue('bigButton')); + $column->expects($this->any()) + ->method('getId') + ->willReturn('1'); + $column->expects($this->any()) + ->method('getIndex') + ->willReturn('name'); + $this->buttonRenderer->setColumn($column); + + $object = new \Magento\Framework\Object(['name' => 'my button']); + $actualResult = $this->buttonRenderer->render($object); + $this->assertEquals($expectedResult, $actualResult); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php new file mode 100644 index 0000000000000..8d308aeea0b41 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/LinkTest.php @@ -0,0 +1,82 @@ +escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); + $this->urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $this->urlBuilderMock->expects($this->once())->method('getUrl')->willReturn('http://magento.loc/linkurl'); + $this->contextMock = $this->getMock( + 'Magento\Backend\Block\Context', + ['getEscaper', 'getUrlBuilder'], + [], + '', + false + ); + $this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock)); + $this->contextMock->expects($this->any()) + ->method('getUrlBuilder') + ->will($this->returnValue($this->urlBuilderMock)); + + $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->linkRenderer = $this->objectManagerHelper->getObject( + 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Link', + ['context' => $this->contextMock] + ); + } + + /** + * Test the basic render action. + */ + public function testRender() + { + $expectedResult = 'Link Caption'; + $column = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + ->disableOriginalConstructor() + ->setMethods(['getCaption', 'getId']) + ->getMock(); + $column->expects($this->any()) + ->method('getCaption') + ->will($this->returnValue('Link Caption')); + $column->expects($this->any()) + ->method('getId') + ->willReturn('1'); + $this->linkRenderer->setColumn($column); + $object = new \Magento\Framework\Object(['id' => '1']); + $actualResult = $this->linkRenderer->render($object); + $this->assertEquals($expectedResult, $actualResult); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php new file mode 100644 index 0000000000000..52e75aadc3fa5 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Widget/Grid/Column/Renderer/NameTest.php @@ -0,0 +1,108 @@ +escaperMock = $this->getMock('Magento\Framework\Escaper', [], [], '', false); + $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0); + $this->urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $this->urlBuilderMock->expects($this->any())->method('getUrl')->willReturn('http://magento.loc/linkurl'); + $this->contextMock = $this->getMock( + 'Magento\Backend\Block\Context', + ['getEscaper', 'getUrlBuilder'], + [], + '', + false + ); + $this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock)); + $this->contextMock->expects($this->any()) + ->method('getUrlBuilder') + ->will($this->returnValue($this->urlBuilderMock)); + + $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->nameRenderer = $this->objectManagerHelper->getObject( + 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Name', + ['context' => $this->contextMock] + ); + } + + /** + * Test the basic render action. + * @dataProvider endpointDataProvider + */ + public function testRender($endpoint, $name, $expectedResult) + { + $column = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') + ->disableOriginalConstructor() + ->setMethods(['getIndex', 'getEditable', 'getGetter']) + ->getMock(); + $column->expects($this->any()) + ->method('getIndex') + ->willReturn('name'); + $column->expects($this->any()) + ->method('getEditable') + ->willReturn(false); + $column->expects($this->any()) + ->method('getGetter') + ->willReturn('getName'); + $this->nameRenderer->setColumn($column); + + $integrationMock = $this->getMockBuilder('Magento\Integration\Model\Integration') + ->disableOriginalConstructor() + ->setMethods(['getName', 'getEndpoint', 'getIdentityLinkUrl']) + ->getMock(); + $integrationMock->expects($this->any())->method('getName')->willReturn($name); + $integrationMock->expects($this->any())->method('getEndpoint')->willReturn($endpoint); + $integrationMock->expects($this->any())->method('getIdentityLinkUrl')->willReturn($endpoint); + $actualResult = $this->nameRenderer->render($integrationMock); + $this->assertEquals($expectedResult, $actualResult); + } + + public function endpointDataProvider() + { + return [ + [ + 'https://myurl', + 'Custom Integration', + 'Custom Integration' + ], + [ + 'http://myurl', + 'Custom Integration', + 'Custom IntegrationIntegration not secure' + ] + ]; + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php index d3fd636940bac..33f4c82175f4c 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTest.php @@ -43,10 +43,10 @@ abstract class IntegrationTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ protected $_backendActionCtxMock; - /** @var \Magento\Integration\Service\V1\Integration|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Integration\Api\IntegrationServiceInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_integrationSvcMock; - /** @var \Magento\Integration\Service\V1\Oauth|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Integration\Api\OauthServiceInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_oauthSvcMock; /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject */ @@ -129,10 +129,10 @@ protected function setUp() 'Magento\Framework\TranslateInterface' )->disableOriginalConstructor()->getMock(); $this->_integrationSvcMock = $this->getMockBuilder( - 'Magento\Integration\Service\V1\Integration' + 'Magento\Integration\Api\IntegrationServiceInterface' )->disableOriginalConstructor()->getMock(); $this->_oauthSvcMock = $this->getMockBuilder( - 'Magento\Integration\Service\V1\Oauth' + 'Magento\Integration\Api\OauthServiceInterface' )->disableOriginalConstructor()->getMock(); $this->_requestMock = $this->getMockBuilder( 'Magento\Framework\App\Request\Http' diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php new file mode 100644 index 0000000000000..121db1fb72357 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Controller/Token/AccessTest.php @@ -0,0 +1,183 @@ +request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + [ + 'getMethod', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getParam', + 'setParams', + 'getParams', + 'getCookie', + 'isSecure' + ], + [], + '', + false + ); + $this->response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); + /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + + /** @var \Magento\Framework\View\Layout\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject */ + $update = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */ + $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $layout->expects($this->any())->method('getUpdate')->will($this->returnValue($update)); + + /** @var \Magento\Framework\View\Page\Config */ + $pageConfig = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf()); + + /** @var \Magento\Framework\View\Page|\PHPUnit_Framework_MockObject_MockObject */ + $page = $this->getMock( + 'Magento\Framework\View\Page', + ['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout'], + [], + '', + false + ); + $page->expects($this->any())->method('getConfig')->will($this->returnValue($pageConfig)); + $page->expects($this->any())->method('addPageLayoutHandles')->will($this->returnSelf()); + $page->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); + + /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ + $view = $this->getMock('Magento\Framework\App\ViewInterface', [], [], '', false); + $view->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); + + /** @var Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */ + $resultFactory = $this->getMock('Magento\Framework\Controller\ResultFactory', [], [], '', false); + $resultFactory->expects($this->any())->method('create')->will($this->returnValue($page)); + + $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); + $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response)); + $this->context->expects($this->any())->method('getObjectManager') + ->will($this->returnValue($objectManager)); + $this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager)); + $this->context->expects($this->any())->method('getView')->will($this->returnValue($view)); + $this->context->expects($this->any())->method('getResultFactory') + ->will($this->returnValue($resultFactory)); + + $this->helperMock = $this->getMock('Magento\Framework\Oauth\Helper\Request', [], [], '', false); + $this->frameworkOauthSvcMock = $this->getMock('Magento\Framework\Oauth\OauthInterface', [], [], '', false); + $this->intOauthServiceMock = $this->getMock('Magento\Integration\Api\OauthServiceInterface', [], [], '', false); + $this->integrationServiceMock = $this->getMock( + 'Magento\Integration\Api\IntegrationServiceInterface', + [], + [], + '', + false + ); + + /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManagerHelper */ + $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->accessAction = $this->objectManagerHelper->getObject( + 'Magento\Integration\Controller\Token\Access', + [ + 'context' => $this->context, + 'oauthService'=> $this->frameworkOauthSvcMock, + 'intOauthService' => $this->intOauthServiceMock, + 'integrationService' => $this->integrationServiceMock, + 'helper' => $this->helperMock, + ] + ); + } + + /** + * Test the basic Access action. + */ + public function testAccessAction() + { + $this->request->expects($this->any()) + ->method('getMethod') + ->willReturn('GET'); + $this->helperMock->expects($this->once()) + ->method('getRequestUrl'); + $this->helperMock->expects($this->once()) + ->method('prepareRequest'); + $this->frameworkOauthSvcMock->expects($this->once()) + ->method('getAccessToken') + ->willReturn(['response']); + /** @var \Magento\Integration\Model\Oauth\Consumer|\PHPUnit_Framework_MockObject_MockObject */ + $consumerMock = $this->getMock('Magento\Integration\Model\Oauth\Consumer', [], [], '', false); + $consumerMock->expects($this->once()) + ->method('getId'); + $this->intOauthServiceMock->expects($this->once()) + ->method('loadConsumerByKey') + ->willReturn($consumerMock); + /** @var \Magento\Integration\Model\Integration|\PHPUnit_Framework_MockObject_MockObject */ + $integrationMock = $this->getMock('Magento\Integration\Model\Integration', [], [], '', false); + $integrationMock->expects($this->once()) + ->method('save') + ->willReturnSelf(); + $this->integrationServiceMock->expects($this->once()) + ->method('findByConsumerId') + ->willReturn($integrationMock); + $this->response->expects($this->once()) + ->method('setBody'); + + $this->accessAction->execute(); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php new file mode 100644 index 0000000000000..f387829278f90 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Controller/Token/RequestTest.php @@ -0,0 +1,147 @@ +request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + [ + 'getMethod', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getParam', + 'setParams', + 'getParams', + 'getCookie', + 'isSecure' + ], + [], + '', + false + ); + $this->response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); + /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false); + /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + + /** @var \Magento\Framework\View\Layout\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject */ + $update = $this->getMock('Magento\Framework\View\Layout\ProcessorInterface', [], [], '', false); + /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */ + $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); + $layout->expects($this->any())->method('getUpdate')->will($this->returnValue($update)); + + /** @var \Magento\Framework\View\Page\Config */ + $pageConfig = $this->getMock('Magento\Framework\View\Page\Config', [], [], '', false); + $pageConfig->expects($this->any())->method('addBodyClass')->will($this->returnSelf()); + + /** @var \Magento\Framework\View\Page|\PHPUnit_Framework_MockObject_MockObject */ + $page = $this->getMock( + 'Magento\Framework\View\Page', + ['getConfig', 'initLayout', 'addPageLayoutHandles', 'getLayout'], + [], + '', + false + ); + $page->expects($this->any())->method('getConfig')->will($this->returnValue($pageConfig)); + $page->expects($this->any())->method('addPageLayoutHandles')->will($this->returnSelf()); + $page->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); + + /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ + $view = $this->getMock('Magento\Framework\App\ViewInterface', [], [], '', false); + $view->expects($this->any())->method('getLayout')->will($this->returnValue($layout)); + + /** @var Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */ + $resultFactory = $this->getMock('Magento\Framework\Controller\ResultFactory', [], [], '', false); + $resultFactory->expects($this->any())->method('create')->will($this->returnValue($page)); + + $this->context = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); + $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response)); + $this->context->expects($this->any())->method('getObjectManager') + ->will($this->returnValue($objectManager)); + $this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager)); + $this->context->expects($this->any())->method('getView')->will($this->returnValue($view)); + $this->context->expects($this->any())->method('getResultFactory') + ->will($this->returnValue($resultFactory)); + + $this->helperMock = $this->getMock('Magento\Framework\Oauth\Helper\Request', [], [], '', false); + $this->frameworkOauthSvcMock = $this->getMock('Magento\Framework\Oauth\OauthInterface', [], [], '', false); + + /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManagerHelper */ + $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->requestAction = $this->objectManagerHelper->getObject( + 'Magento\Integration\Controller\Token\Request', + [ + 'context' => $this->context, + 'oauthService'=> $this->frameworkOauthSvcMock, + 'helper' => $this->helperMock, + ] + ); + } + + /** + * Test the basic Request action. + */ + public function testRequestAction() + { + $this->request->expects($this->any()) + ->method('getMethod') + ->willReturn('GET'); + $this->helperMock->expects($this->once()) + ->method('getRequestUrl'); + $this->helperMock->expects($this->once()) + ->method('prepareRequest'); + $this->frameworkOauthSvcMock->expects($this->once()) + ->method('getRequestToken') + ->willReturn(['response']); + $this->response->expects($this->once()) + ->method('setBody'); + $this->requestAction->execute(); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php b/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php new file mode 100644 index 0000000000000..12be343a47526 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Helper/DataTest.php @@ -0,0 +1,61 @@ +dataHelper = $helper->getObject('Magento\Integration\Helper\Data'); + } + + public function testMapResources() + { + $testData = require __DIR__ . '/_files/acl.php'; + $expectedData = require __DIR__ . '/_files/acl-map.php'; + $this->assertEquals($expectedData, $this->dataHelper->mapResources($testData)); + } + + /** + * @dataProvider integrationDataProvider + */ + public function testIsConfigType($integrationsData, $expectedResult) + { + $this->assertEquals($expectedResult, $this->dataHelper->isConfigType($integrationsData)); + } + + public function integrationDataProvider() + { + return [ + [ + [ + 'id' => 1, + Integration::NAME => 'TestIntegration1', + Integration::EMAIL => 'test-integration1@magento.com', + Integration::ENDPOINT => 'http://endpoint.com', + Integration::SETUP_TYPE => 1, + ], + true, + ], + [ + [ + 'id' => 1, + Integration::NAME => 'TestIntegration1', + Integration::EMAIL => 'test-integration1@magento.com', + Integration::ENDPOINT => 'http://endpoint.com', + Integration::SETUP_TYPE => 0, + ], + false, + ] + ]; + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php index b6d5fa3fdf1ef..10bbc439425e1 100644 --- a/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Helper/Oauth/ConsumerTest.php @@ -31,7 +31,7 @@ class ConsumerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Integration\Helper\Oauth\Data */ protected $_dataHelper; - /** @var \Magento\Integration\Service\V1\OauthInterface */ + /** @var \Magento\Integration\Api\OauthServiceInterface */ protected $_oauthService; /** @var \Psr\Log\LoggerInterface */ @@ -94,7 +94,7 @@ protected function setUp() 'Psr\Log\LoggerInterface' )->getMock(); - $this->_oauthService = new \Magento\Integration\Service\V1\Oauth( + $this->_oauthService = new \Magento\Integration\Model\OauthService( $this->_storeManagerMock, $this->_consumerFactory, $this->_tokenFactory, diff --git a/app/code/Magento/Integration/Test/Unit/Helper/_files/acl-map.php b/app/code/Magento/Integration/Test/Unit/Helper/_files/acl-map.php new file mode 100644 index 0000000000000..08beefb050c6f --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Helper/_files/acl-map.php @@ -0,0 +1,57 @@ + [ + 'data-id' => 'Magento_Webapi', + ], + 'data' => 'Magento Webapi', + 'children' => [ + [ + 'attr' => [ + 'data-id' => 'customer', + ], + 'data' => 'Manage Customers', + 'children' => [ + [ + 'attr' => [ + 'data-id' => 'customer/create', + ], + 'data' => 'Create Customer', + 'children' => [], + 'state' => 'open', + ], + [ + 'attr' => [ + 'data-id' => 'customer/update', + ], + 'data' => 'Edit Customer', + 'children' => [], + 'state' => 'open', + ], + [ + 'attr' => [ + 'data-id' => 'customer/get', + ], + 'data' => 'Get Customer', + 'children' => [], + 'state' => 'open', + ], + [ + 'attr' => [ + 'data-id' => 'customer/delete', + ], + 'data' => 'Delete Customer', + 'children' => [], + 'state' => 'open', + ], + ], + 'state' => 'open', + ], + ], + 'state' => 'open', + ] +]; diff --git a/app/code/Magento/Integration/Test/Unit/Helper/_files/acl.php b/app/code/Magento/Integration/Test/Unit/Helper/_files/acl.php new file mode 100644 index 0000000000000..44b8db90c8c5c --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Helper/_files/acl.php @@ -0,0 +1,39 @@ + 'Magento_Webapi', + 'title' => 'Magento Webapi', + 'children' => [ + [ + 'id' => 'customer', + 'title' => 'Manage Customers', + 'sortOrder' => 20, + 'children' => [ + [ + 'id' => 'customer/create', + 'title' => 'Create Customer', + 'sortOrder' => '30', + 'children' => [], + ], + [ + 'id' => 'customer/update', + 'title' => 'Edit Customer', + 'sortOrder' => '10', + 'children' => [] + ], + [ + 'id' => 'customer/get', + 'title' => 'Get Customer', + 'sortOrder' => '20', + 'children' => [] + ], + ['id' => 'customer/delete', 'title' => 'Delete Customer', 'children' => []], + ], + ], + ], + ] +]; diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/AdminTokenServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php similarity index 95% rename from app/code/Magento/Integration/Test/Unit/Service/V1/AdminTokenServiceTest.php rename to app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php index c5d6469a971b1..1204c9a568ce2 100644 --- a/app/code/Magento/Integration/Test/Unit/Service/V1/AdminTokenServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php @@ -1,6 +1,6 @@ disableOriginalConstructor()->getMock(); - $this->_tokenService = new \Magento\Integration\Service\V1\AdminTokenService( + $this->_tokenService = new \Magento\Integration\Model\AdminTokenService( $this->_tokenFactoryMock, $this->_userModelMock, $this->_tokenModelCollectionFactoryMock, diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/AuthorizationServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php similarity index 95% rename from app/code/Magento/Integration/Test/Unit/Service/V1/AuthorizationServiceTest.php rename to app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php index e642481ad7d86..3f491861f042e 100644 --- a/app/code/Magento/Integration/Test/Unit/Service/V1/AuthorizationServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/AuthorizationServiceTest.php @@ -3,10 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Integration\Test\Unit\Service\V1; - -use \Magento\Integration\Service\V1\AuthorizationService; +namespace Magento\Integration\Test\Unit\Model; +use Magento\Integration\Model\AuthorizationService; use Magento\Authorization\Model\Role; use Magento\Authorization\Model\UserContextInterface; diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php new file mode 100644 index 0000000000000..c7db94a41d216 --- /dev/null +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/SchemaLocatorTest.php @@ -0,0 +1,40 @@ +moduleDir = 'moduleDirectory'; + $this->moduleReader = $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false); + $this->moduleReader->expects($this->any()) + ->method('getModuleDir') + ->willReturn($this->moduleDir); + $this->schemaLocator = new SchemaLocator($this->moduleReader); + } + + public function testGetSchema() + { + $this->assertEquals($this->moduleDir . '/integration/config.xsd', $this->schemaLocator->getSchema()); + } + + public function testGetPerFileSchema() + { + $this->assertNull($this->schemaLocator->getPerFileSchema()); + } +} diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/CustomerTokenServiceTest.php b/app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php similarity index 95% rename from app/code/Magento/Integration/Test/Unit/Service/V1/CustomerTokenServiceTest.php rename to app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php index a468560477195..66aa5af050d6c 100644 --- a/app/code/Magento/Integration/Test/Unit/Service/V1/CustomerTokenServiceTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php @@ -1,19 +1,19 @@ disableOriginalConstructor()->getMock(); - $this->_tokenService = new \Magento\Integration\Service\V1\CustomerTokenService( + $this->_tokenService = new \Magento\Integration\Model\CustomerTokenService( $this->_tokenFactoryMock, $this->_accountManagementMock, $this->_tokenModelCollectionFactoryMock, diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php similarity index 97% rename from app/code/Magento/Integration/Test/Unit/Service/V1/IntegrationTest.php rename to app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php index e3f3a304e13c7..f3e8d48ec022f 100644 --- a/app/code/Magento/Integration/Test/Unit/Service/V1/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/IntegrationServiceTest.php @@ -1,15 +1,15 @@ getMockBuilder( - 'Magento\Integration\Service\V1\Oauth' + 'Magento\Integration\Api\OauthServiceInterface' )->disableOriginalConstructor()->getMock(); $oauthConsumer = $this->getMockBuilder( 'Magento\Integration\Model\Oauth\Consumer' @@ -91,7 +91,7 @@ protected function setUp() ); $oauthConsumerHelper->expects($this->any())->method('loadConsumer')->will($this->returnValue($oauthConsumer)); - $this->_service = new \Magento\Integration\Service\V1\Integration( + $this->_service = new \Magento\Integration\Model\IntegrationService( $this->_integrationFactory, $oauthConsumerHelper ); diff --git a/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php b/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php index 8332ece44408f..adcf3a7e69735 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/ManagerTest.php @@ -15,7 +15,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase /** * Integration service * - * @var \Magento\Integration\Service\V1\IntegrationInterface + * @var \Magento\Integration\Api\IntegrationServiceInterface */ protected $_integrationServiceMock; @@ -42,9 +42,18 @@ public function setUp() )->getMock(); $this->_integrationServiceMock = $this->getMockBuilder( - '\Magento\Integration\Service\V1\Integration' + '\Magento\Integration\Api\IntegrationServiceInterface' )->disableOriginalConstructor()->setMethods( - ['findByName', 'update', 'create'] + [ + 'findByName', + 'update', + 'create', + 'get', + 'findByConsumerId', + 'findActiveIntegrationByConsumerId', + 'delete', + 'getSelectedResources' + ] )->getMock(); $this->_integrationManager = new \Magento\Integration\Model\ConfigBasedIntegrationManager( diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php b/app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php similarity index 98% rename from app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php rename to app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php index 01d17a14abf7f..2346d34ff8e32 100644 --- a/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/OauthServiceTest.php @@ -1,16 +1,16 @@ returnValue($this->_consumerMock) ); - $this->_service = new \Magento\Integration\Service\V1\Oauth( + $this->_service = new \Magento\Integration\Model\OauthService( $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false), $this->_consumerFactory, $this->_tokenFactoryMock, diff --git a/app/code/Magento/Integration/Test/Unit/Model/Plugin/Service/V1/IntegrationTest.php b/app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php similarity index 73% rename from app/code/Magento/Integration/Test/Unit/Model/Plugin/Service/V1/IntegrationTest.php rename to app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php index 2385d865154ee..d1b9cdc11d9a1 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Plugin/Service/V1/IntegrationTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Plugin/IntegrationTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Integration\Test\Unit\Model\Plugin\Service\V1; +namespace Magento\Integration\Test\Unit\Model\Plugin; use Magento\Authorization\Model\Acl\AclRetriever; use Magento\Integration\Model\Integration; @@ -13,9 +13,9 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase /** * API setup plugin * - * @var \Magento\Integration\Model\Plugin\Service\V1\Integration + * @var \Magento\Integration\Model\Plugin\Integration */ - protected $integrationV1Plugin; + protected $integrationPlugin; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -26,20 +26,20 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase protected $aclRetrieverMock; /** - * @var \Magento\Integration\Service\V1\AuthorizationServiceInterface + * @var \Magento\Integration\Api\AuthorizationServiceInterface */ protected $integrationAuthServiceMock; public function setUp() { - $this->subjectMock = $this->getMock('Magento\Integration\Service\V1\Integration', [], [], '', false); + $this->subjectMock = $this->getMock('Magento\Integration\Model\IntegrationService', [], [], '', false); $this->integrationAuthServiceMock = $this->getMockBuilder( - 'Magento\Integration\Service\V1\AuthorizationServiceInterface' + 'Magento\Integration\Api\AuthorizationServiceInterface' )->disableOriginalConstructor()->getMock(); $this->aclRetrieverMock = $this->getMockBuilder('Magento\Authorization\Model\Acl\AclRetriever') ->disableOriginalConstructor() ->getMock(); - $this->integrationV1Plugin = new \Magento\Integration\Model\Plugin\Service\V1\Integration( + $this->integrationPlugin = new \Magento\Integration\Model\Plugin\Integration( $this->integrationAuthServiceMock, $this->aclRetrieverMock ); @@ -59,6 +59,6 @@ public function testAfterDelete() $this->integrationAuthServiceMock->expects($this->once()) ->method('removePermissions') ->with($integrationId); - $this->integrationV1Plugin->afterDelete($this->subjectMock, $integrationsData); + $this->integrationPlugin->afterDelete($this->subjectMock, $integrationsData); } } diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index fa450641b3929..603652fc0c2bc 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-user": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-authorization": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-user": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-authorization": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Integration/etc/di.xml b/app/code/Magento/Integration/etc/di.xml index 12cf8efdc0dea..36429fa01027c 100644 --- a/app/code/Magento/Integration/etc/di.xml +++ b/app/code/Magento/Integration/etc/di.xml @@ -6,14 +6,14 @@ */ --> - - - + + + - - + + Magento\Framework\Stdlib\DateTime\DateTime\Proxy @@ -24,7 +24,7 @@ Magento\Framework\Stdlib\DateTime\DateTime\Proxy - - + + diff --git a/app/code/Magento/Integration/etc/webapi.xml b/app/code/Magento/Integration/etc/webapi.xml index 9b216a11994c9..10473f6d871ab 100644 --- a/app/code/Magento/Integration/etc/webapi.xml +++ b/app/code/Magento/Integration/etc/webapi.xml @@ -8,13 +8,13 @@ - + - + diff --git a/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml b/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml index c30380511ed23..8e9d1d18451e6 100644 --- a/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml +++ b/app/code/Magento/Integration/view/adminhtml/templates/integration/popup_container.phtml @@ -32,8 +32,7 @@ require([ modal: true, autoOpen: true, resizable: false, - minHeight: 200, - minWidth: 300, + minHeight: 0, width: '75%', dialogClass: 'no-close ui-popup-message', position: { diff --git a/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRenderer.php b/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRenderer.php index fb4ff5033e26c..11114ba621c51 100644 --- a/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRenderer.php +++ b/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRenderer.php @@ -7,16 +7,17 @@ */ namespace Magento\LayeredNavigation\Block\Navigation; +use Magento\Catalog\Model\Layer\Filter\FilterInterface; use Magento\Framework\View\Element\Template; +use Magento\LayeredNavigation\Block\Navigation\FilterRendererInterface; -class FilterRenderer extends \Magento\Framework\View\Element\Template implements - \Magento\LayeredNavigation\Block\Navigation\FilterRendererInterface +class FilterRenderer extends Template implements FilterRendererInterface { /** - * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter + * @param FilterInterface $filter * @return string */ - public function render(\Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter) + public function render(FilterInterface $filter) { $this->assign('filterItems', $filter->getItems()); $html = $this->_toHtml(); diff --git a/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRendererInterface.php b/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRendererInterface.php index c382efa03d5bf..ee4f21d11b1d9 100644 --- a/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRendererInterface.php +++ b/app/code/Magento/LayeredNavigation/Block/Navigation/FilterRendererInterface.php @@ -5,13 +5,19 @@ */ namespace Magento\LayeredNavigation\Block\Navigation; +use Magento\Catalog\Model\Layer\Filter\FilterInterface; + +/** + * Interface FilterRendererInterface + * @api + */ interface FilterRendererInterface { /** * Render filter * - * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter + * @param FilterInterface $filter * @return string */ - public function render(\Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter); + public function render(FilterInterface $filter); } diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index cbb01d30b8a62..99f2a20e4e5af 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.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Log/Test/Unit/Console/Command/LogCleanCommandTest.php b/app/code/Magento/Log/Test/Unit/Console/Command/LogCleanCommandTest.php index 0db32a17c3295..c6c40ab0b301f 100644 --- a/app/code/Magento/Log/Test/Unit/Console/Command/LogCleanCommandTest.php +++ b/app/code/Magento/Log/Test/Unit/Console/Command/LogCleanCommandTest.php @@ -32,7 +32,10 @@ public function setUp() public function testExecute() { $mutableConfig = $this->getMock('Magento\Framework\App\Config\MutableScopeConfigInterface', [], [], '', false); - $logFactory = $this->getMock('Magento\Log\Model\LogFactory', [], [], '', false); + $logFactory = $this->getMockBuilder('Magento\Log\Model\LogFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $returnValueMap = [ [ 'Magento\Framework\App\Config\MutableScopeConfigInterface', diff --git a/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php b/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php index 7a7df444bb6a1..a7928b80c4fee 100644 --- a/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php +++ b/app/code/Magento/Log/Test/Unit/Console/Command/LogStatusCommandTest.php @@ -14,7 +14,10 @@ public function testExecute() { $objectManagerFactory = $this->getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false); $objectManager = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); - $resourceFactory = $this->getMock('Magento\Log\Model\Resource\ShellFactory', [], [], '', false); + $resourceFactory = $this->getMockBuilder('Magento\Log\Model\Resource\ShellFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $objectManager->expects($this->once())->method('create')->willReturn($resourceFactory); $resource = $this->getMock('Magento\Log\Model\Resource\Shell', [], [], '', false); $resourceFactory->expects($this->once())->method('create')->willReturn($resource); diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index be4497fb03463..dd443c93d7a80 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/MediaStorage/Model/Config/Source/Storage/Media/Database.php b/app/code/Magento/MediaStorage/Model/Config/Source/Storage/Media/Database.php index b27633f7e99ab..3292464d03fa0 100644 --- a/app/code/Magento/MediaStorage/Model/Config/Source/Storage/Media/Database.php +++ b/app/code/Magento/MediaStorage/Model/Config/Source/Storage/Media/Database.php @@ -10,7 +10,7 @@ namespace Magento\MediaStorage\Model\Config\Source\Storage\Media; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; class Database implements \Magento\Framework\Option\ArrayInterface { @@ -35,7 +35,7 @@ public function __construct(DeploymentConfig $deploymentConfig) public function toOptionArray() { $resourceOptions = []; - $resourceConfig = $this->deploymentConfig->get(ConfigOptionsList::KEY_RESOURCE); + $resourceConfig = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_RESOURCE); if (null !== $resourceConfig) { foreach (array_keys($resourceConfig) as $resourceName) { $resourceOptions[] = ['value' => $resourceName, 'label' => $resourceName]; diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php index d23e188d5fc45..2c0b96b970bd0 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/Config/Source/Storage/Media/DatabaseTest.php @@ -8,7 +8,6 @@ namespace Magento\MediaStorage\Test\Unit\Model\Config\Source\Storage\Media; -use Magento\Framework\Config\ConfigOptionsList; use Magento\MediaStorage\Model\Config\Source\Storage\Media\Database; /** diff --git a/app/code/Magento/MediaStorage/composer.json b/app/code/Magento/MediaStorage/composer.json index d7b80d546362d..e334eb6bad070 100644 --- a/app/code/Magento/MediaStorage/composer.json +++ b/app/code/Magento/MediaStorage/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Msrp/Model/Config.php b/app/code/Magento/Msrp/Model/Config.php index be5d39d56523b..0264dbe485b00 100644 --- a/app/code/Magento/Msrp/Model/Config.php +++ b/app/code/Magento/Msrp/Model/Config.php @@ -72,6 +72,7 @@ public function setStoreId($store) * Check if Minimum Advertised Price is enabled * * @return bool + * @api */ public function isEnabled() { diff --git a/app/code/Magento/Msrp/Model/Msrp.php b/app/code/Magento/Msrp/Model/Msrp.php index fbb1c62f9f7c2..4efbb571b0b8b 100644 --- a/app/code/Magento/Msrp/Model/Msrp.php +++ b/app/code/Magento/Msrp/Model/Msrp.php @@ -34,6 +34,7 @@ public function __construct( * * @param \Magento\Catalog\Model\Product $product * @return bool + * @api */ public function canApplyToProduct($product) { diff --git a/app/code/Magento/Msrp/Model/Product/Options.php b/app/code/Magento/Msrp/Model/Product/Options.php index 3014d1bc3156f..563fccdd2c566 100644 --- a/app/code/Magento/Msrp/Model/Product/Options.php +++ b/app/code/Magento/Msrp/Model/Product/Options.php @@ -35,6 +35,7 @@ public function __construct( * @param \Magento\Catalog\Model\Product $product * @param null $visibility * @return bool|null + * @api */ public function isEnabled($product, $visibility = null) { diff --git a/app/code/Magento/Msrp/Model/Quote/Address/Total.php b/app/code/Magento/Msrp/Model/Quote/Address/Total.php index fa3ccbd9d76da..9af7b08e1174e 100644 --- a/app/code/Magento/Msrp/Model/Quote/Address/Total.php +++ b/app/code/Magento/Msrp/Model/Quote/Address/Total.php @@ -28,6 +28,7 @@ public function __construct(\Magento\Msrp\Helper\Data $msrpData) * * @param \Magento\Quote\Model\Quote\Address $address * @return $this + * @api */ public function collect(\Magento\Quote\Model\Quote\Address $address) { diff --git a/app/code/Magento/Msrp/composer.json b/app/code/Magento/Msrp/composer.json index 9bc87c61c94a6..eef207ca98943 100644 --- a/app/code/Magento/Msrp/composer.json +++ b/app/code/Magento/Msrp/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-bundle": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-downloadable": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-grouped-product": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-bundle": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-downloadable": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-grouped-product": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Msrp/view/base/web/js/msrp.js b/app/code/Magento/Msrp/view/base/web/js/msrp.js index 2630130271999..8bad507ec0714 100644 --- a/app/code/Magento/Msrp/view/base/web/js/msrp.js +++ b/app/code/Magento/Msrp/view/base/web/js/msrp.js @@ -154,6 +154,9 @@ define([ */ _addToCartSubmit: function () { this.element.trigger('addToCart', this.element); + if (this.element.data('stop-processing')) { + return false; + } if (this.options.addToCartButton) { $(this.options.addToCartButton).click(); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditAddress.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditAddress.php index 8982d2cc16d5e..724226b2e27ce 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditAddress.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditAddress.php @@ -14,7 +14,6 @@ class EditAddress extends \Magento\Multishipping\Controller\Checkout\Address public function execute() { $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($addressForm = $this->_view->getLayout()->getBlock('customer_address_edit')) { $addressForm->setTitle( __('Edit Address') diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditBilling.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditBilling.php index 83c8adb397659..eaa98e4e7c403 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditBilling.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditBilling.php @@ -17,7 +17,6 @@ public function execute() \Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_BILLING ); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($addressForm = $this->_view->getLayout()->getBlock('customer_address_edit')) { $id = $this->getRequest()->getParam('id'); $addressForm->setTitle( diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShipping.php index c0eb18bbf1b53..8409ed59f3687 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShipping.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/EditShipping.php @@ -17,7 +17,6 @@ public function execute() \Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_SHIPPING ); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($addressForm = $this->_view->getLayout()->getBlock('customer_address_edit')) { $addressForm->setTitle( __('Edit Shipping Address') diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewBilling.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewBilling.php index 9dda3c8f6ef55..23b209b60b479 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewBilling.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewBilling.php @@ -14,7 +14,6 @@ class NewBilling extends \Magento\Multishipping\Controller\Checkout\Address public function execute() { $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($addressForm = $this->_view->getLayout()->getBlock('customer_address_edit')) { $addressForm->setTitle( __('Create Billing Address') diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php index 8acefa080bf81..1a05f9cc46cf4 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php @@ -19,7 +19,6 @@ public function execute() \Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_SELECT_ADDRESSES ); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($addressForm = $this->_view->getLayout()->getBlock('customer_address_edit')) { $addressForm->setTitle( __('Create Shipping Address') diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/SelectBilling.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/SelectBilling.php index dc1f4f3d182a6..a64e877d58682 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/SelectBilling.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/SelectBilling.php @@ -17,7 +17,6 @@ public function execute() \Magento\Multishipping\Model\Checkout\Type\Multishipping\State::STEP_BILLING ); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Addresses.php b/app/code/Magento/Multishipping/Controller/Checkout/Addresses.php index 12ff7ff8a9fac..38ae81fadc81d 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Addresses.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Addresses.php @@ -31,7 +31,6 @@ public function execute() $this->messageManager->addNotice($message); } $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Billing.php b/app/code/Magento/Multishipping/Controller/Checkout/Billing.php index a47e630a0a852..0f3d9a0103c85 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Billing.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Billing.php @@ -46,7 +46,6 @@ public function execute() $this->_getState()->setActiveStep(State::STEP_BILLING); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Login.php b/app/code/Magento/Multishipping/Controller/Checkout/Login.php index be95bcf37eaa9..8b68c678010de 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Login.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Login.php @@ -21,7 +21,6 @@ public function execute() } $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); // set account create url $loginForm = $this->_view->getLayout()->getBlock('customer.new'); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Overview.php b/app/code/Magento/Multishipping/Controller/Checkout/Overview.php index f54f3bacb356a..9ab19c70889d2 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Overview.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Overview.php @@ -36,7 +36,6 @@ public function execute() $this->_getState()->setCompleteStep(State::STEP_BILLING); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Register.php b/app/code/Magento/Multishipping/Controller/Checkout/Register.php index c7e59e777d829..34aba23698077 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Register.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Register.php @@ -21,7 +21,6 @@ public function execute() } $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $registerForm = $this->_view->getLayout()->getBlock('customer_form_register'); if ($registerForm) { diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Shipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Shipping.php index 5b95a7935bb5f..d8ffd0d2b6af0 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Shipping.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Shipping.php @@ -28,7 +28,6 @@ public function execute() $this->_getState()->setActiveStep(State::STEP_SHIPPING); $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Success.php b/app/code/Magento/Multishipping/Controller/Checkout/Success.php index 810ece590fa1b..52a7de51c1839 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Success.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Success.php @@ -23,7 +23,6 @@ public function execute() } $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); $ids = $this->_getCheckout()->getOrderIds(); $this->_eventManager->dispatch('multishipping_checkout_controller_success_action', ['order_ids' => $ids]); $this->_view->renderLayout(); diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index d2d41a10d7624..169e10c71954c 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -11,6 +11,7 @@ use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Framework\Exception\LocalizedException; /** * Multishipping checkout model @@ -453,6 +454,7 @@ public function setShippingItemsInformation($info) * * @param int $quoteItemId * @param array $data array('qty'=>$qty, 'address'=>$customerAddressId) + * @throws \Magento\Framework\Exception\LocalizedException * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -462,6 +464,11 @@ protected function _addShippingItem($quoteItemId, $data) $qty = isset($data['qty']) ? (int)$data['qty'] : 1; //$qty = $qty > 0 ? $qty : 1; $addressId = isset($data['address']) ? $data['address'] : false; + + if (!$this->isAddressIdApplicable($addressId)) { + throw new LocalizedException(__('Please check shipping address information.')); + } + $quoteItem = $this->getQuote()->getItemById($quoteItemId); if ($addressId && $quoteItem) { @@ -503,10 +510,14 @@ protected function _addShippingItem($quoteItemId, $data) * Reimport customer address info to quote shipping address * * @param int $addressId customer address id + * @throws \Magento\Framework\Exception\LocalizedException * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping */ public function updateQuoteCustomerShippingAddress($addressId) { + if (!$this->isAddressIdApplicable($addressId)) { + throw new LocalizedException(__('Please check shipping address information.')); + } try { $address = $this->addressRepository->getById($addressId); } catch (\Exception $e) { @@ -530,10 +541,14 @@ public function updateQuoteCustomerShippingAddress($addressId) * Reimport customer billing address to quote * * @param int $addressId customer address id + * @throws \Magento\Framework\Exception\LocalizedException * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping */ public function setQuoteCustomerBillingAddress($addressId) { + if (!$this->isAddressIdApplicable($addressId)) { + throw new LocalizedException(__('Please check billing address information.')); + } try { $address = $this->addressRepository->getById($addressId); } catch (\Exception $e) { @@ -931,4 +946,19 @@ public function getCustomer() { return $this->_customerSession->getCustomerDataObject(); } + + /** + * Check if specified address ID belongs to customer. + * + * @param $addressId + * @return bool + */ + protected function isAddressIdApplicable($addressId) + { + $applicableAddressIds = array_map(function($address) { + /** @var \Magento\Customer\Api\Data\AddressInterface $address */ + return $address->getId(); + }, $this->getCustomer()->getAddresses()); + return in_array($addressId, $applicableAddressIds); + } } diff --git a/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecure.php b/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecure.php deleted file mode 100644 index 5d2045ed68e95..0000000000000 --- a/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecure.php +++ /dev/null @@ -1,75 +0,0 @@ -scopeConfig = $scopeConfig; - } - - /** - * {@inheritdoc} - */ - public function isSatisfiedBy($paymentMethod) - { - $is3DSecureSupported = isset( - $this->methodsInfo[$paymentMethod][self::FLAG_ALLOW_MULTIPLE_WITH_3DSECURE] - ) && $this->methodsInfo[$paymentMethod][self::FLAG_ALLOW_MULTIPLE_WITH_3DSECURE]; - return $is3DSecureSupported || !$this->is3DSecureEnabled($paymentMethod); - } - - /** - * Is 3DSecure enabled for payment method - * - * @param string $paymentMethod - * @return bool - */ - protected function is3DSecureEnabled($paymentMethod) - { - return $this->scopeConfig->isSetFlag( - sprintf(self::PATH_PAYMENT_3DSECURE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $paymentMethod) - ) || $this->scopeConfig->isSetFlag( - sprintf(self::PATH_PAYMENT_CENTINEL, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $paymentMethod) - ); - } -} diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php new file mode 100644 index 0000000000000..b274d73a1e466 --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php @@ -0,0 +1,261 @@ +checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); + $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $orderFactoryMock = $this->getMock('\Magento\Sales\Model\OrderFactory', [], [], '', false); + $eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface', [], [], '', false); + $scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $sessionMock = $this->getMock('\Magento\Framework\Session\Generic', [], [], '', false); + $addressFactoryMock = $this->getMock('\Magento\Quote\Model\Quote\AddressFactory', [], [], '', false); + $toOrderMock = $this->getMock('\Magento\Quote\Model\Quote\Address\ToOrder', [], [], '', false); + $toOrderAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address\ToOrderAddress', [], [], '', false); + $toOrderPaymentMock = $this->getMock('\Magento\Quote\Model\Quote\Payment\ToOrderPayment', [], [], '', false); + $toOrderItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item\ToOrderItem', [], [], '', false); + $storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $paymentSpecMock = $this->getMock('\Magento\Payment\Model\Method\SpecificationInterface', [], [], '', false); + $this->helperMock = $this->getMock('\Magento\Multishipping\Helper\Data', [], [], '', false); + $orderSenderMock = $this->getMock('\Magento\Sales\Model\Order\Email\Sender\OrderSender', [], [], '', false); + $priceMock = $this->getMock('\Magento\Framework\Pricing\PriceCurrencyInterface', [], [], '', false); + $quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); + $this->filterBuilderMock = $this->getMock('\Magento\Framework\Api\FilterBuilder', [], [], '', false); + $this->searchCriteriaBuilderMock = $this->getMock( + '\Magento\Framework\Api\SearchCriteriaBuilder', + [], + [], + '', + false + ); + $this->addressRepositoryMock = $this->getMock( + '\Magento\Customer\Api\AddressRepositoryInterface', + [], + [], + '', + false + ); + + /** + * This is used to get past _init() which is called in construct. + */ + $data['checkout_session'] = $this->checkoutSessionMock; + $this->quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $this->customerMock->expects($this->atLeastOnce())->method('getId')->willReturn(null); + $this->checkoutSessionMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($this->quoteMock); + $this->customerSessionMock->expects($this->atLeastOnce())->method('getCustomerDataObject') + ->willReturn($this->customerMock); + + $this->model = new \Magento\Multishipping\Model\Checkout\Type\Multishipping( + $this->checkoutSessionMock, + $this->customerSessionMock, + $orderFactoryMock, + $this->addressRepositoryMock, + $eventManagerMock, + $scopeConfigMock, + $sessionMock, + $addressFactoryMock, + $toOrderMock, + $toOrderAddressMock, + $toOrderPaymentMock, + $toOrderItemMock, + $storeManagerMock, + $paymentSpecMock, + $this->helperMock, + $orderSenderMock, + $priceMock, + $quoteRepositoryMock, + $this->searchCriteriaBuilderMock, + $this->filterBuilderMock, + $data + ); + } + + public function testSetShippingItemsInformation() + { + $info = [ + [ + 1 => [ + 'qty' => 2, + 'address' => 42 + ] + ] + ]; + $customerAddressId = 42; + + $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); + $customerAddresses = [$customerAddressMock]; + + $this->quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([]); + $this->checkoutSessionMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock); + + $this->helperMock->expects($this->once())->method('getMaximumQty')->willReturn(500); + + $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); + $this->quoteMock->expects($this->once())->method('getItemById')->with(array_keys($info[0])[0]) + ->willReturn(null); + + $this->quoteMock->expects($this->atLeastOnce())->method('getAllItems')->willReturn([]); + + $this->filterBuilderMock->expects($this->atLeastOnce())->method('setField')->willReturnSelf(); + $this->filterBuilderMock->expects($this->atLeastOnce())->method('setValue')->willReturnSelf(); + $this->filterBuilderMock->expects($this->atLeastOnce())->method('setConditionType')->willReturnSelf(); + $this->filterBuilderMock->expects($this->atLeastOnce())->method('create')->willReturnSelf(); + + $searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteria', [], [], '', false); + $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('addFilter')->willReturnSelf(); + $this->searchCriteriaBuilderMock->expects($this->atLeastOnce())->method('create') + ->willReturn($searchCriteriaMock); + + $resultMock = $this->getMock('\Magento\Customer\Api\Data\AddressSearchResultsInterface', [], [], '', false); + $this->addressRepositoryMock->expects($this->atLeastOnce())->method('getList')->willReturn($resultMock); + $addressItemMock = $this->getMock('\Magento\Customer\Api\Data\AddressInterface', [], [], '', false); + $resultMock->expects($this->atLeastOnce())->method('getItems')->willReturn([$addressItemMock]); + $addressItemMock->expects($this->atLeastOnce())->method('getId')->willReturn(null); + + $this->assertEquals($this->model, $this->model->setShippingItemsInformation($info)); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Please check shipping address information. + */ + public function testSetShippingItemsInformationForAddressLeak() + { + $info = [ + [ + 1 => [ + 'qty' => 2, + 'address' => 43 + ] + ] + ]; + $customerAddressId = 42; + + $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); + $customerAddresses = [$customerAddressMock]; + + $this->quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([]); + $this->checkoutSessionMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock); + $this->helperMock->expects($this->once())->method('getMaximumQty')->willReturn(500); + $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); + + $this->assertEquals($this->model, $this->model->setShippingItemsInformation($info)); + } + + public function testupdateQuoteCustomerShippingAddress() + { + $addressId = 42; + $customerAddressId = 42; + + $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); + $customerAddresses = [$customerAddressMock]; + $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); + + $this->addressRepositoryMock->expects($this->once())->method('getById')->willReturn(null); + + $this->assertEquals($this->model, $this->model->updateQuoteCustomerShippingAddress($addressId)); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Please check shipping address information. + */ + public function testupdateQuoteCustomerShippingAddressForAddressLeak() + { + $addressId = 43; + $customerAddressId = 42; + + $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); + $customerAddresses = [$customerAddressMock]; + $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); + + $this->assertEquals($this->model, $this->model->updateQuoteCustomerShippingAddress($addressId)); + } + + public function testSetQuoteCustomerBillingAddress() + { + $addressId = 42; + $customerAddressId = 42; + + $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); + $customerAddresses = [$customerAddressMock]; + $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); + + $this->assertEquals($this->model, $this->model->setQuoteCustomerBillingAddress($addressId)); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Please check billing address information. + */ + public function testSetQuoteCustomerBillingAddressForAddressLeak() + { + $addressId = 43; + $customerAddressId = 42; + + $customerAddressMock = $this->getMock('\Magento\Customer\Model\Data\Address', [], [], '', false); + $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); + $customerAddresses = [$customerAddressMock]; + $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); + + $this->assertEquals($this->model, $this->model->setQuoteCustomerBillingAddress($addressId)); + } +} diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/Is3DSecureTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/Is3DSecureTest.php deleted file mode 100644 index e5829d3c775fd..0000000000000 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Payment/Method/Specification/Is3DSecureTest.php +++ /dev/null @@ -1,96 +0,0 @@ -paymentConfigMock = $this->getMock('\Magento\Payment\Model\Config', [], [], '', false); - $this->scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - } - - /** - * Test isSatisfiedBy method - * - * @param array $methodsInfo - * @param bool $is3DSecureEnabled - * @param bool $result - * @dataProvider methodsDataProvider - */ - public function testIsSatisfiedBy($methodsInfo, $is3DSecureEnabled, $result) - { - $method = 'method-name'; - $methodsInfo = [$method => $methodsInfo]; - - $this->paymentConfigMock->expects( - $this->once() - )->method( - 'getMethodsInfo' - )->will( - $this->returnValue($methodsInfo) - ); - $this->scopeConfigMock->expects( - $this->any() - )->method( - 'isSetFlag' - )->will( - $this->returnValue($is3DSecureEnabled) - ); - - $configSpecification = $this->objectManager->getObject( - 'Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure', - ['paymentConfig' => $this->paymentConfigMock, 'scopeConfig' => $this->scopeConfigMock] - ); - - $this->assertEquals( - $result, - $configSpecification->isSatisfiedBy($method), - sprintf('Failed payment method test: "%s"', $method) - ); - } - - /** - * Data provider - * - * @return array - */ - public function methodsDataProvider() - { - return [ - [['allow_multiple_with_3dsecure' => 1], true, true], - [['allow_multiple_with_3dsecure' => 1], false, true], - [['allow_multiple_with_3dsecure' => 0], true, false], - [['allow_multiple_with_3dsecure' => 0], false, true], - [['no-flag' => 0], true, false] - ]; - } -} diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 1f4d39da6193b..bab62579a6cfa 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-payment": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Multishipping/etc/frontend/di.xml b/app/code/Magento/Multishipping/etc/frontend/di.xml index adac7cf03e70d..0320b5cc341c4 100644 --- a/app/code/Magento/Multishipping/etc/frontend/di.xml +++ b/app/code/Magento/Multishipping/etc/frontend/di.xml @@ -17,7 +17,6 @@ Magento\Multishipping\Model\Payment\Method\Specification\Enabled - Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure diff --git a/app/code/Magento/Multishipping/i18n/en_US.csv b/app/code/Magento/Multishipping/i18n/en_US.csv index f4d30b90b52f5..223b8ae5c284f 100644 --- a/app/code/Magento/Multishipping/i18n/en_US.csv +++ b/app/code/Magento/Multishipping/i18n/en_US.csv @@ -44,6 +44,7 @@ Change,Change "Please check shipping addresses information.","Please check shipping addresses information." "Please specify shipping methods for all addresses.","Please specify shipping methods for all addresses." "Please check billing address information.","Please check billing address information." +"Please check shipping address information.","Please check shipping address information." "Select Addresses","Select Addresses" "Order Success","Order Success" "Default Billing","Default Billing" diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout.xml index 2027fc0bafa34..cd004b253876d 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout.xml @@ -8,7 +8,7 @@ - + diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php index 27494f5272324..a03aac30892ad 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php @@ -11,23 +11,18 @@ */ namespace Magento\Newsletter\Block\Adminhtml\Queue; -class Preview extends \Magento\Backend\Block\Widget +class Preview extends \Magento\Newsletter\Block\Adminhtml\Template\Preview { /** - * @var \Magento\Newsletter\Model\TemplateFactory + * {@inheritdoc} */ - protected $_templateFactory; + protected $profilerName = "newsletter_queue_proccessing"; /** * @var \Magento\Newsletter\Model\QueueFactory */ protected $_queueFactory; - /** - * @var \Magento\Newsletter\Model\SubscriberFactory - */ - protected $_subscriberFactory; - /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Newsletter\Model\TemplateFactory $templateFactory @@ -38,68 +33,26 @@ class Preview extends \Magento\Backend\Block\Widget public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Newsletter\Model\TemplateFactory $templateFactory, - \Magento\Newsletter\Model\QueueFactory $queueFactory, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + \Magento\Newsletter\Model\QueueFactory $queueFactory, array $data = [] ) { - $this->_templateFactory = $templateFactory; $this->_queueFactory = $queueFactory; - $this->_subscriberFactory = $subscriberFactory; - parent::__construct($context, $data); + parent::__construct($context, $templateFactory, $subscriberFactory, $data); } /** - * Get html code - * - * @return string + * @param \Magento\Newsletter\Model\Template $template + * @param string $id + * @return $this */ - protected function _toHtml() + protected function loadTemplate(\Magento\Newsletter\Model\Template $template, $id) { - /* @var $template \Magento\Newsletter\Model\Template */ - $template = $this->_templateFactory->create(); - - if ($id = (int)$this->getRequest()->getParam('id')) { - $queue = $this->_queueFactory->create()->load($id); - $template->setTemplateType($queue->getNewsletterType()); - $template->setTemplateText($queue->getNewsletterText()); - $template->setTemplateStyles($queue->getNewsletterStyles()); - } else { - $template->setTemplateType($this->getRequest()->getParam('type')); - $template->setTemplateText($this->getRequest()->getParam('text')); - $template->setTemplateStyles($this->getRequest()->getParam('styles')); - } - - $storeId = (int)$this->getRequest()->getParam('store_id'); - if (!$storeId) { - $defaultStore = $this->_storeManager->getDefaultStoreView(); - if (!$defaultStore) { - $allStores = $this->_storeManager->getStores(); - if (isset($allStores[0])) { - $defaultStore = $allStores[0]; - } - } - $storeId = $defaultStore ? $defaultStore->getId() : null; - } - - \Magento\Framework\Profiler::start("newsletter_queue_proccessing"); - $vars = []; - - $vars['subscriber'] = $this->_subscriberFactory->create(); - - $template->emulateDesign($storeId); - $templateProcessed = $this->_appState->emulateAreaCode( - \Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, - [$template, 'getProcessedTemplate'], - [$vars, true] - ); - $template->revertDesign(); - - if ($template->isPlain()) { - $templateProcessed = "
    " . htmlspecialchars($templateProcessed) . "
    "; - } - - \Magento\Framework\Profiler::stop("newsletter_queue_proccessing"); - - return $templateProcessed; + /** @var \Magento\Newsletter\Model\Queue $queue */ + $queue = $this->_queueFactory->create()->load($id); + $template->setTemplateType($queue->getNewsletterType()); + $template->setTemplateText($queue->getNewsletterText()); + $template->setTemplateStyles($queue->getNewsletterStyles()); + return $this; } } diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php index bc298348c71de..1166eca0d4d88 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php @@ -6,13 +6,18 @@ /** * Newsletter template preview block - * - * @author Magento Core Team */ namespace Magento\Newsletter\Block\Adminhtml\Template; class Preview extends \Magento\Backend\Block\Widget { + /** + * Name for profiler + * + * @var string + */ + protected $profilerName = "newsletter_template_proccessing"; + /** * @var \Magento\Newsletter\Model\TemplateFactory */ @@ -51,26 +56,14 @@ protected function _toHtml() $template = $this->_templateFactory->create(); if ($id = (int)$this->getRequest()->getParam('id')) { - $template->load($id); + $this->loadTemplate($template, $id); } else { $template->setTemplateType($this->getRequest()->getParam('type')); $template->setTemplateText($this->getRequest()->getParam('text')); $template->setTemplateStyles($this->getRequest()->getParam('styles')); } - $storeId = (int)$this->getRequest()->getParam('store_id'); - if (!$storeId) { - $defaultStore = $this->_storeManager->getDefaultStoreView(); - if (!$defaultStore) { - $allStores = $this->_storeManager->getStores(); - if (isset($allStores[0])) { - $defaultStore = $allStores[0]; - } - } - $storeId = $defaultStore ? $defaultStore->getId() : null; - } - - \Magento\Framework\Profiler::start("newsletter_template_proccessing"); + \Magento\Framework\Profiler::start($this->profilerName); $vars = []; $vars['subscriber'] = $this->_subscriberFactory->create(); @@ -78,7 +71,7 @@ protected function _toHtml() $vars['subscriber']->load($this->getRequest()->getParam('subscriber')); } - $template->emulateDesign($storeId); + $template->emulateDesign($this->getStoreId()); $templateProcessed = $this->_appState->emulateAreaCode( \Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, [$template, 'getProcessedTemplate'], @@ -90,8 +83,42 @@ protected function _toHtml() $templateProcessed = "
    " . htmlspecialchars($templateProcessed) . "
    "; } - \Magento\Framework\Profiler::stop("newsletter_template_proccessing"); + \Magento\Framework\Profiler::stop($this->profilerName); return $templateProcessed; } + + /** + * Get Store Id from request or default + * + * @return int|null + */ + protected function getStoreId() + { + $storeId = (int)$this->getRequest()->getParam('store_id'); + if ($storeId) { + return $storeId; + } + + $defaultStore = $this->_storeManager->getDefaultStoreView(); + if (!$defaultStore) { + $allStores = $this->_storeManager->getStores(); + if (isset($allStores[0])) { + $defaultStore = $allStores[0]; + } + } + + return $defaultStore ? $defaultStore->getId() : null; + } + + /** + * @param \Magento\Newsletter\Model\Template $template + * @param string $id + * @return $this + */ + protected function loadTemplate(\Magento\Newsletter\Model\Template $template, $id) + { + $template->load($id); + return $this; + } } diff --git a/app/code/Magento/Newsletter/Controller/Manage/Index.php b/app/code/Magento/Newsletter/Controller/Manage/Index.php index 726b82703f3f4..de782a3d3bc09 100644 --- a/app/code/Magento/Newsletter/Controller/Manage/Index.php +++ b/app/code/Magento/Newsletter/Controller/Manage/Index.php @@ -16,7 +16,6 @@ class Index extends \Magento\Newsletter\Controller\Manage public function execute() { $this->_view->loadLayout(); - $this->_view->getLayout()->initMessages(); if ($block = $this->_view->getLayout()->getBlock('customer_newsletter')) { $block->setRefererUrl($this->_redirect->getRefererUrl()); diff --git a/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php new file mode 100644 index 0000000000000..5cfb59e64bd6e --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php @@ -0,0 +1,115 @@ +getMock('Magento\Backend\Block\Template\Context', [], [], '', false); + $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $context->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager)); + $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); + $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request)); + $this->storeManager = $this->getMock( + 'Magento\Store\Model\StoreManager', + ['getStores', 'getDefaultStoreView'], + [], + '', + false + ); + $context->expects($this->once())->method('getStoreManager')->will($this->returnValue($this->storeManager)); + $appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $context->expects($this->once())->method('getAppState')->will($this->returnValue($appState)); + + $templateFactory = $this->getMock('Magento\Newsletter\Model\TemplateFactory', ['create'], [], '', false); + $this->template = $this->getMock('Magento\Newsletter\Model\Template', [], [], '', false); + $templateFactory->expects($this->once())->method('create')->will($this->returnValue($this->template)); + + $subscriberFactory = $this->getMock('Magento\Newsletter\Model\SubscriberFactory', ['create'], [], '', false); + $this->subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); + $subscriberFactory->expects($this->once())->method('create')->will($this->returnValue($this->subscriber)); + + $queueFactory = $this->getMock('Magento\Newsletter\Model\QueueFactory', ['create'], [], '', false); + $this->queue = $this->getMock('Magento\Newsletter\Model\Queue', ['load'], [], '', false); + $queueFactory->expects($this->any())->method('create')->will($this->returnValue($this->queue)); + + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->preview = $this->objectManager->getObject( + 'Magento\Newsletter\Block\Adminhtml\Queue\Preview', + [ + 'context' => $context, + 'templateFactory' => $templateFactory, + 'subscriberFactory' => $subscriberFactory, + 'queueFactory' => $queueFactory, + ] + ); + } + + public function testToHtmlEmpty() + { + /** @var \Magento\Store\Model\Store $store */ + $store = $this->getMock('Magento\Store\Model\Store', ['getId'], [], '', false); + $this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue($store)); + $result = $this->preview->toHtml(); + $this->assertEquals('', $result); + } + + public function testToHtmlWithId() + { + $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap( + [ + ['id', null, 1], + ['store_id', null, 0] + ] + )); + $this->queue->expects($this->once())->method('load')->will($this->returnSelf()); + $this->template->expects($this->any())->method('isPlain')->will($this->returnValue(true)); + /** @var \Magento\Store\Model\Store $store */ + $this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue(null)); + $store = $this->getMock('Magento\Store\Model\Store', ['getId'], [], '', false); + $this->storeManager->expects($this->once())->method('getStores')->will($this->returnValue([0 => $store])); + $result = $this->preview->toHtml(); + $this->assertEquals('
    ', $result);
    +    }
    +}
    diff --git a/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
    new file mode 100644
    index 0000000000000..9b8fb3cfbfa30
    --- /dev/null
    +++ b/app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
    @@ -0,0 +1,180 @@
    +request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false);
    +        $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false);
    +        $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
    +        $this->template = $this->getMock(
    +            'Magento\Newsletter\Model\Template',
    +            [
    +                'setTemplateType',
    +                'setTemplateText',
    +                'setTemplateStyles',
    +                'isPlain',
    +                'emulateDesign',
    +                'revertDesign',
    +                'getProcessedTemplate',
    +                'load'
    +            ],
    +            [],
    +            '',
    +            false
    +        );
    +        $templateFactory = $this->getMock('Magento\Newsletter\Model\TemplateFactory', ['create'], [], '', false);
    +        $templateFactory->expects($this->once())->method('create')->willReturn($this->template);
    +        $this->subscriberFactory = $this->getMock(
    +            'Magento\Newsletter\Model\SubscriberFactory',
    +            ['create'],
    +            [],
    +            '',
    +            false
    +        );
    +
    +        $this->objectManagerHelper = new ObjectManagerHelper($this);
    +        $this->preview = $this->objectManagerHelper->getObject(
    +            'Magento\Newsletter\Block\Adminhtml\Template\Preview',
    +            [
    +                'appState' => $this->appState,
    +                'storeManager' => $this->storeManager,
    +                'request' => $this->request,
    +                'templateFactory' => $templateFactory,
    +                'subscriberFactory' => $this->subscriberFactory
    +            ]
    +        );
    +    }
    +
    +    public function testToHtml()
    +    {
    +        $this->request->expects($this->any())->method('getParam')->willReturnMap(
    +            [
    +                ['id', null, 1],
    +                ['store_id', null, 1]
    +            ]
    +        );
    +
    +        $this->template->expects($this->atLeastOnce())->method('emulateDesign')->with(1);
    +        $this->template->expects($this->atLeastOnce())->method('revertDesign');
    +
    +        $this->appState->expects($this->atLeastOnce())->method('emulateAreaCode')
    +            ->with(
    +                \Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA,
    +                [$this->template, 'getProcessedTemplate'],
    +                [['subscriber' => null], true]
    +            )
    +            ->willReturn('Processed Template');
    +
    +        $this->assertEquals('Processed Template', $this->preview->toHtml());
    +    }
    +
    +    public function testToHtmlForNewTemplate()
    +    {
    +        $this->request->expects($this->any())->method('getParam')->willReturnMap(
    +            [
    +                ['type', null, TemplateTypesInterface::TYPE_TEXT],
    +                ['text', null, 'Processed Template'],
    +                ['styles', null, '.class-name{color:red;}']
    +            ]
    +        );
    +
    +        $this->template->expects($this->once())->method('setTemplateType')->with(TemplateTypesInterface::TYPE_TEXT)
    +            ->willReturnSelf();
    +        $this->template->expects($this->once())->method('setTemplateText')->with('Processed Template')
    +            ->willReturnSelf();
    +        $this->template->expects($this->once())->method('setTemplateStyles')->with('.class-name{color:red;}')
    +            ->willReturnSelf();
    +        $this->template->expects($this->atLeastOnce())->method('isPlain')->willReturn(true);
    +        $this->template->expects($this->atLeastOnce())->method('emulateDesign')->with(1);
    +        $this->template->expects($this->atLeastOnce())->method('revertDesign');
    +
    +        $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
    +        $store->expects($this->atLeastOnce())->method('getId')->willReturn(1);
    +
    +        $this->storeManager->expects($this->atLeastOnce())->method('getStores')->willReturn([$store]);
    +
    +
    +        $this->appState->expects($this->atLeastOnce())->method('emulateAreaCode')
    +            ->with(
    +                \Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA,
    +                [
    +                    $this->template,
    +                    'getProcessedTemplate'
    +                ],
    +                [
    +                    [
    +                        'subscriber' => null
    +                    ],
    +                    true
    +                ]
    +            )
    +            ->willReturn('Processed Template');
    +
    +        $this->assertEquals('
    Processed Template
    ', $this->preview->toHtml()); + } + + public function testToHtmlWithSubscriber() + { + $this->request->expects($this->any())->method('getParam')->willReturnMap( + [ + ['id', null, 2], + ['store_id', null, 1], + ['subscriber', null, 3] + ] + ); + $subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); + $subscriber->expects($this->atLeastOnce())->method('load')->with(3)->willReturnSelf(); + $this->subscriberFactory->expects($this->atLeastOnce())->method('create')->willReturn($subscriber); + + $this->template->expects($this->atLeastOnce())->method('emulateDesign')->with(1); + $this->template->expects($this->atLeastOnce())->method('revertDesign'); + + $this->appState->expects($this->atLeastOnce())->method('emulateAreaCode') + ->with( + \Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, + [ + $this->template, + 'getProcessedTemplate' + ], + [ + [ + 'subscriber' => $subscriber + ], + true + ] + ) + ->willReturn('Processed Template'); + + $this->assertEquals('Processed Template', $this->preview->toHtml()); + } +} diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index d04e8f6ffd29e..10ca035af0854 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-email": "0.74.0-beta9", - "magento/module-cron": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-require-js": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-email": "0.74.0-beta11", + "magento/module-cron": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-require-js": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml index 76f9bc780ae85..cb7ac6cb26d42 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml +++ b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_queue_preview.xml @@ -15,6 +15,7 @@ + diff --git a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml index cb7ac6cb26d42..d468c2a843414 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml +++ b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_template_preview.xml @@ -12,7 +12,7 @@ - + diff --git a/app/code/Magento/Newsletter/view/adminhtml/templates/subscriber/list.phtml b/app/code/Magento/Newsletter/view/adminhtml/templates/subscriber/list.phtml index b273b7dd4a35b..9ff5ae3d09619 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/templates/subscriber/list.phtml +++ b/app/code/Magento/Newsletter/view/adminhtml/templates/subscriber/list.phtml @@ -20,8 +20,6 @@ diff --git a/app/code/Magento/Newsletter/view/frontend/layout/newsletter_manage_index.xml b/app/code/Magento/Newsletter/view/frontend/layout/newsletter_manage_index.xml index 8e99e84f364f0..a2e65fc7bddc0 100644 --- a/app/code/Magento/Newsletter/view/frontend/layout/newsletter_manage_index.xml +++ b/app/code/Magento/Newsletter/view/frontend/layout/newsletter_manage_index.xml @@ -9,7 +9,7 @@ - + diff --git a/app/code/Magento/OfflinePayments/Block/Form/AbstractInstruction.php b/app/code/Magento/OfflinePayments/Block/Form/AbstractInstruction.php index 95d9e68acd77a..b28812203d8f1 100644 --- a/app/code/Magento/OfflinePayments/Block/Form/AbstractInstruction.php +++ b/app/code/Magento/OfflinePayments/Block/Form/AbstractInstruction.php @@ -20,12 +20,14 @@ abstract class AbstractInstruction extends \Magento\Payment\Block\Form /** * Get instructions text from config * - * @return string + * @return null|string */ public function getInstructions() { if ($this->_instructions === null) { - $this->_instructions = $this->getMethod()->getInstructions(); + /** @var \Magento\Payment\Model\Method\AbstractMethod $method */ + $method = $this->getMethod(); + $this->_instructions = $method->getConfigData('instructions'); } return $this->_instructions; } diff --git a/app/code/Magento/OfflinePayments/Model/Banktransfer.php b/app/code/Magento/OfflinePayments/Model/Banktransfer.php index 9eee92e1e2478..8dbf21229dc41 100644 --- a/app/code/Magento/OfflinePayments/Model/Banktransfer.php +++ b/app/code/Magento/OfflinePayments/Model/Banktransfer.php @@ -41,4 +41,14 @@ class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod * @var bool */ protected $_isOffline = true; + + /** + * Get instructions text from config + * + * @return string + */ + public function getInstructions() + { + return trim($this->getConfigData('instructions')); + } } diff --git a/app/code/Magento/OfflinePayments/Model/Cashondelivery.php b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php index 06f2862acd07e..531d34a41d6f7 100644 --- a/app/code/Magento/OfflinePayments/Model/Cashondelivery.php +++ b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php @@ -12,12 +12,14 @@ */ class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod { + const PAYMENT_METHOD_CASHONDELIVERY_CODE = 'cashondelivery'; + /** * Payment method code * * @var string */ - protected $_code = 'cashondelivery'; + protected $_code = self::PAYMENT_METHOD_CASHONDELIVERY_CODE; /** * Cash On Delivery payment block paths diff --git a/app/code/Magento/OfflinePayments/Model/Checkmo.php b/app/code/Magento/OfflinePayments/Model/Checkmo.php index e282b502979df..964b0e7c46e1d 100644 --- a/app/code/Magento/OfflinePayments/Model/Checkmo.php +++ b/app/code/Magento/OfflinePayments/Model/Checkmo.php @@ -12,10 +12,14 @@ */ class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod { + const PAYMENT_METHOD_CHECKMO_CODE = 'checkmo'; + /** + * Payment method code + * * @var string */ - protected $_code = 'checkmo'; + protected $_code = self::PAYMENT_METHOD_CHECKMO_CODE; /** * @var string @@ -34,27 +38,6 @@ class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod */ protected $_isOffline = true; - /** - * Assign data to info model instance - * - * @param mixed $data - * @return $this - */ - public function assignData($data) - { - $details = []; - if ($this->getPayableTo()) { - $details['payable_to'] = $this->getPayableTo(); - } - if ($this->getMailingAddress()) { - $details['mailing_address'] = $this->getMailingAddress(); - } - if (!empty($details)) { - $this->getInfoInstance()->setAdditionalData(serialize($details)); - } - return $this; - } - /** * @return string */ diff --git a/app/code/Magento/OfflinePayments/Model/CheckmoConfigProvider.php b/app/code/Magento/OfflinePayments/Model/CheckmoConfigProvider.php new file mode 100644 index 0000000000000..cefe1bbb7b239 --- /dev/null +++ b/app/code/Magento/OfflinePayments/Model/CheckmoConfigProvider.php @@ -0,0 +1,75 @@ +escaper = $escaper; + $this->method = $paymentHelper->getMethodInstance($this->methodCode); + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + return $this->method->isAvailable() ? [ + 'payment' => [ + 'checkmo' => [ + 'mailingAddress' => $this->getMailingAddress(), + 'payableTo' => $this->getPayableTo(), + ], + ], + ] : []; + } + + /** + * Get mailing address from config + * + * @return string + */ + protected function getMailingAddress() + { + return nl2br($this->escaper->escapeHtml($this->method->getMailingAddress())); + } + + /** + * Get payable to from config + * + * @return string + */ + protected function getPayableTo() + { + return $this->method->getPayableTo(); + } +} diff --git a/app/code/Magento/OfflinePayments/Model/InstructionsConfigProvider.php b/app/code/Magento/OfflinePayments/Model/InstructionsConfigProvider.php new file mode 100644 index 0000000000000..c1aa56334affb --- /dev/null +++ b/app/code/Magento/OfflinePayments/Model/InstructionsConfigProvider.php @@ -0,0 +1,70 @@ +escaper = $escaper; + foreach ($this->methodCodes as $code) { + $this->methods[$code] = $paymentHelper->getMethodInstance($code); + } + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + $config = []; + foreach ($this->methodCodes as $code) { + if ($this->methods[$code]->isAvailable()) { + $config['payment']['instructions'][$code] = $this->getInstructions($code); + } + } + return $config; + } + + /** + * Get instructions text from config + * + * @param string $code + * @return string + */ + protected function getInstructions($code) + { + return nl2br($this->escaper->escapeHtml($this->methods[$code]->getInstructions())); + } +} diff --git a/app/code/Magento/OfflinePayments/Model/Observer.php b/app/code/Magento/OfflinePayments/Model/Observer.php index 1cb45ac753f56..06b53a9053e94 100644 --- a/app/code/Magento/OfflinePayments/Model/Observer.php +++ b/app/code/Magento/OfflinePayments/Model/Observer.php @@ -21,10 +21,23 @@ public function beforeOrderPaymentSave(\Magento\Framework\Event\Observer $observ { /** @var \Magento\Sales\Model\Order\Payment $payment */ $payment = $observer->getEvent()->getPayment(); - if ($payment->getMethod() === Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE) { + $instructionMethods = [ + Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE, + Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE + ]; + if (in_array($payment->getMethod(), $instructionMethods)) { $payment->setAdditionalInformation( 'instructions', - $payment->getMethodInstance()->getConfigData('instructions') + $payment->getMethodInstance()->getInstructions() + ); + } elseif ($payment->getMethod() === Checkmo::PAYMENT_METHOD_CHECKMO_CODE) { + $payment->setAdditionalInformation( + 'payable_to', + $payment->getMethodInstance()->getPayableTo() + ); + $payment->setAdditionalInformation( + 'mailing_address', + $payment->getMethodInstance()->getMailingAddress() ); } } diff --git a/app/code/Magento/OfflinePayments/Model/Purchaseorder.php b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php index 3a4aa15d08903..d6f1baaadeb35 100644 --- a/app/code/Magento/OfflinePayments/Model/Purchaseorder.php +++ b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php @@ -12,10 +12,14 @@ */ class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod { + const PAYMENT_METHOD_PURCHASEORDER_CODE = 'purchaseorder'; + /** + * Payment method code + * * @var string */ - protected $_code = 'purchaseorder'; + protected $_code = self::PAYMENT_METHOD_PURCHASEORDER_CODE; /** * @var string diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php index ec89394561230..d9f94e686004d 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Block/Form/AbstractInstructionTest.php @@ -25,13 +25,13 @@ public function testGetInstructions() { $method = $this->getMock( 'Magento\Payment\Model\MethodInterface', - ['getInstructions', 'getCode', 'getFormBlockType', 'getTitle'], + ['getConfigData', 'getCode', 'getFormBlockType', 'getTitle'], [], '', false ); $method->expects($this->once()) - ->method('getInstructions') + ->method('getConfigData') ->willReturn('instructions'); $this->_model->setData('method', $method); diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php new file mode 100644 index 0000000000000..32b4aff002128 --- /dev/null +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoConfigProviderTest.php @@ -0,0 +1,78 @@ +methodMock = $this->getMock('Magento\OfflinePayments\Model\Checkmo', [], [], '', false); + + $paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $paymentHelperMock->expects($this->once()) + ->method('getMethodInstance') + ->with(Checkmo::PAYMENT_METHOD_CHECKMO_CODE) + ->willReturn($this->methodMock); + + $this->escaperMock = $this->getMock('Magento\Framework\Escaper'); + $this->escaperMock->expects($this->any()) + ->method('escapeHtml') + ->willReturnArgument(0); + + $this->model = new CheckmoConfigProvider( + $paymentHelperMock, + $this->escaperMock + ); + } + + /** + * @param bool $isAvailable + * @param string $mailingAddress + * @param string $payableTo + * @param array $result + * @dataProvider dataProviderGetConfig + */ + public function testGetConfig($isAvailable, $mailingAddress, $payableTo, $result) + { + $this->methodMock->expects($this->once()) + ->method('isAvailable') + ->willReturn($isAvailable); + $this->methodMock->expects($this->any()) + ->method('getMailingAddress') + ->willReturn($mailingAddress); + $this->methodMock->expects($this->any()) + ->method('getPayableTo') + ->willReturn($payableTo); + + $this->assertEquals($result, $this->model->getConfig()); + } + + public function dataProviderGetConfig() + { + $checkmoCode = Checkmo::PAYMENT_METHOD_CHECKMO_CODE; + return [ + [false, '', '', []], + [true, '', '', ['payment' => [$checkmoCode => ['mailingAddress' => '', 'payableTo' => '']]]], + [true, 'address', '', ['payment' => [$checkmoCode => ['mailingAddress' => 'address', 'payableTo' => '']]]], + [true, '', 'to', ['payment' => [$checkmoCode => ['mailingAddress' => '', 'payableTo' => 'to']]]], + [true, 'addr', 'to', ['payment' => [$checkmoCode => ['mailingAddress' => 'addr', 'payableTo' => 'to']]]], + [false, 'addr', 'to', []], + ]; + } +} diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php index 15ffaf117b49f..bac7e5fd1bcf8 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/CheckmoTest.php @@ -58,23 +58,4 @@ public function testGetMailingAddress() ->willReturn('blah@blah.com'); $this->assertEquals('blah@blah.com', $this->_object->getMailingAddress()); } - - public function testAssignData() - { - $details['payable_to'] = 'payable'; - $details['mailing_address'] = 'blah@blah.com'; - $this->_object->setStore(1); - $this->_scopeConfig->expects($this->any()) - ->method('getValue') - ->willReturnMap([ - ['payment/checkmo/payable_to', 'store', 1, 'payable'], - ['payment/checkmo/mailing_address', 'store', 1, 'blah@blah.com'] - ]); - $instance = $this->getMock('Magento\Payment\Model\Info', ['setAdditionalData'], [], '', false); - $instance->expects($this->once()) - ->method('setAdditionalData') - ->with(serialize($details)); - $this->_object->setData('info_instance', $instance); - $this->_object->assignData(''); - } } diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php new file mode 100644 index 0000000000000..65b5bcf861e25 --- /dev/null +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/InstructionsConfigProviderTest.php @@ -0,0 +1,119 @@ +methodOneMock = $this->getMock( + 'Magento\Payment\Model\Method\AbstractMethod', + ['isAvailable', 'getInstructions'], + [], + '', + false + ); + $this->methodTwoMock = $this->getMock( + 'Magento\Payment\Model\Method\AbstractMethod', + ['isAvailable', 'getInstructions'], + [], + '', + false + ); + + $paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $paymentHelperMock->expects($this->exactly(2)) + ->method('getMethodInstance') + ->willReturnMap([ + [Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE, $this->methodOneMock], + [Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE, $this->methodTwoMock], + ]); + + $this->escaperMock = $this->getMock('Magento\Framework\Escaper'); + $this->escaperMock->expects($this->any()) + ->method('escapeHtml') + ->willReturnArgument(0); + + $this->model = new InstructionsConfigProvider( + $paymentHelperMock, + $this->escaperMock + ); + } + + /** + * @param bool $isOneAvailable + * @param string $instructionsOne + * @param bool $isTwoAvailable + * @param string $instructionsTwo + * @param array $result + * @dataProvider dataProviderGetConfig + */ + public function testGetConfig($isOneAvailable, $instructionsOne, $isTwoAvailable, $instructionsTwo, $result) + { + $this->methodOneMock->expects($this->once()) + ->method('isAvailable') + ->willReturn($isOneAvailable); + $this->methodOneMock->expects($this->any()) + ->method('getInstructions') + ->willReturn($instructionsOne); + + $this->methodTwoMock->expects($this->once()) + ->method('isAvailable') + ->willReturn($isTwoAvailable); + $this->methodTwoMock->expects($this->any()) + ->method('getInstructions') + ->willReturn($instructionsTwo); + + $this->assertEquals($result, $this->model->getConfig()); + } + + public function dataProviderGetConfig() + { + $oneCode = Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE; + $twoCode = Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE; + return [ + [false, '', false, '', []], + [false, 'one', false, 'two', []], + [true, '', false, '', ['payment' => ['instructions' => [$oneCode => '']]]], + [true, 'text one', false, '', ['payment' => ['instructions' => [$oneCode => 'text one']]]], + [false, '', true, '', ['payment' => ['instructions' => [$twoCode => '']]]], + [false, '', true, 'text two', ['payment' => ['instructions' => [$twoCode => 'text two']]]], + [true, '', true, '', ['payment' => ['instructions' => [$oneCode => '', $twoCode => '']]]], + [ + true, + 'text one', + true, + 'text two', + ['payment' => ['instructions' => [$oneCode => 'text one', $twoCode => 'text two']]] + ], + [ + true, + "\n", + true, + "\n", + ['payment' => ['instructions' => [$oneCode => "
    \n", $twoCode => "
    \n"]]] + ], + ]; + } +} diff --git a/app/code/Magento/OfflinePayments/Test/Unit/Model/ObserverTest.php b/app/code/Magento/OfflinePayments/Test/Unit/Model/ObserverTest.php index 43f5c497be467..6c0813747188b 100644 --- a/app/code/Magento/OfflinePayments/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/OfflinePayments/Test/Unit/Model/ObserverTest.php @@ -5,6 +5,10 @@ */ namespace Magento\OfflinePayments\Test\Unit\Model; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\OfflinePayments\Model\Banktransfer; +use Magento\OfflinePayments\Model\Cashondelivery; + class ObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -14,11 +18,15 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManagerHelper = new ObjectManager($this); $this->_model = $objectManagerHelper->getObject('Magento\OfflinePayments\Model\Observer'); } - public function testBeforeOrderPaymentSave() + /** + * @param string $methodCode + * @dataProvider dataProviderBeforeOrderPaymentSaveWithInstructions + */ + public function testBeforeOrderPaymentSaveWithInstructions($methodCode) { $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); $event = $this->getMock('Magento\Framework\Event', ['getPayment'], [], '', false); @@ -31,19 +39,19 @@ public function testBeforeOrderPaymentSave() ); $payment->expects($this->once()) ->method('getMethod') - ->willReturn('banktransfer'); + ->willReturn($methodCode); $payment->expects($this->once()) ->method('setAdditionalInformation') ->with('instructions', 'payment configuration'); $method = $this->getMock( 'Magento\Payment\Model\MethodInterface', - ['getConfigData', 'getFormBlockType', 'getTitle', 'getCode'], + ['getInstructions', 'getFormBlockType', 'getTitle', 'getCode'], [], '', false ); $method->expects($this->once()) - ->method('getConfigData') + ->method('getInstructions') ->willReturn('payment configuration'); $payment->expects($this->once()) ->method('getMethodInstance') @@ -57,7 +65,15 @@ public function testBeforeOrderPaymentSave() $this->_model->beforeOrderPaymentSave($observer); } - public function testBeforeOrderPaymentSaveNoBanktransfer() + public function dataProviderBeforeOrderPaymentSaveWithInstructions() + { + return [ + [Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE], + [Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE], + ]; + } + + public function testBeforeOrderPaymentSaveWithCheckmo() { $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); $event = $this->getMock('Magento\Framework\Event', ['getPayment'], [], '', false); @@ -68,7 +84,55 @@ public function testBeforeOrderPaymentSaveNoBanktransfer() '', false ); - $payment->expects($this->once()) + $payment->expects($this->exactly(2)) + ->method('getMethod') + ->willReturn(\Magento\OfflinePayments\Model\Checkmo::PAYMENT_METHOD_CHECKMO_CODE); + $payment->expects($this->exactly(2)) + ->method('setAdditionalInformation') + ->willReturnMap( + [ + ['payable_to', 'payable to', $payment], + ['mailing_address', 'mailing address', $payment], + ] + ); + + $method = $this->getMock( + 'Magento\Payment\Model\MethodInterface', + ['getPayableTo', 'getMailingAddress', 'getFormBlockType', 'getTitle', 'getCode'], + [], + '', + false + ); + $method->expects($this->once()) + ->method('getPayableTo') + ->willReturn('payable to'); + $method->expects($this->once()) + ->method('getMailingAddress') + ->willReturn('mailing address'); + $payment->expects($this->exactly(2)) + ->method('getMethodInstance') + ->willReturn($method); + $event->expects($this->once()) + ->method('getPayment') + ->willReturn($payment); + $observer->expects($this->once()) + ->method('getEvent') + ->willReturn($event); + $this->_model->beforeOrderPaymentSave($observer); + } + + public function testBeforeOrderPaymentSaveWithOthers() + { + $observer = $this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); + $event = $this->getMock('Magento\Framework\Event', ['getPayment'], [], '', false); + $payment = $this->getMock( + 'Magento\Sales\Model\Order\Payment', + ['getMethod', 'setAdditionalInformation', 'getMethodInstance'], + [], + '', + false + ); + $payment->expects($this->exactly(2)) ->method('getMethod') ->willReturn('somepaymentmethod'); $payment->expects($this->never()) diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 8d059448ce95f..65f21b44ee3f7 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -3,12 +3,13 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-payment": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/OfflinePayments/etc/frontend/di.xml b/app/code/Magento/OfflinePayments/etc/frontend/di.xml new file mode 100644 index 0000000000000..1c1cabff9633b --- /dev/null +++ b/app/code/Magento/OfflinePayments/etc/frontend/di.xml @@ -0,0 +1,17 @@ + + + + + + + Magento\OfflinePayments\Model\InstructionsConfigProvider + Magento\OfflinePayments\Model\CheckmoConfigProvider + + + + diff --git a/app/code/Magento/OfflinePayments/etc/payment.xml b/app/code/Magento/OfflinePayments/etc/payment.xml index 23f8679100fc6..d0f09bdb19feb 100644 --- a/app/code/Magento/OfflinePayments/etc/payment.xml +++ b/app/code/Magento/OfflinePayments/etc/payment.xml @@ -15,23 +15,18 @@ 1 - 1 1 - 1 1 - 1 1 - 1 1 - 1 diff --git a/app/code/Magento/OfflinePayments/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/OfflinePayments/view/frontend/layout/checkout_onepage_index.xml new file mode 100644 index 0000000000000..c6140255ab7f1 --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/layout/checkout_onepage_index.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + Magento_OfflinePayments/js/view/payment/checkmo-method + + Magento_OfflinePayments/payment/checkmo-form + + + + Magento_OfflinePayments/js/view/payment/instructions-method + + Magento_OfflinePayments/payment/instructions-form + + + + Magento_OfflinePayments/js/view/payment/instructions-method + + Magento_OfflinePayments/payment/instructions-form + + + + Magento_OfflinePayments/js/view/payment/purchaseorder-method + + Magento_OfflinePayments/payment/purchaseorder-form + + + + + + + + + + + + + + diff --git a/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/checkmo-method.js b/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/checkmo-method.js new file mode 100644 index 0000000000000..5093e525aaea7 --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/checkmo-method.js @@ -0,0 +1,34 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Checkout/js/view/payment/method-info', + 'mage/translate' + ], + function (methodInfo, $t) { + return methodInfo.extend({ + getMailingAddress: function() { + return window.checkoutConfig.payment.checkmo.mailingAddress; + }, + getPayableTo: function() { + return window.checkoutConfig.payment.checkmo.payableTo; + }, + getInfo: function() { + var info = []; + if (this.getPayableTo()) { + info.push({name: $t('Make Check payable to')}); + info.push({value: this.getPayableTo()}); + } + if (this.getMailingAddress()) { + info.push({name: $t('Send Check to')}); + info.push({html: this.getMailingAddress()}); + } + return info; + } + }); + } +); diff --git a/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/instructions-method.js b/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/instructions-method.js new file mode 100644 index 0000000000000..a3d9e9cdbae67 --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/instructions-method.js @@ -0,0 +1,25 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Checkout/js/view/payment/method-info' + ], + function (methodInfo) { + return methodInfo.extend({ + getInstructions: function() { + return window.checkoutConfig.payment.instructions[this.getCode()]; + }, + getInfo: function() { + var info = []; + if (this.getInstructions()) { + info.push({html: this.getInstructions()}); + } + return info; + } + }); + } +); diff --git a/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/purchaseorder-method.js b/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/purchaseorder-method.js new file mode 100644 index 0000000000000..1233199cc2d86 --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/purchaseorder-method.js @@ -0,0 +1,33 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'jquery', + "mage/translate", + 'Magento_Checkout/js/view/payment/method-info' + ], + function ($, $t, methodInfo) { + return methodInfo.extend({ + defaults: { + purchaseOrderNumber: '' + }, + initObservable: function () { + this._super() + .observe('purchaseOrderNumber'); + return this; + }, + getData: function() { + return {'po_number': this.purchaseOrderNumber()}; + }, + getInfo: function() { + return [ + {'name': 'Purchase Order Number', value: this.purchaseOrderNumber()} + ]; + } + }); + } +); diff --git a/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/checkmo-form.html b/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/checkmo-form.html new file mode 100644 index 0000000000000..92c84f0662ddd --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/checkmo-form.html @@ -0,0 +1,20 @@ + + +
    + +
    +
    + + +
    +
    +
    +
    + +
    + diff --git a/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/instructions-form.html b/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/instructions-form.html new file mode 100644 index 0000000000000..56f30d9cc42c1 --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/instructions-form.html @@ -0,0 +1,9 @@ + + +
    + \ No newline at end of file diff --git a/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/purchaseorder-form.html b/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/purchaseorder-form.html new file mode 100644 index 0000000000000..828045b5b7321 --- /dev/null +++ b/app/code/Magento/OfflinePayments/view/frontend/web/template/payment/purchaseorder-form.html @@ -0,0 +1,22 @@ + +
    +
    + +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 0662f52f42608..0807e7204dec8 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-sales-rule": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-sales-rule": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/PageCache/Controller/Block/Esi.php b/app/code/Magento/PageCache/Controller/Block/Esi.php index 9a59e0b7757b5..93fa5a6f0577f 100644 --- a/app/code/Magento/PageCache/Controller/Block/Esi.php +++ b/app/code/Magento/PageCache/Controller/Block/Esi.php @@ -24,7 +24,7 @@ public function execute() $blockInstance = array_shift($blocks); $html = $blockInstance->toHtml(); $ttl = $blockInstance->getTtl(); - if ($blockInstance instanceof \Magento\Framework\View\Block\IdentityInterface) { + if ($blockInstance instanceof \Magento\Framework\Object\IdentityInterface) { $response->setHeader('X-Magento-Tags', implode(',', $blockInstance->getIdentities())); } } diff --git a/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php b/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php new file mode 100644 index 0000000000000..3b4da78c35557 --- /dev/null +++ b/app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php @@ -0,0 +1,24 @@ +sendVary(); + } +} diff --git a/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php b/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php index e99f21689b8b2..cc7456922903e 100644 --- a/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php +++ b/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php @@ -62,7 +62,7 @@ public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result) if ($subject->isCacheable() && $this->config->isEnabled()) { $tags = []; foreach ($subject->getAllBlocks() as $block) { - if ($block instanceof \Magento\Framework\View\Block\IdentityInterface) { + if ($block instanceof \Magento\Framework\Object\IdentityInterface) { $isEsiBlock = $block->getTtl() > 0; $isVarnish = $this->config->getType() == \Magento\PageCache\Model\Config::VARNISH; if ($isVarnish && $isEsiBlock) { diff --git a/app/code/Magento/PageCache/Test/Unit/Block/Controller/StubBlock.php b/app/code/Magento/PageCache/Test/Unit/Block/Controller/StubBlock.php index f5615b3b13c1d..0a9a9b2fee080 100644 --- a/app/code/Magento/PageCache/Test/Unit/Block/Controller/StubBlock.php +++ b/app/code/Magento/PageCache/Test/Unit/Block/Controller/StubBlock.php @@ -6,7 +6,7 @@ namespace Magento\PageCache\Test\Unit\Block\Controller; -use Magento\Framework\View\Block\IdentityInterface; +use Magento\Framework\Object\IdentityInterface; use Magento\Framework\View\Element\AbstractBlock; class StubBlock extends AbstractBlock implements IdentityInterface diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php new file mode 100755 index 0000000000000..33e3b02e3d53b --- /dev/null +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php @@ -0,0 +1,25 @@ +getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->getMock(); + $responseMock->expects($this->once())->method('sendVary'); + $plugin = new HttpPlugin(); + $plugin->beforeSendResponse($responseMock); + } +} diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index 9a6c4ee4f3b69..e87ef00a74a50 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/PageCache/etc/adminhtml/system.xml b/app/code/Magento/PageCache/etc/adminhtml/system.xml index c646b7fcb862a..e1df259698163 100644 --- a/app/code/Magento/PageCache/etc/adminhtml/system.xml +++ b/app/code/Magento/PageCache/etc/adminhtml/system.xml @@ -60,7 +60,7 @@ - Public content cache lifetime in seconds. If field is empty default value 120 will be saved. + Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. Magento\PageCache\Model\System\Config\Backend\Ttl diff --git a/app/code/Magento/PageCache/etc/config.xml b/app/code/Magento/PageCache/etc/config.xml index a1530794673bb..56b5f971854f0 100644 --- a/app/code/Magento/PageCache/etc/config.xml +++ b/app/code/Magento/PageCache/etc/config.xml @@ -15,15 +15,15 @@ Magento/PageCache/etc/varnish4.vcl - 120 + 86400 1 localhost localhost 8080 - 120 + 86400 - \ No newline at end of file + diff --git a/app/code/Magento/PageCache/etc/frontend/di.xml b/app/code/Magento/PageCache/etc/frontend/di.xml index 50779f57dd331..3bb0051df947e 100644 --- a/app/code/Magento/PageCache/etc/frontend/di.xml +++ b/app/code/Magento/PageCache/etc/frontend/di.xml @@ -20,4 +20,7 @@ + + + diff --git a/app/code/Magento/PageCache/etc/varnish4.vcl b/app/code/Magento/PageCache/etc/varnish4.vcl index 0f3dddb893d95..2a3db0b42339d 100644 --- a/app/code/Magento/PageCache/etc/varnish4.vcl +++ b/app/code/Magento/PageCache/etc/varnish4.vcl @@ -78,7 +78,7 @@ sub vcl_backend_response { return (deliver); } elsif (beresp.http.Cache-Control ~ "private") { set beresp.uncacheable = true; - set beresp.ttl = 120s; + set beresp.ttl = 86400s; return (deliver); } diff --git a/app/code/Magento/PageCache/i18n/de_DE.csv b/app/code/Magento/PageCache/i18n/de_DE.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/de_DE.csv +++ b/app/code/Magento/PageCache/i18n/de_DE.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/PageCache/i18n/en_US.csv b/app/code/Magento/PageCache/i18n/en_US.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/en_US.csv +++ b/app/code/Magento/PageCache/i18n/en_US.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/PageCache/i18n/es_ES.csv b/app/code/Magento/PageCache/i18n/es_ES.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/es_ES.csv +++ b/app/code/Magento/PageCache/i18n/es_ES.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/PageCache/i18n/fr_FR.csv b/app/code/Magento/PageCache/i18n/fr_FR.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/fr_FR.csv +++ b/app/code/Magento/PageCache/i18n/fr_FR.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/PageCache/i18n/nl_NL.csv b/app/code/Magento/PageCache/i18n/nl_NL.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/nl_NL.csv +++ b/app/code/Magento/PageCache/i18n/nl_NL.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/PageCache/i18n/pt_BR.csv b/app/code/Magento/PageCache/i18n/pt_BR.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/pt_BR.csv +++ b/app/code/Magento/PageCache/i18n/pt_BR.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/PageCache/i18n/zh_CN.csv b/app/code/Magento/PageCache/i18n/zh_CN.csv index 6d515fd2809a0..0d57f18488d74 100644 --- a/app/code/Magento/PageCache/i18n/zh_CN.csv +++ b/app/code/Magento/PageCache/i18n/zh_CN.csv @@ -14,6 +14,6 @@ "Backend port","Backend port" "Specify backend port for config file generation. If field is empty default value 8080 will be saved.","Specify backend port for config file generation. If field is empty default value 8080 will be saved." "TTL for public content","TTL for public content" -"Public content cache lifetime in seconds. If field is empty default value 120 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 120 will be saved. " +"Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. ","Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. " "Page Cache","Page Cache" "Full page caching.","Full page caching." diff --git a/app/code/Magento/Payment/Helper/Data.php b/app/code/Magento/Payment/Helper/Data.php index 943b44b9e4532..a848b6dafd334 100644 --- a/app/code/Magento/Payment/Helper/Data.php +++ b/app/code/Magento/Payment/Helper/Data.php @@ -117,7 +117,7 @@ public function getMethodInstance($code) * * @param null|string|bool|int|Store $store * @param Quote|null $quote - * @return array + * @return AbstractMethod[] */ public function getStoreMethods($store = null, $quote = null) { diff --git a/app/code/Magento/Payment/Model/CcConfig.php b/app/code/Magento/Payment/Model/CcConfig.php new file mode 100644 index 0000000000000..59928e91953bb --- /dev/null +++ b/app/code/Magento/Payment/Model/CcConfig.php @@ -0,0 +1,155 @@ +config = $paymentConfig; + $this->assetRepo = $assetRepo; + $this->request = $request; + $this->urlBuilder = $urlBuilder; + $this->logger = $logger; + } + + /** + * Solo/switch card start years + * + * @return array + */ + public function getSsStartYears() + { + $years = []; + $first = date("Y"); + + for ($index = 5; $index >= 0; $index--) { + $year = $first - $index; + $years[$year] = $year; + } + return $years; + } + + /** + * Retrieve availables credit card types + * + * @return array + */ + public function getCcAvailableTypes() + { + return $this->config->getCcTypes(); + } + + /** + * Retrieve credit card expire months + * + * @return array + */ + public function getCcMonths() + { + return $this->config->getMonths(); + } + + /** + * Retrieve credit card expire years + * + * @return array + */ + public function getCcYears() + { + return $this->config->getYears(); + } + + /** + * Retrieve has verification configuration + * + * @return bool + */ + public function hasVerification() + { + return true; + } + + /** + * Whether switch/solo card type available + * + * @return bool + */ + public function hasSsCardType() + { + return false; + } + + /** + * Retrieve CVV tooltip image url + * + * @return string + */ + public function getCvvImageUrl() + { + return $this->getViewFileUrl('Magento_Checkout::cvv.png'); + } + + /** + * Retrieve url of a view file + * + * @param string $fileId + * @param array $params + * @return string + */ + public function getViewFileUrl($fileId, array $params = []) + { + try { + $params = array_merge(['_secure' => $this->request->isSecure()], $params); + return $this->assetRepo->getUrlWithParams($fileId, $params); + } catch (LocalizedException $e) { + $this->logger->critical($e); + return $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']); + } + } +} diff --git a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php new file mode 100644 index 0000000000000..432756f744c80 --- /dev/null +++ b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php @@ -0,0 +1,161 @@ +ccConfig = $ccConfig; + foreach ($this->methodCodes as $code) { + $this->methods[$code] = $paymentHelper->getMethodInstance($code); + } + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + $config = []; + foreach ($this->methodCodes as $methodCode) { + if ($this->methods[$methodCode]->isAvailable()) { + $config = array_merge_recursive($config, [ + 'payment' => [ + 'ccform' => [ + 'availableTypes' => [$methodCode => $this->getCcAvailableTypes($methodCode)], + 'months' => [$methodCode => $this->getCcMonths()], + 'years' => [$methodCode => $this->getCcYears()], + 'hasVerification' => [$methodCode => $this->hasVerification($methodCode)], + 'hasSsCardType' => [$methodCode => $this->hasSsCardType($methodCode)], + 'ssStartYears' => [$methodCode => $this->getSsStartYears()], + 'cvvImageUrl' => [$methodCode => $this->getCvvImageUrl()], + ], + ], + ]); + } + } + return $config; + } + + /** + * Solo/switch card start years + * + * @return array + */ + protected function getSsStartYears() + { + return $this->ccConfig->getSsStartYears(); + } + + /** + * Retrieve credit card expire months + * + * @return array + */ + protected function getCcMonths() + { + return $this->ccConfig->getCcMonths(); + } + + /** + * Retrieve credit card expire years + * + * @return array + */ + protected function getCcYears() + { + return $this->ccConfig->getCcYears(); + } + + /** + * Retrieve CVV tooltip image url + * + * @return string + */ + protected function getCvvImageUrl() + { + return $this->ccConfig->getCvvImageUrl(); + } + + /** + * Retrieve availables credit card types + * + * @param string $methodCode + * @return array + */ + protected function getCcAvailableTypes($methodCode) + { + $types = $this->ccConfig->getCcAvailableTypes(); + $availableTypes = $this->methods[$methodCode]->getConfigData('cctypes'); + if ($availableTypes) { + $availableTypes = explode(',', $availableTypes); + foreach (array_keys($types) as $code) { + if (!in_array($code, $availableTypes)) { + unset($types[$code]); + } + } + } + return $types; + } + + /** + * Retrieve has verification configuration + * + * @param string $methodCode + * @return bool + */ + protected function hasVerification($methodCode) + { + $result = $this->ccConfig->hasVerification(); + $configData = $this->methods[$methodCode]->getConfigData('useccv'); + if ($configData !== null) { + $result = (bool)$configData; + } + return $result; + } + + /** + * Whether switch/solo card type available + * + * @param string $methodCode + * @return bool + */ + protected function hasSsCardType($methodCode) + { + $result = false; + $availableTypes = explode(',', $this->methods[$methodCode]->getConfigData('cctypes')); + $ssPresentations = array_intersect(['SS', 'SM', 'SO'], $availableTypes); + if ($availableTypes && count($ssPresentations) > 0) { + $result = true; + } + return $result; + } +} diff --git a/app/code/Magento/Payment/Model/IframeConfigProvider.php b/app/code/Magento/Payment/Model/IframeConfigProvider.php new file mode 100644 index 0000000000000..4e995b0c22ab5 --- /dev/null +++ b/app/code/Magento/Payment/Model/IframeConfigProvider.php @@ -0,0 +1,202 @@ +assetRepo = $assetRepo; + $this->request = $request; + $this->urlBuilder = $urlBuilder; + $this->logger = $logger; + $this->method = $paymentHelper->getMethodInstance($this->methodCode); + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + return [ + 'payment' => [ + 'iframe' => [ + 'dateDelim' => [$this->methodCode => $this->getDateDelim()], + 'cardFieldsMap' => [$this->methodCode => $this->getCardFieldsMap()], + 'source' => [$this->methodCode => $this->getViewFileUrl('blank.html')], + 'controllerName' => [$this->methodCode => $this->getController()], + 'cgiUrl' => [$this->methodCode => $this->getCgiUrl()], + 'placeOrderUrl' => [$this->methodCode => $this->getPlaceOrderUrl()], + 'saveOrderUrl' => [$this->methodCode => $this->getSaveOrderUrl()], + ], + ], + ]; + } + + /** + * Get delimiter for date + * + * @return string + */ + protected function getDateDelim() + { + $result = ''; + if ($this->method->isAvailable()) { + $configData = $this->getMethodConfigData('date_delim'); + if ($configData !== null) { + $result = $configData; + } + } + + return $result; + } + + /** + * Get map of cc_code, cc_num, cc_expdate for gateway + * Returns json formatted string + * + * @return string + */ + protected function getCardFieldsMap() + { + $result = []; + if ($this->method->isAvailable()) { + $configData = $this->getMethodConfigData('ccfields'); + $keys = ['cccvv', 'ccexpdate', 'ccnum']; + $result = array_combine($keys, explode(',', $configData)); + } + + return $result; + } + + /** + * Retrieve url of a view file + * + * @param string $fileId + * @param array $params + * @return string[] + */ + protected function getViewFileUrl($fileId, array $params = []) + { + try { + $params = array_merge(['_secure' => $this->request->isSecure()], $params); + return $this->assetRepo->getUrlWithParams($fileId, $params); + } catch (LocalizedException $e) { + $this->logger->critical($e); + return $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']); + } + } + + /** + * Retrieve the controller name + * + * @return string + */ + protected function getController() + { + return $this->request->getControllerName(); + } + + /** + * Retrieve place order url on front + * + * @return string + */ + protected function getPlaceOrderUrl() + { + return $this->urlBuilder->getUrl( + $this->getMethodConfigData('place_order_url'), + [ + '_secure' => $this->request->isSecure() + ] + ); + } + + /** + * Retrieve save order url on front + * + * @return string + */ + protected function getSaveOrderUrl() + { + return $this->urlBuilder->getUrl('checkout/onepage/saveOrder', ['_secure' => $this->request->isSecure()]); + } + + /** + * Retrieve gateway url + * + * @return string + */ + protected function getCgiUrl() + { + return (bool)$this->getMethodConfigData('sandbox_flag') + ? $this->getMethodConfigData('cgi_url_test_mode') + : $this->getMethodConfigData('cgi_url'); + } + + /** + * Retrieve config data value by field name + * + * @param string $fieldName + * @return mixed + */ + protected function getMethodConfigData($fieldName) + { + return $this->method->getConfigInterface()->getConfigValue($fieldName); + } +} diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index 5a3a5a8b46262..ce7e1fd8495ca 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -207,13 +207,6 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl */ protected $_scopeConfig; - /** - * Core event manager proxy - * - * @var \Magento\Framework\Event\ManagerInterface - */ - protected $_eventManager; - /** * @var \Psr\Log\LoggerInterface */ @@ -252,7 +245,6 @@ public function __construct( ); $this->_paymentData = $paymentData; $this->_scopeConfig = $scopeConfig; - $this->_eventManager = $context->getEventDispatcher(); $this->logger = $context->getLogger(); $this->initializeData($data); } @@ -765,6 +757,17 @@ public function getTitle() return $this->getConfigData('title'); } + /** + * Retrieve fraud message if exists + * + * @return string + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function getFraudMessage() + { + return $this->getInfoInstance()->getAdditionalInformation('fraud_msg'); + } + /** * Retrieve information from payment configuration * @@ -819,18 +822,33 @@ public function prepareSave() public function isAvailable($quote = null) { $checkResult = new \StdClass(); - $isActive = (bool)(int)$this->getConfigData('active', $quote ? $quote->getStoreId() : null); + $isActive = $this->isActive($quote ? $quote->getStoreId() : null); $checkResult->isAvailable = $isActive; $checkResult->isDeniedInConfig = !$isActive; // for future use in observers $this->_eventManager->dispatch( 'payment_method_is_active', - ['result' => $checkResult, 'method_instance' => $this, 'quote' => $quote] + [ + 'result' => $checkResult, + 'method_instance' => $this, + 'quote' => $quote + ] ); return $checkResult->isAvailable; } + /** + * Is active + * + * @param int|null $storeId + * @return bool + */ + public function isActive($storeId = null) + { + return (bool)(int)$this->getConfigData('active', $storeId); + } + /** * Method that will be executed instead of authorize or capture * if flag isInitializeNeeded set to true diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index 978e75c5840aa..7e9e8c0181169 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -36,13 +36,6 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod */ protected $_localeDate; - /** - * Centinel service model - * - * @var \Magento\Centinel\Model\Service - */ - protected $_centinelService; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -52,7 +45,6 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate - * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -67,7 +59,6 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\Centinel\Model\Service $centinelService, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] @@ -85,7 +76,6 @@ public function __construct( ); $this->_moduleList = $moduleList; $this->_localeDate = $localeDate; - $this->_centinelService = $centinelService; } /** @@ -240,11 +230,6 @@ public function validate() throw new \Magento\Framework\Exception\LocalizedException($errorMsg); } - //This must be after all validation conditions - if ($this->getIsCentinelValidationEnabled()) { - $this->getCentinelValidator()->validate($this->getCentinelValidationData()); - } - return $this; } @@ -369,128 +354,4 @@ public function isAvailable($quote = null) { return $this->getConfigData('cctypes', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote); } - - /** - * Whether centinel service is enabled - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getIsCentinelValidationEnabled() - { - return $this->_moduleList->has('Magento_Centinel') && 1 == $this->getConfigData('centinel'); - } - - /** - * Instantiate centinel validator model - * - * @return \Magento\Centinel\Model\Service - */ - public function getCentinelValidator() - { - $this->_centinelService->setIsModeStrict( - $this->getConfigData('centinel_is_mode_strict') - )->setCustomApiEndpointUrl( - $this->getConfigData('centinel_api_url') - )->setStore( - $this->getStore() - )->setIsPlaceOrder( - $this->_isPlaceOrder() - ); - return $this->_centinelService; - } - - /** - * Return data for Centinel validation - * - * @return \Magento\Framework\Object - */ - public function getCentinelValidationData() - { - $info = $this->getInfoInstance(); - $params = new \Magento\Framework\Object(); - $params->setPaymentMethodCode( - $this->getCode() - )->setCardType( - $info->getCcType() - )->setCardNumber( - $info->getCcNumber() - )->setCardExpMonth( - $info->getCcExpMonth() - )->setCardExpYear( - $info->getCcExpYear() - )->setAmount( - $this->_getAmount() - )->setCurrencyCode( - $this->_getCurrencyCode() - )->setOrderNumber( - $this->_getOrderId() - ); - return $params; - } - - /** - * Order increment ID getter (either real from order or a reserved from quote) - * - * @return string - */ - private function _getOrderId() - { - $info = $this->getInfoInstance(); - - if ($this->_isPlaceOrder()) { - return $info->getOrder()->getIncrementId(); - } else { - if (!$info->getQuote()->getReservedOrderId()) { - $info->getQuote()->reserveOrderId(); - } - return $info->getQuote()->getReservedOrderId(); - } - } - - /** - * Grand total getter - * - * @return string - */ - private function _getAmount() - { - $info = $this->getInfoInstance(); - if ($this->_isPlaceOrder()) { - return (double)$info->getOrder()->getQuoteBaseGrandTotal(); - } else { - return (double)$info->getQuote()->getBaseGrandTotal(); - } - } - - /** - * Currency code getter - * - * @return string - */ - private function _getCurrencyCode() - { - $info = $this->getInfoInstance(); - - if ($this->_isPlaceOrder()) { - return $info->getOrder()->getBaseCurrencyCode(); - } else { - return $info->getQuote()->getBaseCurrencyCode(); - } - } - - /** - * Whether current operation is order placement - * - * @return bool - */ - private function _isPlaceOrder() - { - $info = $this->getInfoInstance(); - if ($info instanceof \Magento\Quote\Model\Quote\Payment) { - return false; - } elseif ($info instanceof \Magento\Sales\Model\Order\Payment) { - return true; - } - } } diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index 3793669383195..40d9cb98f24a5 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -13,6 +13,8 @@ */ class Free extends \Magento\Payment\Model\Method\AbstractMethod { + const PAYMENT_METHOD_FREE_CODE = 'free'; + /** * XML Paths for configuration constants */ @@ -34,7 +36,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod * * @var string */ - protected $_code = 'free'; + protected $_code = self::PAYMENT_METHOD_FREE_CODE; /** * @var PriceCurrencyInterface @@ -95,6 +97,17 @@ public function isAvailable($quote = null) ) == 0; } + /** + * Check whether method is enabled in config + * + * @param \Magento\Quote\Model\Quote|null $quote + * @return bool + */ + public function isAvailableInConfig($quote = null) + { + return parent::isAvailable($quote); + } + /** * Get config payment action, do nothing if status is pending * diff --git a/app/code/Magento/Payment/Model/MethodList.php b/app/code/Magento/Payment/Model/MethodList.php index 5d486411b9f7a..2ec5164d07be7 100644 --- a/app/code/Magento/Payment/Model/MethodList.php +++ b/app/code/Magento/Payment/Model/MethodList.php @@ -7,6 +7,7 @@ namespace Magento\Payment\Model; use Magento\Payment\Model\Method\AbstractMethod; +use Magento\Payment\Model\Method\Free; class MethodList { @@ -41,11 +42,22 @@ public function getAvailableMethods(\Magento\Quote\Api\Data\CartInterface $quote { $store = $quote ? $quote->getStoreId() : null; $methods = []; - $specification = $this->methodSpecificationFactory->create([AbstractMethod::CHECK_ZERO_TOTAL]); + $isFreeAdded = false; foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) { - if ($this->_canUseMethod($method, $quote) && $specification->isApplicable($method, $quote)) { + if ($this->_canUseMethod($method, $quote)) { $method->setInfoInstance($quote->getPayment()); $methods[] = $method; + if ($method->getCode() == Free::PAYMENT_METHOD_FREE_CODE) { + $isFreeAdded = true; + } + } + } + if (!$isFreeAdded) { + /** @var \Magento\Payment\Model\Method\Free $freeMethod */ + $freeMethod = $this->paymentHelper->getMethodInstance(Free::PAYMENT_METHOD_FREE_CODE); + if ($freeMethod->isAvailableInConfig()) { + $freeMethod->setInfoInstance($quote->getPayment()); + $methods[] = $freeMethod; } } return $methods; diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php new file mode 100644 index 0000000000000..ee5d8e15a7617 --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php @@ -0,0 +1,140 @@ +configMock = $this->getMock('Magento\Payment\Model\Config', [], [], '', false); + $this->repositoryMock = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false); + $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->urlMock = $this->getMock('Magento\Framework\UrlInterface'); + $this->loggerMock = $this->getMock('Psr\Log\LoggerInterface'); + + $this->model = new \Magento\Payment\Model\CcConfig( + $this->configMock, + $this->repositoryMock, + $this->requestMock, + $this->urlMock, + $this->loggerMock + ); + } + + public function testGetSsStartYears() + { + $this->assertCount(6, $this->model->getSsStartYears()); + $this->assertEquals(date("Y"), $this->model->getSsStartYears()[date("Y")]); + } + + public function testGetCcAvailableTypes() + { + $data = [1, 2, 3]; + $this->configMock->expects($this->once()) + ->method('getCcTypes') + ->willReturn($data); + + $this->assertEquals($data, $this->model->getCcAvailableTypes()); + } + + public function testGetCcMonths() + { + $data = [1, 2, 3]; + $this->configMock->expects($this->once()) + ->method('getMonths') + ->willReturn($data); + + $this->assertEquals($data, $this->model->getCcMonths()); + } + + public function testGetCcYears() + { + $data = [1, 2, 3]; + $this->configMock->expects($this->once()) + ->method('getYears') + ->willReturn($data); + + $this->assertEquals($data, $this->model->getCcYears()); + } + + public function testHasVerification() + { + $this->assertEquals(true, $this->model->hasVerification()); + } + + public function testHasSsCardType() + { + $this->assertEquals(false, $this->model->hasSsCardType()); + } + + public function testGetCvvImageUrl() + { + $params = ['_secure' => true]; + $fileId = 'Magento_Checkout::cvv.png'; + $fileUrl = 'file url'; + + $this->requestMock->expects($this->once()) + ->method('isSecure') + ->willReturn(true); + + $this->repositoryMock->expects($this->once()) + ->method('getUrlWithParams') + ->with($fileId, $params) + ->willReturn($fileUrl); + + $this->assertEquals($fileUrl, $this->model->getCvvImageUrl()); + } + + public function getViewFileUrlWithException() + { + $params = ['a' => 'b']; + $paramsSecure = ['a' => 'b', '_secure' => false]; + $fileId = 'file id'; + $fileUrl = 'exception url'; + + $this->requestMock->expects($this->once()) + ->method('isSecure') + ->willReturn(false); + + $exception = new LocalizedException('message'); + + $this->repositoryMock->expects($this->once()) + ->method('getUrlWithParams') + ->with($fileId, $paramsSecure) + ->willThrowException($exception); + + $this->loggerMock->expects($this->once()) + ->method('critical') + ->with($exception); + + $this->urlMock->expects($this->once()) + ->method('getUrl') + ->with('', ['_direct' => 'core/index/notFound']) + ->willReturn($fileUrl); + + $this->assertEquals($fileUrl, $this->model->getViewFileUrl($fileId, $params)); + } +} diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php new file mode 100644 index 0000000000000..6550b19172f02 --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Model/CcGenericConfigProviderTest.php @@ -0,0 +1,38 @@ +ccConfigMock = $this->getMock('Magento\Payment\Model\CcConfig', [], [], '', false); + $this->paymentHelperMock = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + + $this->model = new CcGenericConfigProvider( + $this->ccConfigMock, + $this->paymentHelperMock + ); + } + + public function testGetConfig() + { + $this->assertEquals([], $this->model->getConfig()); + } +} diff --git a/app/code/Magento/Payment/Test/Unit/Model/Config/ConverterTest.php b/app/code/Magento/Payment/Test/Unit/Model/Config/ConverterTest.php index a41d440e77e47..ea2ebbe345917 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Config/ConverterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Config/ConverterTest.php @@ -31,7 +31,7 @@ public function testConvert() $expectedResult = [ 'credit_cards' => ['SO' => 'Solo', 'SM' => 'Switch/Maestro'], 'groups' => ['any_payment' => 'Any Payment'], - 'methods' => ['checkmo' => ['allow_multiple_address' => 1, 'allow_multiple_with_3dsecure' => 1]], + 'methods' => ['checkmo' => ['allow_multiple_address' => 1]], ]; $this->assertEquals($expectedResult, $this->_model->convert($dom), '', 0, 20); } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Config/_files/payment.xml b/app/code/Magento/Payment/Test/Unit/Model/Config/_files/payment.xml index 26151a6116dd9..5c01da582585b 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Config/_files/payment.xml +++ b/app/code/Magento/Payment/Test/Unit/Model/Config/_files/payment.xml @@ -23,7 +23,6 @@ 1 - 1 diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethod/Stub.php b/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethod/Stub.php new file mode 100644 index 0000000000000..fe64cea9aca50 --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/AbstractMethod/Stub.php @@ -0,0 +1,24 @@ +scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->setMethods(['getValue']) + ->getMockForAbstractClass(); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->setMethods(['dispatch']) + ->getMockForAbstractClass(); + $this->quoteMock = $this->getMockBuilder('Magento\Quote\Api\Data\CartInterface') + ->setMethods(['getStoreId']) + ->getMockForAbstractClass(); + $contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->setMethods(['getEventDispatcher']) + ->getMock(); + + $contextMock->expects($this->once()) + ->method('getEventDispatcher') + ->willReturn($this->eventManagerMock); + + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->payment = $helper->getObject( + 'Magento\Payment\Test\Unit\Model\Method\AbstractMethod\Stub', + [ + 'scopeConfig' => $this->scopeConfigMock, + 'context' => $contextMock + ] + ); + } + + /** + * @param bool $result + * + * @dataProvider dataProviderForTestIsAvailable + */ + public function testIsAvailable($result) + { + $storeId = 15; + $this->quoteMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeId); + + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with( + 'payment/' . Stub::STUB_CODE . '/active', + ScopeInterface::SCOPE_STORE, + $storeId + )->willReturn($result); + + $this->eventManagerMock->expects($this->once()) + ->method('dispatch') + ->with( + $this->equalTo('payment_method_is_active'), + $this->countOf(3) + ); + + $this->assertEquals($result, $this->payment->isAvailable($this->quoteMock)); + } + + /** + * @return array + */ + public function dataProviderForTestIsAvailable() + { + return [ + [ + 'result' => true + ], + [ + 'result' => false + ], + ]; + } +} diff --git a/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php b/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php index 41e88565fe51a..c8ec10c9cac32 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php @@ -8,6 +8,7 @@ namespace Magento\Payment\Test\Unit\Model; +use Magento\Payment\Model\Method\Free; use \Magento\Payment\Model\MethodList; class MethodListTest extends \PHPUnit_Framework_TestCase @@ -57,7 +58,10 @@ public function testGetAvailableMethods() ->method('getPayment') ->will($this->returnValue($this->getMock('\Magento\Quote\Model\Quote\Payment', [], [], '', false))); - $methodMock = $this->getMock('Magento\Payment\Model\Method\AbstractMethod', ['setInfoInstance'], [], '', false); + $methodMock = $this->getMock('Magento\Payment\Model\Method\AbstractMethod', ['setInfoInstance', 'getCode'], [], '', false); + $methodMock->expects($this->once()) + ->method('getCode') + ->willReturn(Free::PAYMENT_METHOD_FREE_CODE); $compositeMock = $this->getMock('\Magento\Payment\Model\Checks\Composite', [], [], '', false); $compositeMock->expects($this->atLeastOnce()) diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 268b2e08e3183..027fd65073de7 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,17 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-centinel": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Payment/etc/payment.xsd b/app/code/Magento/Payment/etc/payment.xsd index 0acc76bc9acbf..c25bd31d96002 100644 --- a/app/code/Magento/Payment/etc/payment.xsd +++ b/app/code/Magento/Payment/etc/payment.xsd @@ -89,7 +89,6 @@ - diff --git a/app/code/Magento/Payment/etc/payment_file.xsd b/app/code/Magento/Payment/etc/payment_file.xsd index def5383c713b8..c0ecf517a7b3c 100644 --- a/app/code/Magento/Payment/etc/payment_file.xsd +++ b/app/code/Magento/Payment/etc/payment_file.xsd @@ -89,7 +89,6 @@ - diff --git a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml index f2db06784d9fa..b4538bd9f23f7 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml @@ -15,7 +15,7 @@ escapeHtml($block->getMethod()->getTitle()) ?> getSpecificInformation()):?> -
    +
    $_value):?> diff --git a/app/code/Magento/Payment/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Payment/view/frontend/layout/checkout_onepage_index.xml new file mode 100644 index 0000000000000..3f89143cb971b --- /dev/null +++ b/app/code/Magento/Payment/view/frontend/layout/checkout_onepage_index.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + Magento_Payment/js/view/payment/free-method + + + + + + + + + + + + + diff --git a/app/code/Magento/Payment/view/frontend/templates/transparent/iframe.phtml b/app/code/Magento/Payment/view/frontend/templates/transparent/iframe.phtml index 6b55b5df4cd7a..93ac9970e1453 100644 --- a/app/code/Magento/Payment/view/frontend/templates/transparent/iframe.phtml +++ b/app/code/Magento/Payment/view/frontend/templates/transparent/iframe.phtml @@ -18,13 +18,16 @@ $params = $block->getParams(); window.top.location="escapeXssInUrl($params['redirect_parent']) ?>"; window.top.alert(helper('Magento\Framework\Json\Helper\Data')->jsonEncode($params['error_msg']) ?>); + var require = window.top.require; + require(['jquery'], function($) { + $('#opc-review').trigger('hideAjaxLoader'); + }); window.top.location = ""; var require = window.top.require; require(['jquery'], function($) { - $('#opc-review').trigger('hideAjaxLoader'); - $('#opc-review').trigger('saveOrder'); + $('#originalPlaceOrder').click(); }); diff --git a/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js b/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js new file mode 100644 index 0000000000000..8e6e53f0ae7e5 --- /dev/null +++ b/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js @@ -0,0 +1,136 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'underscore', + 'uiComponent', + 'mage/translate' + ], + function (_, component, $t) { + return component.extend({ + defaults: { + template: 'Magento_Payment/payment/cc-form', + creditCardType: '', + creditCardExpYear: '', + creditCardExpMonth: '', + creditCardNumber: '', + creditCardSsStartMonth: '', + creditCardSsStartYear: '', + creditCardVerificationNumber: '' + }, + initObservable: function () { + this._super() + .observe([ + 'creditCardType', + 'creditCardExpYear', + 'creditCardExpMonth', + 'creditCardNumber', + 'creditCardVerificationNumber', + 'creditCardSsStartMonth', + 'creditCardSsStartYear' + ]); + return this; + }, + getCode: function() { + return 'cc'; + }, + getData: function() { + return { + 'cc_type': this.creditCardType(), + 'cc_exp_year': this.creditCardExpYear(), + 'cc_exp_month': this.creditCardExpMonth(), + 'cc_number': this.creditCardNumber(), + additional_data: { + 'cc_cid': this.creditCardVerificationNumber(), + 'cc_ss_start_month': this.creditCardSsStartMonth(), + 'cc_ss_start_year': this.creditCardSsStartYear() + } + }; + }, + getCcAvailableTypes: function() { + return window.checkoutConfig.payment.ccform.availableTypes[this.getCode()]; + }, + getCcMonths: function() { + return window.checkoutConfig.payment.ccform.months[this.getCode()]; + }, + getCcYears: function() { + return window.checkoutConfig.payment.ccform.years[this.getCode()]; + }, + hasVerification: function() { + return window.checkoutConfig.payment.ccform.hasVerification[this.getCode()]; + }, + hasSsCardType: function() { + return window.checkoutConfig.payment.ccform.hasSsCardType[this.getCode()]; + }, + getCvvImageUrl: function() { + return window.checkoutConfig.payment.ccform.cvvImageUrl[this.getCode()]; + }, + getCvvImageHtml: function() { + return '' + $t('Card Verification Number Visual Reference')
+                    + ''; + }, + getSsStartYears: function() { + return window.checkoutConfig.payment.ccform.ssStartYears[this.getCode()]; + }, + getCcAvailableTypesValues: function() { + return _.map(this.getCcAvailableTypes(), function(value, key) { + return { + 'value': key, + 'type': value + } + }); + }, + getCcMonthsValues: function() { + return _.map(this.getCcMonths(), function(value, key) { + return { + 'value': key, + 'month': value + } + }); + }, + getCcYearsValues: function() { + return _.map(this.getCcYears(), function(value, key) { + return { + 'value': key, + 'year': value + } + }); + }, + getSsStartYearsValues: function() { + return _.map(this.getSsStartYears(), function(value, key) { + return { + 'value': key, + 'year': value + } + }); + }, + isShowLegend: function() { + return false; + }, + getCcTypeTitleByCode: function(code) { + var title = ''; + _.each(this.getCcAvailableTypesValues(), function (value) { + if (value['value'] == code) { + title = value['type']; + } + }); + return title; + }, + formatDisplayCcNumber: function(number) { + return 'xxxx-' + number.substr(-4); + }, + getInfo: function() { + return [ + {'name': 'Credit Card Type', value: this.getCcTypeTitleByCode(this.creditCardType())}, + {'name': 'Credit Card Number', value: this.formatDisplayCcNumber(this.creditCardNumber())} + ]; + } + }); + } +); diff --git a/app/code/Magento/Payment/view/frontend/web/js/view/payment/free-method.js b/app/code/Magento/Payment/view/frontend/web/js/view/payment/free-method.js new file mode 100644 index 0000000000000..44285074df09a --- /dev/null +++ b/app/code/Magento/Payment/view/frontend/web/js/view/payment/free-method.js @@ -0,0 +1,15 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Checkout/js/view/payment/method-info' + ], + function (method) { + return method.extend({ + }); + } +); diff --git a/app/code/Magento/Payment/view/frontend/web/js/view/review/actions/iframe.js b/app/code/Magento/Payment/view/frontend/web/js/view/review/actions/iframe.js new file mode 100644 index 0000000000000..a5a78d731cfea --- /dev/null +++ b/app/code/Magento/Payment/view/frontend/web/js/view/review/actions/iframe.js @@ -0,0 +1,45 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent' + ], + function (Component) { + return Component.extend({ + defaults: { + template: 'Magento_Payment/review/actions/iframe' + }, + getSource: function () { + return window.checkoutConfig.payment.iframe.source[this.getCode()]; + }, + getControllerName: function() { + return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; + }, + getPlaceOrderUrl: function() { + return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()]; + }, + getCgiUrl: function() { + return window.checkoutConfig.payment.iframe.cgiUrl[this.getCode()]; + }, + getSaveOrderUrl: function() { + return window.checkoutConfig.payment.iframe.saveOrderUrl[this.getCode()]; + }, + getDateDelim: function() { + return window.checkoutConfig.payment.iframe.dateDelim[this.getCode()]; + }, + getCardFieldsMap: function() { + return window.checkoutConfig.payment.iframe.cardFieldsMap[this.getCode()]; + }, + getCode: function() { + return this.index; + }, + originalPlaceOrder: function(parent) { + return parent.placeOrder.bind(parent); + } + }); + } +); diff --git a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html new file mode 100644 index 0000000000000..96fd1446d2cf3 --- /dev/null +++ b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html @@ -0,0 +1,112 @@ + +
    + +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    + +
    + +
    + +
    +
    +
    + + +
    +
    +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
     
    +
    +
    + +
    diff --git a/app/code/Magento/Payment/view/frontend/web/template/review/actions/iframe.html b/app/code/Magento/Payment/view/frontend/web/template/review/actions/iframe.html new file mode 100644 index 0000000000000..cd9c3342c733f --- /dev/null +++ b/app/code/Magento/Payment/view/frontend/web/template/review/actions/iframe.html @@ -0,0 +1,39 @@ + + + +
    + + + + +
    +
    + + +
    +
    + + + + +
    +
    diff --git a/app/code/Magento/Persistent/Model/Checkout/AddressDataProcessorPlugin.php b/app/code/Magento/Persistent/Model/Checkout/AddressDataProcessorPlugin.php new file mode 100644 index 0000000000000..b6b50120250e8 --- /dev/null +++ b/app/code/Magento/Persistent/Model/Checkout/AddressDataProcessorPlugin.php @@ -0,0 +1,64 @@ +persistentHelper = $persistentHelper; + $this->persistentSession = $persistentSession; + $this->checkoutSession = $checkoutSession; + } + + /** + * Process address additional data + * + * @param AddressAdditionalDataProcessor $subject + * @param AddressAdditionalData $additionalData + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeProcess(AddressAdditionalDataProcessor $subject, AddressAdditionalData $additionalData) + { + if (!$this->persistentHelper->isEnabled() || !$this->persistentHelper->isRememberMeEnabled()) { + return; + } + $checkboxStatus = $additionalData->getExtensionAttributes()->getPersistentRememberMe(); + $isRememberMeChecked = empty($checkboxStatus) ? false : true; + $this->persistentSession->setRememberMeChecked($isRememberMeChecked); + $this->checkoutSession->setRememberMeChecked($isRememberMeChecked); + } +} diff --git a/app/code/Magento/Persistent/Model/CheckoutConfigProvider.php b/app/code/Magento/Persistent/Model/CheckoutConfigProvider.php new file mode 100644 index 0000000000000..e0d2e9a1fe383 --- /dev/null +++ b/app/code/Magento/Persistent/Model/CheckoutConfigProvider.php @@ -0,0 +1,40 @@ +persistentHelper = $persistentHelper; + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + $isCheckboxVisible = $this->persistentHelper->isEnabled() && $this->persistentHelper->isRememberMeEnabled(); + $isCheckboxChecked = $this->persistentHelper->isRememberMeCheckedDefault(); + return [ + 'persistenceConfig' => [ + 'isRememberMeCheckboxVisible' => $isCheckboxVisible, + 'isRememberMeCheckboxChecked' => $isCheckboxChecked, + ], + ]; + } +} diff --git a/app/code/Magento/Persistent/Model/Observer/Session.php b/app/code/Magento/Persistent/Model/Observer/Session.php index 1576a9828fe0c..27cf0e7e34fd0 100644 --- a/app/code/Magento/Persistent/Model/Observer/Session.php +++ b/app/code/Magento/Persistent/Model/Observer/Session.php @@ -191,6 +191,30 @@ public function setRememberMeCheckedStatus(Observer $observer) } } + /** + * Set Checked status of "Remember Me" + * + * @param Observer $observer + * @return void + */ + public function setRememberMeStatusForAjaxLogin(Observer $observer) + { + if (!$this->_persistentData->canProcess($observer) + || !$this->_persistentData->isEnabled() + || !$this->_persistentData->isRememberMeEnabled() + ) { + return; + } + + /** @var $request \Magento\Framework\App\RequestInterface */ + $request = $observer->getEvent()->getRequest(); + if ($request && $request->isXmlHttpRequest()) { + $requestData = \Zend_Json::decode($request->getContent()); + $isRememberMeChecked = empty($requestData['persistent_remember_me']) ? false : true; + $this->_persistentSession->setRememberMeChecked((bool)$isRememberMeChecked); + } + } + /** * Renew persistent cookie * diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 3a61917fbd56d..78c0fb856a495 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -278,6 +278,7 @@ public function deleteByCustomerId($customerId, $clearCookie = true) * Remove persistent cookie * * @return $this + * @api */ public function removePersistentCookie() { @@ -293,6 +294,7 @@ public function removePersistentCookie() * @param int $duration Time in seconds. * @param string $path * @return $this + * @api */ public function setPersistentCookie($duration, $path) { diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index 5d77471171882..e2d1886a9380f 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-cron": "0.74.0-beta9", - "magento/module-page-cache": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-cron": "0.74.0-beta11", + "magento/module-page-cache": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Persistent/etc/di.xml b/app/code/Magento/Persistent/etc/di.xml new file mode 100644 index 0000000000000..8ced83d2cc901 --- /dev/null +++ b/app/code/Magento/Persistent/etc/di.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/app/code/Magento/Persistent/etc/frontend/di.xml b/app/code/Magento/Persistent/etc/frontend/di.xml index c9574570e304f..43ed89834020a 100644 --- a/app/code/Magento/Persistent/etc/frontend/di.xml +++ b/app/code/Magento/Persistent/etc/frontend/di.xml @@ -19,4 +19,14 @@ sortOrder="10" /> + + + + Magento\Persistent\Model\CheckoutConfigProvider + + + + + + diff --git a/app/code/Magento/Persistent/etc/frontend/events.xml b/app/code/Magento/Persistent/etc/frontend/events.xml index a49b4c59c053f..17f57dc96eaa1 100644 --- a/app/code/Magento/Persistent/etc/frontend/events.xml +++ b/app/code/Magento/Persistent/etc/frontend/events.xml @@ -18,6 +18,9 @@ + + + diff --git a/app/code/Magento/Persistent/etc/persistent.xml b/app/code/Magento/Persistent/etc/persistent.xml index afd839440ccb9..fe5138b065419 100644 --- a/app/code/Magento/Persistent/etc/persistent.xml +++ b/app/code/Magento/Persistent/etc/persistent.xml @@ -8,12 +8,6 @@ - - header - Magento\Persistent\Model\Observer - emulateWelcomeBlock - Magento\Theme\Block\Html\Header - top.links Magento\Persistent\Model\Observer diff --git a/app/code/Magento/Persistent/etc/service_data_attributes.xml b/app/code/Magento/Persistent/etc/service_data_attributes.xml new file mode 100644 index 0000000000000..db88666b03bcf --- /dev/null +++ b/app/code/Magento/Persistent/etc/service_data_attributes.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/app/code/Magento/Persistent/etc/webapi_rest/events.xml b/app/code/Magento/Persistent/etc/webapi_rest/events.xml new file mode 100644 index 0000000000000..68f8bc0378d45 --- /dev/null +++ b/app/code/Magento/Persistent/etc/webapi_rest/events.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Persistent/etc/webapi_soap/events.xml b/app/code/Magento/Persistent/etc/webapi_soap/events.xml new file mode 100644 index 0000000000000..68f8bc0378d45 --- /dev/null +++ b/app/code/Magento/Persistent/etc/webapi_soap/events.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Persistent/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Persistent/view/frontend/layout/checkout_onepage_index.xml index 9dd459f911a00..80989653fc335 100644 --- a/app/code/Magento/Persistent/view/frontend/layout/checkout_onepage_index.xml +++ b/app/code/Magento/Persistent/view/frontend/layout/checkout_onepage_index.xml @@ -5,13 +5,40 @@ * See COPYING.txt for license details. */ --> - + - - - - - - + + + + + + + + + + + + Magento_Persistent/js/view/remember-me + additional-login-form-fields + + + + + + + Magento_Persistent/js/view/remember-me + additionalAddressData + additional-fieldsets + + + + + + + + + + + diff --git a/app/code/Magento/Persistent/view/frontend/web/js/view/remember-me.js b/app/code/Magento/Persistent/view/frontend/web/js/view/remember-me.js new file mode 100644 index 0000000000000..f1fdf5593e70c --- /dev/null +++ b/app/code/Magento/Persistent/view/frontend/web/js/view/remember-me.js @@ -0,0 +1,24 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + "ko", + "uiComponent" + ], + function (ko, Component) { + "use strict"; + var persistenceConfig = window.checkoutConfig.persistenceConfig; + return Component.extend({ + defaults: { + template: "Magento_Persistent/remember-me" + }, + dataScope: "global", + isRememberMeCheckboxVisible: ko.observable(persistenceConfig.isRememberMeCheckboxVisible), + isRememberMeCheckboxChecked: ko.observable(persistenceConfig.isRememberMeCheckboxChecked) + }); + } +); diff --git a/app/code/Magento/Persistent/view/frontend/web/template/remember-me.html b/app/code/Magento/Persistent/view/frontend/web/template/remember-me.html new file mode 100644 index 0000000000000..086ba1e3b1afe --- /dev/null +++ b/app/code/Magento/Persistent/view/frontend/web/template/remember-me.html @@ -0,0 +1,16 @@ + + +
    + + + + + + +
    + diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 390671d5442f1..76b833314ba37 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Quote/Api/AddressDetailsManagementInterface.php b/app/code/Magento/Quote/Api/AddressDetailsManagementInterface.php new file mode 100644 index 0000000000000..a721e539ddf50 --- /dev/null +++ b/app/code/Magento/Quote/Api/AddressDetailsManagementInterface.php @@ -0,0 +1,27 @@ +_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + */ + public function setExtensionAttributes( + \Magento\Quote\Api\Data\AddressAdditionalDataExtensionInterface $extensionAttributes + ) { + $this->_setExtensionAttributes($extensionAttributes); + } +} diff --git a/app/code/Magento/Quote/Model/AddressAdditionalDataProcessor.php b/app/code/Magento/Quote/Model/AddressAdditionalDataProcessor.php new file mode 100644 index 0000000000000..716d99c22aeb1 --- /dev/null +++ b/app/code/Magento/Quote/Model/AddressAdditionalDataProcessor.php @@ -0,0 +1,24 @@ +getData(self::SHIPPING_METHODS); + } + + /** + * @{inheritdoc} + */ + public function setShippingMethods($shippingMethods) + { + return $this->setData(self::SHIPPING_METHODS, $shippingMethods); + } + + /** + * @{inheritdoc} + */ + public function getPaymentMethods() + { + return $this->getData(self::PAYMENT_METHODS); + } + + /** + * @{inheritdoc} + */ + public function setPaymentMethods($paymentMethods) + { + return $this->setData(self::PAYMENT_METHODS, $paymentMethods); + } + + /** + * @{inheritdoc} + */ + public function getFormattedShippingAddress() + { + return $this->getData(self::FORMATTED_SHIPPING_ADDRESS); + } + + /** + * @{inheritdoc} + */ + public function getFormattedBillingAddress() + { + return $this->getData(self::FORMATTED_BILLING_ADDRESS); + } + + /** + * @{inheritdoc} + */ + public function setFormattedBillingAddress($formattedBillingAddress) + { + return $this->setData(self::FORMATTED_BILLING_ADDRESS, $formattedBillingAddress); + } + + /** + * @{inheritdoc} + */ + public function setFormattedShippingAddress($formattedShippingAddress) + { + return $this->setData(self::FORMATTED_SHIPPING_ADDRESS, $formattedShippingAddress); + } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\AddressDetailsExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\AddressDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Quote\Api\Data\AddressDetailsExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } + + /** + * @{inheritdoc} + */ + public function getTotals() + { + return $this->getData(self::TOTALS); + } + + /** + * @{inheritdoc} + */ + public function setTotals($totals) + { + return $this->setData(self::TOTALS, $totals); + } +} diff --git a/app/code/Magento/Quote/Model/AddressDetailsManagement.php b/app/code/Magento/Quote/Model/AddressDetailsManagement.php new file mode 100644 index 0000000000000..84c6492510a6d --- /dev/null +++ b/app/code/Magento/Quote/Model/AddressDetailsManagement.php @@ -0,0 +1,122 @@ +billingAddressManagement = $billingAddressManagement; + $this->shippingAddressManagement = $shippingAddressManagement; + $this->paymentMethodManagement = $paymentMethodManagement; + $this->shippingMethodManagement = $shippingMethodManagement; + $this->addressDetailsFactory = $addressDetailsFactory; + $this->dataProcessor = $dataProcessor; + $this->quoteRepository = $quoteRepository; + $this->cartTotalsRepository = $cartTotalsRepository; + } + + /** + * @{inheritdoc} + */ + public function saveAddresses( + $cartId, + \Magento\Quote\Api\Data\AddressInterface $billingAddress, + \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null, + \Magento\Quote\Api\Data\AddressAdditionalDataInterface $additionalData = null, + $checkoutMethod = null + ) { + $this->billingAddressManagement->assign($cartId, $billingAddress); + + /** @var \Magento\Quote\Api\Data\AddressDetailsInterface $addressDetails */ + $addressDetails = $this->addressDetailsFactory->create(); + if ($shippingAddress) { + $this->shippingAddressManagement->assign($cartId, $shippingAddress); + $addressDetails->setFormattedShippingAddress( + $this->shippingAddressManagement->get($cartId)->format('html') + ); + $addressDetails->setShippingMethods($this->shippingMethodManagement->getList($cartId)); + } + $addressDetails->setPaymentMethods($this->paymentMethodManagement->getList($cartId)); + if ($additionalData !== null) { + $this->dataProcessor->process($additionalData); + } + if ($checkoutMethod != null) { + $this->quoteRepository->save( + $this->quoteRepository->getActive($cartId) + ->setCheckoutMethod($checkoutMethod) + ); + } + + $addressDetails->setFormattedBillingAddress( + $this->billingAddressManagement->get($cartId)->format('html') + ); + + $addressDetails->setTotals($this->cartTotalsRepository->get($cartId)); + return $addressDetails; + } +} diff --git a/app/code/Magento/Quote/Model/BillingAddressManagement.php b/app/code/Magento/Quote/Model/BillingAddressManagement.php index 502e4421bcb20..cad5a3b9c42d1 100644 --- a/app/code/Magento/Quote/Model/BillingAddressManagement.php +++ b/app/code/Magento/Quote/Model/BillingAddressManagement.php @@ -9,6 +9,7 @@ use Magento\Framework\Exception\InputException; use Psr\Log\LoggerInterface as Logger; use Magento\Quote\Api\BillingAddressManagementInterface; +use Magento\Framework\Exception\NoSuchEntityException; /** Quote billing address write service object. */ class BillingAddressManagement implements BillingAddressManagementInterface @@ -34,31 +35,66 @@ class BillingAddressManagement implements BillingAddressManagementInterface */ protected $quoteRepository; + /** + * @var \Magento\Customer\Api\AddressRepositoryInterface + */ + protected $addressRepository; + /** * Constructs a quote billing address service object. * * @param QuoteRepository $quoteRepository Quote repository. * @param QuoteAddressValidator $addressValidator Address validator. * @param Logger $logger Logger. + * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository */ public function __construct( QuoteRepository $quoteRepository, QuoteAddressValidator $addressValidator, - Logger $logger + Logger $logger, + \Magento\Customer\Api\AddressRepositoryInterface $addressRepository ) { $this->addressValidator = $addressValidator; $this->logger = $logger; $this->quoteRepository = $quoteRepository; + $this->addressRepository = $addressRepository; } /** * {@inheritDoc} + * @SuppressWarnings(PHPMD.NPathComplexity) */ - public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address) + public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address, $useForShipping = false) { $quote = $this->quoteRepository->getActive($cartId); $this->addressValidator->validate($address); + $customerAddressId = $address->getCustomerAddressId(); + $shippingAddress = null; + $addressData = []; + + if ($useForShipping) { + $shippingAddress = $address; + } + $saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0; + if ($customerAddressId) { + try { + $addressData = $this->addressRepository->getById($customerAddressId); + } catch (NoSuchEntityException $e) { + // do nothing if customer is not found by id + } + $address = $quote->getBillingAddress()->importCustomerAddressData($addressData); + if ($useForShipping) { + $shippingAddress = $quote->getShippingAddress()->importCustomerAddressData($addressData); + $shippingAddress->setSaveInAddressBook($saveInAddressBook); + } + } + $address->setSaveInAddressBook($saveInAddressBook); $quote->setBillingAddress($address); + if ($useForShipping) { + $shippingAddress->setSameAsBilling(1); + $shippingAddress->setCollectShippingRates(true); + $quote->setShippingAddress($shippingAddress); + } $quote->setDataChanges(true); try { $this->quoteRepository->save($quote); diff --git a/app/code/Magento/Quote/Model/Cart/CartTotalManagement.php b/app/code/Magento/Quote/Model/Cart/CartTotalManagement.php new file mode 100644 index 0000000000000..ce36b9a7258d1 --- /dev/null +++ b/app/code/Magento/Quote/Model/Cart/CartTotalManagement.php @@ -0,0 +1,72 @@ +shippingMethodManagement = $shippingMethodManagement; + $this->paymentMethodManagement = $paymentMethodManagement; + $this->cartTotalsRepository = $cartTotalsRepository; + $this->dataProcessor = $dataProcessor; + } + + /** + * {@inheritDoc} + */ + public function collectTotals( + $cartId, + \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, + $shippingCarrierCode = null, + $shippingMethodCode = null, + \Magento\Quote\Api\Data\TotalsAdditionalDataInterface $additionalData = null + ) { + if ($shippingCarrierCode && $shippingMethodCode) { + $this->shippingMethodManagement->set($cartId, $shippingCarrierCode, $shippingMethodCode); + } + $this->paymentMethodManagement->set($cartId, $paymentMethod); + if ($additionalData !== null) { + $this->dataProcessor->process($additionalData, $cartId); + } + return $this->cartTotalsRepository->get($cartId); + } +} diff --git a/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php b/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php index bbf1a3d869c2c..78bdf6da18569 100644 --- a/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php +++ b/app/code/Magento/Quote/Model/Cart/CartTotalRepository.php @@ -8,6 +8,9 @@ use Magento\Quote\Api; use Magento\Quote\Model\QuoteRepository; use Magento\Quote\Api\CartTotalRepositoryInterface; +use Magento\Catalog\Helper\Product\ConfigurationPool; +use Magento\Framework\Api\DataObjectHelper; +use Magento\Quote\Model\Cart\Totals\ItemConverter; /** * Cart totals data object. @@ -34,20 +37,26 @@ class CartTotalRepository implements CartTotalRepositoryInterface private $dataObjectHelper; /** - * Constructs a cart totals data object. - * - * @param Api\Data\TotalsInterfaceFactory $totalsFactory Cart totals factory. - * @param QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @var ConfigurationPool + */ + private $converter; + + /** + * @param Api\Data\TotalsInterfaceFactory $totalsFactory + * @param QuoteRepository $quoteRepository + * @param DataObjectHelper $dataObjectHelper + * @param ItemConverter $converter */ public function __construct( Api\Data\TotalsInterfaceFactory $totalsFactory, QuoteRepository $quoteRepository, - \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + DataObjectHelper $dataObjectHelper, + ItemConverter $converter ) { $this->totalsFactory = $totalsFactory; $this->quoteRepository = $quoteRepository; $this->dataObjectHelper = $dataObjectHelper; + $this->converter = $converter; } /** @@ -65,10 +74,18 @@ public function get($cartId) */ $quote = $this->quoteRepository->getActive($cartId); $shippingAddress = $quote->getShippingAddress(); - $totalsData = array_merge($shippingAddress->getData(), $quote->getData()); + if ($quote->isVirtual()) { + $totalsData = array_merge($quote->getBillingAddress()->getData(), $quote->getData()); + } else { + $totalsData = array_merge($shippingAddress->getData(), $quote->getData()); + } $totals = $this->totalsFactory->create(); $this->dataObjectHelper->populateWithArray($totals, $totalsData, '\Magento\Quote\Api\Data\TotalsInterface'); - $totals->setItems($quote->getAllItems()); + $items = []; + foreach ($quote->getAllVisibleItems() as $index => $item) { + $items[$index] = $this->converter->modelToDataObject($item); + } + $totals->setItems($items); return $totals; } diff --git a/app/code/Magento/Quote/Model/Cart/ShippingMethod.php b/app/code/Magento/Quote/Model/Cart/ShippingMethod.php index 75cba2f03cad9..fd291a03ecc76 100644 --- a/app/code/Magento/Quote/Model/Cart/ShippingMethod.php +++ b/app/code/Magento/Quote/Model/Cart/ShippingMethod.php @@ -163,6 +163,27 @@ public function setAvailable($available) return $this->setData(self::KEY_AVAILABLE, $available); } + /** + * Returns the error message. + * + * @return string|null Shipping Error message. + */ + public function getErrorMessage() + { + return $this->_get(self::KEY_ERROR_MESSAGE); + } + + /** + * Set an error message. + * + * @param string|null $errorMessage + * @return $this + */ + public function setErrorMessage($errorMessage) + { + return $this->setData(self::KEY_ERROR_MESSAGE, $errorMessage); + } + /** * {@inheritdoc} * @@ -184,4 +205,47 @@ public function setExtensionAttributes( ) { return $this->_setExtensionAttributes($extensionAttributes); } + + /** + * {@inheritdoc} + * + * @return float + */ + public function getPriceExclTax() + { + return $this->_get(self::KEY_PRICE_EXCL_TAX); + } + + /** + * {@inheritdoc} + * + * @param float $priceExclTax + * @return $this + */ + public function setPriceExclTax($priceExclTax) + { + return $this->setData(self::KEY_PRICE_EXCL_TAX, $priceExclTax); + } + + + /** + * {@inheritdoc} + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::KEY_PRICE_INCL_TAX); + } + + /** + * {@inheritdoc} + * + * @param float $priceInclTax + * @return $this + */ + public function setPriceInclTax($priceInclTax) + { + return $this->setData(self::KEY_PRICE_INCL_TAX, $priceInclTax); + } } diff --git a/app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php b/app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php index 9f2cef51172c9..a95fa80617c08 100644 --- a/app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php +++ b/app/code/Magento/Quote/Model/Cart/ShippingMethodConverter.php @@ -18,18 +18,26 @@ class ShippingMethodConverter */ protected $shippingMethodDataFactory; + /** + * @var \Magento\Tax\Helper\Data + */ + protected $taxHelper; + /** * Constructs a shipping method converter object. * * @param \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory $shippingMethodDataFactory Shipping method factory. * @param \Magento\Store\Model\StoreManagerInterface $storeManager Store manager interface. + * @param \Magento\Tax\Helper\Data $taxHelper Tax data helper. */ public function __construct( \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory $shippingMethodDataFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Tax\Helper\Data $taxHelper ) { $this->shippingMethodDataFactory = $shippingMethodDataFactory; $this->storeManager = $storeManager; + $this->taxHelper = $taxHelper; } /** @@ -37,7 +45,7 @@ public function __construct( * * @param string $quoteCurrencyCode The quote currency code. * @param \Magento\Quote\Model\Quote\Address\Rate $rateModel The rate model. - * @return mixed Shipping method data object. + * @return \Magento\Quote\Api\Data\ShippingMethodInterface Shipping method data object. */ public function modelToDataObject($rateModel, $quoteCurrencyCode) { @@ -52,6 +60,30 @@ public function modelToDataObject($rateModel, $quoteCurrencyCode) ->setMethodTitle($rateModel->getMethodTitle()) ->setAmount($currency->convert($rateModel->getPrice(), $quoteCurrencyCode)) ->setBaseAmount($rateModel->getPrice()) - ->setAvailable(empty($errorMessage)); + ->setAvailable(empty($errorMessage)) + ->setErrorMessage(empty($errorMessage) ? false : $errorMessage) + ->setPriceExclTax( + $currency->convert($this->getShippingPriceWithFlag($rateModel, false), $quoteCurrencyCode) + ) + ->setPriceInclTax( + $currency->convert($this->getShippingPriceWithFlag($rateModel, true), $quoteCurrencyCode) + ); + } + + /** + * Get Shipping Price including or excluding tax + * + * @param \Magento\Quote\Model\Quote\Address\Rate $rateModel + * @param bool $flag + * @return float + */ + private function getShippingPriceWithFlag($rateModel, $flag) + { + return $this->taxHelper->getShippingPrice( + $rateModel->getPrice(), + $flag, + $rateModel->getAddress(), + $rateModel->getAddress()->getQuote()->getCustomerTaxClassId() + ); } } diff --git a/app/code/Magento/Quote/Model/Cart/Totals/Item.php b/app/code/Magento/Quote/Model/Cart/Totals/Item.php index 0cd716b5082d7..837a7fdcfe47a 100644 --- a/app/code/Magento/Quote/Model/Cart/Totals/Item.php +++ b/app/code/Magento/Quote/Model/Cart/Totals/Item.php @@ -15,6 +15,27 @@ */ class Item extends AbstractExtensibleObject implements TotalsItemInterface { + /** + * Set totals item id + * + * @param int $id + * @return $this + */ + public function setItemId($id) + { + return $this->setData(self::KEY_ITEM_ID, $id); + } + + /** + * Get totals item id + * + * @return int Item id + */ + public function getItemId() + { + return $this->_get(self::KEY_ITEM_ID); + } + /** * Returns the item price in quote currency. * @@ -351,6 +372,85 @@ public function setBaseRowTotalInclTax($baseRowTotalInclTax) return $this->setData(self::KEY_BASE_ROW_TOTAL_INCL_TAX, $baseRowTotalInclTax); } + /** + * Returns the item options data. + * + * @return string[] Item price in quote currency. + */ + public function getOptions() + { + return $this->_get(self::KEY_OPTIONS); + } + + /** + * Sets the item options data. + * + * @param string $options + * @return $this + */ + public function setOptions($options) + { + return $this->setData(self::KEY_OPTIONS, $options); + } + + /** + * Returns the item weee tax applied amount in quote currency. + * + * @return float Item weee tax applied amount in quote currency. + */ + public function getWeeeTaxAppliedAmount() + { + return $this->_get(self::KEY_WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Sets the item weee tax applied amount in quote currency. + * + * @param float $weeeTaxAppliedAmount + * @return $this + */ + public function setWeeeTaxAppliedAmount($weeeTaxAppliedAmount) + { + return $this->setData(self::KEY_WEEE_TAX_APPLIED_AMOUNT, $weeeTaxAppliedAmount); + } + + /** + * Returns the item weee tax applied in quote currency. + * + * @return string[] Item weee tax applied in quote currency. + */ + public function getWeeeTaxApplied() + { + return $this->_get(self::KEY_WEEE_TAX_APPLIED); + } + + /** + * Sets the item weee tax applied in quote currency. + * + * @param string $weeeTaxApplied + * @return $this + */ + public function setWeeeTaxApplied($weeeTaxApplied) + { + return $this->setData(self::KEY_WEEE_TAX_APPLIED, $weeeTaxApplied); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->_get(self::KEY_NAME); + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + return $this->setData(self::KEY_NAME, $name); + } + /** * {@inheritdoc} * diff --git a/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php b/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php new file mode 100644 index 0000000000000..f569f8478b09d --- /dev/null +++ b/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php @@ -0,0 +1,103 @@ +configurationPool = $configurationPool; + $this->eventManager = $eventManager; + $this->totalsItemFactory = $totalsItemFactory; + $this->dataObjectHelper = $dataObjectHelper; + } + + /** + * Converts a specified rate model to a shipping method data object. + * + * @param \Magento\Quote\Model\Quote\Item $item + * @return array + * @throws \Exception + */ + public function modelToDataObject($item) + { + $this->eventManager->dispatch('items_additional_data', ['item' => $item]); + $items = $item->toArray(); + $items['options'] = $this->getFormattedOptionValue($item); + $itemsData = $this->totalsItemFactory->create(); + $this->dataObjectHelper->populateWithArray( + $itemsData, + $items, + '\Magento\Quote\Api\Data\TotalsItemInterface' + ); + return $itemsData; + } + + /** + * Retrieve formatted item options view + * + * @param \Magento\Quote\Api\Data\CartItemInterface $item + * @return string + */ + private function getFormattedOptionValue($item) + { + $optionsData = []; + $options = $this->configurationPool->getByProductType($item->getProductType())->getOptions($item); + foreach ($options as $index => $optionValue) { + /* @var $helper \Magento\Catalog\Helper\Product\Configuration */ + $helper = $this->configurationPool->getByProductType('default'); + $params = [ + 'max_length' => 55, + 'cut_replacer' => ' ...' + ]; + $option = $helper->getFormattedOptionValue($optionValue, $params); + $optionsData[$index] = $option; + $optionsData[$index]['label'] = $optionValue['label']; + } + return \Zend_Json::encode($optionsData); + } +} diff --git a/app/code/Magento/Quote/Model/Cart/TotalsAdditionalData.php b/app/code/Magento/Quote/Model/Cart/TotalsAdditionalData.php new file mode 100644 index 0000000000000..4ffdfd2ef7cc2 --- /dev/null +++ b/app/code/Magento/Quote/Model/Cart/TotalsAdditionalData.php @@ -0,0 +1,37 @@ +_getExtensionAttributes(); + } + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\TotalsAdditionalDataExtensionInterface $extensionAttributes + * @return void + */ + public function setExtensionAttributes( + \Magento\Quote\Api\Data\TotalsAdditionalDataExtensionInterface $extensionAttributes + ) { + $this->_setExtensionAttributes($extensionAttributes); + } +} diff --git a/app/code/Magento/Quote/Model/Cart/TotalsAdditionalDataProcessor.php b/app/code/Magento/Quote/Model/Cart/TotalsAdditionalDataProcessor.php new file mode 100644 index 0000000000000..35a1e9b1a7fe4 --- /dev/null +++ b/app/code/Magento/Quote/Model/Cart/TotalsAdditionalDataProcessor.php @@ -0,0 +1,27 @@ +addressDetailsManagement = $addressDetailsManagement; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; + } + + /** + * @{inheritdoc} + */ + public function saveAddresses( + $cartId, + \Magento\Quote\Api\Data\AddressInterface $billingAddress, + \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null, + \Magento\Quote\Api\Data\AddressAdditionalDataInterface $additionalData = null + ) { + $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); + return $this->addressDetailsManagement->saveAddresses( + $quoteIdMask->getQuoteId(), + $billingAddress, + $shippingAddress, + $additionalData + ); + } +} diff --git a/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php b/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php index 7fe6ef0cfa982..e64d5745d2b0c 100644 --- a/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php +++ b/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php @@ -10,6 +10,8 @@ use Magento\Quote\Api\CartManagementInterface; use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteIdMaskFactory; +use Magento\Quote\Api\Data\PaymentInterface; +use Magento\Quote\Api\CartRepositoryInterface; /** * Cart Management class for guest carts. @@ -28,19 +30,27 @@ class GuestCartManagement implements GuestCartManagementInterface */ protected $quoteIdMaskFactory; + /** + * @var CartRepositoryInterface + */ + protected $cartRepository; + /** * Initialize dependencies. * * @param CartManagementInterface $quoteManagement * @param QuoteIdMaskFactory $quoteIdMaskFactory + * @param CartRepositoryInterface $cartRepository * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( CartManagementInterface $quoteManagement, - QuoteIdMaskFactory $quoteIdMaskFactory + QuoteIdMaskFactory $quoteIdMaskFactory, + CartRepositoryInterface $cartRepository ) { $this->quoteManagement = $quoteManagement; $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->cartRepository = $cartRepository; } /** @@ -68,10 +78,33 @@ public function assignCustomer($cartId, $customerId, $storeId) /** * {@inheritdoc} */ - public function placeOrder($cartId) + public function placeOrder($cartId, $agreements = null, PaymentInterface $paymentMethod = null) { /** @var $quoteIdMask QuoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); - return $this->quoteManagement->placeOrder($quoteIdMask->getQuoteId()); + $this->cartRepository->get($quoteIdMask->getQuoteId()) + ->setCheckoutMethod(CartManagementInterface::METHOD_GUEST); + return $this->quoteManagement->placeOrder($quoteIdMask->getQuoteId(), $agreements, $paymentMethod); + } + + /** + * {@inheritdoc} + */ + public function placeOrderCreatingAccount( + $cartId, + $customer, + $password, + $agreements = null, + PaymentInterface $paymentMethod = null + ) { + /** @var $quoteIdMask QuoteIdMask */ + $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); + return $this->quoteManagement->placeOrderCreatingAccount( + $quoteIdMask->getQuoteId(), + $customer, + $password, + $agreements, + $paymentMethod + ); } } diff --git a/app/code/Magento/Quote/Model/GuestCart/GuestCartTotalManagement.php b/app/code/Magento/Quote/Model/GuestCart/GuestCartTotalManagement.php new file mode 100644 index 0000000000000..92a806211f093 --- /dev/null +++ b/app/code/Magento/Quote/Model/GuestCart/GuestCartTotalManagement.php @@ -0,0 +1,57 @@ +cartTotalManagement = $cartTotalManagement; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; + } + + /** + * {@inheritDoc} + */ + public function collectTotals( + $cartId, + \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, + $shippingCarrierCode = null, + $shippingMethodCode = null, + \Magento\Quote\Api\Data\TotalsAdditionalDataInterface $additionalData = null + ) { + $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); + return $this->cartTotalManagement->collectTotals( + $quoteIdMask->getQuoteId(), + $paymentMethod, + $shippingCarrierCode, + $shippingMethodCode, + $additionalData + ); + } +} diff --git a/app/code/Magento/Quote/Model/PaymentMethodManagement.php b/app/code/Magento/Quote/Model/PaymentMethodManagement.php index b3a512ae1b933..dee5ff38db125 100644 --- a/app/code/Magento/Quote/Model/PaymentMethodManagement.php +++ b/app/code/Magento/Quote/Model/PaymentMethodManagement.php @@ -59,7 +59,13 @@ public function set($cartId, \Magento\Quote\Api\Data\PaymentInterface $method) \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, ]); $payment = $quote->getPayment(); - $payment->importData($method->getData()); + + $data = $method->getData(); + if (isset($data['additional_data'])) { + $data = array_merge($data, (array)$data['additional_data']); + unset($data['additional_data']); + } + $payment->importData($data); if ($quote->isVirtual()) { // check if billing address is set diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index 4cddfa347659b..d8af21ff7e3e7 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -18,16 +18,10 @@ * @method Address setCreatedAt(string $value) * @method string getUpdatedAt() * @method Address setUpdatedAt(string $value) - * @method int getSaveInAddressBook() - * @method Address setSaveInAddressBook(int $value) - * @method int getCustomerAddressId() - * @method Address setCustomerAddressId(int $value) * @method \Magento\Customer\Api\Data\AddressInterface getCustomerAddress() * @method Address setCustomerAddressData(\Magento\Customer\Api\Data\AddressInterface $value) * @method string getAddressType() * @method Address setAddressType(string $value) - * @method int getSameAsBilling() - * @method Address setSameAsBilling(int $value) * @method int getFreeShipping() * @method Address setFreeShipping(int $value) * @method int getCollectShippingRates() @@ -224,6 +218,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements */ protected $_rateRequestFactory; + /** + * @var Address\CustomAttributeListInterface + */ + protected $attributeList; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -253,6 +252,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements * @param \Magento\Customer\Model\Address\Mapper $addressMapper * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection + * @param Address\CustomAttributeListInterface $attributeList * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -283,6 +283,7 @@ public function __construct( \Magento\Shipping\Model\CarrierFactoryInterface $carrierFactory, Address\Validator $validator, \Magento\Customer\Model\Address\Mapper $addressMapper, + Address\CustomAttributeListInterface $attributeList, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] @@ -301,6 +302,7 @@ public function __construct( $this->addressDataFactory = $addressDataFactory; $this->validator = $validator; $this->addressMapper = $addressMapper; + $this->attributeList = $attributeList; parent::__construct( $context, $registry, @@ -475,12 +477,7 @@ public function importCustomerAddressData(\Magento\Customer\Api\Data\AddressInte $this->addressMapper->toFlatArray($address), $this ); - $region = $this->getRegion(); - $regionId = $this->getRegionId(); - if (isset($regionId) && isset($region)) { - $this->setRegionId($regionId); - $this->setRegion($region); - } + $quote = $this->getQuote(); if ($address->getCustomerId() && (!empty($quote) && $address->getCustomerId() == $quote->getCustomerId())) { $customer = $quote->getCustomer(); @@ -1609,6 +1606,59 @@ public function setRegionCode($regionCode) { return $this->setData(self::KEY_REGION_CODE, $regionCode); } + + /** + * {@inheritdoc} + */ + public function getSameAsBilling() + { + return $this->getData(self::SAME_AS_BILLING); + } + + /** + * {@inheritdoc} + */ + public function setSameAsBilling($sameAsBilling) + { + return $this->setData(self::SAME_AS_BILLING, $sameAsBilling); + } + + /** + * {@inheritdoc} + */ + public function getCustomerAddressId() + { + return $this->getData(self::CUSTOMER_ADDRESS_ID); + } + + /** + * {@inheritdoc} + */ + public function setCustomerAddressId($customerAddressId) + { + return $this->setData(self::CUSTOMER_ADDRESS_ID, $customerAddressId); + } + + /** + * Get save in address book flag + * + * @return int|null + */ + public function getSaveInAddressBook() + { + return $this->getData(self::SAVE_IN_ADDRESS_BOOK); + } + + /** + * Set save in address book flag + * + * @param int|null $saveInAddressBook + * @return $this + */ + public function setSaveInAddressBook($saveInAddressBook) + { + return $this->setData(self::SAVE_IN_ADDRESS_BOOK, $saveInAddressBook); + } //@codeCoverageIgnoreEnd /** @@ -1631,4 +1681,12 @@ public function setExtensionAttributes(\Magento\Quote\Api\Data\AddressExtensionI { return $this->_setExtensionAttributes($extensionAttributes); } + + /** + * {@inheritdoc} + */ + protected function getCustomAttributesCodes() + { + return array_keys($this->attributeList->getAttributes()); + } } diff --git a/app/code/Magento/Quote/Model/Quote/Address/CustomAttributeList.php b/app/code/Magento/Quote/Model/Quote/Address/CustomAttributeList.php new file mode 100644 index 0000000000000..adff254d55c5c --- /dev/null +++ b/app/code/Magento/Quote/Model/Quote/Address/CustomAttributeList.php @@ -0,0 +1,19 @@ +getAllItems() as $item) { - $output[] = $item; + if (!$item->isDeleted() && !$item->getParentItemId()) { + $output[] = $item; + } } return $output; } diff --git a/app/code/Magento/Quote/Model/QuoteAddressValidator.php b/app/code/Magento/Quote/Model/QuoteAddressValidator.php index 0098e459fd848..e92780f4056db 100644 --- a/app/code/Magento/Quote/Model/QuoteAddressValidator.php +++ b/app/code/Magento/Quote/Model/QuoteAddressValidator.php @@ -11,29 +11,37 @@ class QuoteAddressValidator /** * Address factory. * - * @var \Magento\Quote\Model\Quote\AddressFactory + * @var \Magento\Customer\Api\AddressRepositoryInterface */ - protected $quoteAddressFactory; + protected $addressReporitory; /** - * Customer factory. + * Customer repository. * - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Customer\Api\CustomerRepositoryInterface */ - protected $customerFactory; + protected $customerRepository; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; /** * Constructs a quote shipping address validator service object. * - * @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory Address factory. - * @param \Magento\Customer\Model\CustomerFactory $customerFactory Customer factory. + * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository + * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository Customer repository. + * @param \Magento\Customer\Model\Session $customerSession */ public function __construct( - \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory, - \Magento\Customer\Model\CustomerFactory $customerFactory + \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, + \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, + \Magento\Customer\Model\Session $customerSession ) { - $this->quoteAddressFactory = $quoteAddressFactory; - $this->customerFactory = $customerFactory; + $this->addressReporitory = $addressRepository; + $this->customerRepository = $customerRepository; + $this->customerSession = $customerSession; } /** @@ -48,8 +56,7 @@ public function validate(\Magento\Quote\Api\Data\AddressInterface $addressData) { //validate customer id if ($addressData->getCustomerId()) { - $customer = $this->customerFactory->create(); - $customer->load($addressData->getCustomerId()); + $customer = $this->customerRepository->getById($addressData->getCustomerId()); if (!$customer->getId()) { throw new \Magento\Framework\Exception\NoSuchEntityException( __('Invalid customer id %1', $addressData->getCustomerId()) @@ -59,9 +66,9 @@ public function validate(\Magento\Quote\Api\Data\AddressInterface $addressData) // validate address id if ($addressData->getId()) { - $address = $this->quoteAddressFactory->create(); - $address->load($addressData->getId()); - if (!$address->getId()) { + try { + $address = $this->addressReporitory->getById($addressData->getId()); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { throw new \Magento\Framework\Exception\NoSuchEntityException( __('Invalid address id %1', $addressData->getId()) ); @@ -70,12 +77,24 @@ public function validate(\Magento\Quote\Api\Data\AddressInterface $addressData) // check correspondence between customer id and address id if ($addressData->getCustomerId()) { if ($address->getCustomerId() != $addressData->getCustomerId()) { - throw new \Magento\Framework\Exception\InputException( - __('Address with id %1 belongs to another customer', $addressData->getId()) + throw new \Magento\Framework\Exception\NoSuchEntityException( + __('Invalid address id %1', $addressData->getId()) ); } } } + + if ($addressData->getCustomerAddressId()) { + $applicableAddressIds = array_map(function ($address) { + /** @var \Magento\Customer\Api\Data\AddressInterface $address */ + return $address->getId(); + }, $this->customerSession->getCustomerDataObject()->getAddresses()); + if (!in_array($addressData->getCustomerAddressId(), $applicableAddressIds)) { + throw new \Magento\Framework\Exception\NoSuchEntityException( + __('Invalid address id %1', $addressData->getCustomerAddressId()) + ); + } + } return true; } } diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index c09a32964aa3f..2d4b3c2810ec5 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -15,6 +15,7 @@ use Magento\Quote\Model\Quote\Address\ToOrderAddress as ToOrderAddressConverter; use Magento\Quote\Model\Quote\Item\ToOrderItem as ToOrderItemConverter; use Magento\Quote\Model\Quote\Payment\ToOrderPayment as ToOrderPaymentConverter; +use Magento\Quote\Api\Data\PaymentInterface; use Magento\Sales\Api\Data\OrderInterfaceFactory as OrderFactory; use Magento\Sales\Api\OrderManagementInterface as OrderManagement; use Magento\Store\Model\StoreManagerInterface; @@ -23,6 +24,7 @@ * Class QuoteManagement * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.TooManyFields) */ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface { @@ -101,6 +103,26 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface */ protected $storeManager; + /** + * @var \Magento\Checkout\Model\Session + */ + protected $checkoutSession; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ + protected $accountManagement; + + /** + * @var \Magento\Checkout\Model\Agreements\AgreementsValidator $agreementsValidator + */ + protected $agreementsValidator; + /** * @param EventManager $eventManager * @param QuoteValidator $quoteValidator @@ -117,6 +139,10 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface * @param \Magento\Customer\Model\CustomerFactory $customerModelFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param StoreManagerInterface $storeManager + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Api\AccountManagementInterface $accountManagement + * @param \Magento\Checkout\Model\Agreements\AgreementsValidator $agreementsValidator * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -134,7 +160,11 @@ public function __construct( \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Customer\Model\CustomerFactory $customerModelFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, - StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Api\AccountManagementInterface $accountManagement, + \Magento\Checkout\Model\Agreements\AgreementsValidator $agreementsValidator ) { $this->eventManager = $eventManager; $this->quoteValidator = $quoteValidator; @@ -151,6 +181,10 @@ public function __construct( $this->customerModelFactory = $customerModelFactory; $this->dataObjectHelper = $dataObjectHelper; $this->storeManager = $storeManager; + $this->checkoutSession = $checkoutSession; + $this->accountManagement = $accountManagement; + $this->customerSession = $customerSession; + $this->agreementsValidator = $agreementsValidator; } /** @@ -264,19 +298,47 @@ protected function createCustomerCart($customerId, $storeId) /** * {@inheritdoc} */ - public function placeOrder($cartId) + public function placeOrder($cartId, $agreements = null, PaymentInterface $paymentMethod = null) { + if (!$this->agreementsValidator->isValid($agreements)) { + throw new \Magento\Framework\Exception\CouldNotSaveException( + __('Please agree to all the terms and conditions before placing the order.') + ); + } $quote = $this->quoteRepository->getActive($cartId); + if ($paymentMethod) { + $paymentMethod->setChecks([ + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, + \Magento\Payment\Model\Method\AbstractMethod::CHECK_ZERO_TOTAL, + ]); + $quote->getPayment()->setQuote($quote); + + $data = $paymentMethod->getData(); + if (isset($data['additional_data'])) { + $data = array_merge($data, (array)$data['additional_data']); + unset($data['additional_data']); + } + $quote->getPayment()->importData($data); + } - if ($quote->getCheckoutMethod() === 'guest') { + if ($quote->getCheckoutMethod() === self::METHOD_GUEST) { $quote->setCustomerId(null); $quote->setCustomerEmail($quote->getBillingAddress()->getEmail()); $quote->setCustomerIsGuest(true); $quote->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID); } - $quoteId = $this->submit($quote)->getId(); - return $quoteId; + $order = $this->submit($quote); + $this->checkoutSession->setLastQuoteId($quote->getId()); + $this->checkoutSession->setLastSuccessQuoteId($quote->getId()); + $this->checkoutSession->setLastOrderId($order->getId()); + $this->checkoutSession->setLastRealOrderId($order->getIncrementId()); + + $this->eventManager->dispatch('checkout_submit_all_after', ['order' => $order, 'quote' => $quote]); + return $order->getId(); } /** @@ -346,9 +408,13 @@ protected function submitQuote(QuoteEntity $quote, $orderData = []) $order = $this->orderFactory->create(); $this->quoteValidator->validateBeforeSubmit($quote); if (!$quote->getCustomerIsGuest()) { + if ($quote->getCustomerId()) { + $this->_prepareCustomerQuote($quote); + } $this->customerManagement->populateCustomerInfo($quote); } $addresses = []; + $quote->reserveOrderId(); if ($quote->isVirtual()) { $this->dataObjectHelper->mergeDataObjects( '\Magento\Sales\Api\Data\OrderInterface', @@ -421,4 +487,49 @@ protected function submitQuote(QuoteEntity $quote, $orderData = []) } return $order; } + + /** + * Prepare quote for customer order submit + * + * @param Quote $quote + * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + protected function _prepareCustomerQuote($quote) + { + /** @var Quote $quote */ + $billing = $quote->getBillingAddress(); + $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress(); + + $customer = $this->customerRepository->getById($quote->getCustomerId()); + $hasDefaultBilling = (bool)$customer->getDefaultBilling(); + $hasDefaultShipping = (bool)$customer->getDefaultShipping(); + + if ($shipping && !$shipping->getSameAsBilling() + && (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook()) + ) { + $shippingAddress = $shipping->exportCustomerAddress(); + if (!$hasDefaultShipping) { + //Make provided address as default shipping address + $shippingAddress->setIsDefaultShipping(true); + $hasDefaultShipping = true; + } + $quote->addCustomerAddress($shippingAddress); + $shipping->setCustomerAddressData($shippingAddress); + } + + if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) { + $billingAddress = $billing->exportCustomerAddress(); + if (!$hasDefaultBilling) { + //Make provided address as default shipping address + if (!$hasDefaultShipping) { + //Make provided address as default shipping address + $billingAddress->setIsDefaultShipping(true); + } + $billingAddress->setIsDefaultBilling(true); + } + $quote->addCustomerAddress($billingAddress); + $billing->setCustomerAddressData($billingAddress); + } + } } diff --git a/app/code/Magento/Quote/Model/Resource/Quote/Item.php b/app/code/Magento/Quote/Model/Resource/Quote/Item.php index cdad5e588315e..dbe8c0944870f 100644 --- a/app/code/Magento/Quote/Model/Resource/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Resource/Quote/Item.php @@ -39,4 +39,18 @@ public function save(\Magento\Framework\Model\AbstractModel $object) } return $result; } + + /** + * {@inheritdoc} + */ + protected function prepareDataForUpdate($object) + { + $data = parent::prepareDataForUpdate($object); + + if (isset($data['updated_at'])) { + unset($data['updated_at']); + } + + return $data; + } } diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php index 40133907d2934..d6ed68479310c 100644 --- a/app/code/Magento/Quote/Model/ShippingAddressManagement.php +++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php @@ -35,24 +35,39 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface protected $addressValidator; /** - * Constructs a quote shipping address write service object. - * + * @var \Magento\Customer\Api\AddressRepositoryInterface + */ + protected $addressRepository; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $scopeConfig; + + /** * @param QuoteRepository $quoteRepository * @param QuoteAddressValidator $addressValidator * @param Logger $logger + * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Quote\Model\QuoteRepository $quoteRepository, QuoteAddressValidator $addressValidator, - Logger $logger + Logger $logger, + \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->quoteRepository = $quoteRepository; $this->addressValidator = $addressValidator; $this->logger = $logger; + $this->addressRepository = $addressRepository; + $this->scopeConfig = $scopeConfig; } /** * {@inheritDoc} + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address) { @@ -63,18 +78,35 @@ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $addres __('Cart contains virtual product(s) only. Shipping address is not applicable.') ); } - $this->addressValidator->validate($address); - $address->setSameAsBilling(0); - $address->setCollectShippingRates(true); + $saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0; + $sameAsBilling = $address->getSameAsBilling() ? 1 : 0; + $customerAddressId = $address->getCustomerAddressId(); + $this->addressValidator->validate($address); $quote->setShippingAddress($address); - $quote->setDataChanges(true); + $address = $quote->getShippingAddress(); + + if ($customerAddressId) { + $addressData = $this->addressRepository->getById($customerAddressId); + $address = $quote->getShippingAddress()->importCustomerAddressData($addressData); + } + $address->setSameAsBilling($sameAsBilling); + $address->setSaveInAddressBook($saveInAddressBook); + $address->setCollectShippingRates(true); try { - $this->quoteRepository->save($quote); + $address->collectTotals()->save(); } catch (\Exception $e) { $this->logger->critical($e); throw new InputException(__('Unable to save address. Please, check input data.')); } + + if (!$quote->validateMinimumAmount($quote->getIsMultiShipping())) { + throw new InputException($this->scopeConfig->getValue( + 'sales/minimum_order/error_message', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $quote->getStoreId() + )); + } return $quote->getShippingAddress()->getId(); } @@ -83,23 +115,14 @@ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $addres */ public function get($cartId) { - /** - * Quote. - * - * @var \Magento\Quote\Model\Quote $quote - */ + /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); if ($quote->isVirtual()) { throw new NoSuchEntityException( __('Cart contains virtual product(s) only. Shipping address is not applicable.') ); } - - /** - * Address. - * - * @var \Magento\Quote\Model\Quote\Address $address - */ + /** @var \Magento\Quote\Model\Quote\Address $address */ return $quote->getShippingAddress(); } } diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index c951f228edbdb..c1dc45aee4a47 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -13,7 +13,6 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Quote\Api\ShippingMethodManagementInterface; -use Magento\Quote\Api\Data\ShippingMethodInterfaceFactory; /** * Shipping method read service. @@ -27,13 +26,6 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface */ protected $quoteRepository; - /** - * Shipping data factory. - * - * @var \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory - */ - protected $methodDataFactory; - /** * Shipping method converter * @@ -45,16 +37,13 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface * Constructs a shipping method read service object. * * @param QuoteRepository $quoteRepository Quote repository. - * @param \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory $methodDataFactory Shipping method factory. * @param \Magento\Quote\Model\Cart\ShippingMethodConverter $converter Shipping method converter. */ public function __construct( QuoteRepository $quoteRepository, - \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory $methodDataFactory, Cart\ShippingMethodConverter $converter ) { $this->quoteRepository = $quoteRepository; - $this->methodDataFactory = $methodDataFactory; $this->converter = $converter; } @@ -77,35 +66,10 @@ public function get($cartId) return null; } - list($carrierCode, $methodCode) = $this->divideNames('_', $shippingAddress->getShippingMethod()); - list($carrierTitle, $methodTitle) = $this->divideNames(' - ', $shippingAddress->getShippingDescription()); - - return $this->methodDataFactory->create() - ->setCarrierCode($carrierCode) - ->setMethodCode($methodCode) - ->setCarrierTitle($carrierTitle) - ->setMethodTitle($methodTitle) - ->setAmount($shippingAddress->getShippingAmount()) - ->setBaseAmount($shippingAddress->getBaseShippingAmount()) - ->setAvailable(true); - } - - /** - * Divides names at specified delimiter character on a specified line. - * - * @param string $delimiter The delimiter character. - * @param string $line The line. - * @return array Array of names. - * @throws \Magento\Framework\Exception\InputException The specified line does not contain the specified delimiter character. - */ - protected function divideNames($delimiter, $line) - { - if (strpos($line, $delimiter) === false) { - throw new InputException( - __('Line "%1" doesn\'t contain delimiter %2', $line, $delimiter) - ); - } - return explode($delimiter, $line); + $shippingAddress->collectShippingRates(); + /** @var \Magento\Quote\Model\Quote\Address\Rate $shippingRate */ + $shippingRate = $shippingAddress->getShippingRateByCode($shippingMethod); + return $this->converter->modelToDataObject($shippingRate, $quote->getQuoteCurrencyCode()); } /** @@ -156,7 +120,6 @@ public function set($cartId, $carrierCode, $methodCode) if (0 == $quote->getItemsCount()) { throw new InputException(__('Shipping method is not applicable for empty cart')); } - if ($quote->isVirtual()) { throw new NoSuchEntityException( __('Cart contains virtual product(s) only. Shipping method is not applicable.') @@ -170,9 +133,8 @@ public function set($cartId, $carrierCode, $methodCode) if (!$billingAddress->getCountryId()) { throw new StateException(__('Billing address is not set')); } - $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); - if (!$shippingAddress->requestShippingRates()) { + if (!$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())) { throw new NoSuchEntityException( __('Carrier with such method not found: %1, %2', $carrierCode, $methodCode) ); diff --git a/app/code/Magento/Quote/Setup/InstallSchema.php b/app/code/Magento/Quote/Setup/InstallSchema.php index 80279e7c2aade..9e810569a1bd9 100644 --- a/app/code/Magento/Quote/Setup/InstallSchema.php +++ b/app/code/Magento/Quote/Setup/InstallSchema.php @@ -147,13 +147,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'customer_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, - ['unsigned' => true, 'default' => '0'], + ['unsigned' => true], 'Customer Id' )->addColumn( 'customer_tax_class_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, - ['unsigned' => true, 'default' => '0'], + ['unsigned' => true], 'Customer Tax Class Id' )->addColumn( 'customer_group_id', @@ -710,7 +710,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con 'created_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_UPDATE], + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], 'Created At' )->addColumn( 'updated_at', diff --git a/app/code/Magento/Quote/Test/Unit/Model/AddressDetailsManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/AddressDetailsManagementTest.php new file mode 100644 index 0000000000000..ab1e0e6c18be2 --- /dev/null +++ b/app/code/Magento/Quote/Test/Unit/Model/AddressDetailsManagementTest.php @@ -0,0 +1,151 @@ +objectManager = new ObjectManager($this); + $this->billingAddressManagement = $this->getMock('Magento\Quote\Api\BillingAddressManagementInterface'); + $this->shippingAddressManagement = $this->getMock('Magento\Quote\Api\ShippingAddressManagementInterface'); + $this->paymentMethodManagement = $this->getMock('Magento\Quote\Api\PaymentMethodManagementInterface'); + $this->shippingMethodManagement = $this->getMock('Magento\Quote\Api\ShippingMethodManagementInterface'); + $this->addressDetailsFactory = $this->getMock( + 'Magento\Quote\Model\AddressDetailsFactory', + ['create'], + [], + '', + false + ); + $this->dataProcessor = $this->getMock('Magento\Quote\Model\AddressAdditionalDataProcessor', [], [], '', false); + $this->quoteRepository = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false); + + $this->model = $this->objectManager->getObject( + 'Magento\Quote\Model\AddressDetailsManagement', + [ + 'billingAddressManagement' => $this->billingAddressManagement, + 'shippingAddressManagement' => $this->shippingAddressManagement, + 'paymentMethodManagement' => $this->paymentMethodManagement, + 'shippingMethodManagement' => $this->shippingMethodManagement, + 'addressDetailsFactory' => $this->addressDetailsFactory, + 'dataProcessor' => $this->dataProcessor, + 'quoteRepository' => $this->quoteRepository, + ] + ); + } + + public function testSaveAddresses() + { + $cartId = 100; + $additionalData = $this->getMock('\Magento\Quote\Api\Data\AddressAdditionalDataInterface'); + $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $shippingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + + $this->billingAddressManagement->expects($this->once()) + ->method('assign') + ->with($cartId, $billingAddressMock) + ->willReturn(1); + + $billingAddressMock->expects($this->once())->method('format')->with('html'); + $this->billingAddressManagement->expects($this->once()) + ->method('get') + ->with($cartId) + ->willReturn($billingAddressMock); + + $this->shippingAddressManagement->expects($this->once()) + ->method('assign') + ->with($cartId, $shippingAddressMock) + ->willReturn(1); + + $shippingAddressMock->expects($this->once())->method('format')->with('html'); + $this->shippingAddressManagement->expects($this->once()) + ->method('get') + ->with($cartId) + ->willReturn($shippingAddressMock); + + $shippingMethodMock = $this->getMock('\Magento\Quote\Api\Data\ShippingMethodInterface'); + $this->shippingMethodManagement->expects($this->once()) + ->method('getList') + ->with($cartId) + ->willReturn([$shippingMethodMock]); + $paymentMethodMock = $this->getMock('\Magento\Quote\Api\Data\PaymentMethodInterface'); + $this->paymentMethodManagement->expects($this->once()) + ->method('getList') + ->with($cartId) + ->willReturn([$paymentMethodMock]); + + $addressDetailsMock = $this->getMock('\Magento\Quote\Model\AddressDetails', [], [], '', false); + $this->addressDetailsFactory->expects($this->once())->method('create')->willReturn($addressDetailsMock); + + $addressDetailsMock->expects($this->once()) + ->method('setShippingMethods') + ->with([$shippingMethodMock]) + ->willReturnSelf(); + $addressDetailsMock->expects($this->once()) + ->method('setPaymentMethods') + ->with([$paymentMethodMock]) + ->willReturnSelf(); + $this->dataProcessor->expects($this->once())->method('process')->with($additionalData); + + $quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $quote->expects($this->once()) + ->method('setCheckoutMethod') + ->willReturnSelf(); + + $this->quoteRepository + ->expects($this->once()) + ->method('getActive') + ->willReturn($quote); + + $this->model->saveAddresses($cartId, $billingAddressMock, $shippingAddressMock, $additionalData, 'register'); + } +} diff --git a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php index 244c1fb1778af..8ddc3c5f8b7fb 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php @@ -8,9 +8,15 @@ namespace Magento\Quote\Test\Unit\Model; use \Magento\Quote\Model\BillingAddressManagement; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase { + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + protected $objectManager; + /** * @var BillingAddressManagement */ @@ -26,15 +32,30 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase */ protected $validatorMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $addressRepository; + /** * @return void */ protected function setUp() { + $this->objectManager = new ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); $this->validatorMock = $this->getMock('\Magento\Quote\Model\QuoteAddressValidator', [], [], '', false); + $this->addressRepository = $this->getMock('\Magento\Customer\Api\AddressRepositoryInterface'); $logger = $this->getMock('\Psr\Log\LoggerInterface'); - $this->model = new BillingAddressManagement($this->quoteRepositoryMock, $this->validatorMock, $logger); + $this->model = $this->objectManager->getObject( + '\Magento\Quote\Model\BillingAddressManagement', + [ + 'quoteRepository' => $this->quoteRepositoryMock, + 'addressValidator' => $this->validatorMock, + 'logger' => $logger, + 'addressRepository' => $this->addressRepository + ] + ); } /** @@ -67,7 +88,8 @@ public function testSetAddressValidationFailed() ->with('cartId') ->will($this->returnValue($quoteMock)); - $this->validatorMock->expects($this->once())->method('validate') + $this->validatorMock->expects($this->once()) + ->method('validate') ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException(__('error123')))); $this->model->assign('cartId', $address); @@ -78,28 +100,70 @@ public function testSetAddressValidationFailed() */ public function testSetAddress() { - $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); - + $cartId = 100; + $useForShipping = true; + $addressId = 1; + $customerAddressId = 10; + + $address = $this->getMock( + 'Magento\Quote\Model\Quote\Address', + ['setSaveInAddressBook', 'getCustomerAddressId', 'getSaveInAddressBook'], + [], + '', + false + ); $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') - ->with('cartId') - ->will($this->returnValue($quoteMock)); - + ->with($cartId) + ->willReturn($quoteMock); $this->validatorMock->expects($this->once())->method('validate') ->with($address) - ->will($this->returnValue(true)); - - $quoteMock->expects($this->once())->method('setBillingAddress')->with($address); + ->willReturn(true); + + $address->expects($this->once())->method('getCustomerAddressId')->willReturn($customerAddressId); + $address->expects($this->once())->method('getSaveInAddressBook')->willReturn(1); + + $customerAddressMock = $this->getMock('Magento\Customer\Api\Data\AddressInterface', [], [], '', false); + $this->addressRepository->expects($this->once()) + ->method('getById') + ->with($customerAddressId) + ->willReturn($customerAddressMock); + + $quoteBillingAddress = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false); + $quoteBillingAddress->expects($this->once())->method('getId')->will($this->returnValue($addressId)); + $quoteMock->expects($this->exactly(2))->method('getBillingAddress')->willReturn($quoteBillingAddress); + $quoteBillingAddress->expects($this->once()) + ->method('importCustomerAddressData') + ->with($customerAddressMock) + ->willReturnSelf(); + + $quoteShippingAddress = $this->getMock( + 'Magento\Quote\Model\Quote\Address', + ['setSaveInAddressBook', 'setSameAsBilling', 'setCollectShippingRates', 'importCustomerAddressData'], + [], + '', + false + ); + $quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($quoteShippingAddress); + $quoteShippingAddress->expects($this->once()) + ->method('importCustomerAddressData') + ->with($customerAddressMock) + ->willReturnSelf(); + $quoteShippingAddress->expects($this->once())->method('setSaveInAddressBook')->with(1)->willReturnSelf(); + + $quoteBillingAddress->expects($this->once())->method('setSaveInAddressBook')->with(1)->willReturnSelf(); + $quoteMock->expects($this->once())->method('setBillingAddress')->with($quoteBillingAddress)->willReturnSelf(); + + $quoteShippingAddress->expects($this->once())->method('setSameAsBilling')->with(1)->willReturnSelf(); + $quoteShippingAddress->expects($this->once())->method('setCollectShippingRates')->with(true)->willReturnSelf(); + + $quoteMock->expects($this->once())->method('setShippingAddress')->with($quoteShippingAddress); $quoteMock->expects($this->once())->method('setDataChanges')->with(true); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); - $addressId = 1; - $billingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); - $billingAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); - $quoteMock->expects($this->once())->method('getBillingAddress') - ->will($this->returnValue($billingAddressMock)); - $this->assertEquals($addressId, $this->model->assign('cartId', $address)); + $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + $this->assertEquals($addressId, $this->model->assign($cartId, $address, $useForShipping)); } /** diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php new file mode 100644 index 0000000000000..949d05f360fde --- /dev/null +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalManagementTest.php @@ -0,0 +1,104 @@ +objectManager = new ObjectManager($this); + $this->shippingMock = $this->getMock('\Magento\Quote\Api\ShippingMethodManagementInterface', [], [], '', false); + $this->paymentMock = $this->getMock('\Magento\Quote\Api\PaymentMethodManagementInterface', [], [], '', false); + $this->cartTotalMock = $this->getMock('\Magento\Quote\Api\CartTotalRepositoryInterface', [], [], '', false); + $this->model = $this->objectManager->getObject( + '\Magento\Quote\Model\Cart\CartTotalManagement', + [ + 'shippingMethodManagement' => $this->shippingMock, + 'paymentMethodManagement' => $this->paymentMock, + 'cartTotalsRepository' => $this->cartTotalMock, + ] + ); + } + + public function testCollectTotals() + { + $cartId = 123; + $shippingCarrierCode = 'careful_carrier'; + $shippingMethodCode = 'drone_delivery'; + $total = 3322.31; + $paymentDataMock = $this->getMock('\Magento\Quote\Api\Data\PaymentInterface', [], [], '', false); + + $this->shippingMock->expects($this->once()) + ->method('set') + ->with($cartId, $shippingCarrierCode, $shippingMethodCode); + $this->paymentMock->expects($this->once())->method('set')->with($cartId, $paymentDataMock); + $this->cartTotalMock->expects($this->once())->method('get')->with($cartId)->willReturn($total); + $this->assertEquals( + $total, + $this->model->collectTotals($cartId, $paymentDataMock, $shippingCarrierCode, $shippingMethodCode) + ); + } + + /** + * @dataProvider collectTotalsShippingData + * @param $shippingCarrierCode + * @param $shippingMethodCode + */ + public function testCollectTotalsNoShipping($shippingCarrierCode, $shippingMethodCode) + { + $cartId = 123; + $total = 3322.31; + $paymentDataMock = $this->getMock('\Magento\Quote\Api\Data\PaymentInterface', [], [], '', false); + + $this->shippingMock->expects($this->never()) + ->method('set') + ->with($cartId, $shippingCarrierCode, $shippingMethodCode); + $this->paymentMock->expects($this->once())->method('set')->with($cartId, $paymentDataMock); + $this->cartTotalMock->expects($this->once())->method('get')->with($cartId)->willReturn($total); + $this->assertEquals( + $total, + $this->model->collectTotals($cartId, $paymentDataMock, $shippingCarrierCode, $shippingMethodCode) + ); + } + + public function collectTotalsShippingData() + { + return [ + ['careful_carrier', null], + [null, 'drone_delivery'], + [null, null], + ]; + } +} diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php index b05e17771e487..5ac3f50b3fed2 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/CartTotalRepositoryTest.php @@ -6,10 +6,20 @@ */ namespace Magento\Quote\Test\Unit\Model\Cart; -use \Magento\Quote\Model\Cart\CartTotalRepository; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CartTotalRepositoryTest extends \PHPUnit_Framework_TestCase { + /** + * @var ObjectManager + */ + protected $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $converterMock; + /** * @var \Magento\Quote\Model\Cart\CartTotalRepository */ @@ -42,6 +52,7 @@ class CartTotalRepositoryTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->objectManager = new ObjectManager($this); $this->totalsFactoryMock = $this->getMock( 'Magento\Quote\Api\Data\TotalsInterfaceFactory', ['create'], @@ -55,31 +66,65 @@ public function setUp() $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') ->disableOriginalConstructor() ->getMock(); + $this->converterMock = $this->getMock( + 'Magento\Quote\Model\Cart\Totals\ItemConverter', + [], + [], + '', + false + ); - $this->model = new CartTotalRepository( - $this->totalsFactoryMock, - $this->quoteRepositoryMock, - $this->dataObjectHelperMock + $this->model = $this->objectManager->getObject( + '\Magento\Quote\Model\Cart\CartTotalRepository', + [ + 'totalsFactory' => $this->totalsFactoryMock, + 'quoteRepository' => $this->quoteRepositoryMock, + 'dataObjectHelper' => $this->dataObjectHelperMock, + 'converter' => $this->converterMock, + ] ); } - public function testGetTotals() + public function testGet() { $cartId = 12; + $itemMock = $this->getMock( + 'Magento\Quote\Model\Quote\Item', + [], + [], + '', + false + ); + $visibleItems = [ + 11 => $itemMock, + ]; + $itemArray = [ + 'name' => 'item', + 'options' => [ 4 => ['label' => 'justLabel']], + ]; $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId) ->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($this->addressMock); $this->addressMock->expects($this->once())->method('getData')->willReturn(['addressData']); $this->quoteMock->expects($this->once())->method('getData')->willReturn(['quoteData']); - $item = $this->getMock('Magento\Quote\Model\Quote\Item', [], [], '', false); - $this->quoteMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$item])); + $this->quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn($visibleItems); - $totals = $this->getMock('Magento\Quote\Model\Cart\Totals', ['setItems'], [], '', false); - $this->totalsFactoryMock->expects($this->once())->method('create')->willReturn($totals); + $totalsMock = $this->getMock('Magento\Quote\Model\Cart\Totals', ['setItems'], [], '', false); + $this->totalsFactoryMock->expects($this->once())->method('create')->willReturn($totalsMock); $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray'); - $totals->expects($this->once())->method('setItems'); + $this->converterMock->expects($this->once()) + ->method('modelToDataObject') + ->with($itemMock) + ->willReturn($itemArray); + + //back in get() + $totalsMock->expects($this->once())->method('setItems')->with( + [ + 11 => $itemArray, + ] + ); - $this->model->get($cartId); + $this->assertEquals($totalsMock, $this->model->get($cartId)); } } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php b/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php index 7692c658f760b..fef4e88702a14 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Cart/ShippingMethodConverterTest.php @@ -10,7 +10,6 @@ namespace Magento\Quote\Test\Unit\Model\Cart; use \Magento\Quote\Model\Cart\ShippingMethodConverter; -use \Magento\Quote\Model\Cart\ShippingMethod; class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase { @@ -49,6 +48,11 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase */ protected $shippingMethodMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $taxHelper; + protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -71,6 +75,8 @@ protected function setUp() 'setAmount', 'setBaseAmount', 'setAvailable', + 'setPriceExclTax', + 'setPriceInclTax' ], [], '', @@ -83,23 +89,31 @@ protected function setUp() 'getCarrierTitle', 'getMethodTitle', '__wakeup', + 'getAddress' ], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->taxHelper = $this->getMock('\Magento\Tax\Helper\Data', [], [], '', false); $this->converter = $objectManager->getObject( 'Magento\Quote\Model\Cart\ShippingMethodConverter', [ 'shippingMethodDataFactory' => $this->shippingMethodDataFactoryMock, 'storeManager' => $this->storeManagerMock, + 'taxHelper' => $this->taxHelper ] ); } public function testModelToDataObject() { + $customerTaxClassId = 100; + $shippingPriceExclTax = 1000; + $shippingPriceInclTax = 1500; + $price = 90.12; + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); $this->storeMock->expects($this->once()) ->method('getBaseCurrency') @@ -107,18 +121,30 @@ public function testModelToDataObject() $this->rateModelMock->expects($this->once())->method('getCarrier')->will($this->returnValue('CARRIER_CODE')); $this->rateModelMock->expects($this->once())->method('getMethod')->will($this->returnValue('METHOD_CODE')); - $this->rateModelMock->expects($this->any())->method('getPrice')->will($this->returnValue(90.12)); - $this->currencyMock->expects($this->once()) - ->method('convert')->with(90.12, 'USD')->will($this->returnValue(100.12)); + $this->rateModelMock->expects($this->any())->method('getPrice')->will($this->returnValue($price)); + $this->currencyMock->expects($this->at(0)) + ->method('convert')->with($price, 'USD')->willReturn(100.12); + $this->currencyMock->expects($this->at(1)) + ->method('convert')->with($shippingPriceExclTax, 'USD')->willReturn($shippingPriceExclTax); + $this->currencyMock->expects($this->at(2)) + ->method('convert')->with($shippingPriceInclTax, 'USD')->willReturn($shippingPriceInclTax); + $this->rateModelMock->expects($this->once()) ->method('getCarrierTitle')->will($this->returnValue('CARRIER_TITLE')); $this->rateModelMock->expects($this->once()) ->method('getMethodTitle')->will($this->returnValue('METHOD_TITLE')); + + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); + $this->rateModelMock->expects($this->exactly(4))->method('getAddress')->willReturn($addressMock); + + $addressMock->expects($this->exactly(2))->method('getQuote')->willReturn($quoteMock); + $quoteMock->expects($this->exactly(2))->method('getCustomerTaxClassId')->willReturn($customerTaxClassId); + $this->shippingMethodDataFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->shippingMethodMock)); - $this->shippingMethodMock->expects($this->once()) ->method('setCarrierCode') ->with('CARRIER_CODE') @@ -147,6 +173,24 @@ public function testModelToDataObject() ->method('setAvailable') ->with(true) ->will($this->returnValue($this->shippingMethodMock)); + $this->shippingMethodMock->expects($this->once()) + ->method('setPriceExclTax') + ->with($shippingPriceExclTax) + ->will($this->returnValue($this->shippingMethodMock)); + $this->shippingMethodMock->expects($this->once()) + ->method('setPriceInclTax') + ->with($shippingPriceInclTax) + ->will($this->returnValue($this->shippingMethodMock)); + + $this->taxHelper->expects($this->at(0)) + ->method('getShippingPrice') + ->with($price, false, $addressMock, $customerTaxClassId) + ->willReturn($shippingPriceExclTax); + + $this->taxHelper->expects($this->at(1)) + ->method('getShippingPrice') + ->with($price, true, $addressMock, $customerTaxClassId) + ->willReturn($shippingPriceInclTax); $this->assertEquals( $this->shippingMethodMock, diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php index 8cc66a238ca8f..63d84bec059de 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php @@ -29,6 +29,16 @@ class GuestCartManagementTest extends \PHPUnit_Framework_TestCase */ protected $quoteIdMaskMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cartRepositoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + /** * @var \Magento\Quote\Model\GuestCart\GuestCartManagement */ @@ -62,11 +72,30 @@ protected function setUp() false ); + $this->cartRepositoryMock = $this->getMock( + 'Magento\Quote\Api\CartRepositoryInterface', + ['get', 'getList'], + [], + '', + false + ); + + $this->quoteMock = $this->getMockForAbstractClass( + 'Magento\Quote\Api\Data\CartInterface', + [], + '', + false, + true, + true, + ['setCheckoutMethod'] + ); + $this->guestCartManagement = $objectManager->getObject( 'Magento\Quote\Model\GuestCart\GuestCartManagement', [ 'quoteManagement' => $this->quoteManagementMock, - 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock + 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, + 'cartRepository' => $this->cartRepositoryMock ] ); } @@ -107,7 +136,9 @@ public function testPlaceOrder() $orderId = 1; $this->quoteIdMaskMock->expects($this->once())->method('load')->with($cartId, 'masked_id')->willReturnSelf(); - $this->quoteIdMaskMock->expects($this->once())->method('getQuoteId')->willReturn($maskedCartId); + $this->cartRepositoryMock->expects($this->once())->method('get')->willReturn($this->quoteMock); + $this->quoteMock->expects($this->once())->method('setCheckoutMethod'); + $this->quoteIdMaskMock->expects($this->any())->method('getQuoteId')->willReturn($maskedCartId); $this->quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteIdMaskMock); $this->quoteManagementMock->expects($this->once())->method('placeOrder')->willReturn($orderId); diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php index c8f6074a62778..527839cb7a3fb 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTestHelper.php @@ -45,7 +45,10 @@ public function mockQuoteIdMask($maskedCartId, $cartId) '', false ); - $quoteIdMaskFactoryMock = $this->testCase->getMock('Magento\Quote\Model\QuoteIdMaskFactory', [], [], '', false); + $quoteIdMaskFactoryMock = $this->testCase->getMockBuilder('Magento\Quote\Model\QuoteIdMaskFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); $quoteIdMaskFactoryMock->expects($this->testCase->once())->method('create')->willReturn($quoteIdMaskMock); $quoteIdMaskMock->expects($this->testCase->once())->method('load')->with($maskedCartId)->willReturnSelf(); $quoteIdMaskMock->expects($this->testCase->once())->method('getQuoteId')->willReturn($cartId); diff --git a/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php index 78751a96441cc..55c75dad00a98 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php @@ -110,7 +110,8 @@ public function testSetVirtualProduct() { $cartId = 100; $paymentId = 200; - $methodData = ['method' => 'data']; + $methodDataWithAdditionalData = ['method' => 'data', 'additional_data' => ['additional' => 'value']]; + $methodData = ['method' => 'data', 'additional' => 'value']; $paymentMethod = 'checkmo'; $quoteMock = $this->getMock( @@ -132,7 +133,7 @@ public function testSetVirtualProduct() \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX, ]) ->willReturnSelf(); - $methodMock->expects($this->once())->method('getData')->willReturn($methodData); + $methodMock->expects($this->once())->method('getData')->willReturn($methodDataWithAdditionalData); $paymentMock = $this->getMock( 'Magento\Quote\Model\Quote\Payment', diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php index 87e7be99c6e04..d50acc5a32a19 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteAddressValidatorTest.php @@ -1,20 +1,15 @@ objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->addressFactoryMock = $this->getMock( - '\Magento\Quote\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false + $this->addressRepositoryMock = $this->getMock( + '\Magento\Customer\Api\AddressRepositoryInterface', + [], + [], + '', + false ); $this->quoteAddressMock = $this->getMock( '\Magento\Quote\Model\Quote\Address', @@ -57,11 +56,22 @@ public function setUp() '', false ); - $this->customerFactoryMock = $this->getMock( - '\Magento\Customer\Model\CustomerFactory', ['create', '__wakeup'], [], '', false); - $this->customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); - - $this->model = new QuoteAddressValidator($this->addressFactoryMock, $this->customerFactoryMock); + $this->customerRepositoryMock = $this->getMock( + '\Magento\Customer\Api\CustomerRepositoryInterface', + [], + [], + '', + false + ); + $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->model = $this->objectManager->getObject( + '\Magento\Quote\Model\QuoteAddressValidator', + [ + 'addressRepository' => $this->addressRepositoryMock, + 'customerRepository' => $this->customerRepositoryMock, + 'customerSession' => $this->customerSessionMock + ] + ); } /** @@ -71,16 +81,12 @@ public function setUp() public function testValidateInvalidCustomer() { $customerId = 100; - - $this->customerFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($this->customerMock)); - - $this->customerMock->expects($this->once())->method('load')->with($customerId); - $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue(null)); - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($customerId); + $this->customerRepositoryMock->expects($this->once())->method('getById')->with($customerId) + ->willReturn($customerMock); $this->model->validate($address); } @@ -90,14 +96,13 @@ public function testValidateInvalidCustomer() */ public function testValidateInvalidAddress() { - $this->customerFactoryMock->expects($this->never())->method('create'); - $this->customerMock->expects($this->never())->method('load'); - - $this->addressFactoryMock->expects($this->once())->method('create') - ->will($this->returnValue($this->quoteAddressMock)); - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $this->customerRepositoryMock->expects($this->never())->method('getById'); $address->expects($this->atLeastOnce())->method('getId')->willReturn(101); + + $this->addressRepositoryMock->expects($this->once())->method('getById') + ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException()); + $this->model->validate($address); } @@ -106,44 +111,50 @@ public function testValidateInvalidAddress() */ public function testValidateNewAddress() { - $this->customerFactoryMock->expects($this->never())->method('create'); - $this->addressFactoryMock->expects($this->never())->method('create'); - + $this->customerRepositoryMock->expects($this->never())->method('getById'); + $this->addressRepositoryMock->expects($this->never())->method('getById'); $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); $this->assertTrue($this->model->validate($address)); } /** - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Address with id 100 belongs to another customer + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Invalid address id 100 */ public function testValidateWithAddressOfOtherCustomer() { $addressCustomer = 100; $addressId = 100; - $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + + $this->customerRepositoryMock->expects($this->once())->method('getById')->with($addressCustomer) + ->willReturn($customerMock); + $this->addressRepositoryMock->expects($this->once())->method('getById')->willReturn($this->quoteAddressMock); + $customerMock->expects($this->once())->method('getId')->willReturn(42); $address->expects($this->atLeastOnce())->method('getId')->willReturn($addressId); $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($addressCustomer); - /** Customer mock */ - $this->customerFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($this->customerMock)); - - $this->customerMock->expects($this->once())->method('load')->with($addressCustomer); - $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue($addressCustomer)); + $this->quoteAddressMock->expects($this->once())->method('getCustomerId')->willReturn(42); + $this->model->validate($address); + } - /** Quote address mock */ - $this->addressFactoryMock->expects($this->once())->method('create') - ->will($this->returnValue($this->quoteAddressMock)); + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Invalid address id 42 + */ + public function testValidateWithInvalidCustomerAddressId() + { + $customerAddressId = 42; + $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $customerAddress = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); - $this->quoteAddressMock->expects($this->once())->method('load')->with($addressId); - $this->quoteAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); - $this->quoteAddressMock->expects($this->any())->method('getCustomerId') - ->will($this->returnValue(10)); + $address->expects($this->atLeastOnce())->method('getCustomerAddressId')->willReturn($customerAddressId); + $this->customerSessionMock->expects($this->once())->method('getCustomerDataObject')->willReturn($customerMock); + $customerMock->expects($this->once())->method('getAddresses')->willReturn([$customerAddress]); + $customerAddress->expects($this->once())->method('getId')->willReturn(43); - /** Validate */ $this->model->validate($address); } @@ -151,29 +162,25 @@ public function testValidateWithValidAddress() { $addressCustomer = 100; $addressId = 100; + $customerAddressId = 42; $address = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); $address->expects($this->atLeastOnce())->method('getId')->willReturn($addressId); $address->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($addressCustomer); + $address->expects($this->atLeastOnce())->method('getCustomerAddressId')->willReturn($customerAddressId); + $customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $customerAddress = $this->getMock('\Magento\Quote\Api\Data\AddressInterface'); - /** Customer mock */ - $this->customerFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($this->customerMock)); - - $this->customerMock->expects($this->once())->method('load')->with($addressCustomer); - $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue($addressCustomer)); + $this->customerRepositoryMock->expects($this->once())->method('getById')->willReturn($customerMock); + $customerMock->expects($this->once())->method('getId')->willReturn($addressCustomer); - /** Quote address mock */ - $this->addressFactoryMock->expects($this->once())->method('create') - ->will($this->returnValue($this->quoteAddressMock)); + $this->addressRepositoryMock->expects($this->once())->method('getById')->willReturn($this->quoteAddressMock); + $this->quoteAddressMock->expects($this->any())->method('getCustomerId')->willReturn($addressCustomer); - $this->quoteAddressMock->expects($this->once())->method('load')->with($addressId); - $this->quoteAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); - $this->quoteAddressMock->expects($this->any())->method('getCustomerId') - ->will($this->returnValue($addressCustomer)); + $this->customerSessionMock->expects($this->once())->method('getCustomerDataObject')->willReturn($customerMock); + $customerMock->expects($this->once())->method('getAddresses')->willReturn([$customerAddress]); + $customerAddress->expects($this->once())->method('getId')->willReturn(42); - /** Validate */ - $this->model->validate($address); + $this->assertTrue($this->model->validate($address)); } } diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php index 12c4248d82c81..8fe61be981cb7 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php @@ -13,6 +13,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.TooManyFields) */ class QuoteManagementTest extends \PHPUnit_Framework_TestCase { @@ -91,6 +92,39 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase */ protected $storeManagerMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $accountManagementMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $agreementsValidatorMock; + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -155,13 +189,54 @@ protected function setUp() ['getStore', 'getStoreId'] ); - $dataObjectHelper = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->quoteMock = $this->getMock( + 'Magento\Quote\Model\Quote', + [ + 'getId', + 'getCheckoutMethod', + 'setCheckoutMethod', + 'setCustomerId', + 'setCustomerEmail', + 'getBillingAddress', + 'setCustomerIsGuest', + 'setCustomerGroupId', + 'assignCustomer', + 'getPayment', + ], + [], + '', + false + ); + + $this->dataObjectHelperMock = $this->getMock('\Magento\Framework\Api\DataObjectHelper', [], [], '', false); + $this->checkoutSessionMock = $this->getMock( + 'Magento\Checkout\Model\Session', + ['setLastQuoteId', 'setLastSuccessQuoteId', 'setLastOrderId', 'setLastRealOrderId'], + [], + '', + false + ); + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); + $this->accountManagementMock = $this->getMock( + '\Magento\Customer\Api\AccountManagementInterface', + [], + [], + '', + false + ); + $this->agreementsValidatorMock = $this->getMock( + '\Magento\Checkout\Model\Agreements\AgreementsValidator', + [], + [], + '', + false + ); $this->model = $objectManager->getObject( 'Magento\Quote\Model\QuoteManagement', [ - 'quoteValidator' => $this->quoteValidator, 'eventManager' => $this->eventManager, + 'quoteValidator' => $this->quoteValidator, 'orderFactory' => $this->orderFactory, 'orderManagement' => $this->orderManagement, 'customerManagement' => $this->customerManagement, @@ -169,12 +244,15 @@ protected function setUp() 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress, 'quoteItemToOrderItem' => $this->quoteItemToOrderItem, 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment, - 'quoteRepository' => $this->quoteRepositoryMock, 'userContext' => $this->userContextMock, + 'quoteRepository' => $this->quoteRepositoryMock, 'customerRepository' => $this->customerRepositoryMock, 'customerModelFactory' => $this->customerFactoryMock, - 'dataObjectHelper' => $dataObjectHelper, - 'storeManager' => $this->storeManagerMock + 'dataObjectHelper' => $this->dataObjectHelperMock, + 'storeManager' => $this->storeManagerMock, + 'checkoutSession' => $this->checkoutSessionMock, + 'customerSession' => $this->customerSessionMock, + 'accountManagement' => $this->accountManagementMock, ] ); } @@ -572,49 +650,195 @@ public function testSubmit() $this->assertEquals($order, $this->model->submit($quote, $orderData)); } - /** - * //Last method throws exception because class method 'submit()' already covered. - * - * @expectedException \Exception - * @expectedExceptionMessage Quote prepared for guest customer. - */ - public function testPlaceOrderIfCustomerIsQuest() + public function testPlaceOrderIfCustomerIsGuest() { $cartId = 100; + $orderId = 332; + $orderIncrementId = 100003332; $email = 'email@mail.com'; - $quoteMock = $this->getMock( - 'Magento\Quote\Model\Quote', + + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->willReturn($this->quoteMock); + + $this->quoteMock->expects($this->once()) + ->method('getCheckoutMethod') + ->willReturn(\Magento\Checkout\Model\Type\Onepage::METHOD_GUEST); + $this->quoteMock->expects($this->once())->method('setCustomerId')->with(null)->willReturnSelf(); + $this->quoteMock->expects($this->once())->method('setCustomerEmail')->with($email)->willReturnSelf(); + + $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', ['getEmail'], [], '', false); + $addressMock->expects($this->once())->method('getEmail')->willReturn($email); + $this->quoteMock->expects($this->once())->method('getBillingAddress')->with()->willReturn($addressMock); + + $this->quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf(); + $this->quoteMock->expects($this->once()) + ->method('setCustomerGroupId') + ->with(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID); + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ + $service = $this->getMock( + '\Magento\Quote\Model\QuoteManagement', + ['submit'], [ - 'getCheckoutMethod', - 'setCustomerId', - 'setCustomerEmail', - 'getBillingAddress', - 'setCustomerIsGuest', - 'setCustomerGroupId' - ], + 'eventManager' => $this->eventManager, + 'quoteValidator' => $this->quoteValidator, + 'orderFactory' => $this->orderFactory, + 'orderManagement' => $this->orderManagement, + 'customerManagement' => $this->customerManagement, + 'quoteAddressToOrder' => $this->quoteAddressToOrder, + 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress, + 'quoteItemToOrderItem' => $this->quoteItemToOrderItem, + 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment, + 'userContext' => $this->userContextMock, + 'quoteRepository' => $this->quoteRepositoryMock, + 'customerRepository' => $this->customerRepositoryMock, + 'customerModelFactory' => $this->customerFactoryMock, + 'dataObjectHelper' => $this->dataObjectHelperMock, + 'storeManager' => $this->storeManagerMock, + 'checkoutSession' => $this->checkoutSessionMock, + 'customerSession' => $this->customerSessionMock, + 'accountManagement' => $this->accountManagementMock, + 'agreementsValidator' => $this->agreementsValidatorMock, + ] + ); + $orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $service->expects($this->once())->method('submit')->willReturn($orderMock); + + $this->quoteMock->expects($this->atLeastOnce())->method('getId')->willReturn($cartId); + $orderMock->expects($this->atLeastOnce())->method('getId')->willReturn($orderId); + $orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($orderIncrementId); + + $this->checkoutSessionMock->expects($this->once())->method('setLastQuoteId')->with($cartId); + $this->checkoutSessionMock->expects($this->once())->method('setLastSuccessQuoteId')->with($cartId); + $this->checkoutSessionMock->expects($this->once())->method('setLastOrderId')->with($orderId); + $this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId); + $this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(true); + + $this->assertEquals($orderId, $service->placeOrder($cartId)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testPlaceOrderIfAgreementsIsNotValid() + { + $this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(false); + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ + $service = $this->getMock( + '\Magento\Quote\Model\QuoteManagement', + ['submit'], + [ + 'eventManager' => $this->eventManager, + 'quoteValidator' => $this->quoteValidator, + 'orderFactory' => $this->orderFactory, + 'orderManagement' => $this->orderManagement, + 'customerManagement' => $this->customerManagement, + 'quoteAddressToOrder' => $this->quoteAddressToOrder, + 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress, + 'quoteItemToOrderItem' => $this->quoteItemToOrderItem, + 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment, + 'userContext' => $this->userContextMock, + 'quoteRepository' => $this->quoteRepositoryMock, + 'customerRepository' => $this->customerRepositoryMock, + 'customerModelFactory' => $this->customerFactoryMock, + 'dataObjectHelper' => $this->dataObjectHelperMock, + 'storeManager' => $this->storeManagerMock, + 'checkoutSession' => $this->checkoutSessionMock, + 'customerSession' => $this->customerSessionMock, + 'accountManagement' => $this->accountManagementMock, + 'agreementsValidator' => $this->agreementsValidatorMock, + ] + ); + $service->placeOrder(45); + } + + public function testPlaceOrder() + { + $cartId = 323; + $orderId = 332; + $orderIncrementId = 100003332; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ + $service = $this->getMock( + '\Magento\Quote\Model\QuoteManagement', + ['submit'], + [ + 'eventManager' => $this->eventManager, + 'quoteValidator' => $this->quoteValidator, + 'orderFactory' => $this->orderFactory, + 'orderManagement' => $this->orderManagement, + 'customerManagement' => $this->customerManagement, + 'quoteAddressToOrder' => $this->quoteAddressToOrder, + 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress, + 'quoteItemToOrderItem' => $this->quoteItemToOrderItem, + 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment, + 'userContext' => $this->userContextMock, + 'quoteRepository' => $this->quoteRepositoryMock, + 'customerRepository' => $this->customerRepositoryMock, + 'customerModelFactory' => $this->customerFactoryMock, + 'dataObjectHelper' => $this->dataObjectHelperMock, + 'storeManager' => $this->storeManagerMock, + 'checkoutSession' => $this->checkoutSessionMock, + 'customerSession' => $this->customerSessionMock, + 'accountManagement' => $this->accountManagementMock, + 'agreementsValidator' => $this->agreementsValidatorMock, + ] + ); + $orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [], [], '', false ); - $this->quoteRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock); - $quoteMock->expects($this->once()) + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($cartId) + ->willReturn($this->quoteMock); + + $quotePayment = $this->getMock('Magento\Quote\Model\Quote\Payment', [], [], '', false); + $quotePayment->expects($this->once()) + ->method('setQuote'); + $quotePayment->expects($this->once()) + ->method('importData'); + $this->quoteMock->expects($this->atLeastOnce()) + ->method('getPayment') + ->willReturn($quotePayment); + + $this->quoteMock->expects($this->once()) ->method('getCheckoutMethod') - ->willReturn(\Magento\Checkout\Model\Type\Onepage::METHOD_GUEST); - $quoteMock->expects($this->once())->method('setCustomerId')->with(null)->willReturnSelf(); - $quoteMock->expects($this->once())->method('setCustomerEmail')->with($email)->willReturnSelf(); + ->willReturn(\Magento\Checkout\Model\Type\Onepage::METHOD_CUSTOMER); + $this->quoteMock->expects($this->never()) + ->method('setCustomerIsGuest') + ->with(true); - $addressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', ['getEmail'], [], '', false); - $addressMock->expects($this->once())->method('getEmail')->willReturn($email); - $quoteMock->expects($this->once())->method('getBillingAddress')->with()->willReturn($addressMock); + $service->expects($this->once())->method('submit')->willReturn($orderMock); - $quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(true)->willReturnSelf(); - $quoteMock->expects($this->once()) - ->method('setCustomerGroupId') - ->with(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID) - ->willThrowException(new \Exception('Quote prepared for guest customer.')); + $this->quoteMock->expects($this->atLeastOnce())->method('getId')->willReturn($cartId); + $orderMock->expects($this->atLeastOnce())->method('getId')->willReturn($orderId); + $orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($orderIncrementId); + + $this->checkoutSessionMock->expects($this->once())->method('setLastQuoteId')->with($cartId); + $this->checkoutSessionMock->expects($this->once())->method('setLastSuccessQuoteId')->with($cartId); + $this->checkoutSessionMock->expects($this->once())->method('setLastOrderId')->with($orderId); + $this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId); + $this->agreementsValidatorMock->expects($this->once())->method('isValid')->willReturn(true); + + $paymentMethod = $this->getMock('Magento\Quote\Model\Quote\Payment', ['setChecks', 'getData'], [], '', false); + $paymentMethod->expects($this->once())->method('setChecks'); + $paymentMethod->expects($this->once())->method('getData')->willReturn(['additional_data' => []]); - $this->model->placeOrder($cartId); + $this->assertEquals($orderId, $service->placeOrder($cartId, null, $paymentMethod)); } /** @@ -651,7 +875,8 @@ protected function getQuote( 'getId', 'getCustomer', 'getAllItems', - 'getPayment' + 'getPayment', + 'reserveOrderId' ], [], '', diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php index ddda3673b55dc..4c5bffe800776 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php @@ -10,7 +10,6 @@ namespace Magento\Quote\Test\Unit\Model; use \Magento\Quote\Model\ShippingAddressManagement; - class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase { /** @@ -40,11 +39,21 @@ class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); $this->quoteAddressMock = $this->getMock( '\Magento\Quote\Model\Quote\Address', - ['setSameAsBilling', 'setCollectShippingRates', '__wakeup'], + [ + 'setSameAsBilling', + 'setCollectShippingRates', + '__wakeup', + 'collectTotals', + 'save', + 'getId', + 'getCustomerAddressId', + 'getSaveInAddressBook' + ], [], '', false @@ -52,10 +61,13 @@ protected function setUp() $this->validatorMock = $this->getMock( 'Magento\Quote\Model\QuoteAddressValidator', [], [], '', false ); - $this->service = new ShippingAddressManagement( - $this->quoteRepositoryMock, - $this->validatorMock, - $this->getMock('\Psr\Log\LoggerInterface') + $this->service = $this->objectManager->getObject( + '\Magento\Quote\Model\ShippingAddressManagement', + [ + 'quoteRepository' => $this->quoteRepositoryMock, + 'addressValidator' => $this->validatorMock, + 'logger' => $this->getMock('\Psr\Log\LoggerInterface') + ] ); } @@ -79,6 +91,7 @@ public function testSetAddressValidationFailed() public function testSetAddress() { + $addressId = 1; $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') @@ -91,15 +104,18 @@ public function testSetAddress() ->with($this->quoteAddressMock) ->will($this->returnValue(true)); - $quoteMock->expects($this->once())->method('setShippingAddress')->with($this->quoteAddressMock); - $quoteMock->expects($this->once())->method('setDataChanges')->with(true); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + $this->quoteAddressMock->expects($this->once())->method('collectTotals')->willReturnSelf(); + $this->quoteAddressMock->expects($this->once())->method('save')->willReturnSelf(); + $this->quoteAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); - $addressId = 1; - $shippingAddressMock = $this->getMock('\Magento\Quote\Model\Quote\Address', [], [], '', false); - $shippingAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); - $quoteMock->expects($this->once())->method('getShippingAddress') - ->will($this->returnValue($shippingAddressMock)); + $quoteMock->expects($this->any()) + ->method('setShippingAddress') + ->with($this->quoteAddressMock) + ->willReturnSelf(); + $quoteMock->expects($this->any()) + ->method('getShippingAddress') + ->will($this->returnValue($this->quoteAddressMock)); + $quoteMock->expects($this->once())->method('validateMinimumAmount')->willReturn(true); $this->assertEquals($addressId, $this->service->assign('cart867', $this->quoteAddressMock)); } @@ -116,10 +132,11 @@ public function testSetAddressForVirtualProduct() ->with('cart867') ->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(true)); + $quoteMock->expects($this->never())->method('setShippingAddress'); - $this->validatorMock->expects($this->never())->method('validate'); + $this->quoteAddressMock->expects($this->never())->method('getCustomerAddressId'); + $this->quoteAddressMock->expects($this->never())->method('setSaveInAddressBook'); - $quoteMock->expects($this->never())->method('setShippingAddress'); $quoteMock->expects($this->never())->method('save'); $this->service->assign('cart867', $this->quoteAddressMock); @@ -131,25 +148,22 @@ public function testSetAddressForVirtualProduct() */ public function testSetAddressWithInabilityToSaveQuote() { + $this->quoteAddressMock->expects($this->once())->method('collectTotals')->willReturnSelf(); + $this->quoteAddressMock->expects($this->once())->method('save')->willThrowException( + new \Exception('Unable to save address. Please, check input data.') + ); + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') ->with('cart867') ->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); + $quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($this->quoteAddressMock); $this->validatorMock->expects($this->once())->method('validate') ->with($this->quoteAddressMock) ->will($this->returnValue(true)); - - $quoteMock->expects($this->once())->method('setShippingAddress')->with($this->quoteAddressMock); - $quoteMock->expects($this->once())->method('setDataChanges')->with(true); - $this->quoteRepositoryMock->expects($this->once()) - ->method('save') - ->with($quoteMock) - ->willThrowException( - new \Exception('Some DB Error') - ); $this->service->assign('cart867', $this->quoteAddressMock); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php index 99a375d651f0b..ef5992e11f7af 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php @@ -98,6 +98,7 @@ protected function setUp() 'requestShippingRates', 'setShippingMethod', '__wakeup', + 'getShippingRateByCode', ], [], '', @@ -137,77 +138,35 @@ public function testGetMethodWhenShippingAddressIsNotSet() $this->assertNull($this->model->get($cartId)); } - /** - * @expectedException \Magento\Framework\Exception\InputException - * @expectedExceptionMessage Line "WrongShippingMethod" doesn't contain delimiter _ - */ - public function testGetMethodWhenShippingMethodIsInvalid() - { - $cartId = 884; - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); - $this->shippingAddressMock->expects($this->once())->method('getCountryId')->will($this->returnValue(34)); - $this->shippingAddressMock->expects($this->exactly(2)) - ->method('getShippingMethod') - ->will($this->returnValue('WrongShippingMethod')); - - $this->assertNull($this->model->get($cartId)); - } - public function testGetMethod() { $cartId = 666; $countryId = 1; + $currencyCode = 'US_dollar'; $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock)); + $this->quoteMock->expects($this->once()) + ->method('getQuoteCurrencyCode')->willReturn($currencyCode); $this->shippingAddressMock->expects($this->any()) ->method('getCountryId')->will($this->returnValue($countryId)); $this->shippingAddressMock->expects($this->any()) ->method('getShippingMethod')->will($this->returnValue('one_two')); + + $this->shippingAddressMock->expects($this->once())->method('collectShippingRates')->willReturnSelf(); + $shippingRateMock = $this->getMock('\Magento\Quote\Model\Quote\Address\Rate', [], [], '', false); + $this->shippingAddressMock->expects($this->once()) - ->method('getShippingDescription')->will($this->returnValue('carrier - method')); - $this->shippingAddressMock->expects($this->once()) - ->method('getShippingAmount')->will($this->returnValue(123.56)); - $this->shippingAddressMock->expects($this->once()) - ->method('getBaseShippingAmount')->will($this->returnValue(100.06)); + ->method('getShippingRateByCode') + ->with('one_two') + ->willReturn($shippingRateMock); $this->shippingMethodMock = $this->getMock('\Magento\Quote\Api\Data\ShippingMethodInterface'); - - $this->methodDataFactoryMock->expects($this->once()) - ->method('create')->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setCarrierCode') - ->with('one') - ->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setMethodCode') - ->with('two') - ->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setCarrierTitle') - ->with('carrier') - ->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setMethodTitle') - ->with('method') - ->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setAmount') - ->with('123.56') - ->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setBaseAmount') - ->with('100.06') - ->willReturn($this->shippingMethodMock); - $this->shippingMethodMock->expects($this->once()) - ->method('setAvailable') - ->with(true) + $this->converterMock->expects($this->once()) + ->method('modelToDataObject') + ->with($shippingRateMock, $currencyCode) ->willReturn($this->shippingMethodMock); - $this->model->get($cartId); } @@ -421,7 +380,7 @@ public function testSetMethodWithNotFoundMethod() $this->shippingAddressMock->expects($this->once()) ->method('setShippingMethod')->with($carrierCode . '_' . $methodCode); $this->shippingAddressMock->expects($this->once()) - ->method('requestShippingRates')->will($this->returnValue(false)); + ->method('getShippingRateByCode')->will($this->returnValue(false)); $this->shippingAddressMock->expects($this->never())->method('save'); $this->model->set($cartId, $carrierCode, $methodCode); @@ -462,7 +421,7 @@ public function testSetMethodWithCouldNotSaveException() $this->shippingAddressMock->expects($this->once()) ->method('setShippingMethod')->with($carrierCode . '_' . $methodCode); $this->shippingAddressMock->expects($this->once()) - ->method('requestShippingRates')->will($this->returnValue(true)); + ->method('getShippingRateByCode')->will($this->returnValue(true)); $exception = new \Exception('Custom Error'); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnSelf()); $this->quoteRepositoryMock->expects($this->once()) @@ -523,7 +482,7 @@ public function testSetMethod() $this->shippingAddressMock->expects($this->once()) ->method('setShippingMethod')->with($carrierCode . '_' . $methodCode); $this->shippingAddressMock->expects($this->once()) - ->method('requestShippingRates')->will($this->returnValue(true)); + ->method('getShippingRateByCode')->will($this->returnValue(true)); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnSelf()); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); diff --git a/app/code/Magento/Quote/composer.json b/app/code/Magento/Quote/composer.json index 516cf07348c9b..0bc179a189f8d 100644 --- a/app/code/Magento/Quote/composer.json +++ b/app/code/Magento/Quote/composer.json @@ -3,25 +3,26 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-catalog-rule": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-authorization": "0.74.0-beta9", - "magento/module-payment": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-sales-sequence": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-catalog-rule": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-authorization": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-sales-sequence": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml index 0b46fc59fb7dc..a9c14a1991ffb 100644 --- a/app/code/Magento/Quote/etc/di.xml +++ b/app/code/Magento/Quote/etc/di.xml @@ -22,8 +22,9 @@ + - + @@ -34,6 +35,8 @@ + + @@ -51,4 +54,9 @@ Magento\Customer\Model\Address\Config\Proxy + + + + +
    diff --git a/app/code/Magento/Quote/etc/webapi.xml b/app/code/Magento/Quote/etc/webapi.xml index 9540a2d3b88aa..9b6ca15468d65 100644 --- a/app/code/Magento/Quote/etc/webapi.xml +++ b/app/code/Magento/Quote/etc/webapi.xml @@ -107,7 +107,7 @@ - + @@ -352,6 +352,12 @@ + + + + + + @@ -489,6 +495,15 @@ %cart_id% + + + + + + + %cart_id% + + @@ -505,6 +520,12 @@ + + + + + + @@ -524,4 +545,13 @@ %cart_id% + + + + + + + %cart_id% + + diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php index ddb112cd99363..9fe1fa27a2c48 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php @@ -127,12 +127,8 @@ protected function _prepareCollection() * Validate from and to date */ try { - $from = $this->_localeDate->date( - $this->getFilter('report_from'), - null, - false - ); - $to = $this->_localeDate->date($this->getFilter('report_to'), null, false); + $from = $this->_localeDate->scopeDate(null, $this->getFilter('report_from'), false); + $to = $this->_localeDate->scopeDate(null, $this->getFilter('report_to'), false); $collection->setInterval($from, $to); } catch (\Exception $e) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php deleted file mode 100644 index 9d2cde108b310..0000000000000 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php +++ /dev/null @@ -1,137 +0,0 @@ - - */ -class Grid extends \Magento\Backend\Block\Widget\Grid\Extended -{ - /** - * @var \Magento\Reports\Model\Resource\Product\CollectionFactory - */ - protected $_collectionFactory; - - /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Reports\Model\Resource\Product\CollectionFactory $collectionFactory - * @param array $data - */ - public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Backend\Helper\Data $backendHelper, - \Magento\Reports\Model\Resource\Product\CollectionFactory $collectionFactory, - array $data = [] - ) { - $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $backendHelper, $data); - } - - /** - * @return void - */ - protected function _construct() - { - parent::_construct(); - $this->setId('productsReportGrid'); - $this->setDefaultSort('entity_id'); - $this->setDefaultDir('desc'); - } - - /** - * @return \Magento\Backend\Block\Widget\Grid - */ - protected function _prepareCollection() - { - $collection = $this->_collectionFactory->create(); - $collection->getEntity()->setStore(0); - - $this->setCollection($collection); - - return parent::_prepareCollection(); - } - - /** - * @return void - */ - protected function _afterLoadCollection() - { - $totalObj = new \Magento\Reports\Model\Totals(); - $this->setTotals($totalObj->countTotals($this)); - } - - /** - * @return \Magento\Backend\Block\Widget\Grid\Extended - */ - protected function _prepareColumns() - { - $this->addColumn( - 'entity_id', - ['header' => __('ID'), 'width' => '50px', 'index' => 'entity_id', 'total' => 'Total'] - ); - - $this->addColumn('name', ['header' => __('Name'), 'index' => 'name']); - - $this->addColumn( - 'viewed', - [ - 'header' => __('Viewed'), - 'width' => '50px', - 'align' => 'right', - 'index' => 'viewed', - 'total' => 'sum' - ] - ); - - $this->addColumn( - 'added', - ['header' => __('Added'), 'width' => '50px', 'align' => 'right', 'index' => 'added', 'total' => 'sum'] - ); - - $this->addColumn( - 'purchased', - [ - 'header' => __('Purchased'), - 'width' => '50px', - 'align' => 'right', - 'index' => 'purchased', - 'total' => 'sum' - ] - ); - - $this->addColumn( - 'fulfilled', - [ - 'header' => __('Fulfilled'), - 'width' => '50px', - 'align' => 'right', - 'index' => 'fulfilled', - 'total' => 'sum' - ] - ); - - $this->addColumn( - 'revenue', - [ - 'header' => __('Revenue'), - 'width' => '50px', - 'align' => 'right', - 'index' => 'revenue', - 'total' => 'sum' - ] - ); - - $this->setCountTotals(true); - - $this->addExportType('*/*/exportProductsCsv', __('CSV')); - $this->addExportType('*/*/exportProductsExcel', __('Excel XML')); - - return parent::_prepareColumns(); - } -} diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php index d40166dff4bb5..59d5cef6ac745 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php @@ -8,6 +8,8 @@ /** * Adminhtml abandoned shopping carts report grid block * + * @method \Magento\Reports\Model\Resource\Quote\Collection getCollection + * * @author Magento Core Team * @SuppressWarnings(PHPMD.DepthOfInheritance) */ diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php index 347405789dc2e..53044f15068e6 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php @@ -16,7 +16,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart /** * @var \Magento\Reports\Model\Resource\Quote\CollectionFactory */ - protected $_quotesFactory; + protected $quoteItemCollectionFactory; /** * @var \Magento\Quote\Model\QueryResolver @@ -26,18 +26,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Reports\Model\Resource\Quote\CollectionFactoryInterface $quotesFactory + * @param \Magento\Reports\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory * @param \Magento\Quote\Model\QueryResolver $queryResolver * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, - \Magento\Reports\Model\Resource\Quote\CollectionFactoryInterface $quotesFactory, \Magento\Quote\Model\QueryResolver $queryResolver, + \Magento\Reports\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory, array $data = [] ) { - $this->_quotesFactory = $quotesFactory; + $this->quoteItemCollectionFactory = $quoteItemCollectionFactory; $this->queryResolver = $queryResolver; parent::__construct($context, $backendHelper, $data); } @@ -56,7 +56,8 @@ protected function _construct() */ protected function _prepareCollection() { - $collection = $this->_quotesFactory->create(); + /** @var \Magento\Reports\Model\Resource\Quote\Item\Collection $collection */ + $collection = $this->quoteItemCollectionFactory->create(); $collection->prepareActiveCartItems(); $this->setCollection($collection); return parent::_prepareCollection(); @@ -68,11 +69,11 @@ protected function _prepareCollection() protected function _prepareColumns() { $this->addColumn( - 'entity_id', + 'product_id', [ 'header' => __('ID'), 'align' => 'right', - 'index' => 'entity_id', + 'index' => 'product_id', 'sortable' => false, 'header_css_class' => 'col-id', 'column_css_class' => 'col-id' @@ -146,6 +147,6 @@ protected function _prepareColumns() */ public function getRowUrl($row) { - return $this->getUrl('catalog/product/edit', ['id' => $row->getEntityId()]); + return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]); } } diff --git a/app/code/Magento/Reports/Block/Product/Viewed.php b/app/code/Magento/Reports/Block/Product/Viewed.php index addfa8cafd53a..947c90c89505c 100644 --- a/app/code/Magento/Reports/Block/Product/Viewed.php +++ b/app/code/Magento/Reports/Block/Product/Viewed.php @@ -13,7 +13,7 @@ * * @author Magento Core Team */ -class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \Magento\Framework\View\Block\IdentityInterface +class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \Magento\Framework\Object\IdentityInterface { const XML_PATH_RECENTLY_VIEWED_COUNT = 'catalog/recently_products/viewed_count'; diff --git a/app/code/Magento/Reports/Model/Resource/Helper.php b/app/code/Magento/Reports/Model/Resource/Helper.php index 08387fcd26d8c..10b1533f42258 100644 --- a/app/code/Magento/Reports/Model/Resource/Helper.php +++ b/app/code/Magento/Reports/Model/Resource/Helper.php @@ -37,17 +37,10 @@ public function mergeVisitorProductIndex($mainTable, $data, $matchFields) } /** - * Update rating position - * - * @param string $type day|month|year - * @param string $column - * @param string $mainTable - * @param string $aggregationTable - * @return $this + * @inheritdoc */ - public function updateReportRatingPos($type, $column, $mainTable, $aggregationTable) + public function updateReportRatingPos($adapter, $type, $column, $mainTable, $aggregationTable) { - $adapter = $this->_getWriteAdapter(); $periodSubSelect = $adapter->select(); $ratingSubSelect = $adapter->select(); $ratingSelect = $adapter->select(); diff --git a/app/code/Magento/Reports/Model/Resource/HelperInterface.php b/app/code/Magento/Reports/Model/Resource/HelperInterface.php index efac474d6d53c..511553db7d508 100644 --- a/app/code/Magento/Reports/Model/Resource/HelperInterface.php +++ b/app/code/Magento/Reports/Model/Resource/HelperInterface.php @@ -24,11 +24,12 @@ public function mergeVisitorProductIndex($mainTable, $data, $matchFields); /** * Update rating position * - * @param string $type day|month|year + * @param \Magento\Framework\DB\Adapter\AdapterInterface $adapter + * @param string $type * @param string $column * @param string $mainTable * @param string $aggregationTable - * @return \Magento\Framework\DB\Helper\AbstractHelper + * @return $this */ - public function updateReportRatingPos($type, $column, $mainTable, $aggregationTable); + public function updateReportRatingPos($adapter, $type, $column, $mainTable, $aggregationTable); } diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 0dd3a60c83761..60b24016381f6 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -457,9 +457,6 @@ public function getDateRange($range, $customStart, $customEnd, $returnObjects = break; } - $dateStart->setTimezone(new \DateTimeZone('Etc/UTC')); - $dateEnd->setTimezone(new \DateTimeZone('Etc/UTC')); - if ($returnObjects) { return [$dateStart, $dateEnd]; } else { @@ -900,8 +897,8 @@ public function addCreateAtPeriodFilter($period) $this->addFieldToFilter( $fieldToFilter, [ - 'from' => $from->format(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT), - 'to' => $to->format(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) + 'from' => $from->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT), + 'to' => $to->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT) ] ); 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 0c71c26aa69eb..78c758649b49c 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -297,7 +297,7 @@ public function useNotifyStockQtyFilter($storeId = null) (int)$this->stockConfiguration->getNotifyStockQty($storeId), $this->_getInventoryItemField('notify_stock_qty') ); - $this->getSelect()->where('qty < ?', $notifyStockExpr); + $this->getSelect()->where($this->_getInventoryItemField('qty') . ' < ?', $notifyStockExpr); return $this; } } diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php index ea190558cac88..6054469f4afc3 100644 --- a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php @@ -3,96 +3,35 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - -/** - * Reports quote collection - * - * @author Magento Core Team - */ namespace Magento\Reports\Model\Resource\Quote; -/** - * Class Collection - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ class Collection extends \Magento\Quote\Model\Resource\Quote\Collection { - const SELECT_COUNT_SQL_TYPE_CART = 1; - - /** - * @var int - */ - protected $_selectCountSqlType = 0; - - /** - * Join fields - * - * @var array - */ - protected $_joinedFields = []; - - /** - * Map - * - * @var array - */ - protected $_map = ['fields' => ['store_id' => 'main_table.store_id']]; - - /** - * @var \Magento\Catalog\Model\Resource\Product\Collection - */ - protected $productResource; - /** * @var \Magento\Customer\Model\Resource\Customer */ protected $customerResource; /** - * @var \Magento\Sales\Model\Resource\Order\Collection - */ - protected $orderResource; - - /** - * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory + * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Catalog\Model\Resource\Product\Collection $productResource * @param \Magento\Customer\Model\Resource\Customer $customerResource - * @param \Magento\Sales\Model\Resource\Order\Collection $orderResource - * @param null $connection + * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ public function __construct( - \Magento\Framework\Data\Collection\EntityFactory $entityFactory, + \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Catalog\Model\Resource\Product\Collection $productResource, \Magento\Customer\Model\Resource\Customer $customerResource, - \Magento\Sales\Model\Resource\Order\Collection $orderResource, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); - $this->productResource = $productResource; $this->customerResource = $customerResource; - $this->orderResource = $orderResource; - } - - /** - * Set type for COUNT SQL select - * - * @param int $type - * @return $this - */ - public function setSelectCountSqlType($type) - { - $this->_selectCountSqlType = $type; - return $this; } /** @@ -129,89 +68,6 @@ public function prepareForAbandonedReport($storeIds, $filter = null) return $this; } - /** - * Prepare select query for products in carts report - * - * @return \Magento\Framework\DB\Select - */ - public function prepareActiveCartItems() - { - $quoteItemsSelect = $this->getSelect(); - $quoteItemsSelect->reset() - ->from(['main_table' => $this->getTable('quote')], '') - ->columns('quote_items.product_id') - ->columns(['carts' => new \Zend_Db_Expr('COUNT(quote_items.item_id)')]) - ->columns('main_table.base_to_global_rate') - ->joinInner( - ['quote_items' => $this->getTable('quote_item')], - 'quote_items.quote_id = main_table.entity_id', - null - )->where( - 'main_table.is_active = ?', - 1 - )->group( - 'quote_items.product_id' - ); - - return $quoteItemsSelect; - } - - /** - * Orders quantity data - * - * @param array $productIds - * @return array - */ - protected function getOrdersData(array $productIds) - { - $ordersSubSelect = clone $this->orderResource->getSelect(); - $ordersSubSelect->reset()->from( - ['oi' => $this->getTable('sales_order_item')], - ['product_id', 'orders' => new \Zend_Db_Expr('COUNT(1)')] - )->where('oi.product_id IN (?)', $productIds)->group( - 'oi.product_id' - ); - - return $this->orderResource->getConnection()->fetchAssoc($ordersSubSelect); - } - - /** - * Add store ids to filter - * - * @param array $storeIds - * @return $this - */ - public function addStoreFilter($storeIds) - { - $this->addFieldToFilter('store_id', ['in' => $storeIds]); - return $this; - } - - /** - * Add customer data - * - * @param array|null $filter - * @return $this - */ - public function addCustomerData($filter = null) - { - $customersSelect = $this->customerResource->getReadConnection()->select(); - $customersSelect->from(['customer' => 'customer_entity'], 'entity_id'); - if (isset($filter['customer_name'])) { - $customersSelect = $this->getCustomerNames($customersSelect); - $customerName = $customersSelect->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' '); - $customersSelect->where( - $customerName . ' LIKE ?', '%' . $filter['customer_name'] . '%' - ); - } - if (isset($filter['email'])) { - $customersSelect->where('customer.email LIKE ?', '%' . $filter['email'] . '%'); - } - $filteredCustomers = $this->customerResource->getReadConnection()->fetchCol($customersSelect); - $this->getSelect()->where('main_table.customer_id IN (?)', $filteredCustomers); - return $this; - } - /** * Add subtotals * @@ -225,7 +81,8 @@ public function addSubtotal($storeIds = '', $filter = null) $this->getSelect()->columns( ['subtotal' => '(main_table.base_subtotal_with_discount*main_table.base_to_global_rate)'] ); - $this->_joinedFields['subtotal'] = '(main_table.base_subtotal_with_discount*main_table.base_to_global_rate)'; + $this->_joinedFields['subtotal'] = + '(main_table.base_subtotal_with_discount*main_table.base_to_global_rate)'; } else { $this->getSelect()->columns(['subtotal' => 'main_table.base_subtotal_with_discount']); $this->_joinedFields['subtotal'] = 'main_table.base_subtotal_with_discount'; @@ -252,17 +109,32 @@ public function addSubtotal($storeIds = '', $filter = null) } /** - * Get select count sql + * Resolve customers data based on ids quote table. * - * @return \Magento\Framework\DB\Select + * @return void */ - public function getSelectCountSql() + public function resolveCustomerNames() { - $countSelect = clone $this->prepareActiveCartItems(); - $countSelect->reset(\Zend_Db_Select::COLUMNS) - ->reset(\Zend_Db_Select::GROUP) - ->columns('COUNT(DISTINCT quote_items.product_id)'); - return $countSelect; + $select = $this->customerResource->getReadConnection()->select(); + $customerName = $select->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' '); + + $select->from( + ['customer' => $this->customerResource->getTable('customer_entity')] + )->columns( + ['customer_name' => $customerName] + )->where( + 'customer.entity_id IN (?)', + array_column( + $this->getData(), + 'customer_id' + ) + ); + $customersData = $select->getAdapter()->fetchAll($this->getCustomerNames($select)); + + foreach ($this->getItems() as $item) { + $item->setData(array_merge($item->getData(), current($customersData))); + next($customersData); + } } /** @@ -286,100 +158,38 @@ protected function getCustomerNames($select) 'customer.entity_id = cust_lname.entity_id', ['lastname' => 'cust_lname.value'] )->where( - 'cust_fname.attribute_id = ?', (int)$attrFirstnameId + 'cust_fname.attribute_id = ?', + (int)$attrFirstnameId )->where( - 'cust_lname.attribute_id = ?', (int)$attrLastnameId + 'cust_lname.attribute_id = ?', + (int)$attrLastnameId ); return $select; } /** - * Resolve customers data based on ids quote table. - * - * @return void - */ - public function resolveCustomerNames() - { - $select = $this->customerResource->getReadConnection()->select(); - $customerName = $select->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' '); - - $select->from( - ['customer' => 'customer_entity'] - )->columns( - ['customer_name' => $customerName] - )->where( - 'customer.entity_id IN (?)', array_column($this->getData(), 'customer_id') - ); - $customersData = $select->getAdapter()->fetchAll($this->getCustomerNames($select)); - - foreach($this->getItems() as $item) { - $item->setData(array_merge($item->getData(), current($customersData))); - next($customersData); - } - } - - /** - * Separate query for product and order data - * - * @param array $productIds - * @return array - * @throws \Magento\Framework\Exception\LocalizedException - */ - protected function getProductData(array $productIds) - { - $productConnection = $this->productResource->getConnection('read'); - $productAttrName = $this->productResource->getAttribute('name'); - $productAttrNameId = (int)$productAttrName->getAttributeId(); - $productAttrPrice = $this->productResource->getAttribute('price'); - $productAttrPriceId = (int)$productAttrPrice->getAttributeId(); - - $select = clone $this->productResource->getSelect(); - $select->reset(); - $select->from( - ['main_table' => $this->getTable('catalog_product_entity')] - )->useStraightJoin( - true - )->joinInner( - ['product_name' => $productAttrName->getBackend()->getTable()], - 'product_name.entity_id = main_table.entity_id' - . ' AND product_name.attribute_id = ' . $productAttrNameId - . ' AND product_name.store_id = ' . \Magento\Store\Model\Store::DEFAULT_STORE_ID, - ['name' => 'product_name.value'] - )->joinInner( - ['product_price' => $productAttrPrice->getBackend()->getTable()], - "product_price.entity_id = main_table.entity_id AND product_price.attribute_id = {$productAttrPriceId}", - ['price' => new \Zend_Db_Expr('product_price.value')] - )->where('main_table.entity_id IN (?)', $productIds); - - $productData = $productConnection->fetchAssoc($select); - return $productData; - } - - /** - * Add data fetched from another database + * Add customer data * + * @param array|null $filter * @return $this */ - protected function _afterLoad() + public function addCustomerData($filter = null) { - parent::_afterLoad(); - $items = $this->getItems(); - $productIds = []; - foreach ($items as $item) { - $productIds[] = $item->getProductId(); + $customersSelect = $this->customerResource->getReadConnection()->select(); + $customersSelect->from(['customer' => $this->getTable('customer_entity')], 'entity_id'); + if (isset($filter['customer_name'])) { + $customersSelect = $this->getCustomerNames($customersSelect); + $customerName = $customersSelect->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' '); + $customersSelect->where( + $customerName . ' LIKE ?', + '%' . $filter['customer_name'] . '%' + ); } - $productData = $this->getProductData($productIds); - $orderData = $this->getOrdersData($productIds); - foreach ($items as $item) { - $item->setId($item->getProductId()); - $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate()); - $item->setName($productData[$item->getProductId()]['name']); - $item->setOrders(0); - if (isset($orderData[$item->getProductId()])) { - $item->setOrders($orderData[$item->getProductId()]['orders']); - } + if (isset($filter['email'])) { + $customersSelect->where('customer.email LIKE ?', '%' . $filter['email'] . '%'); } - + $filteredCustomers = $this->customerResource->getReadConnection()->fetchCol($customersSelect); + $this->getSelect()->where('main_table.customer_id IN (?)', $filteredCustomers); return $this; } } diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Item/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Item/Collection.php new file mode 100644 index 0000000000000..63c1a45f5132c --- /dev/null +++ b/app/code/Magento/Reports/Model/Resource/Quote/Item/Collection.php @@ -0,0 +1,227 @@ + ['store_id' => 'main_table.store_id']]; + + /** + * @var \Magento\Catalog\Model\Resource\Product\Collection + */ + protected $productResource; + + /** + * @var \Magento\Customer\Model\Resource\Customer + */ + protected $customerResource; + + /** + * @var \Magento\Sales\Model\Resource\Order\Collection + */ + protected $orderResource; + + /** + * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory + * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Catalog\Model\Resource\Product\Collection $productResource + * @param \Magento\Customer\Model\Resource\Customer $customerResource + * @param \Magento\Sales\Model\Resource\Order\Collection $orderResource + * @param \Zend_Db_Adapter_Abstract $connection + * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource + */ + public function __construct( + \Magento\Framework\Data\Collection\EntityFactory $entityFactory, + \Psr\Log\LoggerInterface $logger, + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Catalog\Model\Resource\Product\Collection $productResource, + \Magento\Customer\Model\Resource\Customer $customerResource, + \Magento\Sales\Model\Resource\Order\Collection $orderResource, + $connection = null, + \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null + ) { + parent::__construct( + $entityFactory, + $logger, + $fetchStrategy, + $eventManager, + $connection, + $resource + ); + $this->productResource = $productResource; + $this->customerResource = $customerResource; + $this->orderResource = $orderResource; + } + + /** + * Resource initialization + * + * @return void + */ + protected function _construct() + { + $this->_init('Magento\Quote\Model\Quote\Item', 'Magento\Quote\Model\Resource\Quote\Item'); + } + + + /** + * Prepare select query for products in carts report + * + * @return \Magento\Framework\DB\Select + */ + public function prepareActiveCartItems() + { + $quoteItemsSelect = $this->getSelect(); + $quoteItemsSelect->reset() + ->from(['main_table' => $this->getTable('quote_item')], '') + ->columns('main_table.product_id') + ->columns(['carts' => new \Zend_Db_Expr('COUNT(main_table.item_id)')]) + ->columns('quote.base_to_global_rate') + ->joinInner( + ['quote' => $this->getTable('quote')], + 'main_table.quote_id = quote.entity_id', + null + )->where( + 'quote.is_active = ?', + 1 + )->group( + 'main_table.product_id' + ); + + return $quoteItemsSelect; + } + + /** + * Orders quantity data + * + * @param array $productIds + * @return array + */ + protected function getOrdersData(array $productIds) + { + $ordersSubSelect = clone $this->orderResource->getSelect(); + $ordersSubSelect->reset()->from( + ['oi' => $this->getTable('sales_order_item')], + ['product_id', 'orders' => new \Zend_Db_Expr('COUNT(1)')] + )->where('oi.product_id IN (?)', $productIds)->group( + 'oi.product_id' + ); + + return $this->orderResource->getConnection()->fetchAssoc($ordersSubSelect); + } + + /** + * Add store ids to filter + * + * @param array $storeIds + * @return $this + */ + public function addStoreFilter($storeIds) + { + $this->addFieldToFilter('store_id', ['in' => $storeIds]); + return $this; + } + + /** + * Get select count sql + * + * @return \Magento\Framework\DB\Select + */ + public function getSelectCountSql() + { + $countSelect = clone $this->prepareActiveCartItems(); + $countSelect->reset(\Zend_Db_Select::COLUMNS) + ->reset(\Zend_Db_Select::GROUP) + ->columns('COUNT(DISTINCT main_table.product_id)'); + return $countSelect; + } + + /** + * Separate query for product and order data + * + * @param array $productIds + * @return array + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function getProductData(array $productIds) + { + $productConnection = $this->productResource->getConnection('read'); + $productAttrName = $this->productResource->getAttribute('name'); + $productAttrNameId = (int)$productAttrName->getAttributeId(); + $productAttrPrice = $this->productResource->getAttribute('price'); + $productAttrPriceId = (int)$productAttrPrice->getAttributeId(); + + $select = clone $this->productResource->getSelect(); + $select->reset(); + $select->from( + ['main_table' => $this->getTable('catalog_product_entity')] + )->useStraightJoin( + true + )->joinInner( + ['product_name' => $productAttrName->getBackend()->getTable()], + 'product_name.entity_id = main_table.entity_id' + . ' AND product_name.attribute_id = ' . $productAttrNameId + . ' AND product_name.store_id = ' . \Magento\Store\Model\Store::DEFAULT_STORE_ID, + ['name' => 'product_name.value'] + )->joinInner( + ['product_price' => $productAttrPrice->getBackend()->getTable()], + "product_price.entity_id = main_table.entity_id AND product_price.attribute_id = {$productAttrPriceId}", + ['price' => new \Zend_Db_Expr('product_price.value')] + )->where('main_table.entity_id IN (?)', $productIds); + + $productData = $productConnection->fetchAssoc($select); + return $productData; + } + + /** + * Add data fetched from another database + * + * @return $this + */ + protected function _afterLoad() + { + parent::_afterLoad(); + $items = $this->getItems(); + $productIds = []; + foreach ($items as $item) { + $productIds[] = $item->getProductId(); + } + $productData = $this->getProductData($productIds); + $orderData = $this->getOrdersData($productIds); + foreach ($items as $item) { + $item->setId($item->getProductId()); + $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate()); + $item->setName($productData[$item->getProductId()]['name']); + $item->setOrders(0); + if (isset($orderData[$item->getProductId()])) { + $item->setOrders($orderData[$item->getProductId()]['orders']); + } + } + + return $this; + } +} diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php index 8e11e8f401f4f..84a6d7d6a25ef 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php @@ -138,6 +138,7 @@ protected function _truncateTable($table) * @param null|string $to * @param null|\Zend_Db_Select|string $subSelect * @param bool $doNotUseTruncate + * @param \Magento\Framework\DB\Adapter\AdapterInterface $adapter * @return $this */ protected function _clearTableByDateRange( @@ -145,7 +146,8 @@ protected function _clearTableByDateRange( $from = null, $to = null, $subSelect = null, - $doNotUseTruncate = false + $doNotUseTruncate = false, + $adapter = null ) { if ($from === null && $to === null && !$doNotUseTruncate) { $this->_truncateTable($table); @@ -153,7 +155,7 @@ protected function _clearTableByDateRange( } if ($subSelect !== null) { - $deleteCondition = $this->_makeConditionFromDateRangeSelect($subSelect, 'period'); + $deleteCondition = $this->_makeConditionFromDateRangeSelect($subSelect, 'period', $adapter); } else { $condition = []; if ($from !== null) { @@ -229,17 +231,24 @@ protected function _getTableDateRangeSelect( * * @param \Magento\Framework\DB\Select $select * @param string $periodColumn + * @param \Magento\Framework\DB\Adapter\AdapterInterface $adapter * @return array|bool|string */ - protected function _makeConditionFromDateRangeSelect($select, $periodColumn) + protected function _makeConditionFromDateRangeSelect($select, $periodColumn, $adapter = null) { + if (!$adapter) { + $adapter = $this->_getReadAdapter(); + } + static $selectResultCache = []; $cacheKey = (string)$select; if (!array_key_exists($cacheKey, $selectResultCache)) { try { $selectResult = []; - $query = $this->_getReadAdapter()->query($select); + + $query = $adapter->query($select); + while (true == ($date = $query->fetchColumn())) { $selectResult[] = $date; } @@ -255,7 +264,7 @@ protected function _makeConditionFromDateRangeSelect($select, $periodColumn) } $whereCondition = []; - $adapter = $this->_getReadAdapter(); + foreach ($selectResult as $date) { $whereCondition[] = $adapter->prepareSqlCondition($periodColumn, ['like' => $date]); } @@ -349,15 +358,26 @@ protected function _getTableDateRangeRelatedSelect( * @param null|mixed $from * @param null|mixed $to * @param null|int|string|\Magento\Store\Model\Store $store + * @param \Magento\Framework\DB\Adapter\AdapterInterface $adapter * @return string */ - public function getStoreTZOffsetQuery($table, $column, $from = null, $to = null, $store = null) - { - $column = $this->_getWriteAdapter()->quoteIdentifier($column); + public function getStoreTZOffsetQuery( + $table, + $column, + $from = null, + $to = null, + $store = null, + $adapter = null + ) { + if (!$adapter) { + $adapter = $this->_getWriteAdapter(); + } + + $column = $adapter->quoteIdentifier($column); if (null === $from) { - $selectOldest = $this->_getWriteAdapter()->select()->from($table, ["MIN({$column})"]); - $from = $this->_getWriteAdapter()->fetchOne($selectOldest); + $selectOldest = $adapter->select()->from($table, ["MIN({$column})"]); + $from = $adapter->fetchOne($selectOldest); } $periods = $this->_getTZOffsetTransitions( @@ -379,7 +399,7 @@ public function getStoreTZOffsetQuery($table, $column, $from = null, $to = null, $subParts[] = "({$column} between {$ts['from']} and {$ts['to']})"; } - $then = $this->_getWriteAdapter()->getDateAddSql( + $then = $adapter->getDateAddSql( $column, $offset, \Magento\Framework\DB\Adapter\AdapterInterface::INTERVAL_SECOND @@ -445,37 +465,4 @@ protected function _getTZOffsetTransitions($timezone, $from = null, $to = null) return $tzTransitions; } - - /** - * Retrieve store timezone offset from UTC in the form acceptable by SQL's CONVERT_TZ() - * - * @param null|mixed $store - * @return string - */ - protected function _getStoreTimezoneUtcOffset($store = null) - { - return $this->_localeDate->scopeDate($store)->format('P'); - } - - /** - * Retrieve date in UTC timezone - * - * @param mixed $date - * @return null|\DateTime - */ - protected function _dateToUtc($date) - { - if ($date === null) { - return null; - } - - if ($date instanceof \DateTimeInterface) { - $dateUtc = $date; - } else { - $dateUtc = new \DateTime($date); - } - - $dateUtc->setTimezone(new \DateTimeZone('UTC')); - return $dateUtc->format('Y-m-d H:i:s'); - } } diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection.php index c8ee5836cf242..2de5f389f2524 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection.php @@ -174,7 +174,7 @@ protected function _getDayInterval(\DateTime $dateStart) \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE ), - 'start' => $dateStart->format('Y-m-d H:i:s'), + 'start' => $dateStart->format('Y-m-d 00:00:00'), 'end' => $dateStart->format('Y-m-d 23:59:59'), ]; return $interval; @@ -325,12 +325,7 @@ protected function _getReport($fromDate, $toDate) return []; } $reportResource = $this->_collectionFactory->create($this->_reportCollection); - $reportResource->setDateRange( - $this->timeShift($fromDate), - $this->timeShift($toDate) - )->setStoreIds( - $this->getStoreIds() - ); + $reportResource->setDateRange($fromDate, $toDate)->setStoreIds($this->getStoreIds()); return $reportResource; } @@ -354,20 +349,7 @@ public function getReports() } return $this->_reports; } - - /** - * Retrieve time shift - * - * @param string $datetime - * @return string - */ - public function timeShift($datetime) - { - return $this->_localeDate->scopeDate(null, $datetime, true) - ->setTimezone(new \DateTimeZone('UTC')) - ->format('Y-m-d H:i:s'); - } - + /** * Load data * diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php index 9ebd26efbd7e7..56e658e56db51 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php @@ -98,10 +98,6 @@ public function aggregate($from = null, $to = null) $mainTable = $this->getMainTable(); $adapter = $this->_getWriteAdapter(); - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - if ($from !== null || $to !== null) { $subSelect = $this->_getTableDateRangeSelect( $this->getTable('report_event'), @@ -114,7 +110,7 @@ public function aggregate($from = null, $to = null) $subSelect = null; } $this->_clearTableByDateRange($mainTable, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( ['source_table' => $this->getTable('report_event')], @@ -222,12 +218,28 @@ public function aggregate($from = null, $to = null) $insertQuery = $select->insertFromSelect($this->getMainTable(), array_keys($columns)); $adapter->query($insertQuery); - $this->_resourceHelper->updateReportRatingPos('day', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_DAILY)); - $this->_resourceHelper->updateReportRatingPos('month', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_MONTHLY)); - $this->_resourceHelper->updateReportRatingPos('year', 'views_num', $mainTable, $this->getTable(self::AGGREGATION_YEARLY)); - + $this->_resourceHelper->updateReportRatingPos( + $adapter, + 'day', + 'views_num', + $mainTable, + $this->getTable(self::AGGREGATION_DAILY) + ); + $this->_resourceHelper->updateReportRatingPos( + $adapter, + 'month', + 'views_num', + $mainTable, + $this->getTable(self::AGGREGATION_MONTHLY) + ); + $this->_resourceHelper->updateReportRatingPos( + $adapter, + 'year', + 'views_num', + $mainTable, + $this->getTable(self::AGGREGATION_YEARLY) + ); $this->_setFlagData(\Magento\Reports\Model\Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE); - return $this; } } diff --git a/app/code/Magento/Reports/Model/Totals.php b/app/code/Magento/Reports/Model/Totals.php deleted file mode 100644 index 75fbaaed53317..0000000000000 --- a/app/code/Magento/Reports/Model/Totals.php +++ /dev/null @@ -1,76 +0,0 @@ - - */ -class Totals -{ - /** - * Retrieve count totals - * - * @param \Magento\Backend\Block\Widget\Grid $grid - * @param string $from - * @param string $to - * @return \Magento\Framework\Object - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function countTotals($grid, $from, $to) - { - $columns = []; - foreach ($grid->getColumns() as $col) { - $columns[$col->getIndex()] = ["total" => $col->getTotal(), "value" => 0]; - } - - $count = 0; - /** - * This method doesn't work because of commit 6e15235, see MAGETWO-4751 - */ - $report = $grid->getCollection()->getReportFull($from, $to); - foreach ($report as $item) { - if ($grid->getSubReportSize() && $count >= $grid->getSubReportSize()) { - continue; - } - $data = $item->getData(); - - foreach ($columns as $field => $a) { - if ($field !== '') { - $columns[$field]['value'] = $columns[$field]['value'] + (isset($data[$field]) ? $data[$field] : 0); - } - } - $count++; - } - $data = []; - foreach ($columns as $field => $a) { - if ($a['total'] == 'avg') { - if ($field !== '') { - if ($count != 0) { - $data[$field] = $a['value'] / $count; - } else { - $data[$field] = 0; - } - } - } elseif ($a['total'] == 'sum') { - if ($field !== '') { - $data[$field] = $a['value']; - } - } elseif (strpos($a['total'], '/') !== false) { - if ($field !== '') { - $data[$field] = 0; - } - } - } - - $totals = new \Magento\Framework\Object(); - $totals->setData($data); - - return $totals; - } -} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php index d3b7eadd6da68..9e9363ce7bfd0 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php @@ -33,17 +33,17 @@ public function testGetSelectCountSql() ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Collection'); $collection = $this->getMock( 'Magento\Reports\Model\Resource\Quote\Collection', - ['prepareActiveCartItems', 'getSelect'], + ['getSelect'], $constructArgs, '', false ); - $collection->expects($this->once())->method('prepareActiveCartItems')->willReturn($this->selectMock); + $collection->expects($this->once())->method('getSelect')->willReturn($this->selectMock); $this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf(); $this->selectMock->expects($this->once()) ->method('columns') - ->with('COUNT(DISTINCT quote_items.product_id)') + ->with('COUNT(*)') ->willReturnSelf(); $this->assertEquals($this->selectMock, $collection->getSelectCountSql()); } @@ -52,9 +52,9 @@ public function testPrepareActiveCartItems() { /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ $constructArgs = $this->objectManager - ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Collection'); + ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Item\Collection'); $collection = $this->getMock( - 'Magento\Reports\Model\Resource\Quote\Collection', + 'Magento\Reports\Model\Resource\Quote\Item\Collection', ['getSelect', 'getTable'], $constructArgs, '', @@ -76,7 +76,7 @@ public function testLoadWithFilter() { /** @var $collection \PHPUnit_Framework_MockObject_MockObject */ $constructArgs = $this->objectManager - ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Collection'); + ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Item\Collection'); $constructArgs['eventManager'] = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); $readConnectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); $resourceMock = $this->getMock('\Magento\Quote\Model\Resource\Quote', [], [], '', false); @@ -87,7 +87,7 @@ public function testLoadWithFilter() $constructArgs['orderResource'] = $orderResourceMock; $collection = $this->getMock( - 'Magento\Reports\Model\Resource\Quote\Collection', + 'Magento\Reports\Model\Resource\Quote\Item\Collection', [ '_beforeLoad', '_renderFilters', diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 32ac6df61c461..eb7f5031f65c0 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-log": "0.74.0-beta9", - "magento/module-wishlist": "0.74.0-beta9", - "magento/module-review": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-downloadable": "0.74.0-beta9", - "magento/module-sales-rule": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-log": "0.74.0-beta11", + "magento/module-wishlist": "0.74.0-beta11", + "magento/module-review": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-downloadable": "0.74.0-beta11", + "magento/module-sales-rule": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Reports/view/adminhtml/templates/grid.phtml b/app/code/Magento/Reports/view/adminhtml/templates/grid.phtml index 8d8ee2a1a08b6..6975919f29f46 100644 --- a/app/code/Magento/Reports/view/adminhtml/templates/grid.phtml +++ b/app/code/Magento/Reports/view/adminhtml/templates/grid.phtml @@ -12,147 +12,147 @@ $numColumns = sizeof($block->getColumns()); ?> getCollection()): ?> -canDisplayContainer()): ?> + canDisplayContainer()): ?>
    - - getLayout()->getMessagesBlock()->getGroupedHtml() ?> - -getStoreSwitcherVisibility() || $block->getDateFilterVisibility()): ?> -
    - getChildBlock('grid.export')): ?> -
    - getChildHtml('grid.export');?> -
    + + getLayout()->getMessagesBlock()->getGroupedHtml() ?> - getDateFilterVisibility()): ?> -
    -
    - -
    + getStoreSwitcherVisibility() || $block->getDateFilterVisibility()): ?> +
    +
    + getDateFilterVisibility()): ?> +
    + + + + + -
    - -
    + + + + + -
    - - getRefreshButtonHtml() ?> -
    - -
    + $("#getSuffixId('period_date_range') ?>").dateRange({ + dateFormat:"getDateFormat() ?>", + buttonText:"", + from:{ + id:"getSuffixId('period_date_from')?>" + }, + to:{ + id:"getSuffixId('period_date_to')?>" + } + }); + }); + +
    + + getChildBlock('grid.export')): ?> + getChildHtml('grid.export');?> + +
    +
    -
    - -
    -
    -
    escapeHtml($_label)?>:
    - +
    +
    getChildHtml('grid.columnSet'); ?>
    - -canDisplayContainer()): ?> - + }); + diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index c97ad177436bc..631f931f08154 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php index eee22e93bf790..19936996166f1 100644 --- a/app/code/Magento/Review/Block/Customer/ListCustomer.php +++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php @@ -62,7 +62,6 @@ public function __construct( $data ); $this->currentCustomer = $currentCustomer; - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php index 7cd61cd717e8e..f8b66f7ce13a0 100644 --- a/app/code/Magento/Review/Block/Customer/Recent.php +++ b/app/code/Magento/Review/Block/Customer/Recent.php @@ -53,7 +53,6 @@ public function __construct( $this->_collectionFactory = $collectionFactory; parent::__construct($context, $data); $this->currentCustomer = $currentCustomer; - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php index 3bab2ed7c7c79..b7d0c5f76347f 100644 --- a/app/code/Magento/Review/Block/Customer/View.php +++ b/app/code/Magento/Review/Block/Customer/View.php @@ -83,7 +83,6 @@ public function __construct( $context, $data ); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php index cf506a09857d5..5ec35d980c9d2 100644 --- a/app/code/Magento/Review/Block/Form.php +++ b/app/code/Magento/Review/Block/Form.php @@ -25,13 +25,6 @@ class Form extends \Magento\Framework\View\Element\Template */ protected $_reviewData = null; - /** - * Customer session model - * - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - /** * Catalog product model * @@ -46,13 +39,6 @@ class Form extends \Magento\Framework\View\Element\Template */ protected $_ratingFactory; - /** - * Review session model - * - * @var \Magento\Review\Model\Session - */ - protected $_reviewSession; - /** * @var \Magento\Framework\Url\EncoderInterface */ @@ -75,12 +61,15 @@ class Form extends \Magento\Framework\View\Element\Template */ protected $customerUrl; + /** + * @var array + */ + protected $jsLayout; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Url\EncoderInterface $urlEncoder - * @param \Magento\Framework\Session\Generic $reviewSession * @param \Magento\Review\Helper\Data $reviewData - * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager @@ -92,9 +81,7 @@ class Form extends \Magento\Framework\View\Element\Template public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Url\EncoderInterface $urlEncoder, - \Magento\Framework\Session\Generic $reviewSession, \Magento\Review\Helper\Data $reviewData, - \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Review\Model\RatingFactory $ratingFactory, \Magento\Framework\Message\ManagerInterface $messageManager, @@ -103,16 +90,14 @@ public function __construct( array $data = [] ) { $this->urlEncoder = $urlEncoder; - $this->_reviewSession = $reviewSession; $this->_reviewData = $reviewData; - $this->_customerSession = $customerSession; $this->productRepository = $productRepository; $this->_ratingFactory = $ratingFactory; $this->messageManager = $messageManager; $this->httpContext = $httpContext; $this->customerUrl = $customerUrl; parent::__construct($context, $data); - $this->_isScopePrivate = true; + $this->jsLayout = isset($data['jsLayout']) ? $data['jsLayout'] : []; } /** @@ -124,17 +109,6 @@ protected function _construct() { parent::_construct(); - $data = $this->_reviewSession->getFormData(true); - $data = new \Magento\Framework\Object((array)$data); - - // add logged in customer name as nickname - if (!$data->getNickname()) { - $customer = $this->_customerSession->getCustomerDataObject(); - if ($customer && $customer->getId()) { - $data->setNickname($customer->getFirstname()); - } - } - $this->setAllowWriteReviewFlag( $this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite() @@ -151,8 +125,15 @@ protected function _construct() ); } - $this->setTemplate('form.phtml') - ->assign('data', $data); + $this->setTemplate('form.phtml'); + } + + /** + * @return string + */ + public function getJsLayout() + { + return \Zend_Json::encode($this->jsLayout); } /** diff --git a/app/code/Magento/Review/Controller/Customer/Index.php b/app/code/Magento/Review/Controller/Customer/Index.php index bc7634964dfb0..6123c009cdda1 100644 --- a/app/code/Magento/Review/Controller/Customer/Index.php +++ b/app/code/Magento/Review/Controller/Customer/Index.php @@ -19,7 +19,6 @@ public function execute() { /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->getLayout()->initMessages(); if ($navigationBlock = $resultPage->getLayout()->getBlock('customer_account_navigation')) { $navigationBlock->setActive('review/customer'); } diff --git a/app/code/Magento/Review/Controller/Product/View.php b/app/code/Magento/Review/Controller/Product/View.php index a0f96b5126284..f65d1ceb8198c 100644 --- a/app/code/Magento/Review/Controller/Product/View.php +++ b/app/code/Magento/Review/Controller/Product/View.php @@ -57,7 +57,6 @@ public function execute() } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->getLayout()->initMessages(); return $resultPage; } } diff --git a/app/code/Magento/Review/CustomerData/Review.php b/app/code/Magento/Review/CustomerData/Review.php new file mode 100644 index 0000000000000..7ae540e32bb68 --- /dev/null +++ b/app/code/Magento/Review/CustomerData/Review.php @@ -0,0 +1,36 @@ +reviewSession = $reviewSession; + } + + /** + * {@inheritdoc} + */ + public function getSectionData() + { + return (array)$this->reviewSession->getFormData(true) + ['nickname' => '','title' => '', 'detail' => '']; + } +} diff --git a/app/code/Magento/Review/Model/Resource/Rating.php b/app/code/Magento/Review/Model/Resource/Rating.php index e09fa16992692..86601a0bb1156 100644 --- a/app/code/Magento/Review/Model/Resource/Rating.php +++ b/app/code/Magento/Review/Model/Resource/Rating.php @@ -159,90 +159,111 @@ public function getStores($ratingId) * * @param \Magento\Framework\Model\AbstractModel|\Magento\Review\Model\Rating $object * @return $this - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { parent::_afterSave($object); - - $adapter = $this->_getWriteAdapter(); - $ratingId = (int)$object->getId(); - if ($object->hasRatingCodes()) { - $ratingTitleTable = $this->getTable('rating_title'); - $adapter->beginTransaction(); - try { - $select = $adapter->select()->from( - $ratingTitleTable, - ['store_id', 'value'] - )->where( - 'rating_id = :rating_id' - ); - $old = $adapter->fetchPairs($select, [':rating_id' => $ratingId]); - $new = array_filter(array_map('trim', $object->getRatingCodes())); - - $insert = array_diff_assoc($new, $old); - $delete = array_diff_assoc($old, $new); - if (!empty($delete)) { - $where = ['rating_id = ?' => $ratingId, 'store_id IN(?)' => array_keys($delete)]; - $adapter->delete($ratingTitleTable, $where); - } - - if ($insert) { - $data = []; - foreach ($insert as $storeId => $title) { - $data[] = ['rating_id' => $ratingId, 'store_id' => (int)$storeId, 'value' => $title]; - } - if (!empty($data)) { - $adapter->insertMultiple($ratingTitleTable, $data); - } - } - $adapter->commit(); - } catch (\Exception $e) { - $this->_logger->critical($e); - $adapter->rollBack(); - } + $this->processRatingCodes($object); } if ($object->hasStores()) { - $ratingStoreTable = $this->getTable('rating_store'); - $adapter->beginTransaction(); - try { - $select = $adapter->select()->from( - $ratingStoreTable, - ['store_id'] - )->where( - 'rating_id = :rating_id' - ); - $old = $adapter->fetchCol($select, [':rating_id' => $ratingId]); - $new = $object->getStores(); - - $insert = array_diff($new, $old); - $delete = array_diff($old, $new); - - if ($delete) { - $where = ['rating_id = ?' => $ratingId, 'store_id IN(?)' => $delete]; - $adapter->delete($ratingStoreTable, $where); - } + $this->processRatingStores($object); + } - if ($insert) { - $data = []; - foreach ($insert as $storeId) { - $data[] = ['rating_id' => $ratingId, 'store_id' => (int)$storeId]; - } - $adapter->insertMultiple($ratingStoreTable, $data); - } + return $this; + } - $adapter->commit(); - } catch (\Exception $e) { - $this->_logger->critical($e); - $adapter->rollBack(); - } + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function processRatingCodes(\Magento\Framework\Model\AbstractModel $object) + { + $adapter = $this->_getWriteAdapter(); + $ratingId = (int)$object->getId(); + $table = $this->getTable('rating_title'); + $select = $adapter->select()->from($table, ['store_id', 'value']) + ->where('rating_id = :rating_id'); + $old = $adapter->fetchPairs($select, [':rating_id' => $ratingId]); + $new = array_filter(array_map('trim', $object->getRatingCodes())); + $this->deleteRatingData($ratingId, $table, array_diff_assoc($old, $new)); + + $insert = []; + foreach (array_diff_assoc($new, $old) as $storeId => $title) { + $insert[] = ['rating_id' => $ratingId, 'store_id' => (int)$storeId, 'value' => $title]; } + $this->insertRatingData($table, $insert); + return $this; + } + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function processRatingStores(\Magento\Framework\Model\AbstractModel $object) + { + $adapter = $this->_getWriteAdapter(); + $ratingId = (int)$object->getId(); + $table = $this->getTable('rating_store'); + $select = $adapter->select()->from($table, ['store_id']) + ->where('rating_id = :rating_id'); + $old = $adapter->fetchCol($select, [':rating_id' => $ratingId]); + $new = $object->getStores(); + $this->deleteRatingData($ratingId, $table, array_diff_assoc($old, $new)); + + $insert = []; + foreach (array_keys(array_diff_assoc($new, $old)) as $storeId) { + $insert[] = ['rating_id' => $ratingId, 'store_id' => (int)$storeId]; + } + $this->insertRatingData($table, $insert); return $this; } + /** + * @param int $ratingId + * @param string $table + * @param array $data + * @return void + */ + protected function deleteRatingData($ratingId, $table, array $data) + { + if (empty($data)) { + return; + } + $adapter = $this->_getWriteAdapter(); + $adapter->beginTransaction(); + try { + $where = ['rating_id = ?' => $ratingId, 'store_id IN(?)' => array_keys($data)]; + $adapter->delete($table, $where); + $adapter->commit(); + } catch (\Exception $e) { + $this->_logger->critical($e); + $adapter->rollBack(); + } + } + + /** + * @param string $table + * @param array $data + * @return void + */ + protected function insertRatingData($table, array $data) + { + if (empty($data)) { + return; + } + $adapter = $this->_getWriteAdapter(); + $adapter->beginTransaction(); + try { + $adapter->insertMultiple($table, $data); + $adapter->commit(); + } catch (\Exception $e) { + $this->_logger->critical($e); + $adapter->rollBack(); + } + } + /** * Perform actions after object delete * Prepare rating data for reaggregate all data for reviews diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php index 9ca5b4617f759..16798e3f8b1e5 100644 --- a/app/code/Magento/Review/Model/Resource/Review.php +++ b/app/code/Magento/Review/Model/Resource/Review.php @@ -322,8 +322,6 @@ public function getTotalReviews($entityPkValue, $approvedOnly = false, $storeId */ public function aggregate($object) { - $readAdapter = $this->_getReadAdapter(); - $writeAdapter = $this->_getWriteAdapter(); if (!$object->getEntityPkValue() && $object->getId()) { $object->load($object->getReviewId()); } @@ -332,48 +330,74 @@ public function aggregate($object) $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false); foreach ($ratingSummaries as $ratingSummaryObject) { - if ($ratingSummaryObject->getCount()) { - $ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount()); - } else { - $ratingSummary = $ratingSummaryObject->getSum(); - } + $this->aggregateReviewSummary($object, $ratingSummaryObject); + } + } - $reviewsCount = $this->getTotalReviews( - $object->getEntityPkValue(), - true, - $ratingSummaryObject->getStoreId() - ); - $select = $readAdapter->select()->from($this->_aggregateTable) - ->where('entity_pk_value = :pk_value') - ->where('entity_type = :entity_type') - ->where('store_id = :store_id'); - $bind = [ - ':pk_value' => $object->getEntityPkValue(), - ':entity_type' => $object->getEntityId(), - ':store_id' => $ratingSummaryObject->getStoreId(), - ]; - $oldData = $readAdapter->fetchRow($select, $bind); - - $data = new \Magento\Framework\Object(); - - $data->setReviewsCount($reviewsCount) - ->setEntityPkValue($object->getEntityPkValue()) - ->setEntityType($object->getEntityId()) - ->setRatingSummary($ratingSummary > 0 ? $ratingSummary : 0) - ->setStoreId($ratingSummaryObject->getStoreId()); - - $writeAdapter->beginTransaction(); - try { - if ($oldData['primary_id'] > 0) { - $condition = ["{$this->_aggregateTable}.primary_id = ?" => $oldData['primary_id']]; - $writeAdapter->update($this->_aggregateTable, $data->getData(), $condition); - } else { - $writeAdapter->insert($this->_aggregateTable, $data->getData()); - } - $writeAdapter->commit(); - } catch (\Exception $e) { - $writeAdapter->rollBack(); + /** + * Aggregate review summary + * + * @param \Magento\Framework\Model\AbstractModel $object + * @param \Magento\Review\Model\Rating $ratingSummaryObject + * @return void + */ + protected function aggregateReviewSummary($object, $ratingSummaryObject) + { + $readAdapter = $this->_getReadAdapter(); + + if ($ratingSummaryObject->getCount()) { + $ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount()); + } else { + $ratingSummary = $ratingSummaryObject->getSum(); + } + + $reviewsCount = $this->getTotalReviews( + $object->getEntityPkValue(), + true, + $ratingSummaryObject->getStoreId() + ); + $select = $readAdapter->select()->from($this->_aggregateTable) + ->where('entity_pk_value = :pk_value') + ->where('entity_type = :entity_type') + ->where('store_id = :store_id'); + $bind = [ + ':pk_value' => $object->getEntityPkValue(), + ':entity_type' => $object->getEntityId(), + ':store_id' => $ratingSummaryObject->getStoreId(), + ]; + $oldData = $readAdapter->fetchRow($select, $bind); + $data = new \Magento\Framework\Object(); + + $data->setReviewsCount($reviewsCount) + ->setEntityPkValue($object->getEntityPkValue()) + ->setEntityType($object->getEntityId()) + ->setRatingSummary($ratingSummary > 0 ? $ratingSummary : 0) + ->setStoreId($ratingSummaryObject->getStoreId()); + + $this->writeReviewSummary($oldData, $data); + } + + /** + * Write rating summary + * + * @param array|bool $oldData + * @param \Magento\Framework\Object $data + * @return void + */ + protected function writeReviewSummary($oldData, \Magento\Framework\Object $data) + { + $writeAdapter = $this->_getWriteAdapter(); + $writeAdapter->beginTransaction(); + try { + if (isset($oldData['primary_id']) && $oldData['primary_id'] > 0) { + $condition = ["{$this->_aggregateTable}.primary_id = ?" => $oldData['primary_id']]; + $writeAdapter->update($this->_aggregateTable, $data->getData(), $condition); + } else { + $writeAdapter->insert($this->_aggregateTable, $data->getData()); } + $writeAdapter->commit(); + } catch (\Exception $e) { + $writeAdapter->rollBack(); } } diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index e3a644daa4a98..6cf24184b523b 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-newsletter": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-ui": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-newsletter": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.74.0-beta9" + "magento/module-cookie": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Review/etc/adminhtml/di.xml b/app/code/Magento/Review/etc/adminhtml/di.xml index 2dca5d41cad4f..1c7aa113dc89b 100644 --- a/app/code/Magento/Review/etc/adminhtml/di.xml +++ b/app/code/Magento/Review/etc/adminhtml/di.xml @@ -6,21 +6,6 @@ */ --> - - - review - - - - - Magento\Review\Model\Session\Storage - - - - - Magento\Review\Model\Session - - Magento\Backend\Model\Session diff --git a/app/code/Magento/Review/etc/frontend/di.xml b/app/code/Magento/Review/etc/frontend/di.xml index dae34ec8e9c5c..b444231bbdb87 100644 --- a/app/code/Magento/Review/etc/frontend/di.xml +++ b/app/code/Magento/Review/etc/frontend/di.xml @@ -16,16 +16,23 @@ Magento\Review\Model\Session\Storage - + Magento\Review\Model\Session - + Magento\Review\Model\Session + + + + Magento\Review\CustomerData\Review + + + diff --git a/app/code/Magento/Review/etc/frontend/sections.xml b/app/code/Magento/Review/etc/frontend/sections.xml new file mode 100644 index 0000000000000..b012be172efd3 --- /dev/null +++ b/app/code/Magento/Review/etc/frontend/sections.xml @@ -0,0 +1,13 @@ + + + + +
    + + diff --git a/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml index b2b2569e8562b..b93a6ed208516 100644 --- a/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml +++ b/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml @@ -6,6 +6,7 @@ */ --> + diff --git a/app/code/Magento/Review/view/frontend/layout/checkout_cart_configure.xml b/app/code/Magento/Review/view/frontend/layout/checkout_cart_configure.xml index b951c8b94f2ff..43629e6e94da8 100644 --- a/app/code/Magento/Review/view/frontend/layout/checkout_cart_configure.xml +++ b/app/code/Magento/Review/view/frontend/layout/checkout_cart_configure.xml @@ -10,6 +10,15 @@ + + + + + Magento_Review/js/view/review + + + + diff --git a/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml b/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml index 7434c634ab44c..799a455f7e0f4 100644 --- a/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml +++ b/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml @@ -8,7 +8,7 @@ - + diff --git a/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml b/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml index 23bfd524f3265..01a6340b9f2bc 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml @@ -9,7 +9,7 @@ - + diff --git a/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml b/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml index 5895da9754976..43e7ba2afa619 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml @@ -9,7 +9,7 @@ - + diff --git a/app/code/Magento/Review/view/frontend/layout/review_product_form_component.xml b/app/code/Magento/Review/view/frontend/layout/review_product_form_component.xml new file mode 100644 index 0000000000000..48416d9b9d85b --- /dev/null +++ b/app/code/Magento/Review/view/frontend/layout/review_product_form_component.xml @@ -0,0 +1,22 @@ + + + + + + + + + + Magento_Review/js/view/review + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Review/view/frontend/layout/wishlist_index_configure.xml b/app/code/Magento/Review/view/frontend/layout/wishlist_index_configure.xml index b951c8b94f2ff..43629e6e94da8 100644 --- a/app/code/Magento/Review/view/frontend/layout/wishlist_index_configure.xml +++ b/app/code/Magento/Review/view/frontend/layout/wishlist_index_configure.xml @@ -10,6 +10,15 @@ + + + + + Magento_Review/js/view/review + + + + diff --git a/app/code/Magento/Review/view/frontend/templates/form.phtml b/app/code/Magento/Review/view/frontend/templates/form.phtml index 87630eb24991c..958cbe2e1de96 100644 --- a/app/code/Magento/Review/view/frontend/templates/form.phtml +++ b/app/code/Magento/Review/view/frontend/templates/form.phtml @@ -14,7 +14,7 @@
    getAllowWriteReviewFlag()): ?> -
    + getBlockHtml('formkey'); ?> getChildHtml('form_fields_before')?>
    @@ -59,19 +59,19 @@
    - +
    - +
    - +
    @@ -79,7 +79,6 @@
    -
    +
    diff --git a/app/code/Magento/Review/view/frontend/web/js/view/review.js b/app/code/Magento/Review/view/frontend/web/js/view/review.js new file mode 100644 index 0000000000000..5e7d51b126e60 --- /dev/null +++ b/app/code/Magento/Review/view/frontend/web/js/view/review.js @@ -0,0 +1,22 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data', + 'Magento_Customer/js/view/customer' +], function (Component, customerData, customer) { + 'use strict'; + + return Component.extend({ + initialize: function () { + this._super(); + + this.review = customerData.get('review').extend({disposableCustomerData: 'review'}); + }, + nickname: function() { + return this.review().nickname || customerData.get('customer')().firstname; + } + }); +}); diff --git a/app/code/Magento/Rss/App/Action/Plugin/BackendAuthentication.php b/app/code/Magento/Rss/App/Action/Plugin/BackendAuthentication.php index 990f0f732aa20..5bdb72f7036ad 100644 --- a/app/code/Magento/Rss/App/Action/Plugin/BackendAuthentication.php +++ b/app/code/Magento/Rss/App/Action/Plugin/BackendAuthentication.php @@ -14,7 +14,8 @@ /** * Class BackendAuthentication - * @package Magento\Rss\App\Action\Plugin + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class BackendAuthentication extends \Magento\Backend\App\Action\Plugin\Authentication { @@ -44,10 +45,14 @@ class BackendAuthentication extends \Magento\Backend\App\Action\Plugin\Authentic * @param ResponseInterface $response * @param \Magento\Framework\App\ActionFlag $actionFlag * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param \Magento\Backend\Model\UrlInterface $backendUrl + * @param \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory + * @param \Magento\Backend\App\BackendAppList $backendAppList * @param \Magento\Framework\HTTP\Authentication $httpAuthentication * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\AuthorizationInterface $authorization * @param array $aclResources + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\Model\Auth $auth, @@ -55,6 +60,9 @@ public function __construct( ResponseInterface $response, \Magento\Framework\App\ActionFlag $actionFlag, \Magento\Framework\Message\ManagerInterface $messageManager, + \Magento\Backend\Model\UrlInterface $backendUrl, + \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory, + \Magento\Backend\App\BackendAppList $backendAppList, \Magento\Framework\HTTP\Authentication $httpAuthentication, \Psr\Log\LoggerInterface $logger, \Magento\Framework\AuthorizationInterface $authorization, @@ -64,7 +72,16 @@ public function __construct( $this->logger = $logger; $this->authorization = $authorization; $this->aclResources = $aclResources; - parent::__construct($auth, $url, $response, $actionFlag, $messageManager); + parent::__construct( + $auth, + $url, + $response, + $actionFlag, + $messageManager, + $backendUrl, + $resultRedirectFactory, + $backendAppList + ); } /** diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 076963b3680d4..56a8badd30416 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 34947bf6b62f7..209f3f3fec531 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sales/Api/CreditmemoCommentRepositoryInterface.php b/app/code/Magento/Sales/Api/CreditmemoCommentRepositoryInterface.php index 5df81ef17ce49..d7c1f067cc046 100644 --- a/app/code/Magento/Sales/Api/CreditmemoCommentRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/CreditmemoCommentRepositoryInterface.php @@ -15,6 +15,7 @@ * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. A credit memo usually includes comments that detail * why the credit memo amount was credited to the customer. + * @api */ interface CreditmemoCommentRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/CreditmemoItemRepositoryInterface.php b/app/code/Magento/Sales/Api/CreditmemoItemRepositoryInterface.php index ebd4882a5f9ba..b322cc7b68f48 100644 --- a/app/code/Magento/Sales/Api/CreditmemoItemRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/CreditmemoItemRepositoryInterface.php @@ -12,6 +12,7 @@ * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. A credit memo item is an invoiced item for which * a merchant creates a credit memo. + * @api */ interface CreditmemoItemRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/CreditmemoManagementInterface.php b/app/code/Magento/Sales/Api/CreditmemoManagementInterface.php index 0211a82933663..e5cf268b13651 100644 --- a/app/code/Magento/Sales/Api/CreditmemoManagementInterface.php +++ b/app/code/Magento/Sales/Api/CreditmemoManagementInterface.php @@ -14,6 +14,7 @@ * After a customer places and pays for an order and an invoice has been issued, the merchant can create a credit memo * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. + * @api */ interface CreditmemoManagementInterface { diff --git a/app/code/Magento/Sales/Api/CreditmemoRepositoryInterface.php b/app/code/Magento/Sales/Api/CreditmemoRepositoryInterface.php index 64607e3622bfc..e01a3e870c412 100644 --- a/app/code/Magento/Sales/Api/CreditmemoRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/CreditmemoRepositoryInterface.php @@ -11,6 +11,7 @@ * After a customer places and pays for an order and an invoice has been issued, the merchant can create a credit memo * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. + * @api */ interface CreditmemoRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php index 3a4a5c23033f4..246eaee49d645 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php @@ -12,6 +12,7 @@ * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. A credit memo usually includes comments that detail * why the credit memo amount was credited to the customer. + * @api */ interface CreditmemoCommentInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php index 71ad928a2a8b8..6c669297ee40b 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php @@ -12,6 +12,7 @@ * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. A credit memo usually includes comments that detail * why the credit memo amount was credited to the customer. + * @api */ interface CreditmemoCommentSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php index ce5a46b9838b4..18a23bde8430e 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php @@ -14,6 +14,7 @@ * After a customer places and pays for an order and an invoice has been issued, the merchant can create a credit memo * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. + * @api */ interface CreditmemoInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php index f93eedf1cff1f..ff7e1b5f35500 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php @@ -12,6 +12,7 @@ * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. A credit memo item is an invoiced item for which * a merchant creates a credit memo. + * @api */ interface CreditmemoItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php index 5379dd74e78be..ad037370d3485 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php @@ -12,6 +12,7 @@ * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. A credit memo item is an invoiced item for which * a merchant creates a credit memo. + * @api */ interface CreditmemoItemSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php index 2e3456b6b11c3..854443a60eca6 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php @@ -11,6 +11,7 @@ * After a customer places and pays for an order and an invoice has been issued, the merchant can create a credit memo * to refund all or part of the amount paid for any returned or undelivered items. The memo restores funds to the * customer account so that the customer can make future purchases. + * @api */ interface CreditmemoSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php index ec6fce4016f6a..06dc4919b4bff 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php @@ -10,6 +10,7 @@ * * An invoice is a record of the receipt of payment for an order. An invoice can include comments that detail the * invoice history. + * @api */ interface InvoiceCommentInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php index 4ba898bfedc01..fd46600844985 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php @@ -10,6 +10,7 @@ * * An invoice is a record of the receipt of payment for an order. An invoice can include comments that detail the * invoice history. + * @api */ interface InvoiceCommentSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/InvoiceInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceInterface.php index fcbe20b83f28c..c69386840857f 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceInterface.php @@ -9,6 +9,7 @@ * Invoice interface. * * An invoice is a record of the receipt of payment for an order. + * @api */ interface InvoiceInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php index 6dc2d85022e72..013f8d143bd22 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php @@ -9,6 +9,7 @@ * Invoice item interface. * * An invoice is a record of the receipt of payment for an order. An invoice item is a purchased item in an invoice. + * @api */ interface InvoiceItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface { @@ -111,6 +112,10 @@ interface InvoiceItemInterface extends \Magento\Framework\Api\ExtensibleDataInte * Base hidden tax amount. */ const BASE_HIDDEN_TAX_AMOUNT = 'base_hidden_tax_amount'; + /** + * Invoice + */ + const INVOICE = 'invoice'; /** * Gets the additional data for the invoice item. diff --git a/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php index 6472290a10f7b..50132c276f220 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php @@ -9,6 +9,7 @@ * Invoice item search result interface. * * An invoice is a record of the receipt of payment for an order. An invoice item is a purchased item in an invoice. + * @api */ interface InvoiceItemSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php index 01fcf9d051d7f..3be17c7084718 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php @@ -9,6 +9,7 @@ * Invoice search result interface. * * An invoice is a record of the receipt of payment for an order. + * @api */ interface InvoiceSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php index 9e9e53f1727a0..d7b863b782f2b 100644 --- a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderAddressInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php index 1008f41c2095e..d0a9d55c08c6a 100644 --- a/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderAddressSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderInterface.php b/app/code/Magento/Sales/Api/Data/OrderInterface.php index 42ccf6aee23c1..37ca125b00de8 100644 --- a/app/code/Magento/Sales/Api/Data/OrderInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php index e10e196380670..8dec85a858189 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php index d380b316080c1..4fa7587d80fab 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderItemSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index 44fda2cdbcc1c..54efdc168711b 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php index 2e0d8d19cc886..474b015aff872 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderPaymentSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderSearchResultInterface.php index c7a7ca1a511ec..b11a2c04de8d3 100644 --- a/app/code/Magento/Sales/Api/Data/OrderSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderSearchResultInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderSearchResultInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php b/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php index 3a27e326c3b88..30f6f471db03d 100644 --- a/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderStatusHistoryInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php index 01b15f1bf39ab..05d2ffc7e90fb 100644 --- a/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderStatusHistorySearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php index e6bcd71928463..17b0f122a8871 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. A shipment document can contain comments. + * @api */ interface ShipmentCommentInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php index 6fa9ff5b0f5db..442f6ee17c215 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. A shipment document can contain comments. + * @api */ interface ShipmentCommentSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php index 67b3b60b05266..92d75fd267425 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. + * @api */ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php index ad75b14cde2a1..e6819d60fa9df 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. A product is an item in a shipment. + * @api */ interface ShipmentItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php index f709fe623aa57..54b6f999fba13 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. A product is an item in a shipment. + * @api */ interface ShipmentItemSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php index 00b79d6f50e6d..5ef9b96c4d343 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. + * @api */ interface ShipmentPackageInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php index 828de5d7be7b4..41aed7955a1bf 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php @@ -12,6 +12,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. + * @api */ interface ShipmentSearchResultInterface extends SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php index e9bfa3915c407..5a8a77987cc71 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php @@ -11,6 +11,7 @@ * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. Merchants and customers can track * shipments. + * @api */ interface ShipmentTrackInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php index 26187c86ce99d..e34a4003452d6 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php @@ -11,6 +11,7 @@ * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. Merchants and customers can track * shipments. + * @api */ interface ShipmentTrackSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/Data/TransactionInterface.php b/app/code/Magento/Sales/Api/Data/TransactionInterface.php index 92d431c6e0b57..1e0de41ea000d 100644 --- a/app/code/Magento/Sales/Api/Data/TransactionInterface.php +++ b/app/code/Magento/Sales/Api/Data/TransactionInterface.php @@ -9,6 +9,7 @@ * Transaction interface. * * A transaction is an interaction between a merchant and a customer such as a purchase, a credit, a refund, and so on. + * @api */ interface TransactionInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php index 414b5d05d27d0..20e23a5f9bd33 100644 --- a/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php @@ -9,6 +9,7 @@ * Transaction search result interface. * * A transaction is an interaction between a merchant and a customer such as a purchase, a credit, a refund, and so on. + * @api */ interface TransactionSearchResultInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Sales/Api/InvoiceCommentRepositoryInterface.php b/app/code/Magento/Sales/Api/InvoiceCommentRepositoryInterface.php index dd11d597539a5..c7e2d8cfb759c 100644 --- a/app/code/Magento/Sales/Api/InvoiceCommentRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/InvoiceCommentRepositoryInterface.php @@ -10,6 +10,7 @@ * * An invoice is a record of the receipt of payment for an order. An invoice can include comments that detail the * invoice history. + * @api */ interface InvoiceCommentRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/InvoiceItemRepositoryInterface.php b/app/code/Magento/Sales/Api/InvoiceItemRepositoryInterface.php index c56acfbc7982e..90ae5cea092df 100644 --- a/app/code/Magento/Sales/Api/InvoiceItemRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/InvoiceItemRepositoryInterface.php @@ -9,6 +9,7 @@ * Invoice item repository interface. * * An invoice is a record of the receipt of payment for an order. An invoice item is a purchased item in an invoice. + * @api */ interface InvoiceItemRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/InvoiceManagementInterface.php b/app/code/Magento/Sales/Api/InvoiceManagementInterface.php index 74eb5c8d97565..21b17007eaf19 100644 --- a/app/code/Magento/Sales/Api/InvoiceManagementInterface.php +++ b/app/code/Magento/Sales/Api/InvoiceManagementInterface.php @@ -9,6 +9,7 @@ * Invoice management interface. * * An invoice is a record of the receipt of payment for an order. + * @api */ interface InvoiceManagementInterface { diff --git a/app/code/Magento/Sales/Api/InvoiceRepositoryInterface.php b/app/code/Magento/Sales/Api/InvoiceRepositoryInterface.php index 0bf21460035ef..23310e2926834 100644 --- a/app/code/Magento/Sales/Api/InvoiceRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/InvoiceRepositoryInterface.php @@ -9,6 +9,7 @@ * Invoice repository interface. * * An invoice is a record of the receipt of payment for an order. + * @api */ interface InvoiceRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/OrderAddressRepositoryInterface.php b/app/code/Magento/Sales/Api/OrderAddressRepositoryInterface.php index cb47b144035f1..5c3db02774762 100644 --- a/app/code/Magento/Sales/Api/OrderAddressRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/OrderAddressRepositoryInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderAddressRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/OrderItemRepositoryInterface.php b/app/code/Magento/Sales/Api/OrderItemRepositoryInterface.php index 5c6f916b06c67..e1832a09e5568 100644 --- a/app/code/Magento/Sales/Api/OrderItemRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/OrderItemRepositoryInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderItemRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/OrderManagementInterface.php b/app/code/Magento/Sales/Api/OrderManagementInterface.php index 071d1ac787f6b..26b17139ba971 100644 --- a/app/code/Magento/Sales/Api/OrderManagementInterface.php +++ b/app/code/Magento/Sales/Api/OrderManagementInterface.php @@ -14,6 +14,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderManagementInterface { diff --git a/app/code/Magento/Sales/Api/OrderPaymentRepositoryInterface.php b/app/code/Magento/Sales/Api/OrderPaymentRepositoryInterface.php index 3f18ebde7e1d1..eeaa7a0743f1f 100644 --- a/app/code/Magento/Sales/Api/OrderPaymentRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/OrderPaymentRepositoryInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderPaymentRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/OrderRepositoryInterface.php b/app/code/Magento/Sales/Api/OrderRepositoryInterface.php index 2792ce4156893..d8420ce0da729 100644 --- a/app/code/Magento/Sales/Api/OrderRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/OrderRepositoryInterface.php @@ -11,6 +11,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/OrderStatusHistoryRepositoryInterface.php b/app/code/Magento/Sales/Api/OrderStatusHistoryRepositoryInterface.php index 66db1edbaa466..b99bf0dc2c729 100644 --- a/app/code/Magento/Sales/Api/OrderStatusHistoryRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/OrderStatusHistoryRepositoryInterface.php @@ -14,6 +14,7 @@ * An order is a document that a web store issues to a customer. Magento generates a sales order that lists the product * items, billing and shipping addresses, and shipping and payment methods. A corresponding external document, known as * a purchase order, is emailed to the customer. + * @api */ interface OrderStatusHistoryRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/ShipmentCommentRepositoryInterface.php b/app/code/Magento/Sales/Api/ShipmentCommentRepositoryInterface.php index 75280b53e3cb1..e6605c9c5dd24 100644 --- a/app/code/Magento/Sales/Api/ShipmentCommentRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/ShipmentCommentRepositoryInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. A shipment document can contain comments. + * @api */ interface ShipmentCommentRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/ShipmentItemRepositoryInterface.php b/app/code/Magento/Sales/Api/ShipmentItemRepositoryInterface.php index f8947acf54dd8..0db3adabf885c 100644 --- a/app/code/Magento/Sales/Api/ShipmentItemRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/ShipmentItemRepositoryInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. A product is an item in a shipment. + * @api */ interface ShipmentItemRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/ShipmentManagementInterface.php b/app/code/Magento/Sales/Api/ShipmentManagementInterface.php index bcc53da8a4e14..d925a643f9290 100644 --- a/app/code/Magento/Sales/Api/ShipmentManagementInterface.php +++ b/app/code/Magento/Sales/Api/ShipmentManagementInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. + * @api */ interface ShipmentManagementInterface { diff --git a/app/code/Magento/Sales/Api/ShipmentRepositoryInterface.php b/app/code/Magento/Sales/Api/ShipmentRepositoryInterface.php index 6ab4561c3c5dd..2d19d0f6dbe46 100644 --- a/app/code/Magento/Sales/Api/ShipmentRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/ShipmentRepositoryInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. + * @api */ interface ShipmentRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/ShipmentTrackRepositoryInterface.php b/app/code/Magento/Sales/Api/ShipmentTrackRepositoryInterface.php index 49cd3346025d6..5d7817b0c828d 100644 --- a/app/code/Magento/Sales/Api/ShipmentTrackRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/ShipmentTrackRepositoryInterface.php @@ -10,6 +10,7 @@ * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This * document lists the products and their quantities in the delivery package. + * @api */ interface ShipmentTrackRepositoryInterface { diff --git a/app/code/Magento/Sales/Api/TransactionRepositoryInterface.php b/app/code/Magento/Sales/Api/TransactionRepositoryInterface.php index 5d168c8f9e6e4..5cada3d87f7a2 100644 --- a/app/code/Magento/Sales/Api/TransactionRepositoryInterface.php +++ b/app/code/Magento/Sales/Api/TransactionRepositoryInterface.php @@ -9,6 +9,7 @@ * Transaction repository interface. * * A transaction is an interaction between a merchant and a customer such as a purchase, a credit, a refund, and so on. + * @api */ interface TransactionRepositoryInterface { diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index adee793ade5d1..73d800c831866 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -51,7 +51,6 @@ public function __construct( $this->_customerSession = $customerSession; $this->_orderConfig = $orderConfig; parent::__construct($context, $data); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Sales/Block/Reorder/Sidebar.php b/app/code/Magento/Sales/Block/Reorder/Sidebar.php index b163209d45441..61b8767104077 100644 --- a/app/code/Magento/Sales/Block/Reorder/Sidebar.php +++ b/app/code/Magento/Sales/Block/Reorder/Sidebar.php @@ -6,149 +6,29 @@ namespace Magento\Sales\Block\Reorder; use Magento\Customer\Model\Context; -use Magento\Framework\View\Block\IdentityInterface; /** - * Sales order view block - * - * @method Sidebar setOrders(\Magento\Sales\Model\Resource\Order\Collection $ordersCollection) - * @method \Magento\Sales\Model\Resource\Order\Collection|null getOrders() + * Last ordered items sidebar */ -class Sidebar extends \Magento\Framework\View\Element\Template implements IdentityInterface +class Sidebar extends \Magento\Framework\View\Element\Template { - /** - * Limit of orders in side bar - */ - const SIDEBAR_ORDER_LIMIT = 5; - - /** - * @var string - */ - protected $_template = 'order/history.phtml'; - - /** - * @var \Magento\Sales\Model\Resource\Order\CollectionFactory - */ - protected $_orderCollectionFactory; - - /** - * @var \Magento\Sales\Model\Order\Config - */ - protected $_orderConfig; - - /** - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - /** * @var \Magento\Framework\App\Http\Context */ protected $httpContext; - /** - * @var \Magento\CatalogInventory\Api\StockRegistryInterface - */ - protected $stockRegistry; - /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Sales\Model\Resource\Order\CollectionFactory $orderCollectionFactory - * @param \Magento\Sales\Model\Order\Config $orderConfig - * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\App\Http\Context $httpContext - * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Sales\Model\Resource\Order\CollectionFactory $orderCollectionFactory, - \Magento\Sales\Model\Order\Config $orderConfig, - \Magento\Customer\Model\Session $customerSession, \Magento\Framework\App\Http\Context $httpContext, - \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, array $data = [] ) { - $this->_orderCollectionFactory = $orderCollectionFactory; - $this->_orderConfig = $orderConfig; - $this->_customerSession = $customerSession; - $this->httpContext = $httpContext; - $this->stockRegistry = $stockRegistry; parent::__construct($context, $data); - $this->_isScopePrivate = true; - } - - /** - * Init orders - * - * @return void - */ - protected function _construct() - { - parent::_construct(); - if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) { - $this->initOrders(); - } - } - - /** - * Init customer order for display on front - * - * @return void - */ - public function initOrders() - { - $customerId = $this->getCustomerId() ? $this->getCustomerId() : $this->_customerSession->getCustomerId(); - - $orders = $this->_orderCollectionFactory->create() - ->addAttributeToFilter('customer_id', $customerId) - ->addAttributeToFilter('status', ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]) - ->addAttributeToSort('created_at', 'desc') - ->setPage(1, 1); - //TODO: add filter by current website - $this->setOrders($orders); - } - - /** - * Get list of last ordered products - * - * @return array - */ - public function getItems() - { - $items = []; - $order = $this->getLastOrder(); - $limit = self::SIDEBAR_ORDER_LIMIT; - - if ($order) { - $website = $this->_storeManager->getStore()->getWebsiteId(); - foreach ($order->getParentItemsRandomCollection($limit) as $item) { - if ($item->getProduct() && in_array($website, $item->getProduct()->getWebsiteIds())) { - $items[] = $item; - } - } - } - - return $items; - } - - /** - * Check item product availability for reorder - * - * @param \Magento\Sales\Model\Order\Item $orderItem - * @return boolean - */ - public function isItemAvailableForReorder(\Magento\Sales\Model\Order\Item $orderItem) - { - try { - $stockItem = $this->stockRegistry->getStockItem( - $orderItem->getProduct()->getId(), - $orderItem->getStore()->getWebsiteId() - ); - return $stockItem->getIsInStock(); - } catch (\Magento\Framework\Exception\NoSuchEntityException $noEntityException) { - return false; - } + $this->httpContext = $httpContext; } /** @@ -162,21 +42,6 @@ public function getFormActionUrl() return $this->getUrl('checkout/cart/addgroup', ['_secure' => true]); } - /** - * Last order getter - * - * @return \Magento\Sales\Model\Order|false - */ - public function getLastOrder() - { - if (!$this->getOrders()) { - return false; - } - foreach ($this->getOrders() as $order) { - return $order; - } - } - /** * Render "My Orders" sidebar block * @@ -187,18 +52,4 @@ protected function _toHtml() $isValid = $this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->getCustomerId(); return $isValid ? parent::_toHtml() : ''; } - - /** - * Return identifiers for produced content - * - * @return array - */ - public function getIdentities() - { - $identities = []; - foreach ($this->getItems() as $item) { - $identities = array_merge($identities, $item->getProduct()->getIdentities()); - } - return $identities; - } } diff --git a/app/code/Magento/Sales/Controller/AbstractController/View.php b/app/code/Magento/Sales/Controller/AbstractController/View.php index cd851bc94b9d9..987fa30704e59 100644 --- a/app/code/Magento/Sales/Controller/AbstractController/View.php +++ b/app/code/Magento/Sales/Controller/AbstractController/View.php @@ -50,7 +50,6 @@ public function execute() /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); - $resultPage->getLayout()->initMessages(); /** @var \Magento\Framework\View\Element\Html\Links $navigationBlock */ $navigationBlock = $resultPage->getLayout()->getBlock('customer_account_navigation'); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php index 7386069e8f8e9..83c87cd3c45b4 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php @@ -33,10 +33,7 @@ public function execute() $message = __('The payment has been denied.'); break; case 'update': - $order->getPayment()->registerPaymentReviewAction( - \Magento\Sales\Model\Order\Payment::REVIEW_ACTION_UPDATE, - true - ); + $order->getPayment()->update(); $message = __('The payment update has been made.'); break; default: diff --git a/app/code/Magento/Sales/Controller/Order/History.php b/app/code/Magento/Sales/Controller/Order/History.php index d93a7b3b1fc0e..5a87a8b944258 100644 --- a/app/code/Magento/Sales/Controller/Order/History.php +++ b/app/code/Magento/Sales/Controller/Order/History.php @@ -38,7 +38,6 @@ public function execute() { /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); - $resultPage->getLayout()->initMessages(); $resultPage->getConfig()->getTitle()->set(__('My Orders')); $block = $resultPage->getLayout()->getBlock('customer.account.link.back'); diff --git a/app/code/Magento/Sales/CustomerData/LastOrderedItems.php b/app/code/Magento/Sales/CustomerData/LastOrderedItems.php new file mode 100644 index 0000000000000..f5e8ee34cdd8d --- /dev/null +++ b/app/code/Magento/Sales/CustomerData/LastOrderedItems.php @@ -0,0 +1,155 @@ +_orderCollectionFactory = $orderCollectionFactory; + $this->_orderConfig = $orderConfig; + $this->_customerSession = $customerSession; + $this->stockRegistry = $stockRegistry; + $this->_storeManager = $storeManager; + } + + /** + * Init customer order for display on front + * + * @return void + */ + protected function initOrders() + { + $customerId = $this->_customerSession->getCustomerId(); + + $orders = $this->_orderCollectionFactory->create() + ->addAttributeToFilter('customer_id', $customerId) + ->addAttributeToFilter('status', ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]) + ->addAttributeToSort('created_at', 'desc') + ->setPage(1, 1); + //TODO: add filter by current website + $this->orders = $orders; + } + + /** + * Get list of last ordered products + * + * @return array + */ + protected function getItems() + { + $items = []; + $order = $this->getLastOrder(); + $limit = self::SIDEBAR_ORDER_LIMIT; + + if ($order) { + $website = $this->_storeManager->getStore()->getWebsiteId(); + foreach ($order->getParentItemsRandomCollection($limit) as $item) { + if ($item->getProduct() && in_array($website, $item->getProduct()->getWebsiteIds())) { + $items[] = [ + 'id' => $item->getId(), + 'name' => $item->getName(), + 'url' => $item->getProduct()->getProductUrl(), + 'is_saleable' => $this->isItemAvailableForReorder($item), + ]; + } + } + } + + return $items; + } + + /** + * Check item product availability for reorder + * + * @param \Magento\Sales\Model\Order\Item $orderItem + * @return boolean + */ + protected function isItemAvailableForReorder(\Magento\Sales\Model\Order\Item $orderItem) + { + try { + $stockItem = $this->stockRegistry->getStockItem( + $orderItem->getProduct()->getId(), + $orderItem->getStore()->getWebsiteId() + ); + return $stockItem->getIsInStock(); + } catch (\Magento\Framework\Exception\NoSuchEntityException $noEntityException) { + return false; + } + } + + /** + * Last order getter + * + * @return \Magento\Sales\Model\Order|void + */ + protected function getLastOrder() + { + if (!$this->orders) { + $this->initOrders(); + } + foreach ($this->orders as $order) { + return $order; + } + } + + /** + * {@inheritdoc} + */ + public function getSectionData() + { + return ['items' => $this->getItems()]; + } +} diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 43f4b95497720..cbf8a5e746b78 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -592,13 +592,14 @@ public function canCreditmemo() */ public function canHold() { - $state = $this->getState(); - if ($this->isCanceled() || - $this->isPaymentReview() || - $state === self::STATE_COMPLETE || - $state === self::STATE_CLOSED || - $state === self::STATE_HOLDED - ) { + $notHoldableStates = [ + self::STATE_CANCELED, + self::STATE_PAYMENT_REVIEW, + self::STATE_COMPLETE, + self::STATE_CLOSED, + self::STATE_HOLDED + ]; + if (in_array($this->getState(), $notHoldableStates)) { return false; } @@ -916,77 +917,14 @@ public function getShippingAddress() } /** - * Order state setter. - * If status is specified, will add order status history with specified comment - * the setData() cannot be overridden because of compatibility issues with resource model - * By default allows to set any state. Can also update status to default or specified value - * Complete and closed states are encapsulated intentionally + * Set order state * * @param string $state - * @param string|bool $status - * @param string $comment - * @param bool $isCustomerNotified - * @param bool $shouldProtectState - * @return \Magento\Sales\Model\Order - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function setState( - $state, - $status = false, - $comment = '', - $isCustomerNotified = null, - $shouldProtectState = true - ) { - - // attempt to set the specified state - if ($shouldProtectState) { - if ($this->isStateProtected($state)) { - throw new \Magento\Framework\Exception\LocalizedException( - __('The Order State "%1" must not be set manually.', $state) - ); - } - } - - $transport = new \Magento\Framework\Object( - [ - 'state' => $state, - 'status' => $status, - 'comment' => $comment, - 'is_customer_notified' => $isCustomerNotified - ] - ); - - $this->_eventManager->dispatch( - 'sales_order_state_change_before', - ['order' => $this, 'transport' => $transport] - ); - $status = $transport->getStatus(); - $this->setData('state', $transport->getState()); - - // add status history - if ($status) { - if ($status === true) { - $status = $this->getConfig()->getStateDefaultStatus($transport->getState()); - } - $this->setStatus($status); - $history = $this->addStatusHistoryComment($transport->getComment(), false); - // no sense to set $status again - $history->setIsCustomerNotified($transport->getIsCustomerNotified()); - } - return $this; - } - - /** - * Whether specified state can be set from outside - * @param string $state - * @return bool + * @return $this */ - public function isStateProtected($state) + public function setState($state) { - if (empty($state)) { - return false; - } - return self::STATE_COMPLETE == $state || self::STATE_CLOSED == $state; + return $this->setData(self::STATE, $state); } /** @@ -1019,7 +957,7 @@ public function addStatusToHistory($status, $comment = '', $isCustomerNotified = * * @param string $comment * @param bool|string $status - * @return OrderStatusHistoryInterface[] + * @return OrderStatusHistoryInterface */ public function addStatusHistoryComment($comment, $status = false) { @@ -1087,7 +1025,8 @@ public function hold() } $this->setHoldBeforeState($this->getState()); $this->setHoldBeforeStatus($this->getStatus()); - $this->setState(self::STATE_HOLDED, true); + $this->setState(self::STATE_HOLDED) + ->setStatus($this->getConfig()->getStateDefaultStatus(self::STATE_HOLDED)); return $this; } @@ -1102,7 +1041,9 @@ public function unhold() if (!$this->canUnhold()) { throw new \Magento\Framework\Exception\LocalizedException(__('You cannot remove the hold.')); } - $this->setState($this->getHoldBeforeState(), $this->getHoldBeforeStatus()); + + $this->setState($this->getHoldBeforeState()) + ->setStatus($this->getHoldBeforeStatus()); $this->setHoldBeforeState(null); $this->setHoldBeforeStatus(null); return $this; @@ -1127,6 +1068,7 @@ public function cancel() /** * Prepare order totals to cancellation + * * @param string $comment * @param bool $graceful * @return $this @@ -1135,13 +1077,13 @@ public function cancel() public function registerCancellation($comment = '', $graceful = true) { if ($this->canCancel() || $this->isPaymentReview()) { - $cancelState = self::STATE_CANCELED; + $state = self::STATE_CANCELED; foreach ($this->getAllItems() as $item) { - if ($cancelState != self::STATE_PROCESSING && $item->getQtyToRefund()) { + if ($state != self::STATE_PROCESSING && $item->getQtyToRefund()) { if ($item->getQtyToShip() > $item->getQtyToCancel()) { - $cancelState = self::STATE_PROCESSING; + $state = self::STATE_PROCESSING; } else { - $cancelState = self::STATE_COMPLETE; + $state = self::STATE_COMPLETE; } } $item->cancel(); @@ -1162,7 +1104,11 @@ public function registerCancellation($comment = '', $graceful = true) $this->setTotalCanceled($this->getGrandTotal() - $this->getTotalPaid()); $this->setBaseTotalCanceled($this->getBaseGrandTotal() - $this->getBaseTotalPaid()); - $this->setState($cancelState, true, $comment, null, false); + $this->setState($state) + ->setStatus($this->getConfig()->getStateDefaultStatus($state)); + if (!empty($comment)) { + $this->addStatusHistoryComment($comment, false); + } } elseif (!$graceful) { throw new \Magento\Framework\Exception\LocalizedException(__('We cannot cancel this order.')); } diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index 036aec6851211..8042de931cedc 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -432,11 +432,12 @@ public function cancel() $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() - $this->getBaseCost()); if ($this->getState() == self::STATE_PAID) { - $this->getOrder()->setTotalPaid($this->getOrder()->getTotalPaid() - $this->getGrandTotal()); - $this->getOrder()->setBaseTotalPaid($this->getOrder()->getBaseTotalPaid() - $this->getBaseGrandTotal()); + $order->setTotalPaid($order->getTotalPaid() - $this->getGrandTotal()); + $order->setBaseTotalPaid($order->getBaseTotalPaid() - $this->getBaseGrandTotal()); } $this->setState(self::STATE_CANCELED); - $this->getOrder()->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true); + $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING) + ->setStatus($order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING)); $this->_eventManager->dispatch('sales_order_invoice_cancel', [$this->_eventObject => $this]); return $this; } diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Item.php b/app/code/Magento/Sales/Model/Order/Invoice/Item.php index 403e14bfa9ec6..5e29ee78a7afa 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Item.php @@ -44,11 +44,6 @@ class Item extends AbstractModel implements InvoiceItemInterface */ protected $_eventObject = 'invoice_item'; - /** - * @var \Magento\Sales\Model\Order\Invoice|null - */ - protected $_invoice = null; - /** * @var \Magento\Sales\Model\Order\Item|null */ @@ -104,13 +99,12 @@ protected function _construct() /** * Declare invoice instance * - * @param \Magento\Sales\Model\Order\Invoice $invoice + * @param \Magento\Sales\Api\Data\InvoiceInterface $invoice * @return $this */ - public function setInvoice(\Magento\Sales\Model\Order\Invoice $invoice) + public function setInvoice(\Magento\Sales\Api\Data\InvoiceInterface $invoice) { - $this->_invoice = $invoice; - return $this; + return $this->setData(self::INVOICE, $invoice); } /** @@ -120,7 +114,7 @@ public function setInvoice(\Magento\Sales\Model\Order\Invoice $invoice) */ public function getInvoice() { - return $this->_invoice; + return $this->getData(self::INVOICE); } /** @@ -158,29 +152,10 @@ public function getOrderItem() * * @param float $qty * @return $this - * @throws \Magento\Framework\Exception\LocalizedException */ public function setQty($qty) { - if ($this->getOrderItem()->getIsQtyDecimal()) { - $qty = (double)$qty; - } else { - $qty = (int)$qty; - } - $qty = $qty > 0 ? $qty : 0; - /** - * Check qty availability - */ - $qtyToInvoice = sprintf("%F", $this->getOrderItem()->getQtyToInvoice()); - $qty = sprintf("%F", $qty); - if ($qty <= $qtyToInvoice || $this->getOrderItem()->isDummy()) { - $this->setData('qty', $qty); - } else { - throw new \Magento\Framework\Exception\LocalizedException( - __('We found an invalid quantity to invoice item "%1".', $this->getName()) - ); - } - return $this; + return $this->setData(self::QTY, $qty); } /** diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index ce5d9a79c6a57..8bb5b416876d0 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -11,6 +11,8 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Model\Order\Payment\Info; use Magento\Sales\Api\Data\OrderPaymentInterface; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Payment\Transaction; /** * Order payment information @@ -37,7 +39,7 @@ class Payment extends Info implements OrderPaymentInterface /** * Order model object * - * @var \Magento\Sales\Model\Order + * @var Order */ protected $_order; @@ -161,10 +163,10 @@ protected function _construct() /** * Declare order model object * - * @param \Magento\Sales\Model\Order $order + * @param Order $order * @return $this */ - public function setOrder(\Magento\Sales\Model\Order $order) + public function setOrder(Order $order) { $this->_order = $order; return $this; @@ -173,7 +175,7 @@ public function setOrder(\Magento\Sales\Model\Order $order) /** * Retrieve order model object * - * @return \Magento\Sales\Model\Order + * @return Order */ public function getOrder() { @@ -195,7 +197,7 @@ public function canCapture() if ($authTransaction && $authTransaction->getIsClosed()) { $orderTransaction = $this->_lookupTransaction( null, - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_ORDER + Transaction::TYPE_ORDER ); if (!$orderTransaction) { return false; @@ -248,7 +250,7 @@ public function place() $methodInstance = $this->getMethodInstance(); $methodInstance->setStore($order->getStoreId()); - $orderState = \Magento\Sales\Model\Order::STATE_NEW; + $orderState = Order::STATE_NEW; $orderStatus = $methodInstance->getConfigData('order_status'); $isCustomerNotified = false; @@ -265,7 +267,7 @@ public function place() $orderStatus = $stateObject->getStatus() ?: $orderStatus; $isCustomerNotified = $stateObject->getIsNotified(); } else { - $orderState = \Magento\Sales\Model\Order::STATE_PROCESSING; + $orderState = Order::STATE_PROCESSING; $this->processAction($action, $order); $orderState = $order->getState() ? $order->getState() : $orderState; $orderStatus = $order->getStatus() ? $order->getStatus() : $orderStatus; @@ -288,13 +290,13 @@ public function place() /** * Set appropriate state to order or add status to order history * - * @param \Magento\Sales\Model\Order $order + * @param Order $order * @param string $orderState * @param string $orderStatus * @param bool $isCustomerNotified * @return void */ - protected function updateOrder(\Magento\Sales\Model\Order $order, $orderState, $orderStatus, $isCustomerNotified) + protected function updateOrder(Order $order, $orderState, $orderStatus, $isCustomerNotified) { // add message if order was put into review during authorization or capture $message = $order->getCustomerNote(); @@ -302,14 +304,17 @@ protected function updateOrder(\Magento\Sales\Model\Order $order, $orderState, $ $originalOrderStatus = $order->getStatus(); switch (true) { - case ($message && ($originalOrderState == \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW)): + case ($message && ($originalOrderState == Order::STATE_PAYMENT_REVIEW)): $order->addStatusToHistory($originalOrderStatus, $message, $isCustomerNotified); break; case ($message): case ($originalOrderState && $message): case ($originalOrderState != $orderState): case ($originalOrderStatus != $orderStatus): - $order->setState($orderState, $orderStatus, $message, $isCustomerNotified); + $order->setState($orderState) + ->setStatus($orderStatus) + ->addStatusHistoryComment($message) + ->setIsCustomerNotified($isCustomerNotified); break; default: break; @@ -320,10 +325,10 @@ protected function updateOrder(\Magento\Sales\Model\Order $order, $orderState, $ * Perform actions based on passed action name * * @param string $action - * @param \Magento\Sales\Model\Order $order + * @param Order $order * @return void */ - protected function processAction($action, \Magento\Sales\Model\Order $order) + protected function processAction($action, Order $order) { $totalDue = $order->getTotalDue(); $baseTotalDue = $order->getBaseTotalDue(); @@ -377,7 +382,7 @@ public function capture($invoice) $this->_isCaptureFinal($paidWorkaround); $this->_generateTransactionId( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE, + Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction() ); @@ -398,13 +403,13 @@ public function capture($invoice) $invoice->getTransactionId() ); } - $status = true; + $status = false; if (!$invoice->getIsPaid() && !$this->getIsTransactionPending()) { // attempt to capture: this can trigger "is_transaction_pending" $this->getMethodInstance()->setStore($order->getStoreId())->capture($this, $amountToCapture); $transaction = $this->_addTransaction( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE, + Transaction::TYPE_CAPTURE, $invoice, true ); @@ -414,22 +419,28 @@ public function capture($invoice) 'An amount of %1 will be captured after being approved at the payment gateway.', $this->_formatPrice($amountToCapture) ); - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; + $state = Order::STATE_PAYMENT_REVIEW; if ($this->getIsFraudDetected()) { - $status = \Magento\Sales\Model\Order::STATUS_FRAUD; + $status = Order::STATUS_FRAUD; } $invoice->setIsPaid(false); } else { // normal online capture: invoice is marked as "paid" $message = __('Captured amount of %1 online', $this->_formatPrice($amountToCapture)); - $state = \Magento\Sales\Model\Order::STATE_PROCESSING; + $state = Order::STATE_PROCESSING; $invoice->setIsPaid(true); $this->_updateTotals(['base_amount_paid_online' => $amountToCapture]); } $message = $this->_prependMessage($message); $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState($state, $status, $message); + if (!$status) { + $status = $order->getConfig()->getStateDefaultStatus($state); + } + + $order->setState($state) + ->setStatus($status) + ->addStatusHistoryComment($message); $this->getMethodInstance()->processInvoice($invoice, $this); return $this; } @@ -454,7 +465,7 @@ public function capture($invoice) public function registerCaptureNotification($amount, $skipFraudDetection = false) { $this->_generateTransactionId( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE, + Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction() ); @@ -474,31 +485,15 @@ public function registerCaptureNotification($amount, $skipFraudDetection = false } } - $status = true; if ($this->getIsTransactionPending()) { $message = __( 'An amount of %1 will be captured after being approved at the payment gateway.', $this->_formatPrice($amount) ); - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; - if ($this->getIsFraudDetected()) { - $message = __( - 'Order is suspended as its capture amount %1 is suspected to be fraudulent.', - $this->_formatPrice($amount) - ); - $status = \Magento\Sales\Model\Order::STATUS_FRAUD; - } + $state = Order::STATE_PAYMENT_REVIEW; } else { $message = __('Registered notification about captured amount of %1.', $this->_formatPrice($amount)); - $state = \Magento\Sales\Model\Order::STATE_PROCESSING; - if ($this->getIsFraudDetected()) { - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; - $message = __( - 'Order is suspended as its capture amount %1 is suspected to be fraudulent.', - $this->_formatPrice($amount) - ); - $status = \Magento\Sales\Model\Order::STATUS_FRAUD; - } + $state = Order::STATE_PROCESSING; // register capture for an existing invoice if ($invoice && Invoice::STATE_OPEN == $invoice->getState()) { $invoice->pay(); @@ -506,15 +501,26 @@ public function registerCaptureNotification($amount, $skipFraudDetection = false $order->addRelatedObject($invoice); } } + if ($this->getIsFraudDetected()) { + $state = Order::STATE_PAYMENT_REVIEW; + $message = __( + 'Order is suspended as its capture amount %1 is suspected to be fraudulent.', + $this->_formatPrice($amount) + ); + $status = Order::STATUS_FRAUD; + } else { + $status = $order->getConfig()->getStateDefaultStatus($state); + } $transaction = $this->_addTransaction( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE, + Transaction::TYPE_CAPTURE, $invoice, true ); $message = $this->_prependMessage($message); $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState($state, $status, $message); + + $order->setState($state)->setStatus($status)->addStatusHistoryComment($message); return $this; } @@ -654,9 +660,8 @@ public function registerVoidNotification($amount = null) public function refund($creditmemo) { $baseAmountToRefund = $this->_formatAmount($creditmemo->getBaseGrandTotal()); - $order = $this->getOrder(); - $this->_generateTransactionId(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND); + $this->_generateTransactionId(Transaction::TYPE_REFUND); // call refund from gateway if required $isOnline = false; @@ -711,7 +716,7 @@ public function refund($creditmemo) // update transactions and order state $transaction = $this->_addTransaction( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND, + Transaction::TYPE_REFUND, $creditmemo, $isOnline ); @@ -725,8 +730,7 @@ public function refund($creditmemo) } $message = $message = $this->_prependMessage($message); $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true, $message); - + $this->setOrderStateProcessing($message); $this->_eventManager->dispatch( 'sales_order_payment_refund', ['payment' => $this, 'creditmemo' => $creditmemo] @@ -751,7 +755,7 @@ public function registerRefundNotification($amount) { $notificationAmount = $amount; $this->_generateTransactionId( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND, + Transaction::TYPE_REFUND, $this->_lookupTransaction($this->getParentTransactionId()) ); if ($this->_isTransactionExists()) { @@ -825,14 +829,14 @@ public function registerRefundNotification($amount) $this->setCreatedCreditmemo($creditmemo); // update transactions and order state $transaction = $this->_addTransaction( - \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND, + Transaction::TYPE_REFUND, $creditmemo ); $message = $this->_prependMessage( __('Registered notification about refunded amount of %1.', $this->_formatPrice($amount)) ); $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true, $message); + $this->setOrderStateProcessing($message); return $this; } @@ -910,7 +914,25 @@ public function canFetchTransactionInfo() */ public function accept() { - $this->registerPaymentReviewAction(self::REVIEW_ACTION_ACCEPT, true); + $transactionId = $this->getLastTransId(); + + /** @var \Magento\Payment\Model\Method\AbstractMethod $method */ + $method = $this->getMethodInstance()->setStore($this->getOrder()->getStoreId()); + if ($method->acceptPayment($this)) { + $invoice = $this->_getInvoiceForTransactionId($transactionId); + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('Approved the payment online.')) + ); + $this->updateBaseAmountPaidOnlineTotal($invoice); + $this->setOrderStateProcessing($message); + } else { + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('There is no need to approve this payment.')) + ); + $this->setOrderStatePaymentReview($message, $transactionId); + } return $this; } @@ -921,115 +943,126 @@ public function accept() */ public function deny() { - $this->registerPaymentReviewAction(self::REVIEW_ACTION_DENY, true); + $transactionId = $this->getLastTransId(); + + /** @var \Magento\Payment\Model\Method\AbstractMethod $method */ + $method = $this->getMethodInstance()->setStore($this->getOrder()->getStoreId()); + if ($method->denyPayment($this)) { + $invoice = $this->_getInvoiceForTransactionId($transactionId); + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('Denied the payment online')) + ); + $this->cancelInvoiceAndRegisterCancellation($invoice, $message); + } else { + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('There is no need to deny this payment.')) + ); + $this->setOrderStatePaymentReview($message, $transactionId); + } return $this; } /** - * Perform the payment review action: either initiated by merchant or by a notification - * - * Sets order to processing state and optionally approves invoice or cancels the order + * Performs registered payment update. * - * @param string $action - * @param bool $isOnline + * @throws \Magento\Framework\Exception\LocalizedException * @return $this - * @throws \Exception - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) */ - public function registerPaymentReviewAction($action, $isOnline) + public function update() { - $order = $this->getOrder(); - - $transactionId = $isOnline ? $this->getLastTransId() : $this->getTransactionId(); + $transactionId = $this->getLastTransId(); $invoice = $this->_getInvoiceForTransactionId($transactionId); - // invoke the payment method to determine what to do with the transaction - $result = null; - $message = null; - switch ($action) { - case self::REVIEW_ACTION_ACCEPT: - if ($isOnline) { - if ($this->getMethodInstance()->setStore($order->getStoreId())->acceptPayment($this)) { - $result = true; - $message = __('Approved the payment online.'); - } else { - $result = -1; - $message = __('There is no need to approve this payment.'); - } - } else { - $result = (bool)$this->getNotificationResult() ? true : -1; - $message = __('Registered notification about approved payment.'); - } - break; - case self::REVIEW_ACTION_DENY: - if ($isOnline) { - if ($this->getMethodInstance()->setStore($order->getStoreId())->denyPayment($this)) { - $result = false; - $message = __('Denied the payment online'); - } else { - $result = -1; - $message = __('There is no need to deny this payment.'); - } - } else { - $result = (bool)$this->getNotificationResult() ? false : -1; - $message = __('Registered notification about denied payment.'); - } - break; - case self::REVIEW_ACTION_UPDATE: - if ($isOnline) { - $this->getMethodInstance()->setStore( - $order->getStoreId() - )->fetchTransactionInfo( - $this, - $transactionId - ); - } - if ($this->getIsTransactionApproved()) { - $result = true; - $message = __('Registered update about approved payment.'); - } elseif ($this->getIsTransactionDenied()) { - $result = false; - $message = __('Registered update about denied payment.'); - } else { - $result = -1; - $message = __('There is no update for the payment.'); - } - break; - default: - throw new \Exception('Not implemented.'); + $this->getMethodInstance()->setStore($this->getOrder()->getStoreId()) + ->fetchTransactionInfo($this, $transactionId); + + if ($this->getIsTransactionApproved()) { + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('Registered update about approved payment.')) + ); + $this->updateBaseAmountPaidOnlineTotal($invoice); + $this->setOrderStateProcessing($message); + } elseif ($this->getIsTransactionDenied()) { + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('Registered update about denied payment.')) + ); + $this->cancelInvoiceAndRegisterCancellation($invoice, $message); + } else { + $message = $this->_appendTransactionToMessage( + $transactionId, + $this->_prependMessage(__('There is no update for the payment.')) + ); + $this->setOrderStatePaymentReview($message, $transactionId); } - $message = $this->_prependMessage($message); - if ($transactionId) { - $message = $this->_appendTransactionToMessage($transactionId, $message); + + return $this; + } + + /** + * Triggers invoice pay and updates base_amount_paid_online total. + * + * @param \Magento\Sales\Model\Order\Invoice|false $invoice + */ + protected function updateBaseAmountPaidOnlineTotal($invoice) + { + if ($invoice instanceof Invoice) { + $invoice->pay(); + $this->_updateTotals(['base_amount_paid_online' => $invoice->getBaseGrandTotal()]); + $this->getOrder()->addRelatedObject($invoice); } + } - // process payment in case of positive or negative result, or add a comment - if (-1 === $result) { // switch won't work with such $result! - if ($order->getState() != \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) { - $status = $this->getIsFraudDetected() ? \Magento\Sales\Model\Order::STATUS_FRAUD : false; - $order->setState(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW, $status, $message); - if ($transactionId) { - $this->setLastTransId($transactionId); - } - } else { - $order->addStatusHistoryComment($message); - } - } elseif (true === $result) { - if ($invoice) { - $invoice->pay(); - $this->_updateTotals(['base_amount_paid_online' => $invoice->getBaseGrandTotal()]); - $order->addRelatedObject($invoice); + /** + * Sets order state to 'processing' with appropriate message + * + * @param \Magento\Framework\Phrase|string $message + */ + protected function setOrderStateProcessing($message) + { + $this->getOrder()->setState(Order::STATE_PROCESSING) + ->setStatus($this->getOrder()->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)) + ->addStatusHistoryComment($message); + } + + /** + * Cancel invoice and register order cancellation + * + * @param Invoice|false $invoice + * @param string $message + */ + protected function cancelInvoiceAndRegisterCancellation($invoice, $message) + { + if ($invoice instanceof Invoice) { + $invoice->cancel(); + $this->getOrder()->addRelatedObject($invoice); + } + $this->getOrder()->registerCancellation($message, false); + } + + /** + * Sets order state status to 'payment_review' with appropriate message + * + * @param string $message + * @param int|null $transactionId + */ + protected function setOrderStatePaymentReview($message, $transactionId) + { + if ($this->getOrder()->getState() != Order::STATE_PAYMENT_REVIEW) { + $this->getOrder()->setState(Order::STATE_PAYMENT_REVIEW) + ->addStatusHistoryComment($message); + if ($this->getIsFraudDetected()) { + $this->getOrder()->setStatus(Order::STATUS_FRAUD); } - $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true, $message); - } elseif (false === $result) { - if ($invoice) { - $invoice->cancel(); - $order->addRelatedObject($invoice); + if ($transactionId) { + $this->setLastTransId($transactionId); } - $order->registerCancellation($message, false); + } else { + $this->getOrder()->addStatusHistoryComment($message); } - return $this; } /** @@ -1048,8 +1081,8 @@ protected function _order($amount) // do ordering $order = $this->getOrder(); - $state = \Magento\Sales\Model\Order::STATE_PROCESSING; - $status = true; + $state = Order::STATE_PROCESSING; + $status = false; $this->getMethodInstance()->setStore($order->getStoreId())->order($this, $amount); if ($this->getSkipOrderProcessing()) { @@ -1062,19 +1095,24 @@ protected function _order($amount) 'The order amount of %1 is pending approval on the payment gateway.', $this->_formatPrice($amount) ); - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; + $state = Order::STATE_PAYMENT_REVIEW; if ($this->getIsFraudDetected()) { - $status = \Magento\Sales\Model\Order::STATUS_FRAUD; + $status = Order::STATUS_FRAUD; } } else { $message = __('Ordered amount of %1', $this->_formatPrice($amount)); } // update transactions, order state and add comments - $transaction = $this->_addTransaction(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_ORDER); + $transaction = $this->_addTransaction(Transaction::TYPE_ORDER); $message = $this->_prependMessage($message); $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState($state, $status, $message); + + if (!$status) { + $status = $order->getConfig()->getStateDefaultStatus($state); + } + + $order->setState($state)->setStatus($status)->addStatusHistoryComment($message); return $this; } @@ -1104,8 +1142,8 @@ public function authorize($isOnline, $amount) // do authorization $order = $this->getOrder(); - $state = \Magento\Sales\Model\Order::STATE_PROCESSING; - $status = true; + $state = Order::STATE_PROCESSING; + $status = false; if ($isOnline) { // invoke authorization on gateway $this->getMethodInstance()->setStore($order->getStoreId())->authorize($this, $amount); @@ -1113,14 +1151,14 @@ public function authorize($isOnline, $amount) // similar logic of "payment review" order as in capturing if ($this->getIsTransactionPending()) { - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; + $state = Order::STATE_PAYMENT_REVIEW; $message = __( 'We will authorize %1 after the payment is approved at the payment gateway.', $this->_formatPrice($amount) ); } else { if ($this->getIsFraudDetected()) { - $state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW; + $state = Order::STATE_PAYMENT_REVIEW; $message = __( 'Order is suspended as its authorizing amount %1 is suspected to be fraudulent.', $this->_formatPrice($amount, $this->getCurrencyCode()) @@ -1130,15 +1168,19 @@ public function authorize($isOnline, $amount) } } if ($this->getIsFraudDetected()) { - $status = \Magento\Sales\Model\Order::STATUS_FRAUD; + $status = Order::STATUS_FRAUD; } // update transactions, order state and add comments - $transaction = $this->_addTransaction(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH); + $transaction = $this->_addTransaction(Transaction::TYPE_AUTH); $message = $this->_prependMessage($message); $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState($state, $status, $message); + if (!$status) { + $status = $order->getConfig()->getStateDefaultStatus($state); + } + + $order->setState($state)->setStatus($status)->addStatusHistoryComment($message); return $this; } @@ -1160,7 +1202,7 @@ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void') { $order = $this->getOrder(); $authTransaction = $this->getAuthorizationTransaction(); - $this->_generateTransactionId(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_VOID, $authTransaction); + $this->_generateTransactionId(Transaction::TYPE_VOID, $authTransaction); $this->setShouldCloseParentTransaction(true); // attempt to void @@ -1187,14 +1229,14 @@ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void') } // update transactions, order state and add comments - $transaction = $this->_addTransaction(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_VOID, null, true); + $transaction = $this->_addTransaction(Transaction::TYPE_VOID, null, true); $message = $this->hasMessage() ? $this->getMessage() : __('Voided authorization.'); $message = $this->_prependMessage($message); if ($amount) { $message .= ' ' . __('Amount: %1.', $this->_formatPrice($amount)); } $message = $this->_appendTransactionToMessage($transaction, $message); - $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true, $message); + $this->setOrderStateProcessing($message); $order->setDataChanges(true); return $this; } @@ -1228,7 +1270,7 @@ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void') * @param string $type * @param \Magento\Sales\Model\AbstractModel $salesDocument * @param bool $failsafe - * @return null|\Magento\Sales\Model\Order\Payment\Transaction + * @return null|Transaction * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -1300,7 +1342,7 @@ protected function _addTransaction($type, $salesDocument = null, $failsafe = fal * @param \Magento\Sales\Model\AbstractModel $salesDocument * @param bool $failsafe * @param bool|string $message - * @return null|\Magento\Sales\Model\Order\Payment\Transaction + * @return null|Transaction */ public function addTransaction($type, $salesDocument = null, $failsafe = false, $message = false) { @@ -1318,10 +1360,10 @@ public function addTransaction($type, $salesDocument = null, $failsafe = false, /** * Import details data of specified transaction * - * @param \Magento\Sales\Model\Order\Payment\Transaction $transactionTo + * @param Transaction $transactionTo * @return $this */ - public function importTransactionInfo(\Magento\Sales\Model\Order\Payment\Transaction $transactionTo) + public function importTransactionInfo(Transaction $transactionTo) { $data = $this->getMethodInstance()->setStore( $this->getOrder()->getStoreId() @@ -1331,7 +1373,7 @@ public function importTransactionInfo(\Magento\Sales\Model\Order\Payment\Transac ); if ($data) { $transactionTo->setAdditionalInformation( - \Magento\Sales\Model\Order\Payment\Transaction::RAW_DETAILS, + Transaction::RAW_DETAILS, $data ); } @@ -1372,7 +1414,7 @@ protected function _isTransactionExists($txnId = null) /** * Append transaction ID (if any) message to the specified message * - * @param \Magento\Sales\Model\Order\Payment\Transaction|null $transaction + * @param Transaction|null $transaction * @param string $message * @return string */ @@ -1438,7 +1480,7 @@ protected function _formatPrice($amount) * * @param string $txnId * @param bool|string $txnType - * @return \Magento\Sales\Model\Order\Payment\Transaction|false + * @return Transaction|false */ protected function _lookupTransaction($txnId, $txnType = false) { @@ -1482,7 +1524,7 @@ protected function _lookupTransaction($txnId, $txnType = false) * * @param string $txnId * @param bool|string $txnType - * @return \Magento\Sales\Model\Order\Payment\Transaction|false + * @return Transaction|false */ public function lookupTransaction($txnId, $txnType = false) { @@ -1491,7 +1533,7 @@ public function lookupTransaction($txnId, $txnType = false) /** * Lookup an authorization transaction using parent transaction id, if set - * @return \Magento\Sales\Model\Order\Payment\Transaction|false + * @return Transaction|false */ public function getAuthorizationTransaction() { @@ -1502,7 +1544,7 @@ public function getAuthorizationTransaction() } if (!$txn) { - $txn = $this->_lookupTransaction(false, \Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH); + $txn = $this->_lookupTransaction(false, Transaction::TYPE_AUTH); } return $txn; } @@ -1510,7 +1552,7 @@ public function getAuthorizationTransaction() /** * Lookup the transaction by id * @param string $transactionId - * @return \Magento\Sales\Model\Order\Payment\Transaction|false + * @return Transaction|false */ public function getTransaction($transactionId) { @@ -1522,7 +1564,7 @@ public function getTransaction($transactionId) * If no transactions were set before invoking, may generate an "offline" transaction id * * @param string $type - * @param bool|\Magento\Sales\Model\Order\Payment\Transaction $transactionBasedOn + * @param bool|Transaction $transactionBasedOn * @return void */ protected function _generateTransactionId($type, $transactionBasedOn = false) diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index 2ce05faf436ff..08d6786e108bd 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -13,7 +13,7 @@ * @method string getStatus() * @method string getLabel() */ -class Status extends \Magento\Framework\Model\AbstractModel +class Status extends \Magento\Sales\Model\AbstractModel { /** * @var \Magento\Store\Model\StoreManagerInterface @@ -23,6 +23,8 @@ class Status extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -31,15 +33,26 @@ class Status extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $resource, + $resourceCollection, + $data + ); $this->_storeManager = $storeManager; } + /** * @return void */ diff --git a/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php b/app/code/Magento/Sales/Model/Order/Tax/Item.php similarity index 95% rename from app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php rename to app/code/Magento/Sales/Model/Order/Tax/Item.php index 8ecadf3eec086..7d9e70931d6b5 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php +++ b/app/code/Magento/Sales/Model/Order/Tax/Item.php @@ -3,10 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tax\Model\Sales\Order\Tax; +namespace Magento\Sales\Model\Order\Tax; /** - * @codeCoverageIgnore + * Sales Order Tax Item model */ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface @@ -25,7 +25,7 @@ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements */ protected function _construct() { - $this->_init('Magento\Tax\Model\Resource\Sales\Order\Tax\Item'); + $this->_init('Magento\Sales\Model\Resource\Order\Tax\Item'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php index 862b5079bad3c..53afa0147c775 100644 --- a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php +++ b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php @@ -52,7 +52,7 @@ protected function _construct() protected function getConnection() { if (!$this->connection) { - $this->connection = $this->_resources->getConnection('write'); + $this->connection = $this->_resources->getConnection('sales_write'); } return $this->connection; } diff --git a/app/code/Magento/Sales/Model/Resource/Attribute.php b/app/code/Magento/Sales/Model/Resource/Attribute.php index b82a11cfd242d..7e5c1ce612448 100644 --- a/app/code/Magento/Sales/Model/Resource/Attribute.php +++ b/app/code/Magento/Sales/Model/Resource/Attribute.php @@ -45,7 +45,7 @@ public function __construct( protected function getConnection() { if (!$this->connection) { - $this->connection = $this->resource->getConnection('write'); + $this->connection = $this->resource->getConnection('sales_write'); } return $this->connection; } diff --git a/app/code/Magento/Sales/Model/Resource/EntityAbstract.php b/app/code/Magento/Sales/Model/Resource/EntityAbstract.php index 7b03391b8fa13..681bbf2886ec1 100644 --- a/app/code/Magento/Sales/Model/Resource/EntityAbstract.php +++ b/app/code/Magento/Sales/Model/Resource/EntityAbstract.php @@ -78,6 +78,9 @@ public function __construct( $this->sequenceManager = $sequenceManager; $this->gridAggregator = $gridAggregator; $this->entitySnapshot = $entitySnapshot; + if ($resourcePrefix === null) { + $resourcePrefix = 'sales'; + } parent::__construct($context, $resourcePrefix); } diff --git a/app/code/Magento/Sales/Model/Resource/Helper.php b/app/code/Magento/Sales/Model/Resource/Helper.php index 958b798694b80..d5aa62d239d22 100644 --- a/app/code/Magento/Sales/Model/Resource/Helper.php +++ b/app/code/Magento/Sales/Model/Resource/Helper.php @@ -44,17 +44,31 @@ public function getBestsellersReportUpdateRatingPos( $mainTable, $aggregationTable ) { + $adapter = $this->_resource->getConnection('sales_write'); if ($aggregation == $aggregationAliases['monthly']) { $this->_reportsResourceHelper->updateReportRatingPos( + $adapter, 'month', 'qty_ordered', $mainTable, $aggregationTable ); } elseif ($aggregation == $aggregationAliases['yearly']) { - $this->_reportsResourceHelper->updateReportRatingPos('year', 'qty_ordered', $mainTable, $aggregationTable); + $this->_reportsResourceHelper->updateReportRatingPos( + $adapter, + 'year', + 'qty_ordered', + $mainTable, + $aggregationTable + ); } else { - $this->_reportsResourceHelper->updateReportRatingPos('day', 'qty_ordered', $mainTable, $aggregationTable); + $this->_reportsResourceHelper->updateReportRatingPos( + $adapter, + 'day', + 'qty_ordered', + $mainTable, + $aggregationTable + ); } return $this; diff --git a/app/code/Magento/Sales/Model/Resource/Order.php b/app/code/Magento/Sales/Model/Resource/Order.php index 67f1fbf14b845..326b6a5cee171 100644 --- a/app/code/Magento/Sales/Model/Resource/Order.php +++ b/app/code/Magento/Sales/Model/Resource/Order.php @@ -89,21 +89,22 @@ public function __construct( public function aggregateProductsByTypes($orderId, $productTypeIds = [], $isProductTypeIn = false) { $adapter = $this->getReadConnection(); - $select = $adapter->select()->from( - ['o' => $this->getTable('sales_order_item')], - ['o.product_type', new \Zend_Db_Expr('COUNT(*)')] - )->joinInner( - ['p' => $this->getTable('catalog_product_entity')], - 'o.product_id=p.entity_id', - [] - )->where( - 'o.order_id=?', - $orderId - )->group( - 'o.product_type' - ); + $select = $adapter->select() + ->from( + ['o' => $this->getTable('sales_order_item')], + ['o.product_type', new \Zend_Db_Expr('COUNT(*)')] + ) + ->where('o.order_id=?', $orderId) + ->where('o.product_id IS NOT NULL') + ->group('o.product_type'); if ($productTypeIds) { - $select->where(sprintf('(o.product_type %s (?))', $isProductTypeIn ? 'IN' : 'NOT IN'), $productTypeIds); + $select->where( + sprintf( + '(o.product_type %s (?))', + $isProductTypeIn ? 'IN' : 'NOT IN' + ), + $productTypeIds + ); } return $adapter->fetchPairs($select); } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php b/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php index a0530530e0b14..f09ef08054b6e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php @@ -26,22 +26,24 @@ 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); + $order->setState(Order::STATE_COMPLETE) + ->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_COMPLETE)); } } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo() ) { if ($order->getState() !== Order::STATE_CLOSED) { - $order->setState(Order::STATE_CLOSED, true, '', $userNotification, false); + $order->setState(Order::STATE_CLOSED) + ->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED)); } } } if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) { - $order->setState(Order::STATE_PROCESSING, true, '', $userNotification); + $order->setState(Order::STATE_PROCESSING) + ->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)); } return $this; } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php index c4a1ff9408d4c..6ebf0702bb9eb 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php @@ -8,6 +8,9 @@ use Magento\Framework\App\Resource; use Psr\Log\LoggerInterface as LogWriter; use Magento\Framework\Exception\LocalizedException; +use Magento\SalesSequence\Model\Manager; +use \Magento\Sales\Model\Resource\EntityAbstract; +use \Magento\Sales\Model\Resource\EntitySnapshot; /** * Order status resource model @@ -30,27 +33,6 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected $stateTable; - /** - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * Class constructor - * - * @param \Magento\Framework\Model\Resource\Db\Context $context - * @param LogWriter $logger - * @param string|null $resourcePrefix - */ - public function __construct( - \Magento\Framework\Model\Resource\Db\Context $context, - LogWriter $logger, - $resourcePrefix = null - ) { - $this->logger = $logger; - parent::__construct($context, $resourcePrefix); - } - /** * Internal constructor * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php index fb5c0d7730738..f0532bbef278e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollection { /** * Internal constructor diff --git a/app/code/Magento/Sales/Model/Resource/Order/Tax.php b/app/code/Magento/Sales/Model/Resource/Order/Tax.php index 99a6b67e2ea60..17c3a0c240318 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Tax.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Tax.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Tax extends \Magento\Framework\Model\Resource\Db\AbstractDb +class Tax extends \Magento\Sales\Model\Resource\EntityAbstract { /** * Model initialization diff --git a/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php index 30f1ec27ecbd4..0943c4e0d7c07 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Tax/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection +class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollection { /** * Model initialization diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Tax/Item.php similarity index 61% rename from app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php rename to app/code/Magento/Sales/Model/Resource/Order/Tax/Item.php index b13eb4cdfa373..c2818b3447e7d 100644 --- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Tax/Item.php @@ -3,16 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile +namespace Magento\Sales\Model\Resource\Order\Tax; /** * Sales order tax resource model - * - * @author Magento Core Team */ -namespace Magento\Tax\Model\Resource\Sales\Order\Tax; - class Item extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** @@ -25,30 +20,6 @@ protected function _construct() $this->_init('sales_order_tax_item', 'tax_item_id'); } - /** - * Get Tax Items with order tax information - * - * @param int $item_id - * @return array - */ - public function getTaxItemsByItemId($item_id) - { - $adapter = $this->_getReadAdapter(); - $select = $adapter->select()->from( - ['item' => $this->getTable('sales_order_tax_item')], - ['tax_id', 'tax_percent'] - )->join( - ['tax' => $this->getTable('sales_order_tax')], - 'item.tax_id = tax.tax_id', - ['title', 'percent', 'base_amount'] - )->where( - 'item_id = ?', - $item_id - ); - - return $adapter->fetchAll($select); - } - /** * Get Tax Items with order tax information * diff --git a/app/code/Magento/Sales/Model/Resource/Report.php b/app/code/Magento/Sales/Model/Resource/Report.php index 479c898211d61..dba4b71740455 100644 --- a/app/code/Magento/Sales/Model/Resource/Report.php +++ b/app/code/Magento/Sales/Model/Resource/Report.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Report extends \Magento\Framework\Model\Resource\Db\AbstractDb +class Report extends \Magento\Sales\Model\Resource\EntityAbstract { /** * Resource initialization diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php index 43d3b6911072c..0d36c4981107d 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php @@ -96,10 +96,6 @@ protected function _construct() */ public function aggregate($from = null, $to = null) { - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $adapter = $this->_getWriteAdapter(); //$this->_getWriteAdapter()->beginTransaction(); @@ -117,7 +113,7 @@ public function aggregate($from = null, $to = null) } $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( ['source_table' => $this->getTable('sales_order')], @@ -134,25 +130,9 @@ public function aggregate($from = null, $to = null) 'period' => $periodExpr, 'store_id' => 'source_table.store_id', 'product_id' => 'order_item.product_id', - 'product_name' => new \Zend_Db_Expr( - sprintf('MIN(%s)', $adapter->getIfNullSql('product_name.value', 'product_default_name.value')) - ), + 'product_name' => new \Zend_Db_Expr('MIN(order_item.name)'), 'product_price' => new \Zend_Db_Expr( - sprintf( - '%s * %s', - new \Zend_Db_Expr( - sprintf( - 'MIN(%s)', - $adapter->getIfNullSql( - $adapter->getIfNullSql('product_price.value', 'product_default_price.value'), - 0 - ) - ) - ), - new \Zend_Db_Expr( - sprintf('MIN(%s)', $adapter->getIfNullSql('source_table.base_to_global_rate', '0')) - ) - ) + 'MIN(order_item.base_price) * MIN(source_table.base_to_global_rate)' ), 'qty_ordered' => new \Zend_Db_Expr('SUM(order_item.qty_ordered)'), ]; @@ -167,61 +147,9 @@ public function aggregate($from = null, $to = null) )->where( 'source_table.state != ?', \Magento\Sales\Model\Order::STATE_CANCELED - ); - - $joinExpr = [ - 'product.entity_id = order_item.product_id', - $adapter->quoteInto('product.type_id NOT IN(?)', $this->ignoredProductTypes), - ]; - - $joinExpr = implode(' AND ', $joinExpr); - $select->joinInner(['product' => $this->getTable('catalog_product_entity')], $joinExpr, []); - - // join product attributes Name & Price - $attr = $this->_productResource->getAttribute('name'); - $joinExprProductName = [ - 'product_name.entity_id = product.entity_id', - 'product_name.store_id = source_table.store_id', - $adapter->quoteInto('product_name.attribute_id = ?', $attr->getAttributeId()), - ]; - $joinExprProductName = implode(' AND ', $joinExprProductName); - $joinProductName = [ - 'product_default_name.entity_id = product.entity_id', - 'product_default_name.store_id = 0', - $adapter->quoteInto('product_default_name.attribute_id = ?', $attr->getAttributeId()), - ]; - $joinProductName = implode(' AND ', $joinProductName); - $select->joinLeft( - ['product_name' => $attr->getBackend()->getTable()], - $joinExprProductName, - [] - )->joinLeft( - ['product_default_name' => $attr->getBackend()->getTable()], - $joinProductName, - [] - ); - $attr = $this->_productResource->getAttribute('price'); - $joinExprProductPrice = [ - 'product_price.entity_id = product.entity_id', - 'product_price.store_id = source_table.store_id', - $adapter->quoteInto('product_price.attribute_id = ?', $attr->getAttributeId()), - ]; - $joinExprProductPrice = implode(' AND ', $joinExprProductPrice); - - $joinProductPrice = [ - 'product_default_price.entity_id = product.entity_id', - 'product_default_price.store_id = 0', - $adapter->quoteInto('product_default_price.attribute_id = ?', $attr->getAttributeId()), - ]; - $joinProductPrice = implode(' AND ', $joinProductPrice); - $select->joinLeft( - ['product_price' => $attr->getBackend()->getTable()], - $joinExprProductPrice, - [] - )->joinLeft( - ['product_default_price' => $attr->getBackend()->getTable()], - $joinProductPrice, - [] + )->where( + 'order_item.product_type NOT IN(?)', + $this->ignoredProductTypes ); if ($subSelect !== null) { diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php index 3e08b43e5e835..9a9d58ed25995 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php @@ -152,7 +152,7 @@ protected function _applyAggregatedTable() { $select = $this->getSelect(); - // if grouping by product, not by period + //if grouping by product, not by period if (!$this->_period) { $cols = $this->_getSelectedColumns(); $cols[$this->getOrderedField()] = 'SUM(' . $this->getOrderedField() . ')'; @@ -165,16 +165,7 @@ protected function _applyAggregatedTable() } //exclude removed products - $subSelect = $this->getConnection()->select(); - $subSelect->from( - ['existed_products' => $this->getTable('catalog_product_entity')], - new \Zend_Db_Expr('1)') - ); - - $select->exists( - $subSelect, - $mainTable . '.product_id = existed_products.entity_id' - )->group( + $select->where(new \Zend_Db_Expr($mainTable . '.product_id IS NOT NULL'))->group( 'product_id' )->order( $this->getOrderedField() . ' ' . \Magento\Framework\DB\Select::SQL_DESC diff --git a/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php b/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php index a56ed1886c43a..cc66574238777 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php @@ -31,10 +31,6 @@ protected function _construct() */ public function aggregate($from = null, $to = null) { - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $this->_aggregateByOrderCreatedAt($from, $to); $this->_aggregateByInvoiceCreatedAt($from, $to); @@ -76,7 +72,7 @@ protected function _aggregateByInvoiceCreatedAt($from, $to) } $this->_clearTableByDateRange($table, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( ['source_table' => $sourceTable], @@ -187,7 +183,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) } $this->_clearTableByDateRange($table, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql($this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to)); $columns = [ diff --git a/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php b/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php index 0847e44110915..d5876cdbb5df5 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php @@ -47,10 +47,6 @@ public function aggregate($from = null, $to = null) */ protected function _aggregateByField($aggregationField, $from, $to) { - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); diff --git a/app/code/Magento/Sales/Model/Resource/Report/Refunded.php b/app/code/Magento/Sales/Model/Resource/Report/Refunded.php index 0444f43b81077..f930650ddc345 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Refunded.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Refunded.php @@ -31,10 +31,6 @@ protected function _construct() */ public function aggregate($from = null, $to = null) { - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $this->_aggregateByOrderCreatedAt($from, $to); $this->_aggregateByRefundCreatedAt($from, $to); @@ -65,7 +61,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) } $this->_clearTableByDateRange($table, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to) ); @@ -162,7 +158,7 @@ protected function _aggregateByRefundCreatedAt($from, $to) } $this->_clearTableByDateRange($table, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( ['source_table' => $sourceTable], diff --git a/app/code/Magento/Sales/Model/Resource/Report/Shipping.php b/app/code/Magento/Sales/Model/Resource/Report/Shipping.php index c19e0beb5746f..3c26a59c309e1 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Shipping.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Shipping.php @@ -31,10 +31,6 @@ protected function _construct() */ public function aggregate($from = null, $to = null) { - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $this->_aggregateByOrderCreatedAt($from, $to); $this->_aggregateByShippingCreatedAt($from, $to); $this->_setFlagData(\Magento\Reports\Model\Flag::REPORT_SHIPPING_FLAG_CODE); @@ -64,7 +60,7 @@ protected function _aggregateByOrderCreatedAt($from, $to) } $this->_clearTableByDateRange($table, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery($sourceTable, 'created_at', $from, $to) ); @@ -166,7 +162,7 @@ protected function _aggregateByShippingCreatedAt($from, $to) } $this->_clearTableByDateRange($table, $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( ['source_table' => $sourceTable], diff --git a/app/code/Magento/Sales/Model/Service/Order.php b/app/code/Magento/Sales/Model/Service/Order.php index 5860dd46d6c91..fa22e21ff0e17 100644 --- a/app/code/Magento/Sales/Model/Service/Order.php +++ b/app/code/Magento/Sales/Model/Service/Order.php @@ -84,15 +84,13 @@ public function prepareInvoice($qtys = []) $item = $this->_convertor->itemToInvoiceItem($orderItem); if ($orderItem->isDummy()) { $qty = $orderItem->getQtyOrdered() ? $orderItem->getQtyOrdered() : 1; - } elseif (!empty($qtys)) { - if (isset($qtys[$orderItem->getId()])) { - $qty = (double)$qtys[$orderItem->getId()]; - } + } elseif (isset($qtys[$orderItem->getId()])) { + $qty = (double) $qtys[$orderItem->getId()]; } else { $qty = $orderItem->getQtyToInvoice(); } $totalQty += $qty; - $item->setQty($qty); + $this->setInvoiceItemQuantity($item, $qty); $invoice->addItem($item); } $invoice->setTotalQty($totalQty); @@ -101,6 +99,35 @@ public function prepareInvoice($qtys = []) return $invoice; } + /** + * Set quantity to invoice item + * + * @param \Magento\Sales\Model\Order\Invoice\Item $item + * @param float $qty + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function setInvoiceItemQuantity(\Magento\Sales\Model\Order\Invoice\Item $item, $qty) + { + $qty = ($item->getOrderItem()->getIsQtyDecimal()) ? (double) $qty : (int) $qty; + $qty = $qty > 0 ? $qty : 0; + + /** + * Check qty availability + */ + $qtyToInvoice = sprintf("%F", $item->getOrderItem()->getQtyToInvoice()); + $qty = sprintf("%F", $qty); + if ($qty > $qtyToInvoice && !$item->getOrderItem()->isDummy()) { + throw new \Magento\Framework\Exception\LocalizedException( + __('We found an invalid quantity to invoice item "%1".', $item->getName()) + ); + } + + $item->setQty($qty); + + return $this; + } + /** * Prepare order shipment based on order items and requested items qty * diff --git a/app/code/Magento/Sales/Model/Service/OrderService.php b/app/code/Magento/Sales/Model/Service/OrderService.php index 2fce36918d22d..20733b00649dd 100644 --- a/app/code/Magento/Sales/Model/Service/OrderService.php +++ b/app/code/Magento/Sales/Model/Service/OrderService.php @@ -9,6 +9,8 @@ /** * Class OrderService + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class OrderService implements OrderManagementInterface { @@ -37,6 +39,11 @@ class OrderService implements OrderManagementInterface */ protected $notifier; + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $eventManager; + /** * Constructor * @@ -45,19 +52,22 @@ class OrderService implements OrderManagementInterface * @param \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Sales\Model\OrderNotifier $notifier + * @param \Magento\Framework\Event\ManagerInterface $eventManager */ public function __construct( \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Sales\Api\OrderStatusHistoryRepositoryInterface $historyRepository, \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, - \Magento\Sales\Model\OrderNotifier $notifier + \Magento\Sales\Model\OrderNotifier $notifier, + \Magento\Framework\Event\ManagerInterface $eventManager ) { $this->orderRepository = $orderRepository; $this->historyRepository = $historyRepository; $this->criteriaBuilder = $criteriaBuilder; $this->filterBuilder = $filterBuilder; $this->notifier = $notifier; + $this->eventManager = $eventManager; } /** @@ -149,20 +159,82 @@ public function unHold($id) /** * @param \Magento\Sales\Api\Data\OrderInterface $order * @return \Magento\Sales\Api\Data\OrderInterface + * @throws \Exception */ public function place(\Magento\Sales\Api\Data\OrderInterface $order) { // transaction will be here //begin transaction try { -// $order = $this->orderRepository->save($order); $order->place(); return $this->orderRepository->save($order); - //commit } catch (\Exception $e) { throw $e; //rollback; } } + + /** + * Order state setter. + * + * If status is specified, will add order status history with specified comment + * the setData() cannot be overridden because of compatibility issues with resource model + * By default allows to set any state. Can also update status to default or specified value + * Complete and closed states are encapsulated intentionally + * + * @param \Magento\Sales\Api\Data\OrderInterface $order + * @param string $state + * @param string|bool $status + * @param string $comment + * @param bool $isCustomerNotified + * @param bool $shouldProtectState + * @return \Magento\Sales\Model\Order + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function setState( + \Magento\Sales\Api\Data\OrderInterface $order, + $state, + $status = false, + $comment = '', + $isCustomerNotified = null, + $shouldProtectState = true + ) { + // attempt to set the specified state + if ($shouldProtectState) { + if ($order->isStateProtected($state)) { + throw new \Magento\Framework\Exception\LocalizedException( + __('The Order State "%1" must not be set manually.', $state) + ); + } + } + + $transport = new \Magento\Framework\Object( + [ + 'state' => $state, + 'status' => $status, + 'comment' => $comment, + 'is_customer_notified' => $isCustomerNotified + ] + ); + + $this->eventManager->dispatch( + 'sales_order_state_change_before', + ['order' => $this, 'transport' => $transport] + ); + $status = $transport->getStatus(); + $order->setData('state', $transport->getState()); + + // add status history + if ($status) { + if ($status === true) { + $status = $order->getConfig()->getStateDefaultStatus($transport->getState()); + } + $order->setStatus($status); + $history = $order->addStatusHistoryComment($transport->getComment(), false); + // no sense to set $status again + $history->setIsCustomerNotified($transport->getIsCustomerNotified()); + } + return $this; + } } diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php index 21014f444dcc2..a51b0b23971e7 100644 --- a/app/code/Magento/Sales/Setup/InstallSchema.php +++ b/app/code/Magento/Sales/Setup/InstallSchema.php @@ -5038,6 +5038,105 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con ); $installer->getConnection()->createTable($table); + /** + * Create table 'sales_order_tax_item' + */ + $table = $setup->getConnection()->newTable( + $setup->getTable('sales_order_tax_item') + )->addColumn( + 'tax_item_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], + 'Tax Item Id' + )->addColumn( + 'tax_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['unsigned' => true, 'nullable' => false], + 'Tax Id' + )->addColumn( + 'item_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['unsigned' => true, 'nullable' => true], + 'Item Id' + )->addColumn( + 'tax_percent', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + ['nullable' => false], + 'Real Tax Percent For Item' + )->addColumn( + 'amount', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + ['nullable' => false], + 'Tax amount for the item and tax rate' + )->addColumn( + 'base_amount', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + ['nullable' => false], + 'Base tax amount for the item and tax rate' + )->addColumn( + 'real_amount', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + ['nullable' => false], + 'Real tax amount for the item and tax rate' + )->addColumn( + 'real_base_amount', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + ['nullable' => false], + 'Real base tax amount for the item and tax rate' + )->addColumn( + 'associated_item_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => true, 'unsigned' => true], + 'Id of the associated item' + )->addColumn( + 'taxable_item_type', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 32, + ['nullable' => false], + 'Type of the taxable item' + )->addIndex( + $setup->getIdxName('sales_order_tax_item', ['item_id']), + ['item_id'] + )->addIndex( + $setup->getIdxName( + 'sales_order_tax_item', + ['tax_id', 'item_id'], + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ), + ['tax_id', 'item_id'], + ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] + )->addForeignKey( + $setup->getFkName('sales_order_tax_item', 'associated_item_id', 'sales_order_item', 'item_id'), + 'associated_item_id', + $setup->getTable('sales_order_item'), + 'item_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE + )->addForeignKey( + $setup->getFkName('sales_order_tax_item', 'tax_id', 'sales_order_tax', 'tax_id'), + 'tax_id', + $setup->getTable('sales_order_tax'), + 'tax_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE + )->addForeignKey( + $setup->getFkName('sales_order_tax_item', 'item_id', 'sales_order_item', 'item_id'), + 'item_id', + $setup->getTable('sales_order_item'), + 'item_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE + )->setComment( + 'Sales Order Tax Item' + ); + $setup->getConnection()->createTable($table); + /** * Create table 'sales_order_status' */ diff --git a/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php b/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php index 9e32496a24722..5c34eb49fdbb9 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Reorder/SidebarTest.php @@ -64,6 +64,7 @@ class SidebarTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->markTestIncomplete('MAGETWO-36789'); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); $this->httpContext = $this->getMock('Magento\Framework\App\Http\Context', ['getValue'], [], '', false); @@ -94,7 +95,7 @@ protected function setUp() 'addAttributeToFilter', 'addAttributeToSort', 'setPage', - 'setOrders' + 'setOrders', ], [], '', diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php new file mode 100644 index 0000000000000..63dae97d9093c --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php @@ -0,0 +1,159 @@ +contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', + 'getResponse', + 'getMessageManager', + 'getRedirect', + 'getObjectManager', + 'getSession', + 'getActionFlag', + 'getHelper', + 'getResultRedirectFactory' + ], + [], + '', + false + ); + + $this->messageManagerMock = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + + $this->resultRedirectFactoryMock = $this->getMock( + 'Magento\Backend\Model\View\Result\RedirectFactory', + ['create'], + [], + '', + false + ); + + $this->paymentMock = $this->getMock( + 'Magento\Sales\Model\Order\Payment', + ['registerPaymentReviewAction', 'update'], + [], + '', + false + ); + + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + ['load', 'getId', 'getPayment', 'save'], + [], + '', + false + ); + + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + + + $this->resultRedirectMock = $this->getMock( + 'Magento\Backend\Model\View\Result\Redirect', + ['setPath'], + [], + '', + false + ); + + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->setMethods(['getParam']) + ->disableOriginalConstructor()->getMock(); + + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once()) + ->method('getResultRedirectFactory') + ->willReturn($this->resultRedirectFactoryMock); + + $this->reviewPayment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + 'Magento\Sales\Controller\Adminhtml\Order\ReviewPayment', + [ + 'context' => $this->contextMock + ] + ); + } + + public function testExecuteUpdateAction() + { + $orderId = 30; + $action = 'update'; + + $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->willReturn($orderId); + $this->requestMock->expects($this->at(1))->method('getParam')->with('action')->willReturn($action); + + $this->resultRedirectFactoryMock->expects($this->once())->method('create') + ->willReturn($this->resultRedirectMock); + + $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\Sales\Model\Order') + ->willReturn($this->orderMock); + + $this->orderMock->expects($this->once())->method('load')->with($orderId)->willReturn($this->orderMock); + $this->orderMock->expects($this->any())->method('getId')->willReturn($orderId); + $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock); + $this->orderMock->expects($this->once())->method('save')->willReturnSelf(); + + $this->messageManagerMock->expects($this->once())->method('addSuccess') + ->with('The payment update has been made.'); + + $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf(); + + $this->paymentMock->expects($this->once())->method('update'); + + $result = $this->reviewPayment->execute(); + $this->assertEquals($this->resultRedirectMock, $result); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php index 9359af03ee68d..0439e7ec6e26e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php @@ -39,7 +39,7 @@ protected function setUp() $this->config = $this->getMock('Magento\Framework\App\Config', [], [], '', false); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager\Proxy', [], [], '', false); + $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); $this->context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManager); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php index 729c19940ccff..78dca5c8d308b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Grid/AsyncIndexingTest.php @@ -29,7 +29,7 @@ class AsyncIndexingTest extends \PHPUnit_Framework_TestCase protected $context; /** - * @var \Magento\Framework\Event\Manager\Proxy|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Event\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $eventManager; @@ -39,7 +39,7 @@ protected function setUp() $this->config = $this->getMock('Magento\Framework\App\Config', [], [], '', false); - $this->eventManager = $this->getMock('Magento\Framework\Event\Manager\Proxy', [], [], '', false); + $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); $this->context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManager); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php index 8e4abcc37683f..914ba25fe3027 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/ItemTest.php @@ -98,30 +98,9 @@ public function testGetOrderItemFromFactory() public function testSetQty() { - $this->orderItemFactoryMock->expects($this->once())->method('create')->willReturn($this->orderItemMock); - $this->orderItemMock->expects($this->once())->method('load')->with(1)->willReturn($this->orderItemMock); - $this->orderItemMock->expects($this->once())->method('getIsQtyDecimal')->willReturn(true); - $this->orderItemMock->expects($this->once())->method('getQtyToInvoice')->willReturn(2); - $this->orderItemMock->expects($this->once())->method('isDummy')->willReturn(true); - $this->item->setOrderItemId(1); - $this->assertEquals($this->item->setQty(3), $this->item); - } - - - /** - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage We found an invalid quantity to invoice item "Item Name". - */ - public function testSetQtyWrongQty() - { - $this->orderItemFactoryMock->expects($this->once())->method('create')->willReturn($this->orderItemMock); - $this->orderItemMock->expects($this->once())->method('load')->with(1)->willReturn($this->orderItemMock); - $this->orderItemMock->expects($this->once())->method('getIsQtyDecimal')->willReturn(true); - $this->orderItemMock->expects($this->once())->method('getQtyToInvoice')->willReturn(2); - $this->orderItemMock->expects($this->once())->method('isDummy')->willReturn(false); - $this->item->setOrderItemId(1); - $this->item->setName('Item Name'); - $this->assertEquals($this->item->setQty(3), $this->item); + $qty = 3; + $this->assertEquals($this->item->setQty($qty), $this->item); + $this->assertEquals($this->item->getQty(), $qty); } public function testRegister() diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php new file mode 100644 index 0000000000000..88bd090c82de8 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php @@ -0,0 +1,177 @@ +objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); + + $arguments = [ + 'orderFactory' => $this->orderFactory, + ]; + $this->model = $this->objectManager->getObject('Magento\Sales\Model\Order\Item', $arguments); + } + + + public function testSetParentItemNull() + { + $this->assertEquals($this->model, $this->model->setParentItem(null)); + $this->assertNull($this->model->getParentItem()); + } + + + public function testSetParentItem() + { + $item = $this->objectManager->getObject('Magento\Sales\Model\Order\Item', []); + $this->assertEquals($this->model, $this->model->setParentItem($item)); + $this->assertEquals($item, $this->model->getParentItem()); + $this->assertTrue($item->getHasChildren()); + $this->assertCount(1, $item->getChildrenItems()); + } + + public function testGetPatentItem() + { + $item = $this->objectManager->getObject('Magento\Sales\Model\Order\Item', []); + $this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::PARENT_ITEM, $item); + $this->assertEquals($item, $this->model->getParentItem()); + } + + public function testSetOrder() + { + $orderId = 123; + $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $order->expects($this->once()) + ->method('getId') + ->willReturn($orderId); + $this->assertEquals($this->model, $this->model->setOrder($order)); + $this->assertEquals($orderId, $this->model->getOrderId()); + } + + public function testGetOrder() + { + //order and order_id was not set + $this->assertNull($this->model->getOrder()); + + //set order_id and get order by id + $orderId = 123; + $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $order->expects($this->once()) + ->method('load') + ->with($orderId) + ->willReturnSelf(); + $this->orderFactory->expects($this->once()) + ->method('create') + ->willReturn($order); + $this->model->setOrderId($orderId); + $this->assertEquals($order, $this->model->getOrder()); + + //get existed order + $this->assertEquals($order, $this->model->getOrder()); + } + + /** + * @param $qtyBackOrdered + * @param $hasChildren + * @param $qtyCanceled + * @param $qtyInvoiced + * @param $qtyOrdered + * @param $qtyRefunded + * @param $qtyShipped + * @param $expectedStatus + * + * @dataProvider getStatusIdDataProvider + */ + public function testGetStatusId( + $qtyBackOrdered, + $qtyCanceled, + $qtyInvoiced, + $qtyOrdered, + $qtyRefunded, + $qtyShipped, + $expectedStatus + ) { + $this->model->setQtyBackordered($qtyBackOrdered); + $this->model->setQtyCanceled($qtyCanceled); + $this->model->setQtyInvoiced($qtyInvoiced); + $this->model->setQtyOrdered($qtyOrdered); + $this->model->setQtyRefunded($qtyRefunded); + $this->model->setQtyShipped($qtyShipped); + + $this->assertEquals($expectedStatus, $this->model->getStatusId()); + } + + public function getStatusIdDataProvider() + { + return [ + [0, 0, 0, null, 0, 0, \Magento\Sales\Model\Order\Item::STATUS_PENDING], + [0, 10, 1, 100, 10, 80, \Magento\Sales\Model\Order\Item::STATUS_SHIPPED], + [1, 10, 1, 100, 10, 80, \Magento\Sales\Model\Order\Item::STATUS_SHIPPED], + [1, 10, 1, 100, 10, 99, \Magento\Sales\Model\Order\Item::STATUS_MIXED], + [0, 10, 80, 100, 10, 0, \Magento\Sales\Model\Order\Item::STATUS_INVOICED], + [1, 10, 80, 100, 10, 0, \Magento\Sales\Model\Order\Item::STATUS_INVOICED], + [1, 10, 99, 100, 10, 0, \Magento\Sales\Model\Order\Item::STATUS_MIXED], + [80, 10, null, 100, 10, null, \Magento\Sales\Model\Order\Item::STATUS_BACKORDERED], + [null, null, null, 9, 9, null, \Magento\Sales\Model\Order\Item::STATUS_REFUNDED], + [null, 9, null, 9, null, null, \Magento\Sales\Model\Order\Item::STATUS_CANCELED], + [1, 10, 70, 100, 10, 79, \Magento\Sales\Model\Order\Item::STATUS_PARTIAL], + [0, 10, 70, 100, 10, 79, \Magento\Sales\Model\Order\Item::STATUS_PARTIAL] + ]; + } + + public function testGetStatuses() + { + $statuses = [ + \Magento\Sales\Model\Order\Item::STATUS_PENDING => 'Ordered', + \Magento\Sales\Model\Order\Item::STATUS_SHIPPED => 'Shipped', + \Magento\Sales\Model\Order\Item::STATUS_INVOICED => 'Invoiced', + \Magento\Sales\Model\Order\Item::STATUS_BACKORDERED => 'Backordered', + \Magento\Sales\Model\Order\Item::STATUS_RETURNED => 'Returned', + \Magento\Sales\Model\Order\Item::STATUS_REFUNDED => 'Refunded', + \Magento\Sales\Model\Order\Item::STATUS_CANCELED => 'Canceled', + \Magento\Sales\Model\Order\Item::STATUS_PARTIAL => 'Partial', + \Magento\Sales\Model\Order\Item::STATUS_MIXED => 'Mixed', + ]; + $this->assertEquals($statuses, $this->model->getStatuses()); + } + + public function testGetOriginalPrice() + { + $price = 9.99; + $this->model->setPrice($price); + $this->assertEquals($price, $this->model->getOriginalPrice()); + + $originalPrice = 5.55; + $this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::ORIGINAL_PRICE, $originalPrice); + $this->assertEquals($originalPrice, $this->model->getOriginalPrice()); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php index 0b9e28a977f3c..ae0a682d0c934 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/TransactionRepositoryTest.php @@ -42,7 +42,7 @@ protected function setUp() { $this->transactionFactory = $this->getMock( 'Magento\Sales\Model\Order\Payment\TransactionFactory', - [], + ['create'], [], '', false diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index 3fd4c2b549773..fe5e70a1a7b81 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -5,33 +5,84 @@ */ namespace Magento\Sales\Test\Unit\Model\Order; -use \Magento\Sales\Model\Order\Payment; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Payment; /** * Class PaymentTest * - * @package Magento\Sales\Model\Order + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PaymentTest extends \PHPUnit_Framework_TestCase { - /** @var Payment */ - private $payment; + /** + * @var Payment + */ + protected $payment; - /** @var \Magento\Payment\Helper\Data | \PHPUnit_Framework_MockObject_MockObject */ - private $helperMock; + /** + * @var \Magento\Payment\Helper\Data | \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; - /** @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject */ - private $eventManagerMock; + /** + * @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; - /** @var \Magento\Directory\Model\PriceCurrency | \PHPUnit_Framework_MockObject_MockObject */ - private $priceCurrencyMock; + /** + * @var \Magento\Directory\Model\PriceCurrency | \PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrencyMock; - /** @var \Magento\Sales\Model\Order | \PHPUnit_Framework_MockObject_MockObject $orderMock */ - private $orderMock; + /** + * @var \Magento\Directory\Model\Currency | \PHPUnit_Framework_MockObject_MockObject + */ + protected $currencyMock; - /** @var \Magento\Payment\Model\Method\AbstractMethod | \PHPUnit_Framework_MockObject_MockObject $orderMock */ - private $paymentMethodMock; + /** + * @var Order | \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + /** + * @var \Magento\Payment\Model\Method\AbstractMethod | \PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentMethodMock; + + /** @var \Magento\Sales\Model\Order\Invoice | \PHPUnit_Framework_MockObject_MockObject $orderMock */ + private $invoiceMock; + + private $transactionId; + + /** + * @var \Magento\Sales\Model\Order\Payment\TransactionFactory | \PHPUnit_Framework_MockObject_MockObject + */ + protected $transactionFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $transactionCollectionFactory; + + /** + * @var \Magento\Sales\Model\Service\OrderFactory | \PHPUnit_Framework_MockObject_MockObject + */ + protected $serviceOrderFactory; + + /** + * @var \Magento\Sales\Model\Service\Order | \PHPUnit_Framework_MockObject_MockObject + */ + protected $serviceOrder; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo | \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditMemoMock; + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ protected function setUp() { $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') @@ -55,6 +106,10 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['format']) ->getMock(); + $this->currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + ->disableOriginalConstructor() + ->setMethods(['formatTxt']) + ->getMock(); $this->priceCurrencyMock->expects($this->any()) ->method('format') @@ -66,44 +121,111 @@ function ($value) { $this->paymentMethodMock = $this->getMockBuilder('Magento\Payment\Model\Method\AbstractMethod') ->disableOriginalConstructor() - ->setMethods([ - 'canVoid', - 'authorize', - 'getConfigData', - 'getConfigPaymentAction', - 'validate', - ]) + ->setMethods( + [ + 'canVoid', + 'authorize', + 'getConfigData', + 'getConfigPaymentAction', + 'validate', + 'setStore', + 'acceptPayment', + 'denyPayment', + 'fetchTransactionInfo', + 'canCapture', + 'canRefund' + ] + ) ->getMock(); - $this->helperMock->expects($this->once()) - ->method('getMethodInstance') + $this->invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getTransactionId', + 'load', + 'getId', + 'pay', + 'cancel', + 'getGrandTotal', + 'getBaseGrandTotal', + 'getShippingAmount', + 'getBaseShippingAmount', + 'getBaseTotalRefunded' + ] + ) + ->getMock(); + $this->helperMock->method('getMethodInstance') ->will($this->returnValue($this->paymentMethodMock)); $this->orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') ->disableOriginalConstructor() - ->setMethods([ - 'getConfig', - 'setState', - 'getStoreId', - 'getBaseGrandTotal', - 'getBaseCurrency', - 'getBaseCurrencyCode', - 'getTotalDue', - 'getBaseTotalDue', - ]) + ->setMethods( + [ + 'getConfig', + 'setState', + 'setStatus', + 'getStoreId', + 'getBaseGrandTotal', + 'getBaseCurrency', + 'getBaseCurrencyCode', + 'getTotalDue', + 'getBaseTotalDue', + 'getInvoiceCollection', + 'addRelatedObject', + 'getState', + 'addStatusHistoryComment', + 'registerCancellation', + ] + ) ->getMock(); - $this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - 'Magento\Sales\Model\Order\Payment', + $this->transactionFactory = $this->getMock( + 'Magento\Sales\Model\Order\Payment\TransactionFactory', + ['create'], + [], + '', + false + ); + $this->transactionCollectionFactory = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->serviceOrderFactory = $this->getMock( + 'Magento\Sales\Model\Service\OrderFactory', + ['create'], + [], + '', + false + ); + $this->serviceOrder = $this->getMock( + 'Magento\Sales\Model\Service\Order', + [], + [], + '', + false + ); + $this->creditMemoMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', [ - 'context' => $context, - 'paymentData' => $this->helperMock, - 'priceCurrency' => $this->priceCurrencyMock, - ] + 'setPaymentRefundDisallowed', + 'getItemsCollection', + 'getItems', + 'setAutomaticallyCreated', + 'register', + 'addComment', + 'save', + 'getGrandTotal' + ], + [], + '', + false ); - $this->payment->setMethod('any'); - $this->payment->setOrder($this->orderMock); + $this->initPayment($context); } protected function tearDown() @@ -113,6 +235,9 @@ protected function tearDown() public function testCancel() { + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); // check fix for partial refunds in Payflow Pro $this->paymentMethodMock->expects($this->once()) ->method('canVoid') @@ -126,29 +251,13 @@ public function testPlace() { $newOrderStatus = 'new_status'; - /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfigMock */ - $orderConfigMock = $this->getMockBuilder('Magento\Sales\Model\Order\Config') - ->disableOriginalConstructor() - ->setMethods(['getStateStatuses', 'getStateDefaultStatus']) - ->getMock(); - - $orderConfigMock->expects($this->once()) - ->method('getStateStatuses') - ->with(\Magento\Sales\Model\Order::STATE_NEW) - ->will($this->returnValue(['firstStatus', 'secondStatus'])); - - $orderConfigMock->expects($this->once()) - ->method('getStateDefaultStatus') - ->with(\Magento\Sales\Model\Order::STATE_NEW) - ->will($this->returnValue($newOrderStatus)); + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); - $this->orderMock->expects($this->exactly(2)) - ->method('getConfig') - ->will($this->returnValue($orderConfigMock)); + $this->mockGetDefaultStatus(Order::STATE_NEW, $newOrderStatus, ['first', 'second']); - $this->orderMock->expects($this->once()) - ->method('setState') - ->with(\Magento\Sales\Model\Order::STATE_NEW, $newOrderStatus); + $this->assertOrderUpdated(Order::STATE_NEW, $newOrderStatus); $this->paymentMethodMock->expects($this->once()) ->method('getConfigPaymentAction') @@ -169,6 +278,15 @@ public function testAuthorize() { $storeID = 1; $amount = 10; + $status = 'status'; + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); $baseCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') ->disableOriginalConstructor() @@ -195,9 +313,8 @@ function ($value) { ->method('getBaseCurrency') ->willReturn($baseCurrencyMock); - $this->orderMock->expects($this->once()) - ->method('setState') - ->with(\Magento\Sales\Model\Order::STATE_PROCESSING, true, 'Authorized amount of ' . $amount); + $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status); + $this->assertOrderUpdated(Order::STATE_PROCESSING, $status, 'Authorized amount of ' . $amount); $this->paymentMethodMock->expects($this->once()) ->method('authorize') @@ -214,6 +331,15 @@ public function testAuthorizeFraudDetected() { $storeID = 1; $amount = 10; + $message = "Order is suspended as its authorizing amount $amount is suspected to be fraudulent."; + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); $baseCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') ->disableOriginalConstructor() @@ -240,13 +366,7 @@ function ($value) { ->method('getBaseCurrency') ->willReturn($baseCurrencyMock); - $this->orderMock->expects($this->once()) - ->method('setState') - ->with( - \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW, - \Magento\Sales\Model\Order::STATUS_FRAUD, - "Order is suspended as its authorizing amount $amount is suspected to be fraudulent." - ); + $this->assertOrderUpdated(Order::STATE_PAYMENT_REVIEW, Order::STATUS_FRAUD, $message); $this->paymentMethodMock->expects($this->once()) ->method('authorize') @@ -266,6 +386,16 @@ public function testAuthorizeTransactionPending() { $storeID = 1; $amount = 10; + $status = 'status'; + $message = "We will authorize $amount after the payment is approved at the payment gateway."; + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); $baseCurrencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') ->disableOriginalConstructor() @@ -292,13 +422,8 @@ function ($value) { ->method('getBaseCurrency') ->willReturn($baseCurrencyMock); - $this->orderMock->expects($this->once()) - ->method('setState') - ->with( - \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW, - true, - "We will authorize $amount after the payment is approved at the payment gateway." - ); + $this->mockGetDefaultStatus(Order::STATE_PAYMENT_REVIEW, $status); + $this->assertOrderUpdated(Order::STATE_PAYMENT_REVIEW, $status, $message); $this->paymentMethodMock->expects($this->once()) ->method('authorize') @@ -313,4 +438,934 @@ function ($value) { $this->assertEquals($amount, $paymentResult->getBaseAmountAuthorized()); $this->assertTrue($paymentResult->getIsTransactionPending()); } + + public function testAcceptApprovePaymentTrue() + { + $baseGrandTotal = 300.00; + $message = sprintf('Approved the payment online. Transaction ID: "%s"', $this->transactionId); + $acceptPayment = true; + + $this->payment->setLastTransId($this->transactionId); + + $this->mockInvoice($this->transactionId); + + $this->mockResultTrueMethods($this->transactionId, $baseGrandTotal, $message); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('acceptPayment') + ->with($this->payment) + ->willReturn($acceptPayment); + + $this->payment->accept(); + $this->assertEquals($baseGrandTotal, $this->payment->getBaseAmountPaidOnline()); + } + + public function acceptPaymentFalseProvider() + { + return [ + 'Fraud = 1' => [ + true, + Order::STATUS_FRAUD + ], + 'Fraud = 0' => [ + false, + false + ], + ]; + } + + /** + * @dataProvider acceptPaymentFalseProvider + * @param bool $isFraudDetected + * @param bool $status + */ + public function testAcceptApprovePaymentFalse($isFraudDetected, $status) + { + $message = sprintf('There is no need to approve this payment. Transaction ID: "%s"', $this->transactionId); + $acceptPayment = false; + $orderState = 'random_state'; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_fraud_detected', $isFraudDetected); + + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn($orderState); + + $this->assertOrderUpdated(Order::STATE_PAYMENT_REVIEW, $status, $message); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('acceptPayment') + ->with($this->payment) + ->willReturn($acceptPayment); + + $this->payment->accept(); + $this->assertEquals($this->transactionId, $this->payment->getLastTransId()); + } + + /** + * + * @dataProvider acceptPaymentFalseProvider + * @param bool $isFraudDetected + */ + public function testAcceptApprovePaymentFalseOrderState($isFraudDetected) + { + $message = sprintf('There is no need to approve this payment. Transaction ID: "%s"', $this->transactionId); + $acceptPayment = false; + $orderState = Order::STATE_PAYMENT_REVIEW; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_fraud_detected', $isFraudDetected); + + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn($orderState); + + $this->orderMock->expects($this->never()) + ->method('setState'); + $this->orderMock->expects($this->once()) + ->method('addStatusHistoryComment') + ->with($message); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('acceptPayment') + ->with($this->payment) + ->willReturn($acceptPayment); + + $this->payment->accept(); + $this->assertEquals($this->transactionId, $this->payment->getLastTransId()); + } + + public function testDenyPaymentFalse() + { + $denyPayment = true; + $message = sprintf('Denied the payment online Transaction ID: "%s"', $this->transactionId); + + $this->payment->setLastTransId($this->transactionId); + + $this->mockInvoice($this->transactionId); + $this->mockResultFalseMethods($message); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('denyPayment') + ->with($this->payment) + ->willReturn($denyPayment); + + $this->payment->deny(); + } + + /** + * @dataProvider acceptPaymentFalseProvider + * @param bool $isFraudDetected + * @param bool $status + */ + public function testDenyPaymentNegative($isFraudDetected, $status) + { + $denyPayment = false; + $message = sprintf('There is no need to deny this payment. Transaction ID: "%s"', $this->transactionId); + + $orderState = 'random_state'; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_fraud_detected', $isFraudDetected); + + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn($orderState); + + $this->assertOrderUpdated(Order::STATE_PAYMENT_REVIEW, $status, $message); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('denyPayment') + ->with($this->payment) + ->willReturn($denyPayment); + + $this->payment->deny(); + } + + public function testDenyPaymentNegativeStateReview() + { + $denyPayment = false; + $message = sprintf('There is no need to deny this payment. Transaction ID: "%s"', $this->transactionId); + + $orderState = Order::STATE_PAYMENT_REVIEW; + + $this->payment->setLastTransId($this->transactionId); + + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn($orderState); + + $this->orderMock->expects($this->never()) + ->method('setState'); + $this->orderMock->expects($this->once()) + ->method('addStatusHistoryComment') + ->with($message); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('denyPayment') + ->with($this->payment) + ->willReturn($denyPayment); + + $this->payment->deny(); + } + + /** + * @param int $transactionId + * @param int $countCall + */ + protected function mockInvoice($transactionId, $countCall = 1) + { + $this->invoiceMock->expects($this->once()) + ->method('getTransactionId') + ->willReturn($transactionId); + $this->invoiceMock->expects($this->once()) + ->method('load') + ->with($transactionId); + $this->invoiceMock->expects($this->once()) + ->method('getId') + ->willReturn($transactionId); + $this->orderMock->expects($this->exactly($countCall)) + ->method('getInvoiceCollection') + ->willReturn([$this->invoiceMock]); + } + + public function testUpdateOnlineTransactionApproved() + { + $message = sprintf('Registered update about approved payment. Transaction ID: "%s"', $this->transactionId); + + $storeId = 50; + $baseGrandTotal = 299.99; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_transaction_approved', true); + + $this->mockInvoice($this->transactionId); + $this->mockResultTrueMethods($this->transactionId, $baseGrandTotal, $message); + + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeId); + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->with($storeId) + ->willReturn($this->paymentMethodMock); + $this->paymentMethodMock->expects($this->once()) + ->method('fetchTransactionInfo') + ->with($this->payment, $this->transactionId); + + $this->payment->update(); + $this->assertEquals($baseGrandTotal, $this->payment->getBaseAmountPaidOnline()); + } + + public function testUpdateOnlineTransactionDenied() + { + $message = sprintf('Registered update about denied payment. Transaction ID: "%s"', $this->transactionId); + + $storeId = 50; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_transaction_denied', true); + + $this->mockInvoice($this->transactionId); + $this->mockResultFalseMethods($message); + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeId); + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->with($storeId) + ->willReturn($this->paymentMethodMock); + $this->paymentMethodMock->expects($this->once()) + ->method('fetchTransactionInfo') + ->with($this->payment, $this->transactionId); + + $this->payment->update(); + } + + /** + * @dataProvider acceptPaymentFalseProvider + * @param bool $isFraudDetected + * @param bool $status + */ + public function testUpdateOnlineTransactionDeniedFalse($isFraudDetected, $status) + { + $message = sprintf('There is no update for the payment. Transaction ID: "%s"', $this->transactionId); + + $storeId = 50; + $orderState = 'random_state'; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_transaction_denied', false); + $this->payment->setData('is_transaction_approved', false); + $this->payment->setData('is_fraud_detected', $isFraudDetected); + + $this->mockInvoice($this->transactionId); + + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn($orderState); + + $this->assertOrderUpdated(Order::STATE_PAYMENT_REVIEW, $status, $message); + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeId); + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->with($storeId) + ->willReturn($this->paymentMethodMock); + $this->paymentMethodMock->expects($this->once()) + ->method('fetchTransactionInfo') + ->with($this->payment, $this->transactionId); + + $this->payment->update(); + $this->assertEquals($this->transactionId, $this->payment->getLastTransId()); + } + + public function testUpdateOnlineTransactionDeniedFalseHistoryComment() + { + $message = sprintf('There is no update for the payment. Transaction ID: "%s"', $this->transactionId); + + $storeId = 50; + $orderState = Order::STATE_PAYMENT_REVIEW; + + $this->payment->setLastTransId($this->transactionId); + $this->payment->setData('is_transaction_denied', false); + $this->payment->setData('is_transaction_approved', false); + + $this->mockInvoice($this->transactionId); + + $this->orderMock->expects($this->once()) + ->method('getState') + ->willReturn($orderState); + + $this->orderMock->expects($this->never()) + ->method('setState'); + + $this->orderMock->expects($this->once()) + ->method('addStatusHistoryComment') + ->with($message); + + $this->orderMock->expects($this->once()) + ->method('getStoreId') + ->willReturn($storeId); + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->with($storeId) + ->willReturn($this->paymentMethodMock); + $this->paymentMethodMock->expects($this->once()) + ->method('fetchTransactionInfo') + ->with($this->payment, $this->transactionId); + + $this->payment->update(); + $this->assertEquals($this->transactionId, $this->payment->getLastTransId()); + } + + /** + * @param int $transactionId + * @param float $baseGrandTotal + * @param string $message + */ + protected function mockResultTrueMethods($transactionId, $baseGrandTotal, $message) + { + $status = 'status'; + + $this->invoiceMock->expects($this->once()) + ->method('pay') + ->willReturn($transactionId); + $this->invoiceMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->willReturn($baseGrandTotal); + + //acceptPayment = true + $this->orderMock->expects($this->once()) + ->method('addRelatedObject') + ->with($this->invoiceMock); + + $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status); + $this->assertOrderUpdated(Order::STATE_PROCESSING, $status, $message); + } + + /** + * @param $message + */ + protected function mockResultFalseMethods($message) + { + $this->invoiceMock->expects($this->once()) + ->method('cancel'); + $this->orderMock->expects($this->once()) + ->method('addRelatedObject') + ->with($this->invoiceMock); + $this->orderMock->expects($this->once()) + ->method('registerCancellation') + ->with($message, false); + } + + public function testAcceptWithoutInvoiceResultTrue() + { + $baseGrandTotal = null; + $acceptPayment = true; + + $this->payment->setData('transaction_id', $this->transactionId); + + $this->invoiceMock->expects($this->never()) + ->method('pay'); + + $this->orderMock->expects($this->any()) + ->method('getInvoiceCollection') + ->willReturn([]); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('acceptPayment') + ->with($this->payment) + ->willReturn($acceptPayment); + + $status = 'status'; + $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status); + $this->assertOrderUpdated(Order::STATE_PROCESSING, $status, __('Approved the payment online.')); + + $this->payment->accept(); + $this->assertEquals($baseGrandTotal, $this->payment->getBaseAmountPaidOnline()); + } + + public function testDenyWithoutInvoiceResultFalse() + { + $baseGrandTotal = null; + $denyPayment = true; + + $this->payment->setData('transaction_id', $this->transactionId); + + $this->invoiceMock->expects($this->never()) + ->method('cancel'); + + $this->orderMock->expects($this->any()) + ->method('getInvoiceCollection') + ->willReturn([]); + + $this->helperMock->expects($this->once()) + ->method('getMethodInstance') + ->will($this->returnValue($this->paymentMethodMock)); + + $this->paymentMethodMock->expects($this->once()) + ->method('setStore') + ->will($this->returnSelf()); + + $this->paymentMethodMock->expects($this->once()) + ->method('denyPayment') + ->with($this->payment) + ->willReturn($denyPayment); + + $status = 'status'; + $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status); + $this->assertOrderUpdated(Order::STATE_PROCESSING, $status, __('Denied the payment online')); + + $this->payment->deny(); + $this->assertEquals($baseGrandTotal, $this->payment->getBaseAmountPaidOnline()); + } + + public function testCanCaptureNoAuthorizationTransaction() + { + $this->paymentMethodMock->expects($this->once()) + ->method('canCapture') + ->willReturn(true); + $this->assertTrue($this->payment->canCapture()); + } + + public function testCanCaptureCreateTransaction() + { + $this->paymentMethodMock->expects($this->once()) + ->method('canCapture') + ->willReturn(true); + + $parentTransactionId = 1; + $this->payment->setParentTransactionId($parentTransactionId); + + $transaction = $this->getMock('Magento\Sales\Model\Order\Payment\Transaction', [], [], '', false); + $transaction->expects($this->once()) + ->method('setOrderPaymentObject') + ->willReturnSelf(); + $transaction->expects($this->once()) + ->method('loadByTxnId') + ->willReturnSelf(); + $transaction->expects($this->once()) + ->method('getId') + ->willReturn($parentTransactionId); + + $transaction->expects($this->once()) + ->method('getIsClosed') + ->willReturn(false); + + $this->transactionFactory->expects($this->once()) + ->method('create') + ->willReturn($transaction); + + $this->assertTrue($this->payment->canCapture()); + } + + public function testCanCaptureAuthorizationTransaction() + { + $paymentId = 1; + $this->payment->setId($paymentId); + + $this->paymentMethodMock->expects($this->once()) + ->method('canCapture') + ->willReturn(true); + + $transaction = $this->getMock('Magento\Sales\Model\Order\Payment\Transaction', [], [], '', false); + $collection = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Payment\Transaction\Collection', + [], + [], + '', + false + ); + $this->transactionCollectionFactory->expects($this->once()) + ->method('create') + ->willReturn($collection); + $collection->expects($this->once()) + ->method('setOrderFilter') + ->willReturnSelf(); + $collection->expects($this->once()) + ->method('addPaymentIdFilter') + ->willReturnSelf(); + $collection->expects($this->once()) + ->method('addTxnTypeFilter') + ->willReturnSelf(); + $collection->method('setOrder') + ->willReturnMap( + [ + ['created_at', \Magento\Framework\Data\Collection::SORT_ORDER_DESC, $collection], + ['transaction_id', \Magento\Framework\Data\Collection::SORT_ORDER_DESC, [$transaction]] + ] + ); + + $this->assertTrue($this->payment->canCapture()); + } + + public function testPay() + { + $expects = [ + 'amount_paid' => 10, + 'base_amount_paid' => 10, + 'shipping_captured' => 5, + 'base_shipping_captured' => 5, + ]; + $this->assertNull($this->payment->getData('amount_paid')); + $this->invoiceMock->expects($this->once())->method('getGrandTotal')->willReturn($expects['amount_paid']); + $this->invoiceMock->expects($this->once())->method('getBaseGrandTotal')->willReturn( + $expects['base_amount_paid'] + ); + $this->invoiceMock->expects($this->once())->method('getShippingAmount')->willReturn( + $expects['shipping_captured'] + ); + $this->invoiceMock->expects($this->once())->method('getBaseShippingAmount')->willReturn( + $expects['base_shipping_captured'] + ); + $this->eventManagerMock->expects($this->once())->method('dispatch')->with( + 'sales_order_payment_pay', + ['payment' => $this->payment, 'invoice' => $this->invoiceMock] + ); + $this->assertSame($this->payment, $this->payment->pay($this->invoiceMock)); + $this->assertEquals($expects['amount_paid'], $this->payment->getData('amount_paid')); + $this->assertEquals($expects['base_amount_paid'], $this->payment->getData('base_amount_paid')); + $this->assertEquals($expects['shipping_captured'], $this->payment->getData('shipping_captured')); + $this->assertEquals($expects['base_shipping_captured'], $this->payment->getData('base_shipping_captured')); + } + + + public function testCancelInvoice() + { + $expects = [ + 'amount_paid' => 10, + 'base_amount_paid' => 10, + 'shipping_captured' => 5, + 'base_shipping_captured' => 5, + ]; + $this->assertNull($this->payment->getData('amount_paid')); + $this->invoiceMock->expects($this->once())->method('getGrandTotal')->willReturn($expects['amount_paid']); + $this->invoiceMock->expects($this->once())->method('getBaseGrandTotal')->willReturn( + $expects['base_amount_paid'] + ); + $this->invoiceMock->expects($this->once())->method('getShippingAmount')->willReturn( + $expects['shipping_captured'] + ); + $this->invoiceMock->expects($this->once())->method('getBaseShippingAmount')->willReturn( + $expects['base_shipping_captured'] + ); + $this->eventManagerMock->expects($this->once())->method('dispatch')->with( + 'sales_order_payment_cancel_invoice', + ['payment' => $this->payment, 'invoice' => $this->invoiceMock] + ); + $this->assertSame($this->payment, $this->payment->cancelInvoice($this->invoiceMock)); + $this->assertEquals(-1 * $expects['amount_paid'], $this->payment->getData('amount_paid')); + $this->assertEquals(-1 * $expects['base_amount_paid'], $this->payment->getData('base_amount_paid')); + $this->assertEquals(-1 * $expects['shipping_captured'], $this->payment->getData('shipping_captured')); + $this->assertEquals( + -1 * $expects['base_shipping_captured'], + $this->payment->getData('base_shipping_captured') + ); + } + + public function testRegisterRefundNotificationTransactionExists() + { + $amount = 10; + $this->payment->setParentTransactionId($this->transactionId); + $transaction = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Payment\Transaction', + ['setOrderPaymentObject', 'loadByTxnId', 'getId'], + [], + '', + false + ); + $this->transactionFactory->expects($this->atLeastOnce()) + ->method('create') + ->willReturn($transaction); + $transaction->expects($this->atLeastOnce()) + ->method('setOrderPaymentObject') + ->with($this->payment) + ->willReturnSelf(); + $transaction->expects($this->exactly(2)) + ->method('loadByTxnId') + ->withConsecutive( + [$this->transactionId], + [$this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND] + )->willReturnSelf(); + $transaction->expects($this->atLeastOnce()) + ->method('getId') + ->willReturnOnConsecutiveCalls( + $this->transactionId, + $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND + ); + $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount)); + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testRegisterRefundNotification() + { + $message = 'Registered notification about refunded amount of . Transaction ID: "100-refund"'; + $amount = 50; + $grandTotalCreditMemo = 50; + $invoiceBaseGrandTotal = 50; + $invoiceBaseTotalRefunded = 0; + $this->invoiceMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($invoiceBaseGrandTotal); + $this->invoiceMock->expects($this->any())->method('getBaseTotalRefunded')->willReturn( + $invoiceBaseTotalRefunded + ); + $this->creditMemoMock->expects($this->any())->method('getGrandTotal')->willReturn($grandTotalCreditMemo); + $this->payment->setParentTransactionId($this->transactionId); + $this->mockInvoice($this->transactionId, 1); + $this->serviceOrderFactory->expects($this->once())->method('create')->with( + ['order' => $this->orderMock] + )->willReturn($this->serviceOrder); + $this->serviceOrder->expects($this->once())->method('prepareInvoiceCreditmemo')->with( + $this->invoiceMock, + ['adjustment_negative' => $invoiceBaseGrandTotal - $amount] + )->willReturn( + $this->creditMemoMock + ); + $this->creditMemoMock->expects($this->once())->method('setPaymentRefundDisallowed')->willReturnSelf(); + $this->creditMemoMock->expects($this->once())->method('setAutomaticallyCreated')->willReturnSelf(); + $this->creditMemoMock->expects($this->once())->method('register')->willReturnSelf(); + $this->creditMemoMock->expects($this->once())->method('addComment')->willReturnSelf(); + $this->creditMemoMock->expects($this->once())->method('save')->willReturnSelf(); + $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock); + + $newTransaction = $this->getMock( + 'Magento\Sales\Model\Order\Payment\Transaction', + [ + 'getId', + 'setOrderPaymentObject', + 'loadByTxnId', + 'setTxnId', + 'setTxnType', + 'isFailsafe', + 'getTxnId', + 'getTxnType' + ], + [], + '', + false + ); + + $parentTransaction = $this->getMock( + 'Magento\Sales\Model\Order\Payment\Transaction', + ['setOrderPaymentObject', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], + [], + '', + false + ); + $this->transactionFactory->expects($this->exactly(3)) + ->method('create') + ->willReturnOnConsecutiveCalls($parentTransaction, $newTransaction, $newTransaction, $newTransaction); + $parentTransaction->expects($this->atLeastOnce()) + ->method('setOrderPaymentObject') + ->with($this->payment) + ->willReturnSelf(); + $parentTransaction->expects($this->exactly(1)) + ->method('loadByTxnId') + ->with($this->transactionId)->willReturnSelf(); + $newTransaction->expects($this->exactly(1)) + ->method('loadByTxnId') + ->with($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND) + ->willReturnSelf(); + $parentTransaction->expects($this->atLeastOnce()) + ->method('getId') + ->willReturnOnConsecutiveCalls( + $this->transactionId, + $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND + )->willReturnOnConsecutiveCalls( + $this->transactionId, + $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND + ); + $newTransaction->expects($this->once())->method('setTxnId')->with( + $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND + )->willReturn($newTransaction); + $newTransaction->expects($this->atLeastOnce())->method('getTxnId')->willReturn( + $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND + ); + $newTransaction->expects($this->atLeastOnce()) + ->method('setOrderPaymentObject') + ->willReturnSelf(); + $newTransaction->expects($this->once())->method('setTxnType')->with( + \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND + )->willReturn($newTransaction); + $newTransaction->expects($this->once())->method('isFailsafe')->with( + false + )->willReturn($newTransaction); + $this->orderMock->expects($this->atLeastOnce())->method('addRelatedObject'); + + $status = 'status'; + + $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status); + $this->assertOrderUpdated(Order::STATE_PROCESSING, $status, $message); + + $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount)); + $this->assertSame($this->creditMemoMock, $this->payment->getData('created_creditmemo')); + $this->assertEquals($grandTotalCreditMemo, $this->payment->getData('amount_refunded')); + } + + public function testRegisterRefundNotificationWrongAmount() + { + $amount = 30; + $grandTotalCreditMemo = 50; + $invoiceBaseGrandTotal = 50; + $invoiceBaseTotalRefunded = 0; + $this->invoiceMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($invoiceBaseGrandTotal); + $this->invoiceMock->expects($this->any())->method('getBaseTotalRefunded')->willReturn( + $invoiceBaseTotalRefunded + ); + $this->creditMemoMock->expects($this->any())->method('getGrandTotal')->willReturn($grandTotalCreditMemo); + $this->payment->setParentTransactionId($this->transactionId); + $this->mockInvoice($this->transactionId, 1); + $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock); + $parentTransaction = $this->getMock( + 'Magento\Sales\Model\Order\Payment\Transaction', + ['setOrderPaymentObject', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], + [], + '', + false + ); + $parentTransaction->expects($this->atLeastOnce()) + ->method('setOrderPaymentObject') + ->with($this->payment) + ->willReturnSelf(); + $parentTransaction->expects($this->exactly(1)) + ->method('loadByTxnId') + ->with($this->transactionId)->willReturnSelf(); + $newTransaction = $this->getMock( + 'Magento\Sales\Model\Order\Payment\Transaction', + [ + 'getId', + 'setOrderPaymentObject', + 'loadByTxnId', + 'setTxnId', + 'setTxnType', + 'isFailsafe', + 'getTxnId', + 'getTxnType' + ], + [], + '', + false + ); + $this->transactionFactory->expects($this->exactly(2)) + ->method('create') + ->willReturnOnConsecutiveCalls($parentTransaction, $newTransaction); + $newTransaction->expects($this->exactly(1)) + ->method('loadByTxnId') + ->with($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND) + ->willReturnSelf(); + $newTransaction->expects($this->atLeastOnce()) + ->method('setOrderPaymentObject') + ->willReturnSelf(); + $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount)); + } + + /** + * @dataProvider boolProvider + */ + public function testCanRefund($canRefund) + { + $this->paymentMethodMock->expects($this->once()) + ->method('canRefund') + ->willReturn($canRefund); + $this->assertEquals($canRefund, $this->payment->canRefund()); + } + + public function boolProvider() + { + return [ + [true], + [false] + ]; + } + + /** + * @param $context + */ + protected function initPayment($context) + { + $this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + 'Magento\Sales\Model\Order\Payment', + [ + 'context' => $context, + 'serviceOrderFactory' => $this->serviceOrderFactory, + 'paymentData' => $this->helperMock, + 'priceCurrency' => $this->priceCurrencyMock, + 'transactionFactory' => $this->transactionFactory, + 'transactionCollectionFactory' => $this->transactionCollectionFactory + ] + ); + + $this->payment->setMethod('any'); + $this->payment->setOrder($this->orderMock); + + $this->transactionId = 100; + } + + protected function assertOrderUpdated( + $state, + $status = null, + $message = null, + $isCustomerNotified = null + ) { + $this->orderMock->expects($this->any()) + ->method('setState') + ->with($state) + ->willReturnSelf(); + $this->orderMock->expects($this->any()) + ->method('setStatus') + ->with($status) + ->willReturnSelf(); + + $statusHistory = $this->getMockForAbstractClass( + 'Magento\Sales\Api\Data\OrderStatusHistoryInterface' + ); + $this->orderMock->expects($this->any()) + ->method('addStatusHistoryComment') + ->with($message) + ->willReturn($statusHistory); + $this->orderMock->expects($this->any()) + ->method('setIsCustomerNotified') + ->with($isCustomerNotified) + ->willReturn($statusHistory); + } + + protected function mockGetDefaultStatus($state, $status, $allStatuses = []) + { + /** @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject $orderConfigMock */ + $orderConfigMock = $this->getMockBuilder('Magento\Sales\Model\Order\Config') + ->disableOriginalConstructor() + ->setMethods(['getStateStatuses', 'getStateDefaultStatus']) + ->getMock(); + + if (!empty($allStatuses)) { + $orderConfigMock->expects($this->any()) + ->method('getStateStatuses') + ->with(Order::STATE_NEW) + ->will($this->returnValue($allStatuses)); + } + + $orderConfigMock->expects($this->any()) + ->method('getStateDefaultStatus') + ->with($state) + ->will($this->returnValue($status)); + + $this->orderMock->expects($this->any()) + ->method('getConfig') + ->will($this->returnValue($orderConfigMock)); + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index b222a99d48745..a147cdaa901cc 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -49,6 +49,11 @@ class OrderTest extends \PHPUnit_Framework_TestCase */ protected $historyCollectionFactoryMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Pricing\PriceCurrencyInterface + */ + protected $priceCurrency; + protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -75,7 +80,7 @@ protected function setUp() ); $this->item = $this->getMock( 'Magento\Sales\Model\Resource\Order\Item', - ['isDeleted', 'getQtyToInvoice', 'getParentItemId', 'getQuoteItemId'], + ['isDeleted', 'getQtyToInvoice', 'getParentItemId', 'getQuoteItemId', 'getLockedDoInvoice'], [], '', false @@ -91,6 +96,16 @@ protected function setUp() ->method('create') ->willReturn($collection); + $this->priceCurrency = $this->getMockForAbstractClass( + 'Magento\Framework\Pricing\PriceCurrencyInterface', + [], + '', + false, + false, + true, + ['round'] + ); + $this->incrementId = '#00000001'; $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); $context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false); @@ -105,7 +120,8 @@ protected function setUp() 'orderItemCollectionFactory' => $this->orderItemCollectionFactoryMock, 'data' => ['increment_id' => $this->incrementId], 'context' => $context, - 'historyCollectionFactory' => $this->historyCollectionFactoryMock + 'historyCollectionFactory' => $this->historyCollectionFactoryMock, + 'priceCurrency' => $this->priceCurrency ] ); } @@ -194,6 +210,102 @@ public function testCanCancelIsPaymentReview() $this->assertFalse($this->order->canCancel()); } + public function testCanInvoice() + { + $this->item->expects($this->any()) + ->method('getQtyToInvoice') + ->willReturn(42); + $this->item->expects($this->any()) + ->method('getLockedDoInvoice') + ->willReturn(false); + + $this->assertTrue($this->order->canInvoice()); + } + + /** + * @param string $status + * + * @dataProvider notInvoicingStatesProvider + */ + public function testCanNotInvoiceInSomeStates($status) + { + $this->item->expects($this->any()) + ->method('getQtyToInvoice') + ->willReturn(42); + $this->item->expects($this->any()) + ->method('getLockedDoInvoice') + ->willReturn(false); + $this->order->setData('state', $status); + $this->assertFalse($this->order->canInvoice()); + } + + public function testCanNotInvoiceWhenActionInvoiceFlagIsFalse() + { + $this->item->expects($this->any()) + ->method('getQtyToInvoice') + ->willReturn(42); + $this->item->expects($this->any()) + ->method('getLockedDoInvoice') + ->willReturn(false); + $this->order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_INVOICE, false); + $this->assertFalse($this->order->canInvoice()); + } + + public function testCanNotInvoiceWhenLockedInvoice() + { + $this->item->expects($this->any()) + ->method('getQtyToInvoice') + ->willReturn(42); + $this->item->expects($this->any()) + ->method('getLockedDoInvoice') + ->willReturn(true); + $this->assertFalse($this->order->canInvoice()); + } + + public function testCanNotInvoiceWhenDidNotHaveQtyToInvoice() + { + $this->item->expects($this->any()) + ->method('getQtyToInvoice') + ->willReturn(0); + $this->item->expects($this->any()) + ->method('getLockedDoInvoice') + ->willReturn(false); + $this->assertFalse($this->order->canInvoice()); + } + + public function testCanCreditMemo() + { + $totalPaid = 10; + $this->order->setTotalPaid($totalPaid); + $this->priceCurrency->expects($this->once())->method('round')->with($totalPaid)->willReturnArgument(0); + $this->assertTrue($this->order->canCreditmemo()); + } + + public function testCanNotCreditMemoWithTotalNull() + { + $totalPaid = 0; + $this->order->setTotalPaid($totalPaid); + $this->priceCurrency->expects($this->once())->method('round')->with($totalPaid)->willReturnArgument(0); + $this->assertFalse($this->order->canCreditmemo()); + } + + /** + * @param string $state + * + * @dataProvider canNotCreditMemoStatesProvider + */ + public function testCanNotCreditMemoWithSomeStates($state) + { + $this->order->setData('state', $state); + $this->assertFalse($this->order->canCreditmemo()); + } + + public function testCanNotCreditMemoWithForced() + { + $this->order->setData('forced_can_creditmemo', true); + $this->assertTrue($this->order->canCreditmemo()); + } + public function testCanEditIfHasInvoices() { $invoiceCollection = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Invoice\Collection') @@ -590,4 +702,23 @@ public function testGetStatusHistories() $this->assertEquals($collectionItems, $this->order->getStatusHistories()); } } + + public function notInvoicingStatesProvider() + { + return [ + [\Magento\Sales\Model\Order::STATE_COMPLETE], + [\Magento\Sales\Model\Order::STATE_CANCELED], + [\Magento\Sales\Model\Order::STATE_CLOSED] + ]; + } + + public function canNotCreditMemoStatesProvider() + { + return [ + [\Magento\Sales\Model\Order::STATE_HOLDED], + [\Magento\Sales\Model\Order::STATE_CANCELED], + [\Magento\Sales\Model\Order::STATE_CLOSED], + [\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW] + ]; + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/EntityMetadataTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/EntityMetadataTest.php new file mode 100644 index 0000000000000..bfb0c1ab8c032 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/EntityMetadataTest.php @@ -0,0 +1,82 @@ +model = $this->getMock( + 'Magento\Sales\Model\AbstractModel', + [], + [], + '', + false + ); + $this->resource = $this->getMockForAbstractClass( + 'Magento\Framework\DB\Adapter\AdapterInterface', + [], + "", + false, + false, + true, + ['getReadConnection', 'getMainTable'] + ); + $this->connection = $this->getMockForAbstractClass( + 'Magento\Framework\DB\Adapter\AdapterInterface', + [], + "", + false, + false + ); + $this->model->expects($this->any())->method('getResource')->willReturn($this->resource); + $this->resource->expects($this->any())->method('getReadConnection')->willReturn($this->connection); + $this->entityMetadata = $objectManager->getObject('Magento\Sales\Model\Resource\EntityMetadata'); + } + + public function testGetFields() + { + $mainTable = 'main_table'; + $expectedDescribedTable = 'described_table'; + $this->resource->expects($this->any())->method('getMainTable')->willReturn($mainTable); + $this->connection->expects($this->once())->method('describeTable')->with($mainTable)->willReturn( + $expectedDescribedTable + ); + $this->assertEquals($expectedDescribedTable, $this->entityMetadata->getFields($this->model)); + //get from cached + $this->connection->expects($this->never())->method('describeTable'); + $this->assertEquals($expectedDescribedTable, $this->entityMetadata->getFields($this->model)); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/EntitySnapshotTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/EntitySnapshotTest.php new file mode 100644 index 0000000000000..6a7b4c896a044 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/EntitySnapshotTest.php @@ -0,0 +1,106 @@ +model = $this->getMock( + 'Magento\Sales\Model\AbstractModel', + [], + [], + '', + false + ); + + $this->entityMetadata = $this->getMock( + 'Magento\Sales\Model\Resource\EntityMetadata', + [], + [], + '', + false + ); + + $this->entitySnapshot = $objectManager->getObject( + 'Magento\Sales\Model\Resource\EntitySnapshot', + ['entityMetadata' => $this->entityMetadata] + ); + } + + public function testRegisterSnapshot() + { + $entityId = 1; + $data = [ + 'id' => $entityId, + 'name' => 'test', + 'description' => '', + 'custom_not_present_attribute' => '' + ]; + $fields = [ + 'id', + 'name', + 'description' + ]; + $this->model->expects($this->once())->method('getData')->willReturn($data); + $this->model->expects($this->once())->method('getId')->willReturn($entityId); + $this->entityMetadata->expects($this->once())->method('getFields')->with($this->model)->willReturn($fields); + $this->entitySnapshot->registerSnapshot($this->model); + } + + public function testIsModified() + { + $entityId = 1; + $data = [ + 'id' => $entityId, + 'name' => 'test', + 'description' => '', + 'custom_not_present_attribute' => '' + ]; + $fields = [ + 'id' => [], + 'name' => [], + 'description' => [] + ]; + $modifiedData = array_merge($data, ['name' => 'newName']); + $this->model->expects($this->exactly(4))->method('getData')->willReturnOnConsecutiveCalls( + $data, + $modifiedData, + $modifiedData, + $modifiedData + ); + $this->model->expects($this->any())->method('getId')->willReturn($entityId); + $this->entityMetadata->expects($this->exactly(4))->method('getFields')->with($this->model)->willReturn($fields); + $this->entitySnapshot->registerSnapshot($this->model); + $this->assertTrue($this->entitySnapshot->isModified($this->model)); + $this->entitySnapshot->registerSnapshot($this->model); + $this->assertFalse($this->entitySnapshot->isModified($this->model)); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/HelperTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/HelperTest.php new file mode 100644 index 0000000000000..5c71ba5f653cd --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/HelperTest.php @@ -0,0 +1,115 @@ +appResource = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + + $this->resourceHelper = $this->getMock( + 'Magento\Reports\Model\Resource\Helper', + [], + [], + '', + false + ); + + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + [], + [], + '', + false + ); + + $this->helper = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Helper', + [ + 'resource' => $this->appResource, + 'reportsResourceHelper' => $this->resourceHelper + ] + ); + } + + /** + * @param string $aggregation + * @param array $aggregationAliases + * @param string $expectedType + * + * @dataProvider getBestsellersReportUpdateRatingPosProvider + */ + public function testGetBestsellersReportUpdateRatingPos($aggregation, $aggregationAliases, $expectedType) + { + $mainTable = 'main_table'; + $aggregationTable = 'aggregation_table'; + $this->resourceHelper->expects($this->once())->method('updateReportRatingPos')->with( + $this->adapterMock, + $expectedType, + 'qty_ordered', + $mainTable, + $aggregationTable + ); + $this->appResource->expects($this->once()) + ->method('getConnection') + ->with('sales_write') + ->willReturn($this->adapterMock); + $this->helper->getBestsellersReportUpdateRatingPos( + $aggregation, + $aggregationAliases, + $mainTable, + $aggregationTable + ); + } + + /** + * @return array + */ + public function getBestsellersReportUpdateRatingPosProvider() + { + return [ + ['alias', ['monthly' => 'alias', 'daily' => 'alias2', 'yearly' => 'alias3'], 'month'], + ['alias', ['monthly' => 'alias2', 'daily' => 'alias', 'yearly' => 'alias3'], 'day'], + ['alias', ['monthly' => 'alias2', 'daily' => 'alias2', 'yearly' => 'alias'], 'year'], + ]; + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Handler/StateTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Handler/StateTest.php index 0b80b65655e91..30baabf851a18 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Handler/StateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Handler/StateTest.php @@ -40,12 +40,16 @@ public function setUp() 'setState', 'getTotalRefunded', 'hasForcedCanCreditmemo', - 'getIsInProcess' + 'getIsInProcess', + 'getConfig' ], [], '', false ); + $this->orderMock->expects($this->any()) + ->method('getConfig') + ->willReturnSelf(); $this->addressMock = $this->getMock( 'Magento\Sales\Model\Order\Address', [], @@ -82,12 +86,6 @@ 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)); @@ -111,7 +109,7 @@ public function testCheckSetStateComplete() ->will($this->returnValue(Order::STATE_PROCESSING)); $this->orderMock->expects($this->once()) ->method('setState') - ->with(Order::STATE_COMPLETE, true, '', true) + ->with(Order::STATE_COMPLETE) ->will($this->returnSelf()); $this->assertEquals($this->state, $this->state->check($this->orderMock)); } @@ -124,12 +122,6 @@ 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)); @@ -159,7 +151,7 @@ public function testCheckSetStateClosed() ->will($this->returnValue(Order::STATE_PROCESSING)); $this->orderMock->expects($this->once()) ->method('setState') - ->with(Order::STATE_CLOSED, true, '', true) + ->with(Order::STATE_CLOSED) ->will($this->returnSelf()); $this->assertEquals($this->state, $this->state->check($this->orderMock)); } @@ -172,12 +164,6 @@ 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)); @@ -198,7 +184,7 @@ public function testCheckSetStateProcessing() ->will($this->returnValue(true)); $this->orderMock->expects($this->once()) ->method('setState') - ->with(Order::STATE_PROCESSING, true, '', true) + ->with(Order::STATE_PROCESSING) ->will($this->returnSelf()); $this->assertEquals($this->state, $this->state->check($this->orderMock)); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Status/History/CollectionTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Status/History/CollectionTest.php index f2390ca68cd4b..7d0dc3b50ec51 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Status/History/CollectionTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Status/History/CollectionTest.php @@ -65,7 +65,7 @@ public function setUp() false ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\Resource\Db\AbstractDb', + 'Magento\Sales\Model\Resource\EntityAbstract', [], '', false, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Tax/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Tax/ItemTest.php new file mode 100644 index 0000000000000..29d6bfca4cb0a --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Tax/ItemTest.php @@ -0,0 +1,106 @@ +adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + [], + [], + '', + false + ); + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any())->method('getTableName')->willReturnArgument(0); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->taxItem = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Tax\Item', + [ + 'resource' => $this->appResourceMock + ] + ); + } + + public function testGetTaxItemsByOrderId() + { + $orderId = 1; + $taxItems = [ + [ + 'tax_id' => 1, + 'tax_percent' => 5, + 'item_id' => 1, + 'taxable_item_type' => 4, + 'associated_item_id' => 1, + 'real_amount' => 12, + 'real_base_amount' => 12 + ] + ]; + $select = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->adapterMock->expects($this->once())->method('select')->willReturn($select); + $select->expects($this->once())->method('from')->with( + ['item' => 'sales_order_tax_item'], + [ + 'tax_id', + 'tax_percent', + 'item_id', + 'taxable_item_type', + 'associated_item_id', + 'real_amount', + 'real_base_amount', + ] + )->willReturnSelf(); + $select->expects($this->once())->method('join')->with( + ['tax' => 'sales_order_tax'], + 'item.tax_id = tax.tax_id', + ['code', 'title', 'order_id'] + )->willReturnSelf(); + $select->expects($this->once())->method('where')->with( + 'tax.order_id = ?', + $orderId + )->willReturnSelf(); + $this->adapterMock->expects($this->once())->method('fetchAll')->with($select)->willReturn($taxItems); + $this->assertEquals($taxItems, $this->taxItem->getTaxItemsByOrderId($orderId)); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php index fc02960d41d23..97414f5511a6e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/OrderServiceTest.php @@ -54,6 +54,10 @@ class OrderServiceTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Api\Data\OrderStatusHistorySearchResultInterface */ protected $orderSearchResultMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Event\ManagerInterface + */ + protected $eventManagerMock; protected function setUp() { @@ -107,12 +111,18 @@ protected function setUp() ) ->disableOriginalConstructor() ->getMock(); + $this->eventManagerMock = $this->getMockBuilder( + 'Magento\Framework\Event\ManagerInterface' + ) + ->disableOriginalConstructor() + ->getMock(); $this->orderService = new \Magento\Sales\Model\Service\OrderService( $this->orderRepositoryMock, $this->orderStatusHistoryRepositoryMock, $this->searchCriteriaBuilderMock, $this->filterBuilderMock, - $this->orderNotifierMock + $this->orderNotifierMock, + $this->eventManagerMock ); } diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index eaf6b99ecb86b..9e16e143a504d 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,35 +3,35 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-authorization": "0.74.0-beta9", - "magento/module-payment": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-sales-rule": "0.74.0-beta9", - "magento/module-sales-sequence": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-gift-message": "0.74.0-beta9", - "magento/module-reports": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-wishlist": "0.74.0-beta9", - "magento/module-email": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-ui": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-authorization": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-sales-rule": "0.74.0-beta11", + "magento/module-sales-sequence": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-gift-message": "0.74.0-beta11", + "magento/module-reports": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-wishlist": "0.74.0-beta11", + "magento/module-email": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 9e20997c62f00..fee757be252e7 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -195,4 +195,29 @@ + + + sales + + + + + sales + + + + + sales + + + + + sales + + + + + sales + + diff --git a/app/code/Magento/Sales/etc/frontend/di.xml b/app/code/Magento/Sales/etc/frontend/di.xml index 7abf1a3fe1373..aaa767fae649c 100644 --- a/app/code/Magento/Sales/etc/frontend/di.xml +++ b/app/code/Magento/Sales/etc/frontend/di.xml @@ -15,4 +15,11 @@ + + + + Magento\Sales\CustomerData\LastOrderedItems + + + diff --git a/app/code/Magento/Sales/etc/frontend/sections.xml b/app/code/Magento/Sales/etc/frontend/sections.xml new file mode 100644 index 0000000000000..c30c1d8793455 --- /dev/null +++ b/app/code/Magento/Sales/etc/frontend/sections.xml @@ -0,0 +1,19 @@ + + + + +
    + + +
    + + +
    + + diff --git a/app/code/Magento/Sales/etc/resources.xml b/app/code/Magento/Sales/etc/resources.xml new file mode 100644 index 0000000000000..99b74cc540afd --- /dev/null +++ b/app/code/Magento/Sales/etc/resources.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/app/code/Magento/Sales/view/adminhtml/templates/items/column/qty.phtml b/app/code/Magento/Sales/view/adminhtml/templates/items/column/qty.phtml index 46b39dc3a78af..5cf772879bed1 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/items/column/qty.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/items/column/qty.phtml @@ -8,7 +8,7 @@ ?> getItem()): ?> - +
    diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/comments/view.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/comments/view.phtml index 096b709861235..d07aa26f62841 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/comments/view.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/comments/view.phtml @@ -13,11 +13,13 @@
    - +
    + +
    diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/comment.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/comment.phtml index bd3da1a28327e..4163d1ad7890d 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/comment.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/comment.phtml @@ -12,8 +12,10 @@
    - +
    -
    isGiftMessagesAvailable()) : ?> +
    + - - diff --git a/app/code/Magento/Sales/view/frontend/web/js/view/last-ordered-items.js b/app/code/Magento/Sales/view/frontend/web/js/view/last-ordered-items.js new file mode 100644 index 0000000000000..a6589f6bb0899 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/web/js/view/last-ordered-items.js @@ -0,0 +1,28 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data' +], function (Component, customerData) { + 'use strict'; + + return Component.extend({ + initialize: function () { + var isShowAddToCart = false; + + this._super(); + this.lastOrderedItems = customerData.get('last-ordered-items'); + + for (var item in this.lastOrderedItems.items) { + if (item['is_saleable']) { + isShowAddToCart = true; + break; + } + } + + this.lastOrderedItems.isShowAddToCart = isShowAddToCart; + } + }); +}); diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php index 09ac004deb982..4448a0d73bdc7 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php @@ -49,12 +49,10 @@ public function aggregate($from = null, $to = null) */ protected function _aggregateByOrder($aggregationField, $from, $to) { - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $table = $this->getMainTable(); $sourceTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); + $salesAdapter = $this->_resources->getConnection('sales_read'); $adapter->beginTransaction(); try { @@ -64,11 +62,11 @@ protected function _aggregateByOrder($aggregationField, $from, $to) $subSelect = null; } - $this->_clearTableByDateRange($table, $from, $to, $subSelect); + $this->_clearTableByDateRange($table, $from, $to, $subSelect, false, $salesAdapter); - // convert dates from UTC to current admin timezone + // convert dates to current admin timezone $periodExpr = $adapter->getDatePartSql( - $this->getStoreTZOffsetQuery($sourceTable, $aggregationField, $from, $to) + $this->getStoreTZOffsetQuery($sourceTable, $aggregationField, $from, $to, null, $salesAdapter) ); $columns = [ @@ -140,14 +138,18 @@ protected function _aggregateByOrder($aggregationField, $from, $to) $select->from(['source_table' => $sourceTable], $columns)->where('coupon_code IS NOT NULL'); if ($subSelect !== null) { - $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period', $salesAdapter)); } $select->group([$periodExpr, 'store_id', 'status', 'coupon_code']); $select->having('COUNT(entity_id) > 0'); - $adapter->query($select->insertFromSelect($table, array_keys($columns))); + $aggregatedData = $salesAdapter->fetchAll($select); + + if ($aggregatedData) { + $adapter->insertOnDuplicate($table, $aggregatedData, array_keys($columns)); + } $select->reset(); @@ -169,7 +171,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to) $select->from($table, $columns)->where('store_id <> 0'); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); + $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'period', $salesAdapter)); } $select->group(['period', 'order_status', 'coupon_code']); diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 1f0337f3ce436..3dc6150964c04 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.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-rule": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-payment": "0.74.0-beta9", - "magento/module-reports": "0.74.0-beta9", - "magento/module-catalog-rule": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-rule": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/module-reports": "0.74.0-beta11", + "magento/module-catalog-rule": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml index 5aa241a5a16ce..612dcb6f8a264 100644 --- a/app/code/Magento/SalesRule/etc/di.xml +++ b/app/code/Magento/SalesRule/etc/di.xml @@ -24,4 +24,19 @@ + + + sales + + + + + sales + + + + + sales + + diff --git a/app/code/Magento/SalesSequence/Model/Builder.php b/app/code/Magento/SalesSequence/Model/Builder.php index 2e7a1cda6798f..fb3e51760e3ac 100644 --- a/app/code/Magento/SalesSequence/Model/Builder.php +++ b/app/code/Magento/SalesSequence/Model/Builder.php @@ -246,7 +246,7 @@ public function create() $metadata->setHasDataChanges(true); try { $this->resourceMetadata->save($metadata); - $adapter = $this->appResource->getConnection('write'); + $adapter = $this->appResource->getConnection('sales_write'); if (!$adapter->isTableExists($this->data['sequence_table'])) { $adapter->query( $this->ddlSequence->getCreateSequenceDdl( diff --git a/app/code/Magento/SalesSequence/Model/Sequence.php b/app/code/Magento/SalesSequence/Model/Sequence.php index e7c9a9f3876e5..96b9d4e0443a0 100644 --- a/app/code/Magento/SalesSequence/Model/Sequence.php +++ b/app/code/Magento/SalesSequence/Model/Sequence.php @@ -49,7 +49,7 @@ public function __construct( $pattern = self::DEFAULT_PATTERN ) { $this->meta = $meta; - $this->adapter = $resource->getConnection('write'); + $this->adapter = $resource->getConnection('sales_write'); $this->pattern = $pattern; } diff --git a/app/code/Magento/SalesSequence/Test/Unit/Model/BuilderTest.php b/app/code/Magento/SalesSequence/Test/Unit/Model/BuilderTest.php index 75ae26beb34bb..67c686c0221bc 100644 --- a/app/code/Magento/SalesSequence/Test/Unit/Model/BuilderTest.php +++ b/app/code/Magento/SalesSequence/Test/Unit/Model/BuilderTest.php @@ -225,7 +225,7 @@ private function stepCreateSequence($sequenceName, $startNumber) ->method('getTableName'); $this->resourceMock->expects($this->any()) ->method('getConnection') - ->with('write') + ->with('sales_write') ->willReturn($this->adapter); $this->sequence->expects($this->once()) ->method('getCreateSequenceDdl') diff --git a/app/code/Magento/SalesSequence/composer.json b/app/code/Magento/SalesSequence/composer.json index 1e06f65ed8406..3856305eb8e41 100644 --- a/app/code/Magento/SalesSequence/composer.json +++ b/app/code/Magento/SalesSequence/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php index 4226695723fd5..3a31a0555a739 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php @@ -5,12 +5,31 @@ */ namespace Magento\Search\Controller\Adminhtml\Term; -use Magento\Search\Controller\Adminhtml\Term as TermController; +use Magento\Backend\App\Action\Context; use Magento\Framework\Controller\ResultFactory; +use Magento\Search\Model\QueryFactory; +use Magento\Search\Controller\Adminhtml\Term as TermController; use Magento\Framework\Exception\LocalizedException; class Save extends TermController { + /** + * @var QueryFactory + */ + private $queryFactory; + + /** + * @param Context $context + * @param QueryFactory $queryFactory + */ + public function __construct( + Context $context, + QueryFactory $queryFactory + ) { + parent::__construct($context); + $this->queryFactory = $queryFactory; + } + /** * Save search query * @@ -19,54 +38,69 @@ class Save extends TermController */ public function execute() { - $hasError = false; $data = $this->getRequest()->getPostValue(); - $queryId = $this->getRequest()->getPost('query_id', null); - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); if ($this->getRequest()->isPost() && $data) { - /* @var $model \Magento\Search\Model\Query */ - $model = $this->_objectManager->create('Magento\Search\Model\Query'); - - // validate query - $queryText = $this->getRequest()->getPost('query_text', false); - $storeId = $this->getRequest()->getPost('store_id', false); - try { - if ($queryText) { - $model->setStoreId($storeId); - $model->loadByQueryText($queryText); - if ($model->getId() && $model->getId() != $queryId) { - throw new LocalizedException( - __('You already have an identical search term query.') - ); - } elseif (!$model->getId() && $queryId) { - $model->load($queryId); - } - } elseif ($queryId) { - $model->load($queryId); - } - + $model = $this->loadQuery(); $model->addData($data); $model->setIsProcessed(0); $model->save(); $this->messageManager->addSuccess(__('You saved the search term.')); } catch (LocalizedException $e) { $this->messageManager->addError($e->getMessage()); - $hasError = true; + return $this->proceedToEdit($data); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong while saving the search query.')); - $hasError = true; + return $this->proceedToEdit($data); } } - if ($hasError) { - $this->_getSession()->setPageData($data); - $resultRedirect->setPath('search/*/edit', ['id' => $queryId]); - return $resultRedirect; - } else { - $resultRedirect->setPath('search/*'); - return $resultRedirect; + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + return $redirectResult->setPath('search/*'); + } + + /** + * Create\Load Query model instance + * + * @return \Magento\Search\Model\Query + * @throws \Magento\Framework\Exception\LocalizedException + */ + private function loadQuery() + { + //validate query + $queryText = $this->getRequest()->getPost('query_text', false); + $queryId = $this->getRequest()->getPost('query_id', null); + + /* @var $model \Magento\Search\Model\Query */ + $model = $this->queryFactory->create(); + if ($queryText) { + $storeId = $this->getRequest()->getPost('store_id', false); + $model->setStoreId($storeId); + $model->loadByQueryText($queryText); + if ($model->getId() && $model->getId() != $queryId) { + throw new \Magento\Framework\Exception\LocalizedException( + __('You already have an identical search term query.') + ); + } + } + if ($queryId && !$model->getId()) { + $model->load($queryId); } + return $model; + } + + /** + * Redirect to Edit page + * + * @param array $data + * @return \Magento\Backend\Model\View\Result\Redirect + */ + private function proceedToEdit($data) + { + $this->_getSession()->setPageData($data); + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + return $redirectResult->setPath('search/*/edit', ['id' => $this->getRequest()->getPost('query_id', null)]); } } diff --git a/app/code/Magento/Search/Model/Resource/Helper.php b/app/code/Magento/Search/Model/Resource/Helper.php deleted file mode 100644 index 3a9ddcf7bb682..0000000000000 --- a/app/code/Magento/Search/Model/Resource/Helper.php +++ /dev/null @@ -1,84 +0,0 @@ - words, 1 => terms) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - public function prepareTerms($str, $maxWordLength = 0) - { - $boolWords = ['+' => '+', '-' => '-', '|' => '|', '<' => '<', '>' => '>', '~' => '~', '*' => '*']; - $brackets = ['(' => '(', ')' => ')']; - $words = [0 => ""]; - $terms = []; - preg_match_all('/([\(\)]|[\"\'][^"\']*[\"\']|[^\s\"\(\)]*)/uis', $str, $matches); - $isOpenBracket = 0; - foreach ($matches[1] as $word) { - $word = trim($word); - if (strlen($word)) { - $word = str_replace('"', '', $word); - $isBool = in_array(strtoupper($word), $boolWords); - $isBracket = in_array($word, $brackets); - if (!$isBool && !$isBracket) { - $terms[$word] = $word; - $word = '"' . $word . '"'; - $words[] = $word; - } elseif ($isBracket) { - if ($word == '(') { - $isOpenBracket++; - } else { - $isOpenBracket--; - } - $words[] = $word; - } elseif ($isBool) { - $words[] = $word; - } - } - } - if ($isOpenBracket > 0) { - $words[] = sprintf("%')" . $isOpenBracket . "s", ''); - } elseif ($isOpenBracket < 0) { - $words[0] = sprintf("%'(" . $isOpenBracket . "s", ''); - } - if ($maxWordLength && count($terms) > $maxWordLength) { - $terms = array_slice($terms, 0, $maxWordLength); - } - $result = [$words, $terms]; - return $result; - } - - /** - * Use sql compatible with Full Text indexes - * - * @param string $table The table to insert data into. - * @param array $data Column-value pairs or array of column-value pairs. - * @param array $fields update fields pairs or values - * @return int The number of affected rows. - */ - public function insertOnDuplicate($table, array $data, array $fields = []) - { - return $this->_getWriteAdapter()->insertOnDuplicate($table, $data, $fields); - } -} diff --git a/app/code/Magento/Search/Model/Resource/Query/Collection.php b/app/code/Magento/Search/Model/Resource/Query/Collection.php index c441ac7b760cc..03772a446b6dd 100644 --- a/app/code/Magento/Search/Model/Resource/Query/Collection.php +++ b/app/code/Magento/Search/Model/Resource/Query/Collection.php @@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Search resource helper * - * @var \Magento\Search\Model\Resource\Helper + * @var \Magento\Framework\DB\Helper */ protected $_resourceHelper; @@ -40,7 +40,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\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Search\Model\Resource\Helper $resourceHelper + * @param \Magento\Framework\DB\Helper $resourceHelper * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Search\Model\Resource\Helper $resourceHelper, + \Magento\Framework\DB\Helper $resourceHelper, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Search/Setup/UpgradeSchema.php b/app/code/Magento/Search/Setup/UpgradeSchema.php new file mode 100644 index 0000000000000..461c7fd3d3d23 --- /dev/null +++ b/app/code/Magento/Search/Setup/UpgradeSchema.php @@ -0,0 +1,49 @@ +moduleList = $moduleList; + } + + /** + * Upgrades DB schema for a module + * + * @param SchemaSetupInterface $setup + * @param ModuleContextInterface $context + * @return void + */ + public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context) + { + if (version_compare($context->getVersion(), '2.0.0.1') < 0) { + $setup->startSetup(); + $connection = $setup->getConnection(); + $tableName = $setup->getTable('search_query'); + $idxName = $setup->getIdxName('search_query', ['is_processed']); + $connection->addIndex($tableName, $idxName, ['is_processed']); + $setup->endSetup(); + } + } +} diff --git a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php new file mode 100644 index 0000000000000..5197e7d83e450 --- /dev/null +++ b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php @@ -0,0 +1,236 @@ +context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->redirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->setMethods(['setPath']) + ->disableOriginalConstructor() + ->getMock(); + $redirectFactory = $this->getMockBuilder('\Magento\Framework\Controller\ResultFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $redirectFactory->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->redirect)); + $this->context->expects($this->any()) + ->method('getResultRedirectFactory') + ->willReturn($redirectFactory); + $this->context->expects($this->any()) + ->method('getResultFactory') + ->willReturn($redirectFactory); + + $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface') + ->disableOriginalConstructor() + ->setMethods(['getPostValue', 'isPost', 'getPost']) + ->getMockForAbstractClass(); + $this->context->expects($this->atLeastOnce()) + ->method('getRequest') + ->willReturn($this->request); + + $objectManager = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMockForAbstractClass(); + $this->context->expects($this->any()) + ->method('getObjectManager') + ->willReturn($objectManager); + + $this->messageManager = $this->getMockBuilder('\Magento\Framework\Message\ManagerInterface') + ->disableOriginalConstructor() + ->setMethods(['addSuccess', 'addError', 'addException']) + ->getMockForAbstractClass(); + $this->context->expects($this->any()) + ->method('getMessageManager') + ->willReturn($this->messageManager); + + $this->session = $this->getMockBuilder('\Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['setPageData']) + ->getMock(); + $this->context->expects($this->any()) + ->method('getSession') + ->willReturn($this->session); + + $this->query = $this->getMockBuilder('Magento\Search\Model\Query') + ->disableOriginalConstructor() + ->setMethods(['getId', 'load', 'addData', 'setIsProcessed', 'save', 'loadByQueryText', 'setStoreId']) + ->getMock(); + $queryFactory = $this->getMockBuilder('Magento\Search\Model\QueryFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $queryFactory->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->query)); + + $this->controller = $objectManagerHelper->getObject( + 'Magento\Search\Controller\Adminhtml\Term\Save', + [ + 'context' => $this->context, + 'queryFactory' => $queryFactory, + ] + ); + } + + /** + * @param bool $isPost + * @param array $data + * @dataProvider executeIsPostDataDataProvider + */ + public function testExecuteIsPostData($isPost, $data) + { + $this->request->expects($this->at(0))->method('getPostValue')->willReturn($data); + $this->request->expects($this->at(1))->method('isPost')->willReturn($isPost); + $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); + $this->assertSame($this->redirect, $this->controller->execute()); + } + + /** + * @return array + */ + public function executeIsPostDataDataProvider() + { + return [ + [false, ['0' => '0']], + [true, []] + ]; + } + + public function testExecuteLoadQueryQueryId() + { + $queryId = 1; + $queryText = ''; + $this->mockGetRequestData($queryText, $queryId); + + $this->query->expects($this->once())->method('getId')->willReturn(false); + $this->query->expects($this->once())->method('load')->with($queryId); + + $this->messageManager->expects($this->once())->method('addSuccess'); + + $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); + $this->assertSame($this->redirect, $this->controller->execute()); + } + + public function testExecuteLoadQueryQueryIdQueryText() + { + $queryId = 1; + $queryText = 'search'; + $this->mockGetRequestData($queryText, $queryId); + + $this->request->expects($this->at(4))->method('getPost')->with('store_id', false)->willReturn(1); + + $this->query->expects($this->once())->method('setStoreId'); + $this->query->expects($this->once())->method('loadByQueryText')->with($queryText); + $this->query->expects($this->any())->method('getId')->willReturn($queryId); + + $this->messageManager->expects($this->once())->method('addSuccess'); + + $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); + $this->assertSame($this->redirect, $this->controller->execute()); + } + + public function testExecuteLoadQueryQueryIdQueryText2() + { + $queryId = 1; + $queryText = 'search'; + $this->mockGetRequestData($queryText, $queryId); + + $this->request->expects($this->at(4))->method('getPost')->with('store_id', false)->willReturn(1); + + $this->query->expects($this->once())->method('setStoreId'); + $this->query->expects($this->once())->method('loadByQueryText')->with($queryText); + $this->query->expects($this->any())->method('getId')->willReturn(false); + $this->query->expects($this->once())->method('load')->with($queryId); + + $this->messageManager->expects($this->once())->method('addSuccess'); + + $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); + $this->assertSame($this->redirect, $this->controller->execute()); + } + + public function testExecuteLoadQueryQueryIdQueryTextException() + { + $queryId = 1; + $anotherQueryId = 2; + $queryText = 'search'; + $this->mockGetRequestData($queryText, $queryId); + + $this->request->expects($this->at(4))->method('getPost')->with('store_id', false)->willReturn(1); + + $this->query->expects($this->once())->method('setStoreId'); + $this->query->expects($this->once())->method('loadByQueryText')->with($queryText); + $this->query->expects($this->any())->method('getId')->willReturn($anotherQueryId); + + $this->messageManager->expects($this->once())->method('addError'); + $this->session->expects($this->once())->method('setPageData'); + $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); + $this->assertSame($this->redirect, $this->controller->execute()); + } + + public function testExecuteException() + { + $queryId = 1; + $queryText = 'search'; + $this->mockGetRequestData($queryText, $queryId); + + $this->request->expects($this->at(4))->method('getPost')->with('store_id', false)->willReturn(1); + + $this->query->expects($this->once())->method('setStoreId'); + $this->query->expects($this->once())->method('loadByQueryText')->willThrowException(new \Exception()); + + $this->messageManager->expects($this->once())->method('addException'); + $this->session->expects($this->once())->method('setPageData'); + $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); + $this->assertSame($this->redirect, $this->controller->execute()); + } + + /** + * @param string $queryText + * @param int $queryId + */ + private function mockGetRequestData($queryText, $queryId) + { + $this->request->expects($this->at(0))->method('getPostValue')->willReturn(['0' => '0']); + $this->request->expects($this->at(1))->method('isPost')->willReturn(true); + $this->request->expects($this->at(2))->method('getPost')->with('query_text', false)->willReturn($queryText); + $this->request->expects($this->at(3))->method('getPost')->with('query_id', null)->willReturn($queryId); + } +} diff --git a/app/code/Magento/Search/composer.json b/app/code/Magento/Search/composer.json index 52668765670a7..7ef783b540c03 100644 --- a/app/code/Magento/Search/composer.json +++ b/app/code/Magento/Search/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/framework": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-catalog-search": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-reports": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-catalog-search": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-reports": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Search/etc/module.xml b/app/code/Magento/Search/etc/module.xml index 8719bbd18c2cf..2648b158b5042 100644 --- a/app/code/Magento/Search/etc/module.xml +++ b/app/code/Magento/Search/etc/module.xml @@ -7,7 +7,7 @@ --> - + diff --git a/app/code/Magento/Sendfriend/Controller/Product/Send.php b/app/code/Magento/Sendfriend/Controller/Product/Send.php index e9d55a9b6c019..77649da9ffd8d 100644 --- a/app/code/Magento/Sendfriend/Controller/Product/Send.php +++ b/app/code/Magento/Sendfriend/Controller/Product/Send.php @@ -35,7 +35,6 @@ public function execute() /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->getLayout()->initMessages(); $this->_eventManager->dispatch('sendfriend_product', ['product' => $product]); $data = $catalogSession->getSendfriendFormData(); diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index 78965f63e1113..3c9e8d5075961 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index d9a1fede56fa3..6130739675cee 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-contact": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-payment": "0.74.0-beta9", - "magento/module-tax": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-contact": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-payment": "0.74.0-beta11", + "magento/module-tax": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-fedex": "0.74.0-beta9", - "magento/module-ups": "0.74.0-beta9" + "magento/module-fedex": "0.74.0-beta11", + "magento/module-ups": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml index b2001f9ac88a4..d871532f2d44a 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/create/items.phtml @@ -12,7 +12,7 @@
    -
    +
    getQtyOrdered()*1 ?>
    @@ -51,56 +51,63 @@ - +
    + +
    -
    - canCreateShippingLabel()): ?> -
    - - -
    - - -
    - - +
    +
    +
    +
    + canCreateShippingLabel()): ?> +
    + + +
    + - canSendShipmentEmail()): ?> -
    - + + for="notify_customer"> +
    - -
    - getChildHtml('submit_button') ?> + canSendShipmentEmail()): ?> +
    + + +
    + + +
    + getChildHtml('submit_button') ?> +
    diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/packed.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/packed.phtml index 822562c345d8a..595ec01356abc 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/packed.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/packed.phtml @@ -23,7 +23,7 @@
    -
    +
    @@ -116,7 +116,7 @@
    -
    +
    diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking.phtml index cb8d042a65f47..ed1580194287a 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking.phtml @@ -73,9 +73,29 @@ require(['prototype'], function(){ - - - + + + diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/view/items.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/view/items.phtml index 1ebeae21eb75e..07e9a9876f358 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/view/items.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/view/items.phtml @@ -7,7 +7,7 @@ // @codingStandardsIgnoreFile ?> -
    +
    + + + + + + + +
    diff --git a/app/code/Magento/Shipping/view/frontend/templates/items.phtml b/app/code/Magento/Shipping/view/frontend/templates/items.phtml index 36c8d6d4b7219..7c5cc15e6521b 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/items.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/items.phtml @@ -25,7 +25,7 @@ - getTrackingPopupUrlBySalesModel($_shipment) ?>","windowName":"trackshipment","width":800,"height":600,"top":0,"left":0,"resizable":1,"scrollbars":1}}' diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 2f6c061cfa861..2734a6ec1f315 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-catalog-url-rewrite": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-catalog-url-rewrite": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Store/App/Response/Redirect.php b/app/code/Magento/Store/App/Response/Redirect.php index 6c156523c881a..de8025f07a2aa 100644 --- a/app/code/Magento/Store/App/Response/Redirect.php +++ b/app/code/Magento/Store/App/Response/Redirect.php @@ -203,21 +203,10 @@ public function redirect(\Magento\Framework\App\ResponseInterface $response, $pa protected function _isUrlInternal($url) { if (strpos($url, 'http') !== false) { - $unsecure = strpos( - $url, - $this->_storeManager->getStore()->getBaseUrl( - \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, - false - ) - ) === 0; - $secure = strpos( - $url, - $this->_storeManager->getStore()->getBaseUrl( - \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, - true - ) - ) === 0; - return $unsecure || $secure; + $directLinkType = \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK; + $unsecureBaseUrl = $this->_storeManager->getStore()->getBaseUrl($directLinkType, false); + $secureBaseUrl = $this->_storeManager->getStore()->getBaseUrl($directLinkType, true); + return (strpos($url, $unsecureBaseUrl) === 0) || (strpos($url, $secureBaseUrl) === 0); } return false; } diff --git a/app/code/Magento/Store/Block/Switcher.php b/app/code/Magento/Store/Block/Switcher.php index 505e883bd0963..6a70699370b1c 100644 --- a/app/code/Magento/Store/Block/Switcher.php +++ b/app/code/Magento/Store/Block/Switcher.php @@ -219,7 +219,7 @@ public function getStoreName() public function getTargetStorePostData(\Magento\Store\Model\Store $store) { return $this->_postDataHelper->getPostData( - $this->getHomeUrl(), + $this->getUrl('stores/store/switch'), ['___store' => $store->getCode(), '___from_store' => $this->getStoreCode()] ); } diff --git a/app/code/Magento/Store/Controller/Store/SwitchAction.php b/app/code/Magento/Store/Controller/Store/SwitchAction.php new file mode 100644 index 0000000000000..ca58ab2ef516f --- /dev/null +++ b/app/code/Magento/Store/Controller/Store/SwitchAction.php @@ -0,0 +1,18 @@ +getResponse()->setRedirect($this->_redirect->getRedirectUrl()); + } +} diff --git a/app/code/Magento/Store/Model/StoreManagerInterface.php b/app/code/Magento/Store/Model/StoreManagerInterface.php index 68d9acb741a45..da7e40ba6d1df 100644 --- a/app/code/Magento/Store/Model/StoreManagerInterface.php +++ b/app/code/Magento/Store/Model/StoreManagerInterface.php @@ -6,6 +6,11 @@ namespace Magento\Store\Model; +/** + * Store manager interface + * + * @api + */ interface StoreManagerInterface { /** diff --git a/app/code/Magento/Store/Test/Unit/Block/SwitcherTest.php b/app/code/Magento/Store/Test/Unit/Block/SwitcherTest.php index 98cce841ccb4a..c03af7b60983a 100644 --- a/app/code/Magento/Store/Test/Unit/Block/SwitcherTest.php +++ b/app/code/Magento/Store/Test/Unit/Block/SwitcherTest.php @@ -22,11 +22,16 @@ class SwitcherTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; + /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $urlBuilder; + protected function setUp() { $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')->getMock(); + $this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface'); $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); $this->context->expects($this->any())->method('getStoreManager')->will($this->returnValue($this->storeManager)); + $this->context->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilder)); $this->corePostDataHelper = $this->getMock('Magento\Framework\Data\Helper\PostHelper', [], [], '', false); $this->switcher = (new ObjectManager($this))->getObject( 'Magento\Store\Block\Switcher', @@ -44,8 +49,10 @@ public function testGetTargetStorePostData() $currentStore = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); $currentStore->expects($this->any())->method('getCode')->will($this->returnValue('current-store')); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($currentStore)); + $storeSwitchUrl = 'stores/store/switch'; + $this->urlBuilder->expects($this->any())->method('getUrl')->with($storeSwitchUrl)->willReturnArgument(0); $this->corePostDataHelper->expects($this->any())->method('getPostData') - ->with(null, ['___store' => 'new-store', '___from_store' => 'current-store']); + ->with($storeSwitchUrl, ['___store' => 'new-store', '___from_store' => 'current-store']); $this->switcher->getTargetStorePostData($store); } diff --git a/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php b/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php new file mode 100644 index 0000000000000..aca8247744ce9 --- /dev/null +++ b/app/code/Magento/Store/Test/Unit/Controller/Store/SwitchActionTest.php @@ -0,0 +1,46 @@ +response = $this->getMock('Magento\Framework\App\ResponseInterface', ['setRedirect', 'sendResponse']); + $this->redirect = $this->getMock('\Magento\Framework\App\Response\RedirectInterface'); + $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); + $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response)); + $this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($this->redirect)); + $this->unit = (new ObjectManager($this))->getObject( + 'Magento\Store\Controller\Store\SwitchAction', + [ + 'context' => $this->context, + ] + ); + } + + public function testExecute() + { + $this->redirect->expects($this->once())->method('getRedirectUrl')->willReturn('url-redirect'); + $this->response->expects($this->once())->method('setRedirect')->with('url-redirect'); + $this->unit->execute(); + } +} diff --git a/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php b/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php index 08b0387396799..51fe75f9bf9f1 100644 --- a/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php +++ b/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php @@ -54,24 +54,27 @@ public function __construct( } /** - * @param array $items - * @return array + * Prepare Data Source + * + * @param array $dataSource + * @return void */ - public function prepareItems(array & $items) + public function prepareDataSource(array & $dataSource) { - foreach ($items as & $item) { - $item[$this->getData('name')] = $this->prepareItem($item); + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->prepareItem($item); + } } - return $items; } /** * Get data * * @param array $item - * @return mixed + * @return string */ - public function prepareItem(array $item) + protected function prepareItem(array $item) { $content = ''; $origStores = $item['store_id']; diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index 78afa713c8fa4..34f6bf80e6365 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-directory": "0.74.0-beta9", - "magento/module-ui": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-directory": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index c1584145c2d3d..320253c316b88 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -52,7 +52,7 @@ - + diff --git a/app/code/Magento/Centinel/etc/frontend/routes.xml b/app/code/Magento/Store/etc/frontend/routes.xml similarity index 78% rename from app/code/Magento/Centinel/etc/frontend/routes.xml rename to app/code/Magento/Store/etc/frontend/routes.xml index 136230f5ce152..2c118f7a8786e 100644 --- a/app/code/Magento/Centinel/etc/frontend/routes.xml +++ b/app/code/Magento/Store/etc/frontend/routes.xml @@ -7,8 +7,8 @@ --> - - + + diff --git a/app/code/Magento/Store/etc/frontend/sections.xml b/app/code/Magento/Store/etc/frontend/sections.xml new file mode 100644 index 0000000000000..97683ac6f4357 --- /dev/null +++ b/app/code/Magento/Store/etc/frontend/sections.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/code/Magento/Tax/Api/Data/GrandTotalDetailsInterface.php b/app/code/Magento/Tax/Api/Data/GrandTotalDetailsInterface.php new file mode 100644 index 0000000000000..3fb1e6fd5b28e --- /dev/null +++ b/app/code/Magento/Tax/Api/Data/GrandTotalDetailsInterface.php @@ -0,0 +1,67 @@ +_taxData = $taxHelper; - $this->_taxConfig = $taxConfig; - parent::__construct($context, $customerSession, $checkoutSession, $data); - } - - /** - * Get subtotal, including tax. - * - * @return float - */ - public function getSubtotalInclTax() - { - $subtotal = 0; - $totals = $this->getTotals(); - if (isset($totals['subtotal'])) { - $subtotal = $totals['subtotal']->getValueInclTax(); - if (!$subtotal) { - $subtotal = $totals['subtotal']->getValue(); - } - } - - return $subtotal; - } - - /** - * Get subtotal, excluding tax. - * - * @return float - */ - public function getSubtotalExclTax() - { - $subtotal = 0; - $totals = $this->getTotals(); - if (isset($totals['subtotal'])) { - $subtotal = $totals['subtotal']->getValueExclTax(); - if (!$subtotal) { - $subtotal = $totals['subtotal']->getValue(); - } - } - return $subtotal; - } - - /** - * Return whether subtotal should be displayed including tax - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getDisplaySubtotalInclTax() - { - return $this->_taxConfig->displayCartSubtotalInclTax(); - } - - /** - * Return whether subtotal should be displayed excluding tax - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getDisplaySubtotalExclTax() - { - return $this->_taxConfig->displayCartSubtotalExclTax(); - } - - /** - * Return whether subtotal should be displayed excluding and including tax - * - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getDisplaySubtotalBoth() - { - return $this->_taxConfig->displayCartSubtotalBoth(); - } -} diff --git a/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php b/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php new file mode 100644 index 0000000000000..61a94b5a84887 --- /dev/null +++ b/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php @@ -0,0 +1,68 @@ +taxConfig = $taxConfig; + } + + /** + * {@inheritdoc} + */ + public function getData() + { + return [ + 'components' => [ + 'minicart_content' => [ + 'children' => [ + 'subtotal.container' => [ + 'children' => [ + 'subtotal' => [ + 'children' => [ + 'subtotal.totals' => [ + 'config' => $this->getTotalsConfig(), + ], + ], + ], + ], + ], + ], + ], + ], + ]; + } + + /** + * Get totals config + * + * @return array + */ + protected function getTotalsConfig() + { + return [ + 'display_subtotal_incl_tax' => (int)$this->taxConfig->displayCartSubtotalInclTax(), + 'display_cart_subtotal_excl_tax' => (int)$this->taxConfig->displayCartSubtotalExclTax(), + ]; + } +} diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index 518ee1353d911..c1f0f8d96ef4f 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -81,7 +81,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_attributeFactory; /** - * @var \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory + * @var \Magento\Sales\Model\Resource\Order\Tax\ItemFactory */ protected $_taxItemFactory; @@ -132,7 +132,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Store\Model\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 + * @param \Magento\Sales\Model\Resource\Order\Tax\ItemFactory $taxItemFactory * @param \Magento\Tax\Model\Resource\Sales\Order\Tax\CollectionFactory $orderTaxCollectionFactory * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param TaxCalculationInterface $taxCalculation @@ -150,7 +150,7 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, - \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory, + \Magento\Sales\Model\Resource\Order\Tax\ItemFactory $taxItemFactory, \Magento\Tax\Model\Resource\Sales\Order\Tax\CollectionFactory $orderTaxCollectionFactory, \Magento\Framework\Locale\ResolverInterface $localeResolver, TaxCalculationInterface $taxCalculation, diff --git a/app/code/Magento/Tax/Model/Calculation/GrandTotalDetails.php b/app/code/Magento/Tax/Model/Calculation/GrandTotalDetails.php new file mode 100644 index 0000000000000..79cc180e80fce --- /dev/null +++ b/app/code/Magento/Tax/Model/Calculation/GrandTotalDetails.php @@ -0,0 +1,94 @@ +getData(self::GROUP_ID); + } + + /** + * {@inheritdoc} + */ + public function setGroupId($id) + { + return $this->setData(self::GROUP_ID, $id); + } + + /** + * {@inheritdoc} + */ + public function getAmount() + { + return $this->getData(self::AMOUNT); + } + + /** + * {@inheritdoc} + */ + public function setAmount($amount) + { + return $this->setData(self::AMOUNT, $amount); + } + + /** + * {@inheritdoc} + */ + public function getRates() + { + return $this->getData(self::RATES); + } + + /** + * {@inheritdoc} + */ + public function setRates($rates) + { + return $this->setData(self::RATES, $rates); + } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\GrandTotalDetailsExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\GrandTotalDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\GrandTotalDetailsExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } +} diff --git a/app/code/Magento/Tax/Model/Calculation/GrandTotalRates.php b/app/code/Magento/Tax/Model/Calculation/GrandTotalRates.php new file mode 100644 index 0000000000000..4c23c6444d723 --- /dev/null +++ b/app/code/Magento/Tax/Model/Calculation/GrandTotalRates.php @@ -0,0 +1,77 @@ +getData(self::TITLE); + } + + /** + * {@inheritdoc} + */ + public function setTitle($title) + { + return $this->setData(self::TITLE, $title); + } + + /** + * {@inheritdoc} + */ + public function getPercent() + { + return $this->getData(self::PERCENT); + } + + /** + * {@inheritdoc} + */ + public function setPercent($percent) + { + return $this->setData(self::PERCENT, $percent); + } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\GrandTotalRatesExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\GrandTotalRatesExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\GrandTotalRatesExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } +} diff --git a/app/code/Magento/Tax/Model/Observer.php b/app/code/Magento/Tax/Model/Observer.php index b83a599cd0680..6d790ba4790a4 100644 --- a/app/code/Magento/Tax/Model/Observer.php +++ b/app/code/Magento/Tax/Model/Observer.php @@ -26,7 +26,7 @@ class Observer protected $_orderTaxFactory; /** - * @var \Magento\Tax\Model\Sales\Order\Tax\ItemFactory + * @var \Magento\Sales\Model\Order\Tax\ItemFactory */ protected $_taxItemFactory; @@ -58,7 +58,7 @@ class Observer /** * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory - * @param \Magento\Tax\Model\Sales\Order\Tax\ItemFactory $taxItemFactory + * @param \Magento\Sales\Model\Order\Tax\ItemFactory $taxItemFactory * @param \Magento\Tax\Model\Calculation $calculation * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory @@ -68,7 +68,7 @@ class Observer public function __construct( \Magento\Tax\Helper\Data $taxData, \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory, - \Magento\Tax\Model\Sales\Order\Tax\ItemFactory $taxItemFactory, + \Magento\Sales\Model\Order\Tax\ItemFactory $taxItemFactory, \Magento\Tax\Model\Calculation $calculation, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory, @@ -241,7 +241,7 @@ public function salesEventOrderAfterSave(\Magento\Framework\Event\Observer $obse 'real_base_amount' => $quoteItemId['real_base_amount'], 'taxable_item_type' => $quoteItemId['item_type'], ]; - /** @var $taxItem \Magento\Tax\Model\Sales\Order\Tax\Item */ + /** @var $taxItem \Magento\Sales\Model\Order\Tax\Item */ $taxItem = $this->_taxItemFactory->create(); $taxItem->setData($data)->save(); } diff --git a/app/code/Magento/Tax/Model/Quote/GrandTotalDetails.php b/app/code/Magento/Tax/Model/Quote/GrandTotalDetails.php new file mode 100644 index 0000000000000..e20684a73b880 --- /dev/null +++ b/app/code/Magento/Tax/Model/Quote/GrandTotalDetails.php @@ -0,0 +1,129 @@ +detailsFactory = $detailsFactory; + $this->ratesFactory = $ratesFactory; + $this->extensionFactory = $extensionFactory; + $this->taxConfig = $taxConfig; + $this->taxTotal = $taxTotal; + $this->quoteRepository = $quoteRepository; + } + + /** + * @param array $rates + * @return array + */ + protected function getRatesData($rates) + { + $taxRates = []; + foreach ($rates as $rate) { + $taxRate = $this->ratesFactory->create([]); + $taxRate->setPercent($rate['percent']); + $taxRate->setTitle($rate['title']); + $taxRates[] = $taxRate; + } + return $taxRates; + } + + /** + * @param CartTotalRepository $subject + * @param callable $proceed + * @param int $cartId + * @return \Magento\Quote\Model\Cart\Totals + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundGet(CartTotalRepository $subject, \Closure $proceed, $cartId) + { + $result = $proceed($cartId); + $quote = $this->quoteRepository->getActive($cartId); + $totals = $quote->getTotals(); + + if (!array_key_exists('tax', $totals)) { + return $result; + } + + $taxes = $totals['tax']->getData(); + if (!array_key_exists('full_info', $taxes)) { + return $result; + } + + $detailsId = 1; + $finalData = []; + foreach ($taxes['full_info'] as $info) { + if ((array_key_exists('hidden', $info) && $info['hidden']) + || ($info['amount'] == 0 && $this->taxConfig->displayCartZeroTax()) + ) { + continue; + } + + $taxDetails = $this->detailsFactory->create([]); + $taxDetails->setAmount($info['amount']); + $taxRates = $this->getRatesData($info['rates']); + $taxDetails->setRates($taxRates); + $taxDetails->setGroupId($detailsId); + $finalData[] = $taxDetails; + $detailsId++; + } + $taxInfo = $this->extensionFactory->create('\\Magento\\Quote\\Model\\Cart\\Totals', []); + $taxInfo->setTaxGrandtotalDetails($finalData); + /** @var $result \Magento\Quote\Model\Cart\Totals */ + $result->setExtensionAttributes($taxInfo); + $result->setTaxAmount($taxes['value']); + return $result; + } +} diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php b/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php index c1e02c6c84065..a94664b572af2 100644 --- a/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php +++ b/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php @@ -46,11 +46,9 @@ public function aggregate($from = null, $to = null) */ protected function _aggregateByOrder($aggregationField, $from, $to) { - // convert input dates to UTC to be comparable with DATETIME fields in DB - $from = $this->_dateToUtc($from); - $to = $this->_dateToUtc($to); - $writeAdapter = $this->_getWriteAdapter(); + $salesAdapter = $this->_resources->getConnection('sales_read'); + $writeAdapter->beginTransaction(); try { @@ -66,14 +64,16 @@ protected function _aggregateByOrder($aggregationField, $from, $to) $subSelect = null; } - $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect); - // convert dates from UTC to current admin timezone + $this->_clearTableByDateRange($this->getMainTable(), $from, $to, $subSelect, false, $salesAdapter); + // convert dates to current admin timezone $periodExpr = $writeAdapter->getDatePartSql( $this->getStoreTZOffsetQuery( ['e' => $this->getTable('sales_order')], 'e.' . $aggregationField, $from, - $to + $to, + null, + $salesAdapter ) ); @@ -87,31 +87,29 @@ protected function _aggregateByOrder($aggregationField, $from, $to) 'tax_base_amount_sum' => 'SUM(tax.base_amount * e.base_to_global_rate)', ]; - $select = $writeAdapter->select(); - $select->from( + $select = $writeAdapter->select()->from( ['tax' => $this->getTable('sales_order_tax')], $columns )->joinInner( ['e' => $this->getTable('sales_order')], 'e.entity_id = tax.order_id', [] - )->useStraightJoin(); - - $select->where( + )->useStraightJoin()->where( 'e.state NOT IN (?)', [\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT, \Magento\Sales\Model\Order::STATE_NEW] ); if ($subSelect !== null) { - $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); + $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period', $salesAdapter)); } $select->group([$periodExpr, 'e.store_id', 'code', 'tax.percent', 'e.status']); - $insertQuery = $writeAdapter->insertFromSelect($select, $this->getMainTable(), array_keys($columns)); - $writeAdapter->query($insertQuery); + $aggregatedData = $salesAdapter->fetchAll($select); - $select->reset(); + if ($aggregatedData) { + $writeAdapter->insertArray($this->getMainTable(), array_keys($columns), $aggregatedData); + } $columns = [ 'period' => 'period', @@ -123,10 +121,10 @@ protected function _aggregateByOrder($aggregationField, $from, $to) 'tax_base_amount_sum' => 'SUM(tax_base_amount_sum)', ]; - $select->from($this->getMainTable(), $columns)->where('store_id <> ?', 0); + $select->reset()->from($this->getMainTable(), $columns)->where('store_id <> ?', 0); if ($subSelect !== null) { - $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'period')); + $select->where($this->_makeConditionFromDateRangeSelect($subSelect, 'period', $salesAdapter)); } $select->group(['period', 'code', 'percent', 'order_status']); diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php deleted file mode 100644 index d80ee32cb2fb9..0000000000000 --- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item/Collection.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection -{ - /** - * Initialize resource - * - * @return void - */ - protected function _construct() - { - $this->_init('Magento\Tax\Model\Sales\Order\Tax\Item', 'Magento\Tax\Model\Resource\Sales\Order\Tax\Item'); - } -} diff --git a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php index fed06b4dd1983..8067b04543639 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php +++ b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php @@ -11,12 +11,12 @@ use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterfaceFactory as TaxDetailsDataObjectFactory; use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface as AppliedTax; use Magento\Tax\Model\Sales\Order\Tax; -use Magento\Tax\Model\Sales\Order\Tax\Item; +use Magento\Sales\Model\Order\Tax\Item; class TaxManagement implements \Magento\Tax\Api\OrderTaxManagementInterface { /** - * @var \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory + * @var \Magento\Sales\Model\Resource\Order\Tax\ItemFactory */ protected $orderItemTaxFactory; @@ -42,14 +42,14 @@ class TaxManagement implements \Magento\Tax\Api\OrderTaxManagementInterface /** * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $orderItemTaxFactory + * @param \Magento\Sales\Model\Resource\Order\Tax\ItemFactory $orderItemTaxFactory * @param \Magento\Tax\Api\Data\OrderTaxDetailsInterfaceFactory $orderTaxDetailsDataObjectFactory * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory $itemDataObjectFactory * @param TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory */ public function __construct( \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $orderItemTaxFactory, + \Magento\Sales\Model\Resource\Order\Tax\ItemFactory $orderItemTaxFactory, \Magento\Tax\Api\Data\OrderTaxDetailsInterfaceFactory $orderTaxDetailsDataObjectFactory, \Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory $itemDataObjectFactory, TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory diff --git a/app/code/Magento/Tax/Model/TaxConfigProvider.php b/app/code/Magento/Tax/Model/TaxConfigProvider.php new file mode 100644 index 0000000000000..4f40850d8bfb1 --- /dev/null +++ b/app/code/Magento/Tax/Model/TaxConfigProvider.php @@ -0,0 +1,136 @@ +taxHelper = $taxHelper; + $this->taxConfig = $taxConfig; + } + + /** + * {@inheritdoc} + */ + public function getConfig() + { + return [ + 'isDisplayShippingPriceExclTax' => $this->isDisplayShippingPriceExclTax(), + 'isDisplayShippingBothPrices' => $this->isDisplayShippingBothPrices(), + 'reviewShippingDisplayMode' => $this->getDisplayShippingMode(), + 'reviewItemPriceDisplayMode' => $this->getReviewItemPriceDisplayMode(), + 'reviewTotalsDisplayMode' => $this->getReviewTotalsDisplayMode(), + 'includeTaxInGrandTotal' => $this->isTaxDisplayedInGrandTotal(), + 'isFullTaxSummaryDisplayed' => $this->isFullTaxSummaryDisplayed(), + ]; + } + + /** + * Shipping mode: 'both', 'including', 'excluding' + * + * @return string + */ + public function getDisplayShippingMode() + { + if ($this->taxConfig->displayCartShippingBoth()) { + return 'both'; + } + if ($this->taxConfig->displayCartShippingExclTax()) { + return 'excluding'; + } + return 'including'; + } + + /** + * Return flag whether to display shipping price excluding tax + * + * @return bool + */ + public function isDisplayShippingPriceExclTax() + { + return $this->taxHelper->displayShippingPriceExcludingTax(); + } + + /** + * Return flag whether to display shipping price including and excluding tax + * + * @return bool + */ + public function isDisplayShippingBothPrices() + { + return $this->taxHelper->displayShippingBothPrices(); + } + + /** + * Get review item price display mode + * + * @return string 'both', 'including', 'excluding' + */ + public function getReviewItemPriceDisplayMode() + { + if ($this->taxHelper->displayCartBothPrices()) { + return 'both'; + } + if ($this->taxHelper->displayCartPriceExclTax()) { + return 'excluding'; + } + return 'including'; + } + + /** + * Get review item price display mode + * + * @return string 'both', 'including', 'excluding' + */ + public function getReviewTotalsDisplayMode() + { + if ($this->taxConfig->displayCartSubtotalBoth()) { + return 'both'; + } + if ($this->taxConfig->displayCartSubtotalExclTax()) { + return 'excluding'; + } + return 'including'; + } + + /** + * Show tax details in checkout totals section flag + * + * @return bool + */ + public function isFullTaxSummaryDisplayed() + { + return $this->taxHelper->displayFullSummary(); + } + + /** + * Display tax in grand total section or not + * + * @return bool + */ + public function isTaxDisplayedInGrandTotal() + { + return $this->taxConfig->displayCartTaxWithGrandTotal(); + } +} diff --git a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php new file mode 100644 index 0000000000000..669e0eb247a0b --- /dev/null +++ b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php @@ -0,0 +1,114 @@ +checkoutSession = $checkoutSession; + $this->checkoutHelper = $checkoutHelper; + } + + /** + * Add tax data to result + * + * @param \Magento\Checkout\CustomerData\Cart $subject + * @param array $result + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result) + { + $result['subtotal_incl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalInclTax()); + $result['subtotal_excl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalExclTax()); + return $result; + } + + /** + * Get subtotal, including tax + * + * @return float + */ + protected function getSubtotalInclTax() + { + $subtotal = 0; + $totals = $this->getTotals(); + if (isset($totals['subtotal'])) { + $subtotal = $totals['subtotal']->getValueInclTax() ?: $totals['subtotal']->getValue(); + } + return $subtotal; + } + + /** + * Get subtotal, excluding tax + * + * @return float + */ + protected function getSubtotalExclTax() + { + $subtotal = 0; + $totals = $this->getTotals(); + if (isset($totals['subtotal'])) { + $subtotal = $totals['subtotal']->getValueExclTax() ?: $totals['subtotal']->getValue(); + } + return $subtotal; + } + + /** + * Get totals + * + * @return array + */ + public function getTotals() + { + // TODO: TODO: MAGETWO-34824 duplicate \Magento\Checkout\CustomerData\Cart::getSectionData + if (empty($this->totals)) { + $this->totals = $this->getQuote()->getTotals(); + } + return $this->totals; + } + + /** + * Get active quote + * + * @return \Magento\Quote\Model\Quote + */ + protected function getQuote() + { + if (null === $this->quote) { + $this->quote = $this->checkoutSession->getQuote(); + } + return $this->quote; + } +} diff --git a/app/code/Magento/Tax/Setup/InstallSchema.php b/app/code/Magento/Tax/Setup/InstallSchema.php index 6d708d5862f56..9d53d465bc179 100644 --- a/app/code/Magento/Tax/Setup/InstallSchema.php +++ b/app/code/Magento/Tax/Setup/InstallSchema.php @@ -404,105 +404,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con ) ); - /** - * Create table 'sales_order_tax_item' - */ - $table = $setup->getConnection()->newTable( - $setup->getTable('sales_order_tax_item') - )->addColumn( - 'tax_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Tax Item Id' - )->addColumn( - 'tax_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Tax Id' - )->addColumn( - 'item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => true], - 'Item Id' - )->addColumn( - 'tax_percent', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Real Tax Percent For Item' - )->addColumn( - 'amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Tax amount for the item and tax rate' - )->addColumn( - 'base_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Base tax amount for the item and tax rate' - )->addColumn( - 'real_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Real tax amount for the item and tax rate' - )->addColumn( - 'real_base_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Real base tax amount for the item and tax rate' - )->addColumn( - 'associated_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => true, 'unsigned' => true], - 'Id of the associated item' - )->addColumn( - 'taxable_item_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false], - 'Type of the taxable item' - )->addIndex( - $setup->getIdxName('sales_order_tax_item', ['item_id']), - ['item_id'] - )->addIndex( - $setup->getIdxName( - 'sales_order_tax_item', - ['tax_id', 'item_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['tax_id', 'item_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addForeignKey( - $setup->getFkName('sales_order_tax_item', 'associated_item_id', 'sales_order_item', 'item_id'), - 'associated_item_id', - $setup->getTable('sales_order_item'), - 'item_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $setup->getFkName('sales_order_tax_item', 'tax_id', 'sales_order_tax', 'tax_id'), - 'tax_id', - $setup->getTable('sales_order_tax'), - 'tax_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $setup->getFkName('sales_order_tax_item', 'item_id', 'sales_order_item', 'item_id'), - 'item_id', - $setup->getTable('sales_order_item'), - 'item_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Order Tax Item' - ); - $setup->getConnection()->createTable($table); - $setup->endSetup(); } diff --git a/app/code/Magento/Tax/Test/Unit/Block/Checkout/Cart/Sidebar/TotalsTest.php b/app/code/Magento/Tax/Test/Unit/Block/Checkout/Cart/Sidebar/TotalsTest.php deleted file mode 100644 index c29a90310bfbf..0000000000000 --- a/app/code/Magento/Tax/Test/Unit/Block/Checkout/Cart/Sidebar/TotalsTest.php +++ /dev/null @@ -1,189 +0,0 @@ -quote = $this->getMockBuilder('Magento\Quote\Model\Quote') - ->disableOriginalConstructor() - ->setMethods(['getTotals', '__wakeup']) - ->getMock(); - - $checkoutSession = $this->getMockBuilder('\Magento\Checkout\Model\Session') - ->disableOriginalConstructor() - ->setMethods(['getQuote', '__wakeup']) - ->getMock(); - - $checkoutSession->expects($this->any()) - ->method('getQuote') - ->will($this->returnValue($this->quote)); - - $this->taxHelper = $this->getMockBuilder('\Magento\Tax\Helper\Data') - ->disableOriginalConstructor() - ->getMock(); - - $this->taxConfig = $this->getMockBuilder('\Magento\Tax\Model\Config') - ->disableOriginalConstructor() - ->setMethods([ - 'displayCartSubtotalInclTax', 'displayCartSubtotalExclTax', 'displayCartSubtotalBoth' - ]) - ->getMock(); - - $this->totalsObj = $objectManager->getObject( - 'Magento\Tax\Block\Checkout\Cart\Sidebar\Totals', - [ - 'checkoutSession' => $checkoutSession, - 'taxHelper' => $this->taxHelper, - 'taxConfig' => $this->taxConfig, - ] - ); - } - - /** - * @dataProvider getSubtotalInclTaxDataProvider - */ - public function testGetSubtotalInclTax($totals, $expectedValue) - { - $this->quote->expects($this->once()) - ->method('getTotals') - ->will($this->returnValue($totals)); - - $this->assertEquals($expectedValue, $this->totalsObj->getSubtotalInclTax()); - } - - public function getSubtotalInclTaxDataProvider() - { - $data = [ - 'incl' => [ - 'totals' => [ - 'subtotal' => new Object( - [ - 'value_incl_tax' => self::SUBTOTAL_INCL_TAX, - 'value' => self::SUBTOTAL, - ] - ), - ], - 'expected' => self::SUBTOTAL_INCL_TAX, - ], - 'no_incl_value' => [ - 'totals' => [ - 'subtotal' => new Object( - [ - 'value' => self::SUBTOTAL, - ] - ), - ], - 'expected' => self::SUBTOTAL, - ], - 'no_subtotal' => [ - 'totals' => [], - 'expected' => 0, - ] - ]; - return $data; - } - - /** - * @dataProvider getSubtotalExclTaxDataProvider - */ - public function testGetSubtotalExclTax($totals, $expectedValue) - { - $this->quote->expects($this->once()) - ->method('getTotals') - ->will($this->returnValue($totals)); - - $this->assertEquals($expectedValue, $this->totalsObj->getSubtotalExclTax()); - } - - public function getSubtotalExclTaxDataProvider() - { - $data = [ - 'excl' => [ - 'totals' => [ - 'subtotal' => new Object( - [ - 'value_excl_tax' => self::SUBTOTAL_EXCL_TAX, - 'value' => self::SUBTOTAL, - ] - ), - ], - 'expected' => self::SUBTOTAL_EXCL_TAX, - ], - 'no_excl_value' => [ - 'totals' => [ - 'subtotal' => new Object( - [ - 'value' => self::SUBTOTAL, - ] - ), - ], - 'expected' => self::SUBTOTAL, - ], - 'no_subtotal' => [ - 'totals' => [], - 'expected' => 0, - ] - ]; - return $data; - } - - public function testGetDisplaySubtotalInclTax() - { - $this->taxConfig->expects($this->once()) - ->method('displayCartSubtotalInclTax'); - - $this->totalsObj->getDisplaySubtotalInclTax(); - } - - public function testGetDisplaySubtotalExclTax() - { - $this->taxConfig->expects($this->once()) - ->method('displayCartSubtotalExclTax'); - - $this->totalsObj->getDisplaySubtotalExclTax(); - } - - public function testGetDisplaySubtotalBoth() - { - $this->taxConfig->expects($this->once()) - ->method('displayCartSubtotalBoth'); - - $this->totalsObj->getDisplaySubtotalBoth(); - } -} diff --git a/app/code/Magento/Tax/Test/Unit/GetterSetterTest.php b/app/code/Magento/Tax/Test/Unit/GetterSetterTest.php index 42d12b8a9a0d9..501e4d0747492 100644 --- a/app/code/Magento/Tax/Test/Unit/GetterSetterTest.php +++ b/app/code/Magento/Tax/Test/Unit/GetterSetterTest.php @@ -115,13 +115,13 @@ public function dataProviderGettersSetters() ], 'Items' => [ - 'Magento\Tax\Model\Sales\Order\Tax\Item' + 'Magento\Sales\Model\Order\Tax\Item' ], 'ExtensionAttributes' => 'Magento\Tax\Api\Data\OrderTaxDetailsExtension' ] ], [ - 'Magento\Tax\Model\Sales\Order\Tax\Item', + 'Magento\Sales\Model\Order\Tax\Item', [ 'Type' => 'type', 'ItemId' => 1, @@ -142,7 +142,7 @@ public function dataProviderGettersSetters() 'CustomerId' => 1, 'Items' => [ - 'Magento\Tax\Model\Sales\Order\Tax\Item' + 'Magento\Sales\Model\Order\Tax\Item' ], 'CustomerTaxClassId' => 1, 'ExtensionAttributes' => 'Magento\Tax\Api\Data\QuoteDetailsExtension' diff --git a/app/code/Magento/Tax/Test/Unit/Model/Sales/Order/TaxManagementTest.php b/app/code/Magento/Tax/Test/Unit/Model/Sales/Order/TaxManagementTest.php index 938244cac51ea..2b98948a299df 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Sales/Order/TaxManagementTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Sales/Order/TaxManagementTest.php @@ -71,14 +71,14 @@ public function setUp() $this->orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); $this->orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); $this->taxItemResourceMock = $this->getMock( - 'Magento\Tax\Model\Resource\Sales\Order\Tax\Item', + 'Magento\Sales\Model\Resource\Order\Tax\Item', [], [], '', false ); $this->taxItemFactoryMock = $this->getMock( - 'Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory', + 'Magento\Sales\Model\Resource\Order\Tax\ItemFactory', ['create'], [], '', @@ -94,7 +94,7 @@ public function setUp() ->method('create') ->willReturn($this->appliedTaxDataObject); - $this->itemDataObject = $objectManager->getObject('Magento\Tax\Model\Sales\Order\Tax\Item'); + $this->itemDataObject = $objectManager->getObject('Magento\Sales\Model\Order\Tax\Item'); $this->itemDataObjectFactoryMock = $this->getMock('Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory', $methods, [], '', false); $this->itemDataObjectFactoryMock->expects($this->atLeastOnce()) diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 649e3b923352b..7a48ebcdc469b 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-shipping": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-reports": "0.74.0-beta9", - "magento/module-quote": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-config": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-shipping": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-reports": "0.74.0-beta11", + "magento/module-quote": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml index b68154ae6f2af..7b8eb051ac01d 100644 --- a/app/code/Magento/Tax/etc/di.xml +++ b/app/code/Magento/Tax/etc/di.xml @@ -42,7 +42,7 @@ - + @@ -59,7 +59,22 @@ + + + + + + + + sales + + + + + sales + + diff --git a/app/code/Magento/Tax/etc/frontend/di.xml b/app/code/Magento/Tax/etc/frontend/di.xml index cc60d7de56baa..fa0d913d07cda 100644 --- a/app/code/Magento/Tax/etc/frontend/di.xml +++ b/app/code/Magento/Tax/etc/frontend/di.xml @@ -14,4 +14,21 @@ Magento\Customer\Api\CustomerRepositoryInterface\Proxy + + + + + + + Magento\Tax\CustomerData\CheckoutTotalsJsLayoutDataProvider + + + + + + + Magento\Tax\Model\TaxConfigProvider + + + diff --git a/app/code/Magento/Tax/etc/service_data_attributes.xml b/app/code/Magento/Tax/etc/service_data_attributes.xml new file mode 100644 index 0000000000000..8539bcc8b88d3 --- /dev/null +++ b/app/code/Magento/Tax/etc/service_data_attributes.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/app/code/Magento/Tax/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml b/app/code/Magento/Tax/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml index 5186039d7b12f..b41c99ae84062 100644 --- a/app/code/Magento/Tax/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml +++ b/app/code/Magento/Tax/view/frontend/layout/checkout_cart_sidebar_total_renderers.xml @@ -8,7 +8,30 @@ - + + + + + + + + + + + Magento_Tax/js/view/checkout/minicart/subtotal/totals + + Magento_Tax/checkout/minicart/subtotal/totals + + + + + + + + + + + diff --git a/app/code/Magento/Tax/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Tax/view/frontend/layout/checkout_onepage_index.xml new file mode 100644 index 0000000000000..85969a844c674 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/layout/checkout_onepage_index.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + Magento_Tax/js/view/checkout/shipping_method/price + price + + + + + + + Magento_Checkout/js/view/columns + + + Magento_Tax/js/view/checkout/review/item/columns/price + + + Magento_Tax/js/view/checkout/review/item/columns/subtotal + + + + + + + Magento_Tax/js/view/checkout/review/subtotal + 10 + + + Magento_Tax/js/view/checkout/review/shipping + 20 + + + Magento_Tax/js/view/checkout/review/before_grandtotal + 30 + + + + + + Magento_Tax/js/view/checkout/review/grandtotal + 40 + + + Magento_Tax/js/view/checkout/review/tax_total + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Tax/view/frontend/templates/checkout/cart/minicart/totals.phtml b/app/code/Magento/Tax/view/frontend/templates/checkout/cart/minicart/totals.phtml deleted file mode 100644 index 305831168dfd9..0000000000000 --- a/app/code/Magento/Tax/view/frontend/templates/checkout/cart/minicart/totals.phtml +++ /dev/null @@ -1,29 +0,0 @@ - - -
    - getDisplaySubtotalExclTax()): ?> - - helper('Magento\Checkout\Helper\Data')->formatPrice($block->getSubtotalExclTax()); ?> - - getDisplaySubtotalInclTax()): ?> - - helper('Magento\Checkout\Helper\Data')->formatPrice($block->getSubtotalInclTax()); ?> - - - - helper('Magento\Checkout\Helper\Data')->formatPrice($block->getSubtotalInclTax()) ?> - - - helper('Magento\Checkout\Helper\Data')->formatPrice($block->getSubtotalExclTax()); ?> - - -
    diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js new file mode 100644 index 0000000000000..2de0bfbda639b --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js @@ -0,0 +1,17 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data' +], function (Component, customerData) { + 'use strict'; + + return Component.extend({ + initialize: function () { + this._super(); + this.cart = customerData.get('cart'); + } + }); +}); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/before_grandtotal.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/before_grandtotal.js new file mode 100644 index 0000000000000..72f01914f2df6 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/before_grandtotal.js @@ -0,0 +1,19 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'uiComponent' + ], + function (Component) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Tax/checkout/review/before_grandtotal' + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/grandtotal.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/grandtotal.js new file mode 100644 index 0000000000000..214e16f531e78 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/grandtotal.js @@ -0,0 +1,66 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component, quote, priceUtils) { + "use strict"; + var isTaxDisplayedInGrandTotal = window.checkoutConfig.includeTaxInGrandTotal || false; + var isFullTaxSummaryDisplayed = window.checkoutConfig.isFullTaxSummaryDisplayed || false; + return Component.extend({ + defaults: { + isFullTaxSummaryDisplayed: isFullTaxSummaryDisplayed, + template: 'Magento_Tax/checkout/review/grandtotal' + }, + getColspan: 3, + style: "", + exclTaxLabel: 'Grand Total Excl. Tax', + inclTaxLabel: 'Grand Total Incl. Tax', + basicCurrencyMessage: 'Your credit card will be charged for', + getTitle: function() { + return "Grand Total"; + }, + totals: quote.getTotals(), + getValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().grand_total; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + }, + getBaseValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().base_grand_total; + } + return priceUtils.formatPrice(price, quote.getBasePriceFormat()); + }, + isTaxDisplayedInGrandTotal: isTaxDisplayedInGrandTotal, + getGrandTotalExclTax: function() { + var totals = this.totals(); + if (!totals) { + return 0; + } + var amount = totals.grand_total - totals.tax_amount; + if (amount < 0) { + return 0; + } + return priceUtils.formatPrice(amount, quote.getPriceFormat()); + }, + isBaseGrandTotalDisplayNeeded: function() { + var totals = this.totals(); + if (!totals) { + return false; + } + return totals.base_currency_code != totals.quote_currency_code; + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/item/columns/price.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/item/columns/price.js new file mode 100644 index 0000000000000..839e4a1be856e --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/item/columns/price.js @@ -0,0 +1,38 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'Magento_Checkout/js/view/review/item/column' + ], + function (column) { + "use strict"; + var displayPriceMode = window.checkoutConfig.reviewItemPriceDisplayMode || 'including'; + return column.extend({ + defaults: { + displayPriceMode: displayPriceMode, + ownClass: 'price', + columnTitle: 'Price', + template: 'Magento_Tax/checkout/review/item/columns/price' + }, + isPriceInclTaxDisplayed: function() { + return 'both' == this.displayPriceMode || 'including' == this.displayPriceMode; + }, + isPriceExclTaxDisplayed: function() { + return 'both' == this.displayPriceMode || 'excluding' == this.displayPriceMode; + }, + isBothPricesDisplayed: function() { + return 'both' == this.displayPriceMode; + }, + getPriceExclTax: function(quoteItem) { + return this.getFormattedPrice(quoteItem.price); + }, + getPriceInclTax: function(quoteItem) { + return this.getFormattedPrice(quoteItem.price_incl_tax); + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/item/columns/subtotal.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/item/columns/subtotal.js new file mode 100644 index 0000000000000..2d1bee80d8fb5 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/item/columns/subtotal.js @@ -0,0 +1,23 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'Magento_Tax/js/view/checkout/review/item/columns/price' + ], + function (Price) { + "use strict"; + var displayPriceMode = window.checkoutConfig.reviewItemPriceDisplayMode || 'including'; + return Price.extend({ + defaults: { + displayPriceMode: displayPriceMode, + ownClass: 'subtotal', + columnTitle: 'Subtotal', + template: 'Magento_Tax/checkout/review/item/columns/subtotal' + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/shipping.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/shipping.js new file mode 100644 index 0000000000000..1fc18683237bb --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/shipping.js @@ -0,0 +1,68 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'jquery', + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils', + 'Magento_Checkout/js/model/shipping-service' + ], + function ($, Component, quote, priceUtils, shippingService) { + var displayMode = window.checkoutConfig.reviewShippingDisplayMode; + return Component.extend({ + defaults: { + displayMode: displayMode, + template: 'Magento_Tax/checkout/review/shipping' + }, + getColspan: 3, + style: "", + quoteIsVirtual: quote.isVirtual(), + selectedShippingMethod: quote.getShippingMethod(), + getTitle: function() { + return "Shipping & Handling" + "(" + shippingService.getTitleByCode(this.selectedShippingMethod()) + ")"; + }, + getExcludingLabel: function() { + return "Shipping Excl. Tax" + "(" + shippingService.getTitleByCode(this.selectedShippingMethod()) + ")"; + }, + getIncludingLabel: function() { + return "Shipping Incl. Tax" + "(" + shippingService.getTitleByCode(this.selectedShippingMethod()) + ")"; + }, + totals: quote.getTotals(), + isBothPricesDisplayed: function() { + return 'both' == this.displayMode + }, + isIncludingDisplayed: function() { + return 'including' == this.displayMode; + }, + isExcludingDisplayed: function() { + return 'excluding' == this.displayMode; + }, + getValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().shipping_amount; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + }, + getIncludingValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().shipping_incl_tax; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + }, + getExcludingValue: function() { + var price = 0; + if (this.totals()) { + price = this.totals().shipping_amount; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/subtotal.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/subtotal.js new file mode 100644 index 0000000000000..06a169784c3f6 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/subtotal.js @@ -0,0 +1,50 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component, quote, priceUtils) { + var displaySubtotalMode = window.checkoutConfig.reviewTotalsDisplayMode; + return Component.extend({ + defaults: { + displaySubtotalMode: displaySubtotalMode, + template: 'Magento_Tax/checkout/review/subtotal' + }, + getColspan: 3, + style: "", + excludingTaxMessage: 'Subtotal (Excl. Tax)', + includingTaxMessage: 'Subtotal (Incl. Tax)', + getTitle: function() { + return "Subtotal" + }, + totals: quote.getTotals(), + getValue: function () { + var price = 0; + if (this.totals()) { + price = this.totals().subtotal; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + }, + isBothPricesDisplayed: function() { + return 'both' == this.displaySubtotalMode; + }, + isIncludingTaxDisplayed: function() { + return 'including' == this.displaySubtotalMode; + }, + getValueInclTax: function() { + var price = 0; + if (this.totals()) { + price = this.totals().subtotal_incl_tax; + } + return priceUtils.formatPrice(price, quote.getPriceFormat()); + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/tax_total.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/tax_total.js new file mode 100644 index 0000000000000..56f70a8993f97 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/review/tax_total.js @@ -0,0 +1,54 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [ + 'ko', + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (ko, Component, quote, priceUtils) { + "use strict"; + var isTaxDisplayedInGrandTotal = window.checkoutConfig.includeTaxInGrandTotal; + var isFullTaxSummaryDisplayed = window.checkoutConfig.isFullTaxSummaryDisplayed; + return Component.extend({ + defaults: { + isTaxDisplayedInGrandTotal: isTaxDisplayedInGrandTotal, + template: 'Magento_Tax/checkout/review/tax_total' + }, + colspan: 3, + totals: quote.getTotals(), + style: "", + isFullTaxSummaryDisplayed: isFullTaxSummaryDisplayed, + lastTaxGroupId: null, + isDetailsVisible: ko.observable(), + getTitle: function() { + return "Tax"; + }, + getValue: function() { + var amount = 0; + if (this.totals()) { + amount = this.totals().tax_amount; + } + return priceUtils.formatPrice(amount, quote.getPriceFormat()); + }, + formatPrice: function(amount) { + return priceUtils.formatPrice(amount, quote.getPriceFormat()); + }, + getDetails: function() { + var totals = this.totals(); + if (totals.extension_attributes) { + return totals.extension_attributes.tax_grandtotal_details; + } + return []; + }, + toggleDetails: function() { + this.isDetailsVisible(!this.isDetailsVisible()); + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/js/view/checkout/shipping_method/price.js b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/shipping_method/price.js new file mode 100644 index 0000000000000..bdb1256f25678 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/js/view/checkout/shipping_method/price.js @@ -0,0 +1,31 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component,quote, priceUtils) { + "use strict"; + return Component.extend({ + defaults: { + template: 'Magento_Tax/checkout/shipping_method/price', + }, + + isDisplayShippingPriceExclTax: window.checkoutConfig.isDisplayShippingPriceExclTax, + isDisplayShippingBothPrices: window.checkoutConfig.isDisplayShippingBothPrices, + isPriceEqual: function(item) { + return item.price_excl_tax != item.price_incl_tax; + }, + getFormattedPrice: function (price) { + //todo add format data + return priceUtils.formatPrice(price, quote.getPriceFormat()); + } + }); + } +); diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html new file mode 100644 index 0000000000000..c3c28a5813822 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html @@ -0,0 +1,26 @@ + + +
    + + + + + + + + + + + + + + + +
    diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/before_grandtotal.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/before_grandtotal.html new file mode 100644 index 0000000000000..237b692b59a6f --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/before_grandtotal.html @@ -0,0 +1,10 @@ + + + + + diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/grandtotal.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/grandtotal.html new file mode 100644 index 0000000000000..8c533bcae6fca --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/grandtotal.html @@ -0,0 +1,43 @@ + + +
    + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/item/columns/price.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/item/columns/price.html new file mode 100644 index 0000000000000..fc596c7d1ac5e --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/item/columns/price.html @@ -0,0 +1,23 @@ + + \ No newline at end of file diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/item/columns/subtotal.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/item/columns/subtotal.html new file mode 100644 index 0000000000000..d489e741ba047 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/item/columns/subtotal.html @@ -0,0 +1,23 @@ + + \ No newline at end of file diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/shipping.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/shipping.html new file mode 100644 index 0000000000000..6c7900d23315b --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/shipping.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/subtotal.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/subtotal.html new file mode 100644 index 0000000000000..022131d8a0cc9 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/subtotal.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/review/tax_total.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/tax_total.html new file mode 100644 index 0000000000000..e22db68f36617 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/review/tax_total.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/shipping_method/price.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/shipping_method/price.html new file mode 100644 index 0000000000000..e854b9f1e0bc2 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/shipping_method/price.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json index 8e3954d6b8588..bc5cd99343d01 100644 --- a/app/code/Magento/TaxImportExport/composer.json +++ b/app/code/Magento/TaxImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-tax": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-directory": "0.74.0-beta9", - "magento/module-store": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/module-tax": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-directory": "0.74.0-beta11", + "magento/module-store": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Theme/Block/Html/Footer.php b/app/code/Magento/Theme/Block/Html/Footer.php index f5dac383b3a8f..db5e92850052d 100644 --- a/app/code/Magento/Theme/Block/Html/Footer.php +++ b/app/code/Magento/Theme/Block/Html/Footer.php @@ -10,7 +10,7 @@ /** * Html page footer block */ -class Footer extends \Magento\Framework\View\Element\Template implements \Magento\Framework\View\Block\IdentityInterface +class Footer extends \Magento\Framework\View\Element\Template implements \Magento\Framework\Object\IdentityInterface { /** * Copyright information diff --git a/app/code/Magento/Theme/Block/Html/Header.php b/app/code/Magento/Theme/Block/Html/Header.php index dd74a7e49e8bc..6265241ebaa7e 100644 --- a/app/code/Magento/Theme/Block/Html/Header.php +++ b/app/code/Magento/Theme/Block/Html/Header.php @@ -6,9 +6,6 @@ namespace Magento\Theme\Block\Html; -use Magento\Customer\Helper\View as CustomerViewHelper; -use Magento\Customer\Model\Context; - /** * Html page header block */ @@ -21,42 +18,6 @@ class Header extends \Magento\Framework\View\Element\Template */ protected $_template = 'html/header.phtml'; - /** - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - - /** - * @var \Magento\Framework\App\Http\Context - */ - protected $httpContext; - - /** - * @var \Magento\Customer\Helper\View - */ - protected $_customerViewHelper; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Framework\App\Http\Context $httpContext - * @param CustomerViewHelper $customerViewHelper - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Customer\Model\Session $customerSession, - \Magento\Framework\App\Http\Context $httpContext, - CustomerViewHelper $customerViewHelper, - array $data = [] - ) { - $this->_customerSession = $customerSession; - parent::__construct($context, $data); - $this->httpContext = $httpContext; - $this->_customerViewHelper = $customerViewHelper; - $this->_isScopePrivate = true; - } - /** * Retrieve welcome text * @@ -65,20 +26,10 @@ public function __construct( public function getWelcome() { if (empty($this->_data['welcome'])) { - if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) { - $customerName = $this->_customerViewHelper->getCustomerName( - $this->_customerSession->getCustomerDataObject() - ); - $this->_data['welcome'] = __( - 'Welcome, %1!', - $this->escapeHtml($customerName) - ); - } else { - $this->_data['welcome'] = $this->_scopeConfig->getValue( - 'design/header/welcome', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - } + $this->_data['welcome'] = $this->_scopeConfig->getValue( + 'design/header/welcome', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } return $this->_data['welcome']; } diff --git a/app/code/Magento/Theme/Block/Html/Header/Logo.php b/app/code/Magento/Theme/Block/Html/Header/Logo.php index d496e358bd523..96c41f8defae5 100644 --- a/app/code/Magento/Theme/Block/Html/Header/Logo.php +++ b/app/code/Magento/Theme/Block/Html/Header/Logo.php @@ -78,6 +78,38 @@ public function getLogoAlt() return $this->_data['logo_alt']; } + /** + * Retrieve logo width + * + * @return int + */ + public function getLogoWidth() + { + if (empty($this->_data['logo_width'])) { + $this->_data['logo_width'] = $this->_scopeConfig->getValue( + 'design/header/logo_width', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } + return (int)$this->_data['logo_width'] ? : (int)$this->getLogoImgWidth(); + } + + /** + * Retrieve logo height + * + * @return int + */ + public function getLogoHeight() + { + if (empty($this->_data['logo_height'])) { + $this->_data['logo_height'] = $this->_scopeConfig->getValue( + 'design/header/logo_height', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } + return (int)$this->_data['logo_height'] ? : (int)$this->getLogoImgHeight(); + } + /** * Retrieve logo image URL * diff --git a/app/code/Magento/Theme/Block/Html/Topmenu.php b/app/code/Magento/Theme/Block/Html/Topmenu.php index 177418d892ed4..f3dd2b134b1d2 100644 --- a/app/code/Magento/Theme/Block/Html/Topmenu.php +++ b/app/code/Magento/Theme/Block/Html/Topmenu.php @@ -5,7 +5,7 @@ */ namespace Magento\Theme\Block\Html; -use Magento\Framework\View\Block\IdentityInterface; +use Magento\Framework\Object\IdentityInterface; use Magento\Framework\View\Element\Template; use Magento\Framework\Data\TreeFactory; use Magento\Framework\Data\Tree\Node; diff --git a/app/code/Magento/Theme/CustomerData/Messages.php b/app/code/Magento/Theme/CustomerData/Messages.php new file mode 100644 index 0000000000000..8833692685238 --- /dev/null +++ b/app/code/Magento/Theme/CustomerData/Messages.php @@ -0,0 +1,50 @@ +messageManager = $messageManager; + } + + /** + * {@inheritdoc} + */ + public function getSectionData() + { + $messages = $this->messageManager->getMessages(true); + return [ + 'messages' => array_reduce( + $messages->getItems(), + function (array $result, MessageInterface $message) { + $result[] = ['type' => $message->getType(), 'text' => $message->getText()]; + return $result; + }, + [] + ), + ]; + } +} diff --git a/app/code/Magento/Theme/Test/Unit/Block/Html/HeaderTest.php b/app/code/Magento/Theme/Test/Unit/Block/Html/HeaderTest.php new file mode 100644 index 0000000000000..11de9b286666a --- /dev/null +++ b/app/code/Magento/Theme/Test/Unit/Block/Html/HeaderTest.php @@ -0,0 +1,45 @@ +getMockBuilder('Magento\Framework\View\Element\Template\Context') + ->setMethods(['getScopeConfig']) + ->disableOriginalConstructor() + ->getMock(); + $this->scopeConfig = $this->getMockBuilder('\Magento\Framework\App\Config') + ->setMethods(['getValue']) + ->disableOriginalConstructor()->getMock(); + $context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($this->scopeConfig)); + + $this->unit = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + 'Magento\Theme\Block\Html\Header', + ['context' => $context] + ); + } + + public function testGetWelcomeDefault() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with('design/header/welcome', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->willReturn('Welcome Message'); + + $this->assertEquals('Welcome Message', $this->unit->getWelcome()); + } +} diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 8c025c3292b3e..379e84e5c2327 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-eav": "0.74.0-beta9", - "magento/module-widget": "0.74.0-beta9", - "magento/module-config": "0.74.0-beta9", - "magento/module-media-storage": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-require-js": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-eav": "0.74.0-beta11", + "magento/module-widget": "0.74.0-beta11", + "magento/module-config": "0.74.0-beta11", + "magento/module-media-storage": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-require-js": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-translation": "0.74.0-beta9" + "magento/module-translation": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Theme/etc/adminhtml/system.xml b/app/code/Magento/Theme/etc/adminhtml/system.xml index cd7a73c2a3116..241a28a7d828e 100644 --- a/app/code/Magento/Theme/etc/adminhtml/system.xml +++ b/app/code/Magento/Theme/etc/adminhtml/system.xml @@ -65,6 +65,12 @@ Magento\Config\Model\Config\Backend\Image\Logo logo + + + + + + diff --git a/app/code/Magento/Theme/etc/config.xml b/app/code/Magento/Theme/etc/config.xml index 643a69777e24a..405817f895970 100644 --- a/app/code/Magento/Theme/etc/config.xml +++ b/app/code/Magento/Theme/etc/config.xml @@ -45,7 +45,7 @@ Disallow: /*SID= Default welcome msg!
    - &copy; 2014 Magento Demo Store. All Rights Reserved. + &copy; 2015 Magento Demo Store. All Rights Reserved.
    diff --git a/app/code/Magento/Theme/etc/frontend/di.xml b/app/code/Magento/Theme/etc/frontend/di.xml new file mode 100644 index 0000000000000..c867de0a3b52e --- /dev/null +++ b/app/code/Magento/Theme/etc/frontend/di.xml @@ -0,0 +1,17 @@ + + + + + + + Magento\Theme\CustomerData\Messages + + + + diff --git a/app/code/Magento/Theme/etc/frontend/sections.xml b/app/code/Magento/Theme/etc/frontend/sections.xml new file mode 100644 index 0000000000000..af6139443ffc7 --- /dev/null +++ b/app/code/Magento/Theme/etc/frontend/sections.xml @@ -0,0 +1,13 @@ + + + + +
    + + diff --git a/app/code/Magento/Theme/i18n/de_DE.csv b/app/code/Magento/Theme/i18n/de_DE.csv index 9ddaaa6a018d2..1ad9fbc945b69 100644 --- a/app/code/Magento/Theme/i18n/de_DE.csv +++ b/app/code/Magento/Theme/i18n/de_DE.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!","Standard Willkommensnachricht!" -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column","1 Spalte" "2 columns with left bar","2 Spalten mit linker Leiste" "2 columns with right bar","2 Spalten mit rechter Leiste" diff --git a/app/code/Magento/Theme/i18n/en_US.csv b/app/code/Magento/Theme/i18n/en_US.csv index f95ee406e76ba..5fd68c735ec8e 100644 --- a/app/code/Magento/Theme/i18n/en_US.csv +++ b/app/code/Magento/Theme/i18n/en_US.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!","Default welcome msg!" -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column","1 column" "2 columns with left bar","2 columns with left bar" "2 columns with right bar","2 columns with right bar" diff --git a/app/code/Magento/Theme/i18n/es_ES.csv b/app/code/Magento/Theme/i18n/es_ES.csv index 7a46dedc66d9d..e6a23175f9db3 100644 --- a/app/code/Magento/Theme/i18n/es_ES.csv +++ b/app/code/Magento/Theme/i18n/es_ES.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!","¡Mensaje por defecto de bienvenida!" -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column","1 columna" "2 columns with left bar","2 columnas con barra a la izquierda" "2 columns with right bar","2 columnas con barra a la derecha" diff --git a/app/code/Magento/Theme/i18n/fr_FR.csv b/app/code/Magento/Theme/i18n/fr_FR.csv index 3747f950596d3..97dc59a800614 100644 --- a/app/code/Magento/Theme/i18n/fr_FR.csv +++ b/app/code/Magento/Theme/i18n/fr_FR.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!","Message de bienvenue par défaut!" -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column","1 colonne" "2 columns with left bar","2 colonnes avec barre gauche" "2 columns with right bar","2 colonnes avec barre droite" diff --git a/app/code/Magento/Theme/i18n/nl_NL.csv b/app/code/Magento/Theme/i18n/nl_NL.csv index d5197adbe59b9..2c031ef071545 100644 --- a/app/code/Magento/Theme/i18n/nl_NL.csv +++ b/app/code/Magento/Theme/i18n/nl_NL.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!","Standaard welkom bericht!" -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column","1 kolom" "2 columns with left bar","2 kolommen met linkerbalk" "2 columns with right bar","2 kolommen met rechterbalk" diff --git a/app/code/Magento/Theme/i18n/pt_BR.csv b/app/code/Magento/Theme/i18n/pt_BR.csv index 94aee8c839430..fc7f79e2e2097 100644 --- a/app/code/Magento/Theme/i18n/pt_BR.csv +++ b/app/code/Magento/Theme/i18n/pt_BR.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!","Mensagem de boas-vindas padrão!" -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column","1 coluna" "2 columns with left bar","2 colunas com barra à esquerda" "2 columns with right bar","2 colunas com barra à direita" diff --git a/app/code/Magento/Theme/i18n/zh_CN.csv b/app/code/Magento/Theme/i18n/zh_CN.csv index 603295168ee77..ec081b87a5e89 100644 --- a/app/code/Magento/Theme/i18n/zh_CN.csv +++ b/app/code/Magento/Theme/i18n/zh_CN.csv @@ -129,7 +129,7 @@ Copyright,Copyright "Miscellaneous HTML","Miscellaneous HTML" "This will be displayed just before body closing tag.","This will be displayed just before body closing tag." "Default welcome msg!",默认欢迎信息! -"© 2014 Magento Demo Store. All Rights Reserved.","© 2014 Magento Demo Store. All Rights Reserved." +"© 2015 Magento Demo Store. All Rights Reserved.","© 2015 Magento Demo Store. All Rights Reserved." "1 column",1栏 "2 columns with left bar",2栏带左边栏 "2 columns with right bar",2栏带右边栏 diff --git a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml index 1fdae13532630..f99d3f101fcbb 100644 --- a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml +++ b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml @@ -22,7 +22,6 @@ - diff --git a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-2columns-left.xml b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-2columns-left.xml index 4b53f1edb618b..2ed5687523489 100644 --- a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-2columns-left.xml +++ b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-2columns-left.xml @@ -22,7 +22,6 @@ - diff --git a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-empty.xml b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-empty.xml index 0a9292af843d1..e547bbaedaa5d 100644 --- a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-empty.xml +++ b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-empty.xml @@ -8,7 +8,6 @@ - diff --git a/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml b/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml index 1ccfa7dced43e..771617e828629 100644 --- a/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml +++ b/app/code/Magento/Theme/view/adminhtml/templates/browser/content.phtml @@ -14,7 +14,7 @@ getChildHtml('wysiwyg_files.js') ?>
    -
    + + + +
    + + + +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    + + +
    + + +
    + + +
    +
    + + + + +

    getHeaderText() ?>

    diff --git a/app/code/Magento/Theme/view/base/requirejs-config.js b/app/code/Magento/Theme/view/base/requirejs-config.js index 58dbd2b841a66..5f6994b5d8bc3 100644 --- a/app/code/Magento/Theme/view/base/requirejs-config.js +++ b/app/code/Magento/Theme/view/base/requirejs-config.js @@ -40,6 +40,7 @@ var config = { "jquery/file-uploader": "jquery/fileUploader/jquery.fileupload-fp", "jquery/jquery.hashchange": "jquery/jquery.ba-hashchange.min", "prototype": "legacy-build.min", + "jquery/jquery-storageapi": "jquery/jquery.storageapi.min", "text": "requirejs/text", "domReady": "requirejs/domReady", "ko": "ko/ko", diff --git a/app/code/Magento/Theme/view/frontend/layout/default.xml b/app/code/Magento/Theme/view/frontend/layout/default.xml index efce6ce1922d0..35398f18763fe 100644 --- a/app/code/Magento/Theme/view/frontend/layout/default.xml +++ b/app/code/Magento/Theme/view/frontend/layout/default.xml @@ -39,7 +39,12 @@ -
    +
    \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/group/group.html b/app/code/Magento/Ui/view/base/web/templates/group/group.html index 7db2db6edfd14..bd81b96a73722 100644 --- a/app/code/Magento/Ui/view/base/web/templates/group/group.html +++ b/app/code/Magento/Ui/view/base/web/templates/group/group.html @@ -25,10 +25,12 @@ + +
    diff --git a/app/code/Magento/Ui/view/base/web/templates/tab.html b/app/code/Magento/Ui/view/base/web/templates/tab.html index 8f11fa286ba63..e03c45ae273c9 100644 --- a/app/code/Magento/Ui/view/base/web/templates/tab.html +++ b/app/code/Magento/Ui/view/base/web/templates/tab.html @@ -17,8 +17,8 @@ - - Changes have been made to this section that have not been saved. + diff --git a/app/code/Magento/Ui/view/frontend/web/js/model/errorlist.js b/app/code/Magento/Ui/view/frontend/web/js/model/errorlist.js new file mode 100644 index 0000000000000..4eca983e1f433 --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/js/model/errorlist.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define(['ko'], function(ko) { + "use strict"; + var errors = ko.observableArray([]); + return { + add: function (error) { + var expr = /([%])\w+/g, + errorMessage; + if (!error.hasOwnProperty('parameters')) { + this.clear(); + errors.push(error.message); + return true; + } + errorMessage = error.message.replace(expr, function(varName) { + varName = varName.substr(1); + if (error.parameters.hasOwnProperty(varName)) { + return error.parameters[varName]; + } + return error.parameters.shift(); + }); + this.clear(); + errors.push(errorMessage); + return true; + }, + remove: function() { + errors.shift(); + }, + getAll: function () { + return errors; + }, + clear: function() { + errors.removeAll(); + } + }; +}); diff --git a/app/code/Magento/Ui/view/frontend/web/js/view/errors.js b/app/code/Magento/Ui/view/frontend/web/js/view/errors.js new file mode 100644 index 0000000000000..192a218bb4845 --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/js/view/errors.js @@ -0,0 +1,14 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define(['uiComponent', '../model/errorlist'], function (Component, errors) { + "use strict"; + return Component.extend({ + errorList: errors.getAll(), + defaults: { + template: 'Magento_Ui/errors' + } + }); +}); diff --git a/app/code/Magento/Ui/view/frontend/web/template/errors.html b/app/code/Magento/Ui/view/frontend/web/template/errors.html new file mode 100644 index 0000000000000..15d1bf5d80d22 --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/template/errors.html @@ -0,0 +1,11 @@ + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/code/Magento/Ui/view/frontend/web/templates/form/element/checkbox.html b/app/code/Magento/Ui/view/frontend/web/templates/form/element/checkbox.html new file mode 100644 index 0000000000000..2b99136e3fa31 --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/templates/form/element/checkbox.html @@ -0,0 +1,17 @@ + +
    + + + + + +
    + +
    diff --git a/app/code/Magento/Ui/view/frontend/web/templates/form/element/date.html b/app/code/Magento/Ui/view/frontend/web/templates/form/element/date.html new file mode 100644 index 0000000000000..3574d7d4436fb --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/templates/form/element/date.html @@ -0,0 +1,16 @@ + + diff --git a/app/code/Magento/Ui/view/frontend/web/templates/form/element/email.html b/app/code/Magento/Ui/view/frontend/web/templates/form/element/email.html new file mode 100644 index 0000000000000..1868ef3ac635b --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/templates/form/element/email.html @@ -0,0 +1,16 @@ + + diff --git a/app/code/Magento/Ui/view/frontend/web/templates/form/element/input.html b/app/code/Magento/Ui/view/frontend/web/templates/form/element/input.html new file mode 100644 index 0000000000000..75e6ff74dbe80 --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/templates/form/element/input.html @@ -0,0 +1,16 @@ + + diff --git a/app/code/Magento/Ui/view/frontend/web/templates/form/element/password.html b/app/code/Magento/Ui/view/frontend/web/templates/form/element/password.html new file mode 100644 index 0000000000000..59e628e00d48e --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/templates/form/element/password.html @@ -0,0 +1,16 @@ + + diff --git a/app/code/Magento/Ui/view/frontend/web/templates/form/element/select.html b/app/code/Magento/Ui/view/frontend/web/templates/form/element/select.html new file mode 100644 index 0000000000000..c946719cc3dba --- /dev/null +++ b/app/code/Magento/Ui/view/frontend/web/templates/form/element/select.html @@ -0,0 +1,21 @@ + + +
    diff --git a/app/code/Magento/Weee/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Weee/view/frontend/layout/checkout_onepage_index.xml new file mode 100644 index 0000000000000..e5aa37b3c77ed --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/layout/checkout_onepage_index.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + Magento_Weee/js/view/checkout/review/item/price/unit_incl_tax + unit_incl_tax + + + Magento_Weee/js/view/checkout/review/item/price/unit_excl_tax + unit_excl_tax + + + + + + + Magento_Weee/js/view/checkout/review/item/price/row_incl_tax + row_incl_tax + + + Magento_Weee/js/view/checkout/review/item/price/row_excl_tax + row_excl_tax + + + + + + + + + + + Magento_Weee/js/view/checkout/review/weee_total + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/row_excl_tax.js b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/row_excl_tax.js new file mode 100644 index 0000000000000..000d08a5ca07a --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/row_excl_tax.js @@ -0,0 +1,28 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Weee/js/view/checkout/review/item/price/weee' + ], + function (weee) { + "use strict"; + return weee.extend({ + defaults: { + template: 'Magento_Weee/checkout/review/item/price/row_excl_tax' + }, + + getFinalRowDisplayPriceExclTax: function(item) { + var rowTotalExclTax = parseFloat(item.row_total); + if(!window.checkoutConfig.getIncludeWeeeFlag) { + return rowTotalExclTax + parseFloat(item.weee_tax_applied_amount); + } + return rowTotalExclTax + } + + }); + } +); diff --git a/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/row_incl_tax.js b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/row_incl_tax.js new file mode 100644 index 0000000000000..6fc8b67643282 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/row_incl_tax.js @@ -0,0 +1,38 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Weee/js/view/checkout/review/item/price/weee' + ], + function (weee) { + "use strict"; + return weee.extend({ + defaults: { + template: 'Magento_Weee/checkout/review/item/price/row_incl_tax', + displayArea: 'row_incl_tax' + }, + getFinalRowDisplayPriceInclTax: function(item) { + var rowTotalInclTax = parseFloat(item.row_total_incl_tax); + if(!window.checkoutConfig.getIncludeWeeeFlag) { + + return rowTotalInclTax + this.getRowWeeeTaxInclTax(item); + } + return rowTotalInclTax; + }, + + getRowWeeeTaxInclTax: function(item) { + var weeeTaxAppliedAmounts = JSON.parse(item.weee_tax_applied); + var totalWeeeTaxIncTaxApplied = 0; + weeeTaxAppliedAmounts.forEach(function (weeeTaxAppliedAmount) { + totalWeeeTaxIncTaxApplied+=parseFloat(Math.max(weeeTaxAppliedAmount.row_amount_incl_tax, 0)); + }); + return totalWeeeTaxIncTaxApplied; + } + + }); + } +); diff --git a/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/unit_excl_tax.js b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/unit_excl_tax.js new file mode 100644 index 0000000000000..484b00bacb944 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/unit_excl_tax.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Weee/js/view/checkout/review/item/price/weee' + ], + function (weee) { + "use strict"; + return weee.extend({ + defaults: { + template: 'Magento_Weee/checkout/review/item/price/unit_excl_tax' + }, + + getFinalUnitDisplayPriceExclTax: function(item) { + var unitExclTax = parseFloat(item.price); + if(!window.checkoutConfig.getIncludeWeeeFlag) { + return unitExclTax + parseFloat(item.weee_tax_applied_amount); + } + return unitExclTax; + } + }); + } +); diff --git a/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/unit_incl_tax.js b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/unit_incl_tax.js new file mode 100644 index 0000000000000..d6e03c37b5e1a --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/unit_incl_tax.js @@ -0,0 +1,34 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'Magento_Weee/js/view/checkout/review/item/price/weee' + ], + function (weee) { + "use strict"; + return weee.extend({ + defaults: { + template: 'Magento_Weee/checkout/review/item/price/unit_incl_tax' + }, + getFinalUnitDisplayPriceInclTax: function(item) { + var unitInclTax = parseFloat(item.price_incl_tax); + if(!window.checkoutConfig.getIncludeWeeeFlag) { + return unitInclTax + this.getWeeeTaxInclTax(item); + } + return unitInclTax; + }, + getWeeeTaxInclTax: function(item) { + var weeeTaxAppliedAmounts = JSON.parse(item.weee_tax_applied); + var totalWeeeTaxIncTaxApplied = 0; + weeeTaxAppliedAmounts.forEach(function (weeeTaxAppliedAmount) { + totalWeeeTaxIncTaxApplied+=parseFloat(Math.max(weeeTaxAppliedAmount.amount_incl_tax, 0)); + }); + return totalWeeeTaxIncTaxApplied; + } + }); + } +); diff --git a/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/weee.js b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/weee.js new file mode 100644 index 0000000000000..f6c146aa688fb --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/item/price/weee.js @@ -0,0 +1,41 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component,quote, priceUtils) { + "use strict"; + return Component.extend({ + + isDisplayPriceWithWeeeDetails: function(item) { + if(!parseFloat(item.weee_tax_applied_amount) || parseFloat(item.weee_tax_applied_amount <= 0)) { + return false; + } + return window.checkoutConfig.isDisplayPriceWithWeeeDetails; + }, + isDisplayFinalPrice: function(item) { + if(!parseFloat(item.weee_tax_applied_amount)) { + return false; + } + return window.checkoutConfig.isDisplayFinalPrice; + }, + getFormattedPrice: function (price) { + return priceUtils.formatPrice(price, quote.getPriceFormat()); + }, + getWeeeTaxApplied: function(item) { + if (item.weee_tax_applied) { + return JSON.parse(item.weee_tax_applied) + } + return []; + + } + }); + } +); diff --git a/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/weee_total.js b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/weee_total.js new file mode 100644 index 0000000000000..41aec2c847592 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/js/view/checkout/review/weee_total.js @@ -0,0 +1,48 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils' + ], + function (Component,quote, priceUtils) { + "use strict"; + return Component.extend({ + defaults: { + colspan: 3, + displayArea: 'before_grandtotal', + title: 'FPT', + template: 'Magento_Weee/checkout/review/weee_total' + }, + isIncludedInSubtotal: window.checkoutConfig.isIncludedInSubtotal, + totals: quote.getTotals(), + getColspan: function() { + return this.colspan; + }, + getTitle: function() { + return this.title; + }, + getPureValue: function() { + var items = quote.getItems(); + var sum = 0; + for (var i = 0; i < items.length; i++) { + sum += parseFloat(items[i].weee_tax_applied_row_amount); + } + return sum; + }, + getValue: function() { + var items = quote.getItems(); + var sum = 0; + for (var i = 0; i < items.length; i++) { + sum += parseFloat(items[i].weee_tax_applied_row_amount); + } + return priceUtils.formatPrice(sum, quote.getPriceFormat()); + } + }); + } +); diff --git a/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/row_excl_tax.html b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/row_excl_tax.html new file mode 100644 index 0000000000000..c1a8590e1fe15 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/row_excl_tax.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/row_incl_tax.html b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/row_incl_tax.html new file mode 100644 index 0000000000000..cfc024de59894 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/row_incl_tax.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/unit_excl_tax.html b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/unit_excl_tax.html new file mode 100644 index 0000000000000..eb34f588887ce --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/unit_excl_tax.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/unit_incl_tax.html b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/unit_incl_tax.html new file mode 100644 index 0000000000000..175b2968e1472 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/item/price/unit_incl_tax.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Weee/view/frontend/web/template/checkout/review/weee_total.html b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/weee_total.html new file mode 100644 index 0000000000000..3e9b25d84db82 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/web/template/checkout/review/weee_total.html @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index 569c2fae5e22d..8dcdc466ebb68 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -6,13 +6,11 @@ // @codingStandardsIgnoreFile +namespace Magento\Widget\Model; + /** * Widget model for different purposes - * - * @author Magento Core Team */ -namespace Magento\Widget\Model; - class Widget { /** @@ -86,6 +84,7 @@ public function __construct( * * @param string $type Widget type * @return null|array + * @api */ public function getWidgetByClassType($type) { @@ -185,6 +184,7 @@ public function getConfigAsObject($type) * * @param array $filters Key-value array of filters for widget node properties * @return array + * @api */ public function getWidgets($filters = []) { @@ -215,6 +215,7 @@ public function getWidgets($filters = []) * * @param array $filters Key-value array of filters for widget node properties * @return array + * @api */ public function getWidgetsArray($filters = []) { @@ -241,6 +242,7 @@ public function getWidgetsArray($filters = []) * @param array $params Pre-configured Widget Params * @param bool $asIs Return result as widget directive(true) or as placeholder image(false) * @return string Widget directive ready to parse + * @api */ public function getWidgetDeclaration($type, $params = [], $asIs = true) { diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index 605804092f972..1dcda8848964b 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.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-cms": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-variable": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-cms": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-variable": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml index 497e17ccd7492..94cc3c75709bd 100644 --- a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml +++ b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml @@ -42,7 +42,7 @@ var pageGroupTemplate = '
    '+ ''+ ''+ - '
    isMultiWebsites()): ?>style="display: none;">
    + +
    '+ + '
    '+ ''+ ''+ ''+ @@ -93,7 +93,7 @@ var pageGroupTemplate = '
    '+ ''+ ''+ - '
    '+ + '
    '+ ''+ ''+ ''+ @@ -123,7 +123,7 @@ var pageGroupTemplate = '
    '+ ''+ ''+ - '
    '+ + '
    '+ ''+ ''+ ''+ @@ -154,7 +154,7 @@ var pageGroupTemplate = '
    '+ ''+ ''+ - '
    '+ + '
    '+ ''+ ''+ ''+ diff --git a/app/code/Magento/Wishlist/Block/AbstractBlock.php b/app/code/Magento/Wishlist/Block/AbstractBlock.php index c99eb0a988cf7..48f5f722c297e 100644 --- a/app/code/Magento/Wishlist/Block/AbstractBlock.php +++ b/app/code/Magento/Wishlist/Block/AbstractBlock.php @@ -30,30 +30,21 @@ abstract class AbstractBlock extends \Magento\Catalog\Block\Product\AbstractProd */ protected $httpContext; - /** - * @var \Magento\Catalog\Api\ProductRepositoryInterface - */ - protected $productRepository; - /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param array $data */ public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Framework\App\Http\Context $httpContext, - \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, array $data = [] ) { $this->httpContext = $httpContext; - $this->productRepository = $productRepository; parent::__construct( $context, $data ); - $this->_isScopePrivate = true; } /** @@ -136,14 +127,14 @@ public function getItemRemoveParams($item) } /** - * Retrieve Add Item to shopping cart URL + * Retrieve Add Item to shopping cart params for POST request * * @param string|\Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item * @return string */ - public function getItemAddToCartUrl($item) + public function getItemAddToCartParams($item) { - return $this->_getHelper()->getAddToCartUrl($item); + return $this->_getHelper()->getAddToCartParams($item); } /** @@ -276,23 +267,7 @@ public function hasWishlistItems() */ public function getProductUrl($item, $additional = []) { - if ($item instanceof \Magento\Catalog\Model\Product) { - $product = $item; - } else { - $product = $item->getProduct(); - } - $buyRequest = $item->getBuyRequest(); - if (is_object($buyRequest)) { - $config = $buyRequest->getSuperProductConfig(); - if ($config && !empty($config['product_id'])) { - $product = $this->productRepository->getById( - $config['product_id'], - false, - $this->_storeManager->getStore()->getStoreId() - ); - } - } - return parent::getProductUrl($product, $additional); + return $this->_getHelper()->getProductUrl($item, $additional); } /** diff --git a/app/code/Magento/Wishlist/Block/Customer/Sharing.php b/app/code/Magento/Wishlist/Block/Customer/Sharing.php index ef8e85b3e8679..09fd261f98b86 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Sharing.php +++ b/app/code/Magento/Wishlist/Block/Customer/Sharing.php @@ -47,7 +47,6 @@ public function __construct( $this->_wishlistConfig = $wishlistConfig; $this->_wishlistSession = $wishlistSession; parent::__construct($context, $data); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php index 1d26818f0aac1..6acb81e5f7584 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php +++ b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php @@ -6,14 +6,10 @@ /** * Wishlist sidebar block - * - * @author Magento Core Team */ namespace Magento\Wishlist\Block\Customer; -use Magento\Customer\Model\Context; - -class Sidebar extends \Magento\Wishlist\Block\AbstractBlock implements \Magento\Framework\View\Block\IdentityInterface +class Sidebar extends \Magento\Wishlist\Block\AbstractBlock { /** * Retrieve block title @@ -24,96 +20,4 @@ public function getTitle() { return __('My Wish List'); } - - /** - * Add sidebar conditions to collection - * - * @param \Magento\Wishlist\Model\Resource\Item\Collection $collection - * @return $this - */ - protected function _prepareCollection($collection) - { - $collection->setCurPage(1)->setPageSize(3)->setInStockFilter(true)->setOrder('added_at'); - - return $this; - } - - /** - * Prepare before to html - * - * @return string - */ - protected function _toHtml() - { - if ($this->getItemCount()) { - return parent::_toHtml(); - } - - return ''; - } - - /** - * Can Display wishlist - * - * @deprecated after 1.6.2.0 - * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) - */ - public function getCanDisplayWishlist() - { - return $this->httpContext->getValue(Context::CONTEXT_AUTH); - } - - /** - * Retrieve Wishlist Product Items collection - * - * @return \Magento\Wishlist\Model\Resource\Item\Collection - */ - public function getWishlistItems() - { - if ($this->_collection === null) { - $this->_collection = clone $this->_createWishlistItemCollection(); - $this->_collection->clear(); - $this->_prepareCollection($this->_collection); - } - - return $this->_collection; - } - - /** - * Return wishlist items count - * - * @return int - */ - public function getItemCount() - { - return $this->_getHelper()->getItemCount(); - } - - /** - * Check whether user has items in his wishlist - * - * @return bool - */ - public function hasWishlistItems() - { - return $this->getItemCount() > 0; - } - - /** - * Return identifiers for produced content - * - * @return array - */ - public function getIdentities() - { - $identities = []; - if ($this->getItemCount()) { - foreach ($this->getWishlistItems() as $item) { - /** @var $item \Magento\Wishlist\Model\Item */ - $identities = array_merge($identities, $item->getProduct()->getIdentities()); - } - } - return $identities; - } } diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php index 9a86641155cc6..3a5e76a0d7b98 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php @@ -25,41 +25,38 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock */ protected $_helperPool; - /** - * @var \Magento\Framework\Data\Form\FormKey - */ - protected $_formKey; - /** @var \Magento\Customer\Helper\Session\CurrentCustomer */ protected $currentCustomer; + /** + * @var \Magento\Framework\Data\Helper\PostHelper + */ + protected $postDataHelper; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool - * @param \Magento\Framework\Data\Form\FormKey $formKey * @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer + * @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper * @param array $data */ public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Framework\App\Http\Context $httpContext, - \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool, - \Magento\Framework\Data\Form\FormKey $formKey, \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, + \Magento\Framework\Data\Helper\PostHelper $postDataHelper, array $data = [] ) { parent::__construct( $context, $httpContext, - $productRepository, $data ); - $this->_formKey = $formKey; $this->_helperPool = $helperPool; $this->currentCustomer = $currentCustomer; + $this->postDataHelper = $postDataHelper; } /** @@ -205,14 +202,14 @@ public function getAddToCartQty(\Magento\Wishlist\Model\Item $item) } /** - * Get add all to cart url + * Get add all to cart params for POST request * @return string */ - public function getAddAllToCartUrl() + public function getAddAllToCartParams() { - return $this->getUrl( - '*/*/allcart', - ['wishlist_id' => $this->getWishlistInstance()->getId(), 'form_key' => $this->_formKey->getFormKey()] + return $this->postDataHelper->getPostData( + $this->getUrl('wishlist/index/allcart'), + ['wishlist_id' => $this->getWishlistInstance()->getId()] ); } diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Button.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Button.php index 120c8c01a7017..f0dbe5f8fbb06 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Button.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Button.php @@ -42,7 +42,6 @@ public function __construct( $this->_wishlistData = $wishlistData; $this->_wishlistConfig = $wishlistConfig; parent::__construct($context, $data); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php index c7b90cc4d5bca..dd69186d21493 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php @@ -33,14 +33,12 @@ class Options extends \Magento\Wishlist\Block\AbstractBlock /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool * @param array $data */ public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Framework\App\Http\Context $httpContext, - \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool, array $data = [] ) { @@ -48,7 +46,6 @@ public function __construct( parent::__construct( $context, $httpContext, - $productRepository, $data ); } diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php index 8ccec3c8673d6..887cf063d1a96 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php @@ -11,16 +11,6 @@ */ class Items extends \Magento\Framework\View\Element\Template { - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param array $data - */ - public function __construct(\Magento\Framework\View\Element\Template\Context $context, array $data = []) - { - parent::__construct($context, $data); - $this->_isScopePrivate = true; - } - /** * Retrieve table column object list * diff --git a/app/code/Magento/Wishlist/Block/Link.php b/app/code/Magento/Wishlist/Block/Link.php index d399db34a5991..40708de41248b 100644 --- a/app/code/Magento/Wishlist/Block/Link.php +++ b/app/code/Magento/Wishlist/Block/Link.php @@ -38,7 +38,6 @@ public function __construct( \Magento\Wishlist\Helper\Data $wishlistHelper, array $data = [] ) { - $this->_isScopePrivate = true; $this->_wishlistHelper = $wishlistHelper; parent::__construct($context, $data); } @@ -69,47 +68,4 @@ public function getLabel() { return __('My Wish List'); } - - /** - * @return string - */ - public function getTitle() - { - return $this->getLabel(); - } - - /** - * @return string - */ - public function getCounter() - { - return $this->_createCounter($this->_getItemCount()); - } - - /** - * Count items in wishlist - * - * @return int - */ - protected function _getItemCount() - { - return $this->_wishlistHelper->getItemCount(); - } - - /** - * Create button label based on wishlist item quantity - * - * @param int $count - * @return \Magento\Framework\Phrase|void - */ - protected function _createCounter($count) - { - if ($count > 1) { - return __('%1 items', $count); - } elseif ($count == 1) { - return __('1 item'); - } else { - return; - } - } } diff --git a/app/code/Magento/Wishlist/Block/Share/Wishlist.php b/app/code/Magento/Wishlist/Block/Share/Wishlist.php index 9b6d1c1f1e1e2..7d25989718eb8 100644 --- a/app/code/Magento/Wishlist/Block/Share/Wishlist.php +++ b/app/code/Magento/Wishlist/Block/Share/Wishlist.php @@ -28,14 +28,12 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @param array $data */ public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Framework\App\Http\Context $httpContext, - \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, array $data = [] ) { @@ -43,7 +41,6 @@ public function __construct( parent::__construct( $context, $httpContext, - $productRepository, $data ); } diff --git a/app/code/Magento/Wishlist/Controller/Index/Index.php b/app/code/Magento/Wishlist/Controller/Index/Index.php index 53566774d2400..dc0c7fcb96544 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Index.php +++ b/app/code/Magento/Wishlist/Controller/Index/Index.php @@ -42,7 +42,6 @@ public function execute() } /** @var \Magento\Framework\View\Result\Page resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->getLayout()->initMessages(); return $resultPage; } } diff --git a/app/code/Magento/Wishlist/Controller/Index/Share.php b/app/code/Magento/Wishlist/Controller/Index/Share.php index cfc8f8a7f8b2a..0971a293d331f 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Share.php +++ b/app/code/Magento/Wishlist/Controller/Index/Share.php @@ -20,7 +20,6 @@ public function execute() { /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->getLayout()->initMessages(); return $resultPage; } } diff --git a/app/code/Magento/Wishlist/Controller/Shared/Index.php b/app/code/Magento/Wishlist/Controller/Shared/Index.php index 20ccbf1b45bcf..6f925099159fa 100644 --- a/app/code/Magento/Wishlist/Controller/Shared/Index.php +++ b/app/code/Magento/Wishlist/Controller/Shared/Index.php @@ -66,9 +66,9 @@ public function execute() } $this->registry->register('shared_wishlist', $wishlist); + /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->getLayout()->initMessages(); return $resultPage; } } diff --git a/app/code/Magento/Wishlist/CustomerData/Wishlist.php b/app/code/Magento/Wishlist/CustomerData/Wishlist.php new file mode 100644 index 0000000000000..66525ca123f92 --- /dev/null +++ b/app/code/Magento/Wishlist/CustomerData/Wishlist.php @@ -0,0 +1,130 @@ +wishlistHelper = $wishlistHelper; + $this->productImageView = $productImageView; + $this->block = $block; + $this->view = $view; + } + + /** + * {@inheritdoc} + */ + public function getSectionData() + { + $counter = $this->getCounter(); + return [ + 'counter' => $counter, + 'items' => $counter ? $this->getItems() : [], + ]; + } + + /** + * @return string + */ + protected function getCounter() + { + return $this->createCounter($this->wishlistHelper->getItemCount()); + } + + /** + * Create button label based on wishlist item quantity + * + * @param int $count + * @return \Magento\Framework\Phrase|null + */ + protected function createCounter($count) + { + if ($count > 1) { + return __('%1 items', $count); + } elseif ($count == 1) { + return __('1 item'); + } + return null; + } + + /** + * Get wishlist items + * + * @return array + */ + protected function getItems() + { + $this->view->loadLayout(); + $collection = $this->wishlistHelper->getWishlistItemCollection(); + $collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER) + ->setInStockFilter(true)->setOrder('added_at'); + $items = []; + foreach ($collection as $wishlistItem) { + /** @var \Magento\Catalog\Model\Product $product */ + $product = $wishlistItem->getProduct(); + $this->productImageView->init($product, 'wishlist_sidebar_block', 'Magento_Catalog'); + $items[] = [ + 'image' => [ + 'src' => $this->productImageView->getUrl(), + 'alt' => $this->productImageView->getLabel(), + 'width' => $this->productImageView->getWidth(), + 'height' => $this->productImageView->getHeight(), + ], + 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), + 'product_name' => $product->getName(), + 'product_price' => $this->block->getProductPriceHtml( + $product, + \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + ['item' => $wishlistItem] + ), + 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), + 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), + 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem), + 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem), + ]; + } + return $items; + } +} diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index d54283e4a6a7f..0f1ecf152c3b2 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -90,6 +90,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ protected $wishlistProvider; + /** + * @var \Magento\Catalog\Api\ProductRepositoryInterface + */ + protected $productRepository; + /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\Registry $coreRegistry @@ -99,6 +104,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param WishlistProviderInterface $wishlistProvider + * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ public function __construct( \Magento\Framework\App\Helper\Context $context, @@ -108,7 +114,8 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Helper\PostHelper $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, - WishlistProviderInterface $wishlistProvider + WishlistProviderInterface $wishlistProvider, + \Magento\Catalog\Api\ProductRepositoryInterface $productRepository ) { $this->_coreRegistry = $coreRegistry; $this->_customerSession = $customerSession; @@ -117,6 +124,7 @@ public function __construct( $this->_postDataHelper = $postDataHelper; $this->_customerViewHelper = $customerViewHelper; $this->wishlistProvider = $wishlistProvider; + $this->productRepository = $productRepository; parent::__construct($context); } @@ -359,7 +367,7 @@ public function getUpdateParams($item) } /** - * Retrieve URL for adding item to shopping cart + * Retrieve params for adding item to shopping cart * * @param string|\Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item * @return string @@ -369,6 +377,20 @@ public function getAddToCartUrl($item) return $this->_getUrlStore($item)->getUrl('wishlist/index/cart', $this->_getCartUrlParameters($item)); } + /** + * Retrieve URL for adding item to shopping cart + * + * @param string|\Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item + * @return string + */ + public function getAddToCartParams($item) + { + return $this->_postDataHelper->getPostData( + $this->_getUrlStore($item)->getUrl('wishlist/index/cart'), + $this->_getCartUrlParameters($item) + ); + } + /** * Retrieve URL for adding item to shopping cart from shared wishlist * @@ -377,7 +399,10 @@ public function getAddToCartUrl($item) */ public function getSharedAddToCartUrl($item) { - return $this->_getUrlStore($item)->getUrl('wishlist/shared/cart', $this->_getCartUrlParameters($item)); + return $this->_postDataHelper->getPostData( + $this->_getUrlStore($item)->getUrl('wishlist/shared/cart'), + $this->_getCartUrlParameters($item) + ); } /** @@ -386,21 +411,7 @@ public function getSharedAddToCartUrl($item) */ protected function _getCartUrlParameters($item) { - $continueUrl = $this->urlEncoder->encode( - $this->_getUrl( - 'wishlist/index/index', - [ - '_current' => true, - '_use_rewrite' => true, - '_scope_to_url' => true - ] - ) - ); - - return [ - 'item' => is_string($item) ? $item : $item->getWishlistItemId(), - \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $continueUrl - ]; + return ['item' => is_string($item) ? $item : $item->getWishlistItemId()]; } /** @@ -547,4 +558,32 @@ public function isDisplayQty() \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } + + /** + * Retrieve URL to item Product + * + * @param \Magento\Wishlist\Model\Item|\Magento\Catalog\Model\Product $item + * @param array $additional + * @return string + */ + public function getProductUrl($item, $additional = []) + { + if ($item instanceof \Magento\Catalog\Model\Product) { + $product = $item; + } else { + $product = $item->getProduct(); + } + $buyRequest = $item->getBuyRequest(); + if (is_object($buyRequest)) { + $config = $buyRequest->getSuperProductConfig(); + if ($config && !empty($config['product_id'])) { + $product = $this->productRepository->getById( + $config['product_id'], + false, + $this->_storeManager->getStore()->getStoreId() + ); + } + } + return $product->getUrlModel()->getUrl($product, $additional); + } } diff --git a/app/code/Magento/Wishlist/Helper/Rss.php b/app/code/Magento/Wishlist/Helper/Rss.php index 7726492c33eae..256aa5f790034 100644 --- a/app/code/Magento/Wishlist/Helper/Rss.php +++ b/app/code/Magento/Wishlist/Helper/Rss.php @@ -35,6 +35,7 @@ class Rss extends \Magento\Wishlist\Helper\Data * @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider + * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -48,6 +49,7 @@ public function __construct( \Magento\Framework\Data\Helper\PostHelper $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider, + \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository ) { @@ -62,7 +64,8 @@ public function __construct( $storeManager, $postDataHelper, $customerViewHelper, - $wishlistProvider + $wishlistProvider, + $productRepository ); } diff --git a/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php b/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php deleted file mode 100644 index b873d642d8adf..0000000000000 --- a/app/code/Magento/Wishlist/Test/Unit/Block/Customer/SidebarTest.php +++ /dev/null @@ -1,68 +0,0 @@ -wishlistHelper = $this->getMock('Magento\Wishlist\Helper\Data', ['getItemCount'], [], '', false); - $this->block = $objectManager->getObject( - 'Magento\Wishlist\Block\Customer\Sidebar', - ['wishlistHelper' => $this->wishlistHelper] - ); - } - - protected function tearDown() - { - $this->block = null; - } - - public function testGetIdentitiesItemsPresent() - { - $productTags = ['catalog_product_1']; - - $this->wishlistHelper->expects($this->once())->method('getItemCount')->will($this->returnValue(5)); - - $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); - $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); - - $item = $this->getMock( - 'Magento\Sales\Model\Resource\Order\Item', - ['getProduct', '__wakeup'], - [], - '', - false - ); - $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); - - $collection = new \ReflectionProperty('Magento\Wishlist\Block\Customer\Sidebar', '_collection'); - $collection->setAccessible(true); - $collection->setValue($this->block, [$item]); - - $this->assertEquals($productTags, $this->block->getIdentities()); - } - - public function testGetIdentitiesNoItems() - { - $productTags = []; - - $this->wishlistHelper->expects($this->once())->method('getItemCount')->will($this->returnValue(0)); - - $this->assertEquals($productTags, $this->block->getIdentities()); - } -} diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php index 08108bf77b12d..b7dd62901183f 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php @@ -40,20 +40,11 @@ class DataTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->url = 'http://magento.com/wishlist/index/index/wishlist_id/1/?___store=default'; - $encoded = 'encodedUrl'; - $this->configureUrl = 'http://magento2ce/wishlist/index/configure/id/4/product_id/30/'; - - $urlEncoder = $this->getMock('Magento\Framework\Url\EncoderInterface', [], [], '', false); - $urlEncoder->expects($this->any()) - ->method('encode') - ->with($this->url) - ->will($this->returnValue($encoded)); - $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $store->expects($this->any()) ->method('getUrl') - ->with('wishlist/index/cart', ['item' => '%item%', 'uenc' => $encoded]) + ->with('wishlist/index/cart', ['item' => '%item%']) ->will($this->returnValue($this->url)); $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') @@ -80,9 +71,6 @@ public function setUp() $context->expects($this->once()) ->method('getUrlBuilder') ->will($this->returnValue($urlBuilder)); - $context->expects($this->once()) - ->method('getUrlEncoder') - ->will($this->returnValue($urlEncoder)); $this->wishlistProvider = $this->getMock( 'Magento\Wishlist\Controller\WishlistProviderInterface', diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php index 5a4959ba7e961..55435d1387050 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php @@ -67,6 +67,7 @@ public function setUp() $this->customerFactoryMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterfaceFactory') ->disableOriginalConstructor() + ->setMethods(['create']) ->getMock(); $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') @@ -109,7 +110,6 @@ public function testGetWishlistWithWishlistId() ->getMock(); $this->wishlistFactoryMock->expects($this->once()) ->method('create') - ->with([]) ->willReturn($wishlist); $this->requestMock->expects($this->once()) @@ -137,7 +137,6 @@ public function testGetWishlistWithCustomerId() ->getMock(); $this->wishlistFactoryMock->expects($this->once()) ->method('create') - ->with([]) ->willReturn($wishlist); $this->requestMock->expects($this->at(0)) @@ -163,7 +162,6 @@ public function testGetWishlistWithCustomerId() ->getMock(); $this->customerFactoryMock->expects($this->once()) ->method('create') - ->with([]) ->willReturn($customer); $this->customerRepositoryMock->expects($this->never()) diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 4cf0819224970..2690669164d17 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta9", - "magento/module-customer": "0.74.0-beta9", - "magento/module-catalog": "0.74.0-beta9", - "magento/module-checkout": "0.74.0-beta9", - "magento/module-theme": "0.74.0-beta9", - "magento/module-catalog-inventory": "0.74.0-beta9", - "magento/module-rss": "0.74.0-beta9", - "magento/module-backend": "0.74.0-beta9", - "magento/module-sales": "0.74.0-beta9", - "magento/module-grouped-product": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", - "magento/module-ui": "0.74.0-beta9", + "magento/module-store": "0.74.0-beta11", + "magento/module-customer": "0.74.0-beta11", + "magento/module-catalog": "0.74.0-beta11", + "magento/module-checkout": "0.74.0-beta11", + "magento/module-theme": "0.74.0-beta11", + "magento/module-catalog-inventory": "0.74.0-beta11", + "magento/module-rss": "0.74.0-beta11", + "magento/module-backend": "0.74.0-beta11", + "magento/module-sales": "0.74.0-beta11", + "magento/module-grouped-product": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", + "magento/module-ui": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-configurable-product": "0.74.0-beta9", - "magento/module-downloadable": "0.74.0-beta9", - "magento/module-bundle": "0.74.0-beta9", - "magento/module-cookie": "0.74.0-beta9" + "magento/module-configurable-product": "0.74.0-beta11", + "magento/module-downloadable": "0.74.0-beta11", + "magento/module-bundle": "0.74.0-beta11", + "magento/module-cookie": "0.74.0-beta11" }, "type": "magento2-module", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Wishlist/etc/frontend/di.xml b/app/code/Magento/Wishlist/etc/frontend/di.xml index ae0159a6d6181..e5f0de7c91f3f 100644 --- a/app/code/Magento/Wishlist/etc/frontend/di.xml +++ b/app/code/Magento/Wishlist/etc/frontend/di.xml @@ -23,4 +23,11 @@ + + + + Magento\Wishlist\CustomerData\Wishlist + + + diff --git a/app/code/Magento/Wishlist/etc/frontend/sections.xml b/app/code/Magento/Wishlist/etc/frontend/sections.xml new file mode 100644 index 0000000000000..1195050c33545 --- /dev/null +++ b/app/code/Magento/Wishlist/etc/frontend/sections.xml @@ -0,0 +1,45 @@ + + + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + + +
    +
    + + +
    + + +
    + + +
    + + diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml index 6943f7e2ee4f9..5f000a79c1859 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml @@ -12,12 +12,12 @@ - + - - - - + + + + product.price.render.default @@ -26,36 +26,36 @@ item_list - + - + product-item-inner - + Product Details and Comment - + Add to Cart - + product-item-actions - - + + - - - + + + diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_share.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_share.xml index 39e0f714baf4f..3b79ac989a0ea 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_share.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_share.xml @@ -9,7 +9,7 @@ - + diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml index 5784e293ae634..ccefdab5a09a8 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml @@ -28,7 +28,7 @@ $product = $item->getProduct(); isSaleable()): ?>
    -
    diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml index 9ca9df5034792..d4b7a9dbfa6ca 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml @@ -17,7 +17,7 @@ $columns = $block->getColumns(); getItems())): ?>
      getItems() as $item): ?> - getId() . '">' : '
    1. ' ?> + getId() . '">' : '
    2. ' ?>
      setItem($item); echo $column->toHtml($item);?> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/link.phtml b/app/code/Magento/Wishlist/view/frontend/templates/link.phtml index 95506ea2b1ab4..05c0463c19b48 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/link.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/link.phtml @@ -8,8 +8,24 @@ /* @var $block \Magento\Wishlist\Block\Link */ ?> -
    3. + diff --git a/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml b/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml index 5382f3d1a1beb..1da587a17cf6d 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml @@ -9,60 +9,45 @@ /* @var $block \Magento\Wishlist\Block\Customer\Sidebar */ ?> getItemCount(); $wishlistHelper = $this->helper('Magento\Wishlist\Helper\Data'); ?> isAllow()) : ?> - getLayout()->createBlock('Magento\Catalog\Block\Product\Image');?> -
      +
      getTitle(); ?> - 0): ?> - - + + +
      - hasWishlistItems()): ?> -
        - - getWishlistItems() as $item): ?> - getProduct(); ?> - ' : '
      1. ' ?> + +
          +
        1. - - init($product, 'wishlist_sidebar_block')->toHtml() ?> + +
          - escapeHtml($product->getName()) ?> + + + - getItemPriceHtml( - $item, - \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, - \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST - ); - ?> +
          - isSaleable() && $product->isVisibleInSiteVisibility()): ?> +
          - getTypeInstance()->hasRequiredOptions($product)): ?> - - - helper('Magento\Framework\Data\Helper\PostHelper'); - $postData = $postDataHelper->getPostData($block->getItemAddToCartUrl($item), ['product' => $product->getEntityId()]) - ?> - - + + + + + +
          - +
          - getWishlistItems()) + 1) ? '
        2. ' : '' ?> - +
        -
        + - + +
        - +
      + diff --git a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml index 624a320f30a7e..373ba7176df16 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml @@ -13,9 +13,9 @@ getChildHtml('wishlist.rss.link'));?>
      getChildHtml('top'); ?> diff --git a/app/code/Magento/Wishlist/view/frontend/web/js/view/wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/js/view/wishlist.js new file mode 100644 index 0000000000000..12a4aeaee5d19 --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/web/js/view/wishlist.js @@ -0,0 +1,18 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'uiComponent', + 'Magento_Customer/js/customer-data' +], function (Component, customerData) { + 'use strict'; + + return Component.extend({ + initialize: function () { + this._super(); + + this.wishlist = customerData.get('wishlist'); + } + }); +}); diff --git a/app/code/Magento/Wishlist/view/frontend/web/template/product_image.html b/app/code/Magento/Wishlist/view/frontend/web/template/product_image.html new file mode 100644 index 0000000000000..da88b3236c986 --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/web/template/product_image.html @@ -0,0 +1,7 @@ + + diff --git a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js index 973cde4f0b4e9..bb697c1fa5259 100644 --- a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js +++ b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js @@ -30,14 +30,16 @@ define([ */ _create: function () { var _this = this; - if (!this.options.infoList) { this.element - .on('click', this.options.addToCartSelector, function () { - $.proxy(_this._addItemsToCart($(this)), _this); - }) .on('addToCart', function (event, context) { - $.proxy(_this._addItemsToCart($(context).parents('.cart-cell').find(_this.options.addToCartSelector)), _this); + event.stopPropagation(event); + $(context).data('stop-processing', true); + var urlParams = _this._getItemsToCartParams( + $(context).parents('[data-row=product-item]').find(_this.options.addToCartSelector) + ); + $.mage.dataPost().postData(urlParams); + return false; }) .on('click', this.options.btnRemoveSelector, $.proxy(function (event) { event.preventDefault(); @@ -55,36 +57,20 @@ define([ }); }, - /** - * Validate and Redirect. - * @private - * @param {String} url - */ - _validateAndRedirect: function (url) { - if (this.element.validation({ - errorPlacement: function (error, element) { - error.insertAfter(element.next()); - } - }).valid()) { - this.element.prop('action', url); - window.location.href = url; - } - }, - /** * Add wish list items to cart. * @private * @param {jQuery object} elem - clicked 'add to cart' button */ - _addItemsToCart: function (elem) { + _getItemsToCartParams: function (elem) { if (elem.data(this.options.dataAttribute)) { var itemId = elem.data(this.options.dataAttribute), - url = this.options.addToCartUrl.replace('%item%', itemId), - inputName = $.validator.format(this.options.nameFormat, itemId), - inputValue = $('[name="' + inputName + '"]').val(), - separator = (url.indexOf('?') >= 0) ? '&' : '?'; - url += separator + inputName + '=' + encodeURIComponent(inputValue); - this._validateAndRedirect(url); + url = this.options.addToCartUrl, + qtyName = $.validator.format(this.options.nameFormat, itemId), + qtyValue = elem.parents().find('[name="' + qtyName + '"]').val(); + url.data.item = itemId; + url.data.qty = qtyValue; + return url; } }, @@ -93,15 +79,14 @@ define([ * @private */ _addAllWItemsToCart: function () { - var url = this.options.addAllToCartUrl, - separator = (url.indexOf('?') >= 0) ? '&' : '?'; + var urlParams = this.options.addAllToCartUrl, + separator = (urlParams.action.indexOf('?') >= 0) ? '&' : '?'; this.element.find(this.options.qtySelector).each(function (index, element) { - url += separator + $(element).prop('name') + '=' + encodeURIComponent($(element).val()); + urlParams.action += separator + $(element).prop('name') + '=' + encodeURIComponent($(element).val()); separator = '&'; }); - - this._validateAndRedirect(url); + $.mage.dataPost().postData(urlParams); }, /** diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_main.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_main.less index ce8cabfbf381e..32f42c5055855 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_main.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_main.less @@ -13,3 +13,4 @@ @import 'main/_actions-bar.less'; @import 'main/_page-nav.less'; +@import 'main/_collapsible-blocks.less'; diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less index 1e410484253ff..fada0a346fefb 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less @@ -24,8 +24,8 @@ // -.page-main-actions, -.page-actions.fixed { +.page-main-actions:not(._hidden), +.page-actions._fixed { .extend__clearfix(); background: @page-main-actions__background-color; border-bottom: 1px solid @page-main-actions__border-color; @@ -35,6 +35,11 @@ .page-main-actions { margin: 0 0 @indent__l; + &._hidden { + .store-switcher { + display: none; + } + } } // @@ -44,21 +49,23 @@ .page-actions { @_page-action__indent: 1.3rem; float: right; - &.fixed { - left: @page-wrapper__indent-left; - position: fixed; - right: 0; - top: 0; - z-index: @page-actions__fixed__z-index; - .page-actions-inner { - &:before { - .text-overflow-ellipsis(); - color: @page-title__color; - content: attr(data-title); - float: left; - font-size: @page-title__font-size; - margin-top: .3rem; - max-width: 50%; + .page-main-actions & { + &._fixed { + left: @page-wrapper__indent-left; + position: fixed; + right: 0; + top: 0; + z-index: @page-actions__fixed__z-index; + .page-actions-inner { + &:before { + .text-overflow-ellipsis(); + color: @page-title__color; + content: attr(data-title); + float: left; + font-size: @page-title__font-size; + margin-top: .3rem; + max-width: 50%; + } } } } diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less new file mode 100644 index 0000000000000..433873096a7c1 --- /dev/null +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less @@ -0,0 +1,436 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// ToDo UI: Consider all accordions, should be separated + +// +// Variables +// _____________________________________________ + +@collapsible__border-color: @color-gray80; + +@collapsible-title__color: @color-very-dark-gray-black; +@collapsible-title__font-size: 1.7rem; +@collapsible-title__padding-top: 1.9rem; +@collapsible-title__padding-bottom: @collapsible-title__padding-top; +@collapsible-title__hover__color: darken(@collapsible-title__color, 15%); +@collapsible-title__disabled__color: lighten(@collapsible-title__color, 30%); + +@collapsible-title-icon__size: @collapsible-title__font-size; +@collapsible-title-support-text__font-size: 1.4rem; + +@collapsible-sub-block__indent: 4rem; + +@collapsible-content__indent: 2.6rem; + +// +// Mixins +// _____________________________________________ + +.admin__collapsible-block-wrapper() { + border-bottom: 1px solid @collapsible__border-color; +} + +.admin__collapsible-sub-block-wrapper() { + margin-left: @collapsible-sub-block__indent; +} + +.admin__collapsible-content() { + border: 0; + padding: 0 0 @collapsible-content__indent; +} + +.admin__collapsible-title() { + clear: both; + color: @collapsible-title__color; + cursor: pointer; + display: block; + font-size: @collapsible-title__font-size; + font-weight: @font-weight__semibold; + letter-spacing: .025em; + padding: @collapsible-title__padding-top (@collapsible-title-icon__size + 1rem) @collapsible-title__padding-bottom 0; + position: relative; + text-decoration: none; + transition: color .15s linear; + &:hover { + color: @collapsible-title__hover__color; + text-decoration: none; + } + &:active { + &:before { + .scale(); + } + } + &._disabled, + &.disabled { + color: @collapsible-title__disabled__color; + cursor: default; + } + &:before { + &:extend(.abs-icon all); + content: @icon-expand-open__content; + font-size: @collapsible-title-icon__size; + position: absolute; + right: 1.3rem; + top: 2.3rem; + } +} + +.admin__collapsible-sub-title() { + padding-left: (@collapsible-title-icon__size + 1rem); + padding-right: 0; + &:before { + left: 0; + right: auto; + } +} + +.admin__collapsible-text() { + margin-bottom: .5em; + margin-top: 1rem; +} + +// + +.admin__collapsible-block-wrapper { + .admin__collapsible-block-wrapper(); + .admin__collapsible-title { + .admin__collapsible-title(); + } + &.opened { + > .fieldset-wrapper-title { + .admin__collapsible-title { + &:before { + content: @icon-expand-close__content; + } + } + } + &.fieldset-wrapper { + .fieldset-wrapper-title { + .actions { + display: block; + } + } + } + } + &.fieldset-wrapper { + border-bottom: 1px solid @collapsible__border-color; + padding: 0; + .fieldset-wrapper-title { + border: 0; + margin: 0; + padding: 0; + .actions { + display: none; + } + } + .fieldset-wrapper-content { + padding-bottom: @collapsible-title__padding-bottom; + } + } + &.collapsible-block-wrapper-last { + border-bottom: 0; + } +} + +.fieldset-wrapper { + .admin__collapsible-block-wrapper { + .fieldset-wrapper-title { + .actions { + position: absolute; + right: 1.3rem; + top: 1.4rem; + } + .draggable-handle { + top: 2.4rem; + } + } + .admin__collapsible-title { + font-size: 1.6rem; + padding-left: (@collapsible-title-icon__size + 1rem); + &:before { + left: 0; + right: auto; + top: 2.2rem; + } + } + } +} + +// +// Legacy code +// --------------------------------------------- + +.admin__collapsible-block { + .comment { + // ToDo UI: rename to .collapsible-text + .admin__collapsible-text(); + } + // Second level + .admin__collapsible-block { + border: 0; + .entry-edit-head { + > a { + .admin__collapsible-sub-title(); + } + } + } + ~ .admin__collapsible-block { + // ToDo UI: rename to .collapsible-content + .admin__collapsible-content(); + } +} + +.section-config > .admin__collapsible-block > a, +.accordion > dt a, +.accordion .admin__collapsible-block > a { + .admin__collapsible-title(); + > i { + // ToDo UI: change to .collapsible-sub-title + display: block; + font-size: @collapsible-title-support-text__font-size; + font-style: italic; + font-weight: @font-weight__regular; + padding-top: .4rem; + } +} + +.section-config.active > .admin__collapsible-block > a:before, +.accordion > dt.open a:before, +.accordion .admin__collapsible-block.open a:before { + content: @icon-expand-close__content; +} + +.section-config.active > .admin__collapsible-block + input + fieldset, +.accordion > dt + dd.open, +.accordion .admin__collapsible-block.open + input + fieldset { + display: block; + margin: 0; +} + +// Sortable collapsible blocks + +.sortable-wrapper { + margin-bottom: 1.5rem; +} + +// +// Accordion +// --------------------------------------------- + +.accordion { + margin: 0 0 .8rem; + padding: 0; + dt { + border-bottom: 1px solid @collapsible__border-color; + &.open { + border-bottom: none; + } + } + dd { + border-bottom: 1px solid @collapsible__border-color; + display: none; + &.open { + &:empty { + background: #fff url(../../../../../../web/mui/images/ajax-loader-big.gif) no-repeat center; + height: 100px; + } + } + } + dt, + dd { + &:last-of-type { + border-bottom: none; + } + } + .form-inline { + .config { + td { + padding: 2.2rem 1.5rem 0 0; + } + .scope-label { + padding: 31px 1.5rem 0 0; + } + .value { + padding-right: 4rem; + } + } + > .section-config { + &:last-child { + border-bottom: 0; + } + } + } + .config { + .comment a, + .link-more { + color: #007dbd; + font-size: @font-size__base; + font-weight: 400; + &:focus, + &:hover { + text-decoration: underline; + } + } + legend { + display: none; + } + table { + width: 100%; + } + td { + padding: 2.2rem 1.5rem 0 0; + vertical-align: top; + } + td[colspan] { + padding: 0; + } + input[type='text'], + input[type='password'], + select, + textarea { + width: 100%; + } + input { + &.input-file { + margin-top: 4px; + } + } + select { + &.select-date { + width: 27%; + } + } + .label { + color: #303030; + float: none; + font-size: 14px; + font-weight: 600; + padding-right: 30px; + text-align: right; + width: 33%; + label { + padding-top: 7px; + } + } + .scope-label { + color: #999; + font-size: @font-size__s; + letter-spacing: .05em; + padding: 31px 1.5rem 0 0; + } + .note { + color: #303030; + font-size: 12px; + margin: 5px 0; + a { + color: #007dbd; + font-size: 12px; + font-weight: 400; + &:focus, + &:hover { + text-decoration: underline; + } + } + } + .system-tooltip-box { + position: absolute; + } + .value { + padding-right: 40px; + vertical-align: middle; + width: 44%; + &.with-tooltip { + .tooltip { + bottom: 0; + float: right; + left: 0; + margin: 6px -28px 0 0; + position: relative; + right: 0; + top: 0; + } + .tooltip-content { + background: #31302b; + background: rgba(49, 48, 43, .8); + border-radius: 5px; + bottom: 100%; + font-size: 13px; + line-height: 1.4; + margin: 0 -17px 10px 0; + max-width: 239px; + padding: 18px; + right: 0; + width: 239px; + &:before { + border-bottom: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-top: 5px solid #31302b; + bottom: -5px; + content: ''; + height: 0; + left: auto; + opacity: .8; + position: absolute; + right: 20px; + top: auto; + width: 0; + } + } + .help { + margin: 0; + position: relative; + width: auto; + } + } + .checkboxes { + list-style: none; + margin: -3px 0 0; + padding: 0; + li { + margin: 7px 0; + } + input, + label { + vertical-align: middle; + } + label { + margin-left: 5px; + } + } + .label { + padding: 6px 5px 0 1.5rem; + vertical-align: top; + width: auto; + &:first-child { + padding-left: 0; + } + } + } + } + .paypal-selection-simplified { + padding-left: 30px; + } + .paypal-selection { + border-bottom: 2px solid #c0bbaf; + margin: 10px; + width: 98%; + th { + padding: 6px 10px 7px; + } + input[type='checkbox'] { + margin: -4px 7px 0 0; + } + } + .paypal-payment-notice { + margin: 10px; + } + .custom-options { + border: 1px solid #999; + margin: 0 0 20px; + padding: 0 10px; + } +} diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_page-nav.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_page-nav.less index 0071951108a8b..20f9fd8ed9709 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_page-nav.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_page-nav.less @@ -18,7 +18,7 @@ @admin__page-nav-item__border-color: @border__color; @admin__page-nav-item__margin-vertical: 1.3rem; -@admin__page-nav-item__margin-horizontal: .7rem; +@admin__page-nav-item__margin-horizontal: @action__outer-indent; @admin__page-nav-item__active__color: @color-phoenix; @admin__page-nav-item__hover__background-color: darken(@admin__page-nav__background-color, 5%); diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/pages/_login.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/pages/_login.less index bf9bfec974326..c6966df69c5c1 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/pages/_login.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/pages/_login.less @@ -61,13 +61,13 @@ font-size: 2.6rem; font-weight: @font-weight__light; line-height: @line-height__s; - margin: -1rem 0 .5rem; + margin: -1rem 0 2.5rem; } .admin__field-info { margin-bottom: 3rem; } .admin__field { - .extend__field-rows(); + &:extend(.abs-field-rows all); } .messages { margin-top: -1rem; diff --git a/app/design/adminhtml/Magento/backend/Magento_Config/web/css/source/_module.less b/app/design/adminhtml/Magento/backend/Magento_Config/web/css/source/_module.less new file mode 100644 index 0000000000000..14279a0ecfd92 --- /dev/null +++ b/app/design/adminhtml/Magento/backend/Magento_Config/web/css/source/_module.less @@ -0,0 +1,129 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Stores -> Configuration +// _____________________________________________ + +.section-config { + .admin__collapsible-block-wrapper(); + .admin__collapsible-block { + tr { + &:last-child { + > td { + > .section-config { + border-bottom-color: transparent; + padding-bottom: 0; + > .config { + padding-bottom: 0; + } + } + } + } + } + } + // Sub blocks + .section-config { + .admin__collapsible-sub-block-wrapper(); + .entry-edit-head { + > a { + .admin__collapsible-sub-title(); + } + } + } + &.complex .section-config.with-button.enabled > .entry-edit-head, // PayPal connected + .config td.label label.enabled { + &:before { + &:extend(.abs-icon all); + background-color: @success__color; + border-radius: 100%; + color: @color-white; + content: @icon-check-mage__content; // ex "\e01e" + display: block; + float: left; + font-size: 1.6rem; + font-weight: @font-weight__regular; + height: 1em; + margin-left: -25px; + margin-top: .2rem; + overflow: hidden; + width: 1em; + } + } + &.config-advanced { + padding-top: @collapsible-content__indent; + .section-config { + padding-top: @collapsible-content__indent; + } + } + &.with-button { + padding: 2rem 0; + &.active { + padding-bottom: 0; + .config-heading { + margin-bottom: 2rem; + } + } + .section-config { + margin-left: 0; + .section-config { + margin-left: @collapsible-sub-block__indent; + } + } + .config-heading { + strong { + display: block; + font-size: @font-size__base; + font-weight: @font-weight__bold; + margin-bottom: .5rem; + } + .button-container { + margin: 1.5rem 0 0; + } + } + .button-container { + line-height: 28px; + a { + margin-left: 20px; + } + } + .action-configure { + &.open { + .state-opened { + height: auto; + overflow: auto; + visibility: visible; + } + } + &.open .state-closed, + .state-opened { + height: 0; + overflow: hidden; + visibility: hidden; + } + span { + display: block; + position: relative; + text-align: center; + } + } + } + .config { + padding-bottom: @collapsible-content__indent; + h4 { + color: @collapsible-title__color; + font-size: @collapsible-title__font-size; + font-weight: @font-weight__semibold; + margin-bottom: 0; + padding-left: (@collapsible-title-icon__size + 1rem); + padding-top: @collapsible-content__indent; + } + } + > .config { + &.admin__collapsible-block { + display: none; + } + } +} diff --git a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module.less b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module.less index 9b0d06cc971cd..0b67d8d1e20ca 100644 --- a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module.less +++ b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module.less @@ -16,11 +16,16 @@ ); .action.toggle { - padding: 1px 8px; - border: 1px solid #ada89e; background: #fff; - border-radius: 0 2px 2px 0; + border-radius: 0 1px 1px 0; + border: 1px solid #ada89e; height: 33px; + padding: 4px 5px; + + > span { + display: inline-block; + padding-top: 3px; + } &:after { width: 14px; diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less index 2b4e2e6093170..905245cc06bce 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less @@ -102,12 +102,6 @@ address { font-style: normal; } - - .admin__table-secondary { - .admin__control-text { - width: 5.4rem; - } - } } .admin__page-section-title { @@ -167,7 +161,6 @@ // --------------------------------------------- .tree-store-scope { - max-width: 50rem; .admin__field { margin: 0 0 1rem; } diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_items.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_items.less index 0f621df99f43c..d7e53b974b8d8 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_items.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_items.less @@ -32,7 +32,7 @@ } .order-search-items { - .grid { + .data-grid { .action-configure { float: right; } diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_sidebar.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_sidebar.less index 8ef7ff03c7c52..5b9f4d10b8cf4 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_sidebar.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_sidebar.less @@ -34,6 +34,7 @@ margin: 0 0 @order-create-sidebar__margin; .admin__field-label { display: block; + margin: 0 0 @order-create-sidebar__margin__m; text-align: left; } } diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less index 699576bde84c7..9503592265553 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less @@ -7,6 +7,21 @@ // Totals // --------------------------------------------- +.order-subtotal-table { + .admin__control-text { + width: 5.4rem; + } + .admin__total-amount { + text-align: right; + } +} + +.order-totals { + .admin__total-amount { + text-align: right; + } +} + .order-totals-actions { margin-top: @indent__s; .actions { diff --git a/app/design/adminhtml/Magento/backend/Magento_Shipping/web/css/source/_module.less b/app/design/adminhtml/Magento/backend/Magento_Shipping/web/css/source/_module.less index c1ff50783ee78..73f61bc489957 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Shipping/web/css/source/_module.less +++ b/app/design/adminhtml/Magento/backend/Magento_Shipping/web/css/source/_module.less @@ -75,7 +75,7 @@ } .package-add-products { margin: @indent__base 0 0; - .grid { + .data-grid { padding: 0; button { vertical-align: middle; @@ -106,9 +106,21 @@ } } .action-secondary { + &:extend(.abs-action-l all); float: right; + margin: 0 0 0 @popup__padding__horizontal; } .action-close { &:extend(.abs-action-tertiary all); + font-size: @button__large__font-size; + margin: 0 0 0 @popup__padding__horizontal; + padding: @button__large__padding-vertical 0; + &:before { + content: normal; + } + span { + position: static; + overflow: auto; + } } } diff --git a/app/design/adminhtml/Magento/backend/Magento_Tax/web/css/source/module.less b/app/design/adminhtml/Magento/backend/Magento_Tax/web/css/source/module.less index c987e84d5ba9b..7808918dfd846 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Tax/web/css/source/module.less +++ b/app/design/adminhtml/Magento/backend/Magento_Tax/web/css/source/module.less @@ -3,10 +3,6 @@ // * See COPYING.txt for license details. // */ -.block-footer .action-add { - &:extend(.admin__scope-old button all); -} - .mselect-items-wrapper { button { .button-reset(); diff --git a/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less b/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less index 478bb5847fce9..a0f20e304a680 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less +++ b/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less @@ -5,14 +5,6 @@ // @group Header -button { - border-radius: 2px; - .button(); - &.primary { - .button-primary(); - } -} - .main-col { min-height: 20rem; // ToDo UI: delete if sticky footer } diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less index d01685e141655..d3ef739a9435a 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less @@ -41,6 +41,7 @@ @data-grid-th__hover__background-color: lighten(@data-grid-th__background-color, 5%); @data-grid-th-marker__width: .7rem; +@data-grid-th-marker__required__color: lighten(@color-light-phoenix, 10%); @data-grid-checkbox-cell-inner__padding-top: 1.1rem; @data-grid-checkbox-cell-inner__padding-horizontal: 1.8rem; @@ -49,9 +50,15 @@ // +.admin__data-grid-outer-wrap { + position: relative; // Used to keep spinner inside +} + .admin__data-grid-wrap { + margin-bottom: 2rem; + max-width: 100%; + overflow-x: auto; padding-top: 0; - position: relative; } .admin__data-grid-loading-mask { @@ -81,31 +88,26 @@ border-left: none; border-right: none; border-top: none; + box-sizing: border-box; // ToDo UI: Rewrite old styles. Should be deleted afterwards font-size: @data-grid__font-size; - margin-bottom: 2rem; max-width: 100%; + margin-bottom: 0; width: 100%; thead { - background-color: transparent; // ToDo UI: Rewrite old styles. Should be deleted afterwards + background-color: transparent; color: @text__color; // ToDo UI: Rewrite old styles. Should be deleted afterwards } + tfoot { + th { + padding: @data-grid-cell__padding-vertical @data-grid-cell__padding-horizontal; + } + } tr { &:nth-child(even) { td { background-color: @data-grid-td__even__background-color; } } - &:active { - td { - background-color: @data-grid-tr__active__background-color; - } - } - &:hover { - td { - background-color: @data-grid-tr__hover__background-color; - cursor: pointer; - } - } &.data-grid-tr-no-data { &:hover { td { @@ -115,6 +117,24 @@ } } } + tbody { + tr { + &:active { + td { + background-color: @data-grid-tr__active__background-color; + } + } + &:hover { + td { + background-color: @data-grid-tr__hover__background-color; + } + } + &._clickable, + ._clickable { + cursor: pointer; + } + } + } th, td { font-size: @data-grid__font-size; // ToDo UI: Rewrite old styles. Should be deleted afterwards @@ -173,11 +193,14 @@ .data-grid-th { color: @data-grid-th__color; padding: @data-grid-th__padding-vertical @data-grid-th__padding-horizontal; + vertical-align: middle; &._sortable { + background-clip: padding-box; // Fix for border overlay in Firefox cursor: pointer; padding-right: @data-grid-th__padding-horizontal * 2 + @data-grid-th-marker__width; position: relative; transition: @smooth__background-color; + z-index: 1; &:focus, &:hover { background-color: @data-grid-th__hover__background-color; @@ -187,9 +210,20 @@ padding-top: @data-grid-th__padding-vertical + .1rem; } } + // Required column + &.required { + > span { + &:after { + content: '*'; + margin-left: .3rem; + color: @data-grid-th-marker__required__color; + } + } + } } .data-grid-checkbox-cell { padding: 0; + width: @control-checkbox-radio__size + @data-grid-checkbox-cell-inner__padding-horizontal * 2; &:hover { cursor: default; } @@ -197,7 +231,6 @@ .data-grid-multiselect-cell { padding: @data-grid-th__padding-horizontal @data-grid-th__padding-vertical @data-grid-th__padding-horizontal - .1rem; text-align: center; - width: @control-checkbox-radio__size + @data-grid-checkbox-cell-inner__padding-horizontal * 2; } .data-grid-actions-cell { padding-left: @data-grid-cell__padding-horizontal * 2; @@ -258,7 +291,8 @@ &:before { position: absolute; right: @data-grid-th__padding-horizontal; - top: @data-grid-th__padding-vertical - .1rem; + top: 50%; + margin-top: -.75em; } } &._ascend { @@ -311,3 +345,8 @@ } } } +.data-grid-th { + &._col-xs { + width: 1%; + } +} diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less index 6d5ecd492f8b6..a2dce53bec754 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less @@ -32,15 +32,15 @@ .admin__data-grid-header { font-size: @font-size__base; // ToDo UI: should be deleted, added to prevent fz override with .grid - position: relative; - z-index: @data-grid-header__z-index - 1; } .admin__data-grid-header-row { &:extend(.abs-clearfix all); - margin-bottom: @data-grid-header-row__margin-bottom; - &:first-child { - margin-bottom: @data-grid-header-row__margin-bottom - @data-grid-header-add-indent__bottom; + + .admin__data-grid-header-row { + margin-top: @data-grid-header-row__margin-bottom - @data-grid-header-add-indent__bottom; + } + &:last-child { + margin-bottom: @data-grid-header-row__margin-bottom; } .action-select-wrap { display: block; diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-bookmarks.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-bookmarks.less index 6e3be82858c09..ed9d23e70dee2 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-bookmarks.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-bookmarks.less @@ -29,13 +29,17 @@ .admin__data-grid-action-bookmarks { .admin__action-dropdown-menu__align(right); opacity: @component-modal__opacity; - &._hide { - display: none; - } &._active { z-index: @data-grid-action__z-index; } .admin__action-dropdown { + .admin__action-dropdown-text { + display: inline-block; + max-width: 15rem; + min-width: 4.9rem; + vertical-align: top; + .text-overflow(); + } &:before { &:extend(.abs-icon all); content: @icon-views__content; @@ -44,13 +48,13 @@ .admin__action-dropdown-menu { font-size: @action-dropdown-menu__font-size; left: 0; - padding: 1rem 0 0; + padding: 1rem 0 @action-dropdown-menu-item__padding-vertical; right: auto; > li { padding: 0 @action-dropdown-menu-item-actions__width 0 0; position: relative; white-space: nowrap; - &:not(.action-dropdown-menu-item-last) { + &:not(.action-dropdown-menu-action) { transition: @smooth__background-color; &:hover { background-color: @action-dropdown-menu-item__hover__background-color; @@ -73,17 +77,23 @@ padding-top: @action-dropdown-menu-item__padding-vertical; } } - // Save action - .action-dropdown-menu-item-last { - padding-bottom: @action-dropdown-menu-item__padding-vertical; + // Menu actions + .action-dropdown-menu-action { padding-left: @action-dropdown-menu-item__padding-left / 2; padding-top: @action-dropdown-menu-item__padding-vertical; + + .action-dropdown-menu-item-last { + padding-top: .5rem; + } > a { .link-pattern(); display: inline-block; padding-left: 1.1rem; } } + // Save action + .action-dropdown-menu-item-last { + padding-bottom: 0; + } // Edit state ._edit { .action-dropdown-menu-item { @@ -93,6 +103,12 @@ display: block; } } + // Active item + ._active { + .action-dropdown-menu-link { + font-weight: @font-weight__semibold; + } + } // Edit item .admin__control-text { font-size: @action-dropdown-menu__font-size; diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less index e4148e87f4dbb..fe7365ba224c4 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less @@ -34,7 +34,7 @@ content: @icon-systems__content; font-size: 1.8rem; // Static left: .3rem; - margin-right: .7rem; + margin-right: @action__outer-indent; vertical-align: top; } } diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-filters.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-filters.less index 66df9bda92aae..7689e57c9b1d1 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-filters.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-filters.less @@ -26,6 +26,7 @@ @data-grid-filters-action__active__border-color: @color-gray80; @data-grid-filters-action__active__color: @color-phoenix; +@data-grid-filters-current__margin-borrom: .9rem; @data-grid-filters-current-action-remove__background-color: @color-gray68; @data-grid-filters-current-action-remove__hover__background-color: darken(@data-grid-filters-current-action-remove__background-color, 10%); @data-grid-filters-current-action-remove__size: 1.6rem; @@ -144,7 +145,7 @@ clear: both; font-size: @data-grid-filters__font-size; max-height: 0; - transition: opacity .3s ease, padding .3s ease; + transition: opacity .3s ease; &._show { .appearing__on(); border-bottom: 1px solid @data-grid-filters-action__active__border-color; @@ -255,21 +256,30 @@ // Current chips .admin__data-grid-filters-current { - border-bottom: 1px solid @data-grid-filters-action__active__border-color; - border-top: 1px solid @data-grid-filters-action__active__border-color; + border-bottom: .1rem solid @data-grid-filters-action__active__border-color; + border-top: .1rem solid @data-grid-filters-action__active__border-color; display: none; font-size: @data-grid-filters__font-size; - margin-bottom: .9rem; + margin-bottom: @data-grid-filters-current__margin-borrom; padding-bottom: .8rem; padding-top: 1.1rem; width: 100%; &._show { display: table; + position: relative; + top: -1px; + z-index: 3; + + .admin__data-grid-filters-wrap { + &._show { + margin-top: -(@data-grid-filters-current__margin-borrom + .1rem); + } + } } } .admin__current-filters-list-wrap, -.admin__current-filters-title-wrap { +.admin__current-filters-title-wrap, +.admin__current-filters-actions-wrap { display: table-cell; vertical-align: top; } @@ -318,3 +328,12 @@ } } } + +.admin__current-filters-actions-wrap { + .action-clear { + border: none; + padding-bottom: 0; + padding-top: 0; + white-space: nowrap; + } +} diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 9a9b7884834a5..de44abcd52169 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.5.0|~5.6.0", - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_actions.less b/app/design/adminhtml/Magento/backend/web/css/source/_actions.less index 0353568d0e94a..a0e4de74eaa16 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_actions.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_actions.less @@ -47,10 +47,11 @@ // Secondary button @button-secondary__background-color: @color-brownie; -@button-secondary__border-color: @color-brownie; +@button-secondary__border-color: @button-secondary__background-color; @button-secondary__color: @color-white; @button-secondary__active__background-color: @color-very-dark-gray-black2; @button-secondary__hover__background-color: @color-very-dark-gray-black2; +@button-secondary__hover__border-color: @button-secondary__hover__background-color; // Triangle marker @button-marker-triangle__height: .5rem; @@ -77,6 +78,17 @@ } } +.action-icon() { + background-color: transparent; + border-color: transparent; + box-shadow: none; + &:hover { + background-color: transparent; + border-color: transparent; + box-shadow: none; + } +} + // Used in action dropdown, actions split & all other actions with triangle marker .action-toggle-triangle ( @_dropdown__padding-right: 3rem; @@ -257,6 +269,7 @@ button { &:active, &:focus { background-color: @button-secondary__hover__background-color; + border-color: @button-secondary__hover__border-color; box-shadow: @button__hover__box-shadow; color: @button-secondary__color; text-decoration: none; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_classes.less b/app/design/adminhtml/Magento/backend/web/css/source/_classes.less index 2b420d0e88ff9..7562f5de527b2 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_classes.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_classes.less @@ -14,3 +14,8 @@ .disabled(); } } + +// Text align classes +.a-center { // ToDo UI: should be renamed to ._text-center + text-align: center; +} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_components.less b/app/design/adminhtml/Magento/backend/web/css/source/_components.less index a70fc496ce35d..906c538fc04f7 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_components.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_components.less @@ -11,6 +11,3 @@ @import 'components/_calendar-temp.less'; @import 'components/_messages.less'; @import 'components/_popups.less'; - -@import 'components/_data-grid-temp.less'; - diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_forms.less b/app/design/adminhtml/Magento/backend/web/css/source/_forms.less index 624092c1068bb..2e18751ca4955 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_forms.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_forms.less @@ -3,8 +3,7 @@ // * See COPYING.txt for license details. // */ +@import (reference) 'forms/_extends.less'; @import 'forms/_controls.less'; @import 'forms/_fields.less'; -@import 'forms/_tooltip.less'; @import 'forms/_temp.less'; -@import 'forms/_checkbox-radio.less'; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_sources.less b/app/design/adminhtml/Magento/backend/web/css/source/_sources.less index 197d0d89a271c..90feff4f7b55a 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_sources.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_sources.less @@ -20,6 +20,7 @@ @import '_extends.less'; @import '_tabs.less'; @import '_structure.less'; +@import '_classes.less'; // // Components diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_tables.less b/app/design/adminhtml/Magento/backend/web/css/source/_tables.less index c72dda6889519..5e53b58063d53 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_tables.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_tables.less @@ -38,6 +38,10 @@ table { } } +.admin__table-wrapper { + .table-overflow(); +} + .admin__table-primary, .admin__table-secondary { width: 100%; @@ -91,28 +95,25 @@ table { margin-bottom: .75em; text-align: left; } + thead { + th { + background-color: transparent; + font-weight: @font-weight__semibold; + } + } tbody { th { vertical-align: top; } - } - tr { - &:nth-child(odd) { - th, - td { - background-color: @admin__table-secondary-cell__odd__color; + tr { + &:nth-child(odd) { + th, + td { + background-color: @admin__table-secondary-cell__odd__color; + } } } } - th, - td { - padding: @admin__table-secondary__padding-horizontal @admin__table-secondary__padding-vertical; - text-align: left; - } - th { - color: @admin__table-secondary-th__color; - font-weight: @font-weight__regular; - } tfoot { tr { &:nth-child(odd) { @@ -126,7 +127,13 @@ table { } } } - .admin__total-amount { - text-align: right; + th, + td { + padding: @admin__table-secondary__padding-horizontal @admin__table-secondary__padding-vertical; + text-align: left; + } + th { + color: @admin__table-secondary-th__color; + font-weight: @font-weight__regular; } } diff --git a/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-select.less b/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-select.less index 496f6269e8b3d..774c67ff905c5 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-select.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-select.less @@ -51,6 +51,7 @@ } } &._active { + z-index: @action-select__z-index; .action-select { border-color: @field-control__active__border-color; &:before { diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less index 621b01524dcee..1df52149aa19d 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less @@ -22,29 +22,38 @@ // Datepicker control // --------------------------------------------- -.admin__control-text { - &.hasDatepicker { +.hasDatepicker { + &.admin__control-text { width: 15rem; } + .ui-datepicker-trigger { .button-reset(); .icon-font( - @_icon-font-content: @icon-calendar__content, - @_icon-font: @icons-admin__font-name, - @_icon-font-size: 2.1rem, - @_icon-font-line-height: @action__height, - @_icon-font-text-hide: true, - @_icon-font-position: after, - @_icon-font-color: @ui-datepicker-icon__color + @_icon-font-content: @icon-calendar__content, + @_icon-font: @icons-admin__font-name, + @_icon-font-size: 2.1rem, + @_icon-font-line-height: @action__height, + @_icon-font-text-hide: true, + @_icon-font-position: after, + @_icon-font-color: @ui-datepicker-icon__color ); + display: inline-block; height: @action__height; + margin-left: -@action__height; overflow: hidden; + position: absolute; vertical-align: top; - margin-left: -@action__height; - display: inline-block; + z-index: 1; &:active { .scale(.975); } + + .admin__control-support-text, + + .admin__control-label { + margin-left: @action__height + .5rem; + } + img { + display: none; + } } } @@ -83,6 +92,7 @@ // // Previous, next buttons // --------------------------------------------- + .ui-datepicker-prev, .ui-datepicker-next { cursor: pointer; @@ -294,6 +304,7 @@ .ui-timepicker-div { padding: 10px 0 5px 0; + position: relative; } .ui-datepicker-rtl { diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_data-grid-temp.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_data-grid-temp.less deleted file mode 100644 index 2dded4e6efea6..0000000000000 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_data-grid-temp.less +++ /dev/null @@ -1,321 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -// -// Variables -// --------------------------------------------- - -@data-grid-temp__font-size: 1.3rem; -@data-grid-temp__margin-xs: 1rem; -@data-grid-temp__margin: 2rem; -@data-grid-temp__color: @text__color; - -@data-grid-temp-cell__border-width: 1px; -@data-grid-temp-cell__padding-horizontal: @data-grid-temp__margin-xs; -@data-grid-temp-cell__padding-vertical: @data-grid-temp__margin-xs; - -@data-grid-temp-td__border-color: @color-gray84; -@data-grid-temp-td__border-inner-style: dashed; -@data-grid-temp-td__border-outer-style: solid; -@data-grid-temp-td__even__background-color: @color-white-smoke; -@data-grid-temp-td__hover__background-color: #e5f7fe; -@data-grid-temp-td__odd__background-color: @page__background-color; - -@data-grid-temp-th__border-color: #8a837f; -@data-grid-temp-th__border-style: solid; -@data-grid-temp-th__background-color: @color-brownie; -@data-grid-temp-th__color: @color-white; -@data-grid-temp-th__padding-horizontal: @data-grid-temp-cell__padding-horizontal; -@data-grid-temp-th__padding-vertical: @data-grid-temp-cell__padding-vertical; -@data-grid-temp-th__hover__background-color: lighten(@data-grid-temp-th__background-color, 5%); - -// Pager -@data-grid-temp-pager__width: 4rem; -@data-grid-temp-pager-icon__color: @data-grid-temp-th__background-color; -@data-grid-temp-pager-icon-previous__content: @icon-caret-left__content; -@data-grid-temp-pager-icon-next__content: @icon-caret-right__content; - -// -// Temporary grid styles -// --------------------------------------------- - -.grid { - .hor-scroll { - overflow-x: auto; - } - table { - &:not(.data-table) { - border: none; - font-size: @data-grid-temp__font-size; - margin-bottom: @data-grid-temp__margin; - max-width: 100%; - width: 100%; - - thead { - background-color: transparent; - color: @data-grid-temp__color; - } - - tr { - &:nth-child(even) { - td { - background-color: @data-grid-temp-td__even__background-color; - } - } - &:last-child { - td { - border-bottom: @data-grid-temp-cell__border-width @data-grid-temp-td__border-outer-style @data-grid-temp-td__border-color; - } - } - &:hover { - td { - background-color: @data-grid-temp-td__hover__background-color; - cursor: pointer; - } - } - } - - th, - td { - font-size: @data-grid-temp__font-size; - line-height: @line-height__base; - transition: background-color .3s; - vertical-align: top; - &:last-child { - padding-left: @data-grid-temp__margin; - padding-right: @data-grid-temp__margin; - } - } - - td { - background-color: @data-grid-temp-td__odd__background-color; - border-left: @data-grid-temp-cell__border-width @data-grid-temp-td__border-inner-style @data-grid-temp-td__border-color; - border-right: @data-grid-temp-cell__border-width @data-grid-temp-td__border-inner-style @data-grid-temp-td__border-color; - color: @table__color; - padding: @data-grid-temp-cell__padding-vertical @data-grid-temp-cell__padding-horizontal; - &:first-child { - border-left-style: @data-grid-temp-td__border-outer-style; - } - &:last-child { - border-right-style: @data-grid-temp-td__border-outer-style; - width: 1%; // Making last action smallest column - } - .action-menu { - left: auto; - z-index: 1; - } - } - - th { - background-color: @data-grid-temp-th__background-color; - border-left-color: transparent; - border: @data-grid-temp-cell__border-width @data-grid-temp-th__border-style @data-grid-temp-th__border-color; - color: @data-grid-temp-th__color; - font-weight: @font-weight__semibold; - padding: @data-grid-temp-cell__padding-vertical @data-grid-temp-cell__padding-horizontal; - text-align: left; - &:first-child { - border-left-color: @data-grid-temp-th__border-color; - } - a { - color: @data-grid-temp-th__color; - &:active, - &:visited { - color: @data-grid-temp-th__color; - } - &:hover { - color: @data-grid-temp-th__color; - text-decoration: none; - } - } - } - - // Filters from mui/table.less - .filter { - th { - padding: 6px 3px; - vertical-align: top; - } - .ui-datepicker-trigger { - cursor: pointer; - margin-top: 2px; - img { - display: none; - } - } - .range-line:not(:last-child) { - margin-bottom: 5px; - } - .date { - padding-right: 28px; - position: relative; - .hasDatepicker { - vertical-align: top; - width: 99%; - } - .ui-datepicker-trigger { - .icon-font( - @icon-calendar, - @_icon-font-color: @data-grid-temp-td__even__background-color, - @_icon-font-color-hover: @data-grid-temp-td__hover__background-color, - @_icon-font-size: 42px, - @_icon-font-line-height: 30px - ); - background-color: transparent; - border: none; - margin: 0; - padding: 0; - position: absolute; - right: -3px; - top: -3px; - > span { - position: absolute; - visibility: hidden; - z-index: -1; - } - &:active { - top: -2px; - } - &:focus { - box-shadow: none; - outline: 0; - } - &:before { - height: 2.9rem; - margin-left: .5rem; - width: 3.5rem; - } - &:after { - display: none; - } - } - } - } - // Filters from mui/table.less - } - } - - .not-sort { - padding-right: @data-grid-temp__margin-xs; - } - - .sort-arrow-asc, - .sort-arrow-desc { - padding-right: @data-grid-temp__margin; - position: relative; - &:after { - position: absolute; - right: 0; - top: -1px; - } - } - - .sort-arrow-asc { - .icon-font( - @icon-caret-down__content, - @_icon-font: @icons-admin__font-name, - @_icon-font-color: @data-grid-temp-th__color, - @_icon-font-size: 15px, - @_icon-font-position: after - ); - } - - .sort-arrow-desc { - .icon-font( - @icon-caret-up__content, - @_icon-font: @icons-admin__font-name, - @_icon-font-color: @data-grid-temp-th__color, - @_icon-font-size: 15px, - @_icon-font-position: after - ); - } - - .pager { - float: none; - text-align: center; - } -} - -// -// Grid actions -// --------------------------------------------- - -.grid-actions { - &:extend(.abs-clearfix all); - margin: 0 0 @data-grid-temp__margin; - position: relative; - - .export, - .filter-actions { - float: right; - margin-left: @data-grid-temp__margin-xs; - vertical-align: top; - } -} - -// -// Pager -// --------------------------------------------- - -.pager { - float: left; - margin: 0 1.5rem 0 0; - position: relative; - - .pages-total-found { - margin-right: 2.5rem - } - .pages-total { - margin: 0 @data-grid-temp__margin-xs 0 0; - } - - .view-pages { - .admin__control-select { - margin: 0 @data-grid-temp__margin-xs; - } - } - - label { - &.page { - &:extend(.abs-visually-hidden all); - } - } - - .input-text, - .admin__control-text { - margin: 0 1rem; - min-width: 0; - text-align: center; - width: @data-grid-temp-pager__width; - } - - .action-previous { - .icon-font( - @data-grid-temp-pager-icon-previous__content, - @_icon-font: @icons-admin__font-name, - @_icon-font-color: @data-grid-temp-pager-icon__color, - @_icon-font-size: 17px, - @_icon-font-text-hide: true - ); - - } - .action-next { - .icon-font( - @data-grid-temp-pager-icon-next__content, - @_icon-font: @icons-admin__font-name, - @_icon-font-color: @data-grid-temp-pager-icon__color, - @_icon-font-size: 17px, - @_icon-font-text-hide: true - ); - } - .action-default { - margin-right: @data-grid-temp__margin-xs; - padding: .3em .9em; - vertical-align: top; - &:before { - font-weight: @font-weight__bold; - } - } -} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less index b6d5c27d02ce0..bd58db5506638 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less @@ -91,14 +91,14 @@ .ui-dialog-buttonpane { padding: 0 @popup__padding__horizontal @popup__padding__vertical; } - + .content + .ui-dialog-buttonset { padding-top: @popup__padding__vertical; text-align: right; } .ui-dialog-buttonset { - .extend__clearfix(); + &:extend(.abs-clearfix all); } .action-close { @@ -106,6 +106,13 @@ font-size: @button__large__font-size; margin: 0 0 0 @popup__padding__horizontal; padding: @button__large__padding-vertical 0; + &:before { + content: normal; + } + span { + position: static; + overflow: auto; + } } .ui-button, @@ -115,7 +122,7 @@ float: right; margin: 0 0 0 @popup__padding__horizontal; } - + .fieldset { &:last-child { padding-bottom: 0; @@ -144,7 +151,7 @@ .pager { padding-bottom: 0; } - + .grid-actions { padding-top: 0; } @@ -237,10 +244,10 @@ .main-col, .magento_message { .insert-title-inner { + &:extend(.abs-clearfix all); border-bottom: 1px solid @color-gray68; margin: 0 0 @indent__base; padding-bottom: @indent__xs; - .extend__clearfix(); } .insert-actions { float: right; @@ -257,8 +264,11 @@ } .breadcrumbs { + list-style: none; padding-left: 0; li { + display: inline-block; + margin: 0 @indent__xs @indent__xs 0; &:after { content: ''; margin: 0 @indent__xs 0 0; @@ -308,7 +318,7 @@ } #contents-uploader { - .extend__clearfix() + &:extend(.abs-clearfix all); } .x-tree { @@ -343,12 +353,13 @@ top: 0; } +// The message/dialog popup .ui-popup-message { .ui-dialog-titlebar { background: @color-lazy-sun; - font-size: 1.6rem; + font-size: 1.4rem; font-weight: @font-weight__bold; - padding: 2rem 2rem 0; + padding: 2rem 2rem 0 7.5rem; } .ui-dialog-titlebar-close { right: 1.5rem; @@ -360,6 +371,7 @@ .ui-dialog-content { background: @color-lazy-sun; margin-bottom: 0; + overflow: inherit; padding: 0 2rem 2rem; .messages, .message { @@ -367,6 +379,17 @@ margin-bottom: 0; } } + .message { + &:first-child { + padding-top: 0; + &:before { + top: 0; + } + } + &:last-child { + padding-bottom: 0; + } + } } .ui-dialog-buttonpane { background: @color-lazy-sun; @@ -473,9 +496,9 @@ } .magento_buttons { + &:extend(.abs-clearfix all); padding: 0 @popup__padding__horizontal @popup__padding__vertical; text-align: right; - .extend__clearfix(); .ok_button { &:extend(.ui-dialog .action-primary all); @@ -526,9 +549,9 @@ .popup-title { &:extend(.ui-dialog .ui-dialog-titlebar all); background: @color-lazy-sun; - font-size: 1.6rem; + font-size: 1.4rem; font-weight: @font-weight__bold; - padding: 2rem 2rem 0; + padding: 2rem 2rem 0 7.5rem; } .popup-header { @@ -538,8 +561,8 @@ } .popup-content { + &:extend(.abs-clearfix all); background: @color-lazy-sun; - .extend__clearfix(); padding: 0 2rem 2rem; p { margin-top: 0; @@ -549,8 +572,19 @@ margin-bottom: 0; } } + .message { + &:first-child { + padding-top: 0; + &:before { + top: 0; + } + } + &:last-child { + padding-bottom: 0; + } + } } - + .fieldset { background: @color-lazy-sun; border: 0; @@ -565,16 +599,16 @@ .messages { margin: 0 !important; } - + .actions { + &:extend(.abs-clearfix all); margin: 0; text-align: right; - .extend__clearfix(); .primary { &:extend(.ui-dialog .action-primary all); - font-size: 1.4rem; float: right; + line-height: inherit; margin: 0 0 0 @popup__padding__horizontal; &:hover { box-shadow: none; @@ -582,8 +616,8 @@ } .cancel { + line-height: inherit; &:extend(.ui-dialog .action-close all); - font-size: 1.4rem; &:hover { box-shadow: none; } diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_spinner.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_spinner.less index c9eb6f63a9e7e..e0a5ae51bbd46 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_spinner.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_spinner.less @@ -101,7 +101,7 @@ .loading-old, .loading-mask { background: rgba(255, 255, 255, .4); - z-index: 999; + z-index: 2003; } .loading-old, diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_control-table.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_control-table.less deleted file mode 100644 index 4d4875471506f..0000000000000 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_control-table.less +++ /dev/null @@ -1,58 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -// -// Variables -// _____________________________________________ - -// @todo ui - rebuilt dynamic table control - -// -// Table control -// --------------------------------------------- - -.admin__control-table-wrapper { - max-width: 100%; - overflow-x: auto; - overflow-y: hidden; -} - -.admin__control-table { - width: 100%; - thead { - background: none; - } - td, - th { - background: @color-white-dark-smoke; - border: 0; - border-bottom: 1px solid @color-white; - padding: 1.3rem 2.5rem 1.3rem 0; - text-align: left; - vertical-align: top; - &:first-child { - padding-left: 1.5rem; - } - } - th { - border: 0; - vertical-align: bottom; - color: @color-very-dark-gray-black; - font-size: @font-size__base; - font-weight: @font-weight__semibold; - padding-bottom: 0; - &._required { - span { - &:after { - color: @field-label__required__color; - content: '*'; - } - } - } - } - .action-delete { - &:extend(.abs-action-delete all); - } -} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less index 3c8edc3286994..9eead6e701250 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less @@ -3,8 +3,11 @@ // * See COPYING.txt for license details. // */ -@import (reference) '_extends.less'; -@import '_control-table.less'; +// +// Components +// _____________________________________________ + +@import 'controls/_checkbox-radio.less'; // // Variables @@ -99,7 +102,6 @@ background-position+: ~'calc(100% - 33px)' 0; background-size+: 1px 100%; - height: @field-control__height; padding-right: 4.4rem; // Distance between select switch and inner text transition: @smooth__border-color; @@ -190,11 +192,14 @@ option:empty { line-height: @field-control__line-height; padding-top: @field-control__padding-top; padding-bottom: @field-control__padding-bottom; + + [class*='admin__control-'] { + margin-left: @action__outer-indent; + } } [class*='admin__control-'] { + .admin__control-support-text { - margin-left: .7rem; + margin-left: @action__outer-indent; } } @@ -304,7 +309,7 @@ option:empty { } } .admin__addon { - min-width: auto; + min-width: 0; overflow: hidden; text-align: right; white-space: nowrap; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_extends.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_extends.less index 0a883946949c2..b3418c97be279 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_extends.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_extends.less @@ -24,10 +24,6 @@ // Transformation to rows form layout // --------------------------------------------- -.extend__field-rows() { - &:extend(.abs-field-rows all); -} - .abs-field-rows[class] { > .admin__field-control { float: none; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less index def207f2a0bb7..9bece984eb4ef 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less @@ -3,6 +3,13 @@ // * See COPYING.txt for license details. // */ +// +// Components +// _____________________________________________ + +@import 'fields/_control-table.less'; +@import 'fields/_field-tooltips.less'; + // // Variables // _____________________________________________ @@ -44,7 +51,7 @@ #mix-grid .row(); &.admin__field-wide { - .extend__field-rows(); + &:extend(.abs-field-rows all); } > .admin__field-control { #mix-grid .column(4,9); diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_temp.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_temp.less index 53a728106a5af..2ba9ee7f8678f 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_temp.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_temp.less @@ -39,19 +39,21 @@ // _____________________________________________ .admin__fieldset-wrapper-title { - .extend__clearfix(); + &:extend(.abs-clearfix all); border-bottom: 1px solid @color-gray80; + font-size: 1.7rem; margin-bottom: 30px; padding: 14px 0 16px; - strong, .title { - &:extend(h2); - } - .title { - float: left; - margin: .7rem 0 0; + font-weight: 600; + &.active { + ~ .actions { + display: none; + } + } } .actions { + display: block; float: right; } } @@ -66,7 +68,7 @@ max-width: 500px; padding: 15px 30px; .admin__field { - .extend__field-rows(); + &:extend(.abs-field-rows all); } .admin__legend { display: none; @@ -229,6 +231,7 @@ label.mage-error { // // Login page captcha field @todo ui - Create new captcha markup - Change reload button // _____________________________________________ + .page-layout-admin-login { .field-captcha { padding-left: 30px; @@ -245,3 +248,272 @@ label.mage-error { // _____________________________________________ .ui-datepicker .ui-datepicker-title select:extend(.admin__control-select all) {}; + +// +// Data grid +// _____________________________________________ + +.data-grid { + .head-massaction { + .admin__control-select { + min-width: 6rem; + } + } + .data-grid-filters { + td { + padding: 1rem; + border-bottom: 1px solid #D6D6D6; + } + select, + input[type="text"]{ + width: 100%; + padding: .2rem .4rem; + height: 2.8rem; + min-width: 5rem; + font-size: 1.3rem; + } + .admin__control-text { + width: 100%; + } + select { + padding: .2rem 1.8rem .2rem .3rem; + background-position+: ~'calc(100% - 5px)' -37px; + background-size+: auto; + background-position+: 100%; + background-size+: 18px 100%; + background-position+: ~'calc(100% - 18px)' 0; + background-size+: 1px 100%; + height: 2.8rem; + &:focus { + background-position+: ~'calc(100% - 5px)' 11px; + background-position+: 100%; + background-position+: ~'calc(100% - 18px)' 0; + } + } + td { + .hasDatepicker { + + .ui-datepicker-trigger { + height: 2.8rem; + margin-left: -3.2rem; + width: 2.8rem; + &:after { + line-height: 28px; + } + } + } + } + } + .range-line { + position: relative; + + .range-line { + margin-top: .5rem; + } + } + .col-qty { + .admin__control-text { + &:extend(.abs-control-qty all); + } + } + .field-row { + display: inline-block; + } +} + +.mass-select-info { + &:before { + content: "("; + } + &:after { + content:")"; + } + &._empty { + display: none; + } +} + +.mass-select-wrap { + position: absolute; + top: 100%; + margin-top: 3.3rem; + margin-left: 1.1rem; + select { + position:absolute; + top: 0; + left: 0; + opacity: 0.01; + width: 22px; + height: 22px; + cursor: pointer; + z-index: 2; + + + label { + &:extend(.abs-action-default); + z-index: 1; + width: 16px; + height: 16px; + line-height: 16px; + padding: 0; + + &:before { + &:extend(.admin__control-checkbox + label:before); + position:absolute; + left: 0; + top: 0; + } + &:after { + &:extend(.action-multiselect-wrap .action-multiselect-toggle:after); + top: 40% !important; + } + } + &:focus { + + label { + &:after { + &:extend(.action-multiselect-wrap .action-multiselect-toggle._active:after); + } + } + } + &._checked { + + label { + &:before { + &:extend(.admin__control-checkbox:checked + label:before); + } + } + &._indeterminate { + + label { + &:before { + content: '-'; + font-size: 2rem; + line-height: 0.7rem; + } + } + } + } + &._disabled { + display: none; + + label { + opacity: .6; + cursor: not-allowed; + } + } + } +} + +.admin__data-grid-toolbar { + *, + *:before, + *:after { + box-sizing: border-box; + } + .admin__data-grid-header-row { + &:extend(.abs-cleafix); + .action-select-multiselect { + height: 38px; + left: -1rem; + min-width: 0; + opacity: .01; + top: -1.2rem; + width: 52px; + } + > div + div { + margin-left: @temp_gutter; + } + button { + vertical-align: top; + } + } + .admin__filter-actions { + float: left; + } + .admin__data-grid-export { + float: right; + .admin__control-select { + margin-right: @action__outer-indent; + } + } + .admin__grid-massaction { + float: left; + .admin__control-select { + margin-right: @action__outer-indent; + } + + .admin__control-text { + float: left; + } + .form-inline { + display: inline; + .admin__field-label { + width: auto; + float: none; + padding-right: 1rem; + padding-left: 2rem; + } + } + .admin__grid-massaction-form { + .admin__control-select { + ~ button { + display: none; + } + &._selected { + ~ button { + display: inline-block; + } + } + + } + } + .admin__control-select-placeholder { + color: @color-darkie-gray; + font-weight: @font-weight__bold; + } + } + .admin__data-grid-pager-wrap { + float: right; + } + .admin__data-grid-header-row { + &._massaction { + position: relative; + z-index: 1; + } + } +} + +.admin__grid-control { + .admin__grid-control { + display: none; + } +} + +.ui-dialog { + .admin__data-grid-header-row._massaction, + .mass-select-wrap select, + .mass-select-wrap, + .admin__grid-massaction { + z-index: 2000; + } + .admin__data-grid-wrap { + z-index: 1999; + } +} + +.data-grid { + td.col-action { + a + a { + &:before { + content: ""; + display: block; + } + } + } +} + + +// +// Popups +// _____________________________________________ + +.attribute-popup { + background-color: @color-white; + #edit_form { + padding-left: 1.8rem; + padding-right: 1.8rem; + } +} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_checkbox-radio.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/controls/_checkbox-radio.less similarity index 100% rename from app/design/adminhtml/Magento/backend/web/css/source/forms/_checkbox-radio.less rename to app/design/adminhtml/Magento/backend/web/css/source/forms/controls/_checkbox-radio.less diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/fields/_control-table.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/fields/_control-table.less new file mode 100644 index 0000000000000..90eb06efb93b1 --- /dev/null +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/fields/_control-table.less @@ -0,0 +1,98 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Variables +// --------------------------------------------- + +@control-table-cell__background-color: @color-white-dark-smoke; +@control-table-cell__border-color: @color-white; +@control-table-cell__padding-vertical: 1.3rem; + +// + +.admin__control-table-wrapper { + max-width: 100%; + overflow-x: auto; + overflow-y: hidden; +} + +.admin__control-table { + width: 100%; + thead { + background-color: transparent; + } + tbody { + td { + vertical-align: middle; + } + } + tfoot { + th { + padding-bottom: @control-table-cell__padding-vertical; + } + } + tr { + &:last-child { + th, + td { + border-bottom: none; + } + } + } + td, + th { + background-color: @control-table-cell__background-color; + border: 0; + border-bottom: 1px solid @control-table-cell__border-color; + padding: @control-table-cell__padding-vertical 2.5rem @control-table-cell__padding-vertical 0; + text-align: left; + vertical-align: top; + &:first-child { + padding-left: 1.5rem; + } + } + th { + border: 0; + vertical-align: bottom; + color: @color-very-dark-gray-black; + font-size: @font-size__base; + font-weight: @font-weight__semibold; + padding-bottom: 0; + &._required { + span { + &:after { + color: @field-label__required__color; + content: '*'; + } + } + } + } + // Actions column + .control-table-actions-th { + white-space: nowrap; + } + .control-table-actions-cell { + padding-top: 1.8rem; + text-align: center; + width: 1%; + } + // Draggable column + .col-draggable { + padding-top: 2.2rem; + width: 1%; + } + // Actions + .action-delete { + .action-icon(); + &:before { + &:extend(.abs-icon all); + content: @icon-delete__content; + } + > span { + display: none; + } + } +} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_tooltip.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/fields/_field-tooltips.less similarity index 100% rename from app/design/adminhtml/Magento/backend/web/css/source/forms/_tooltip.less rename to app/design/adminhtml/Magento/backend/web/css/source/forms/fields/_field-tooltips.less diff --git a/app/design/adminhtml/Magento/backend/web/css/source/variables/_actions.less b/app/design/adminhtml/Magento/backend/web/css/source/variables/_actions.less index 6cb821a11a68f..356dc736f9fa3 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/variables/_actions.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/variables/_actions.less @@ -18,5 +18,7 @@ @action__hover__background-color: @color-blue-clear-sky; @action__hover__border-color: darken(@action__border-color, 15%); +@action__outer-indent: .7rem; + // Actions menu @action-menu__hover__background-color: @color-gray89; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/variables/_colors.less b/app/design/adminhtml/Magento/backend/web/css/source/variables/_colors.less index 80492cbd3cd37..b1851c3dae1a8 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/variables/_colors.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/variables/_colors.less @@ -64,5 +64,6 @@ // --------------------------------------------- @primary__color: @color-phoenix; +@success__color: @color-green-apple; @text__color: @color-brown-darkie; @border__color: @color-gray89; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/variables/_structure.less b/app/design/adminhtml/Magento/backend/web/css/source/variables/_structure.less index 65feb808800fd..521d53cbe3e4c 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/variables/_structure.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/variables/_structure.less @@ -46,6 +46,7 @@ // z-index 5 @field-tooltip__z-index: @z-index-5; +@action-select__z-index: @z-index-5; @admin__page-nav-tooltip__z-index: @field-tooltip__z-index; // z-index 7 diff --git a/app/design/adminhtml/Magento/backend/web/css/source/variables/_typography.less b/app/design/adminhtml/Magento/backend/web/css/source/variables/_typography.less index 95422456d853c..85fdad960613b 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/variables/_typography.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/variables/_typography.less @@ -20,7 +20,7 @@ @font-size__tiny: 1.1rem; @font-size__xs: 1rem; -@line-height__base: 1.4; +@line-height__base: 1.36; @line-height__s: 1.2; // Links diff --git a/app/design/adminhtml/Magento/backend/web/css/styles-old.less b/app/design/adminhtml/Magento/backend/web/css/styles-old.less index 77fb1698576b0..e95925876fca2 100644 --- a/app/design/adminhtml/Magento/backend/web/css/styles-old.less +++ b/app/design/adminhtml/Magento/backend/web/css/styles-old.less @@ -751,7 +751,6 @@ input.no-display, fieldset { - border: 1px solid #ccc; padding: 20px; } @@ -907,6 +906,11 @@ input.no-display, } } + // Fix for jquery.jstree.js (checkboxes in admin__scope-old only) + .jstree .jstree-real-checkbox { + display: none; + } + input[type="radio"] { border-radius: 8px; &:checked { @@ -1151,7 +1155,7 @@ input.no-display, background: #fff; border: 0; margin: 0; - padding: 5px 18px 38px; + padding: 5px 0 38px; position: relative; } @@ -1172,7 +1176,9 @@ input.no-display, .fieldset-wrapper > .fieldset-wrapper-title .title, .fieldset > .legend span { - .style10(); + color: #303030; + font-size: 1.7rem; + font-weight: 600; padding: 7px 0 10px; display: inline-block; } @@ -1180,57 +1186,19 @@ input.no-display, // // Collapsable fieldset-wrapper // -------------------------------------- - .collapsable-wrapper { - padding-bottom: 2px; - > .fieldset-wrapper-title { - border-bottom: 1px solid #cac3b4; - margin-bottom: 0; - > .title { - position: relative; - padding-left: 22px; - cursor: pointer; - float: left; - &:before { - position: absolute; - left: 0; - top: 11px; - font-family: 'MUI-Icons'; - font-size: 16px; - font-style: normal; - speak: none; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e02a'; // arrow right icon - color: #b2b0ad; - } - &:hover:before { - color: #7e7e7e; - } - } - } - &.opened { - padding-bottom: 18px; - > .fieldset-wrapper-title { - //border-bottom: 1px solid #ededed; - margin-bottom: 18px; - > .title:before { - content: '\e02c'; // arrow down icon - } - } - } - } // Fieldset styles in another fieldset .fieldset .fieldset-wrapper, .fieldset-wrapper .fieldset-wrapper { border: 1px solid #cac3b4; border-radius: 2px; + margin-bottom: 5px; padding: 0; } .fieldset .fieldset-wrapper .fieldset-wrapper-title, .fieldset-wrapper .fieldset-wrapper .fieldset-wrapper-title { - background:#f7f3eb; + background: #f7f3eb; padding: 0 18px; border: 0; } @@ -1290,12 +1258,19 @@ input.no-display, } // Sortable fieldsets + + .ui-sortable { + margin-bottom: 15px; // should be the same as .sortable-wrapper + } + .ui-sortable .entry-edit .fieldset-wrapper-title, #product_options_container_top .fieldset-wrapper-title { padding-left: 30px; } - .ui-sortable .entry-edit .fieldset-wrapper-title > .title { + #super_config-wrapper, + #grouped-wrapper { + border-bottom: 0; } .fieldset-wrapper-title > .actions, @@ -1983,21 +1958,6 @@ input.no-display, .backup-dialog { margin-top: inherit !important; } -// -// .side-col { -// box-sizing: border-box; -// padding-bottom: 20px; -// padding-right: 10px; -// position: relative; -// width: 25%; -// } -// -// .main-col { -// position: relative; -// width: 75%; -// padding: 0 20px 20px; -// box-sizing: border-box; -// } .col-left { float: left; @@ -2026,63 +1986,13 @@ input.no-display, min-width: 730px; width: 80%; } -// .main-col { -// padding-right: 0; -// padding-left: 0; -// float: right; -// } -// .side-col { -// float: left; -// } - } - -// .col-2-right-layout { -// .side-col { -// float: right; -// } -// .main-col { -// float: left; -// } -// } + } .col-2-left-layout .main-col, .col-2-right-layout .main-col { min-width: 730px; } - // - // Horizontal Tabs - // -------------------------------------- - - .ui-tabs { - clear: both; - margin-bottom: 0; - } - .tabs-horiz { - list-style: none; - margin: 0; - padding: 3px 0 0; - } - - .tabs-horiz > li { - float: left; - margin: 0 5px 0 0; - } - - .tabs-horiz .ui-tabs-anchor { - position: relative; - display: block; - text-decoration: none; - .style7(); - background: #e0dacf; - padding: 11px 15px 13px; - border-radius: 2px 2px 0 0; - } - - .tabs-horiz > .ui-state-active .ui-tabs-anchor { - background: #fff; - } - // // Switcher // -------------------------------------- @@ -2469,6 +2379,10 @@ input.no-display, top: -50px; } + #front_fieldset-wrapper { + border-bottom: 0; + } + .attribute-popup { background: none; } @@ -2503,7 +2417,7 @@ input.no-display, border-top: none; } - .attribute-popup .fieldset-wrapper:not(.collapsable-wrapper) .fieldset-wrapper-title { + .attribute-popup .fieldset-wrapper:not(.admin__collapsible-block) .fieldset-wrapper-title { border-bottom: none; } @@ -2520,13 +2434,20 @@ input.no-display, width: 35%; } - .attribute-popup .collapsable-wrapper, - #manage-titles-wrapper .fieldset-wrapper-title { - margin-bottom: 0; - padding-bottom: 0; + .attribute-popup .admin__collapsible-block-wrapper, + #manage-titles-wrapper { + .fieldset-wrapper-title { + margin-bottom: 0; + padding-bottom: 0; + } + .col-store-view { + .input-text { + width: 100%; + } + } } - .attribute-popup .collapsable-wrapper .fieldset-wrapper-title > .title:before { + .attribute-popup .admin__collapsible-block-wrapper .fieldset-wrapper-title > .title:before { color: #797269; font-size: 14px; top: 9px; @@ -2569,8 +2490,13 @@ input.no-display, display: none; } - #manage-options-panel > .data-table { - clear: both; + #manage-options-panel { + .admin__control-table { + clear: both; + } + .input-text { + width: 100%; + } } // Custom grids view @@ -2693,12 +2619,12 @@ input.no-display, clear: both; } - .customer-information .data-table, + .customer-information .admin__table-secondary, .customer-information address { width: 48.5%; } - .customer-information .data-table { + .customer-information .admin__table-secondary { float: left; width: 48.5%; } @@ -4015,480 +3941,6 @@ input.no-display, border: 1px solid red !important; } - // - // Accordion - // ------------------------ - - .accordion { - margin: 0 0 8px; - padding: 0; - } - - .accordion > dt, - .accordion > dd.open, - .accordion .collapseable, - .section-config.active > .collapseable + input + fieldset, - .accordion .collapseable.open + input + fieldset { - background: #fff; - padding: 5px 18px 2px; - position: relative; - } - - .accordion > dt + dd { - display: none; - } - - .section-config > .config { - &.collapseable { - display: none; - } - } - - .accordion > dt.open, - .section-config.active > .collapseable, - .accordion .collapseable.open { - margin: 0; - border-bottom: 0; - border-radius: 5px 5px 0 0; - } - .section-config.active > .collapseable + input + fieldset, - .accordion > dt + dd.open, - .accordion .collapseable.open + input + fieldset { - padding: 25px 18px 18px; - display: block; - margin-left: 0; - border-top: 0; - border-radius: 0 0 5px 5px; - } - - .section-config > .collapseable > a, - .accordion > dt a, - .accordion .collapseable > a { - .style10(); - display: block; - padding: 7px 0 10px 22px; - text-decoration: none; - position: relative; - cursor: pointer; - border-bottom: 1px solid #cac3b4; - } - - .section-config > .collapseable > a i, - .accordion > dt a i, - .accordion .collapseable > a i { - .style31(); - } - - .section-config > .collapseable > a:before, - .accordion > dt a:before, - .accordion .collapseable > a:before { - position: absolute; - left: 0; - top: 11px; - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-size: 16px; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e02a'; // arrow right icon - color: #b2b0ad; - } - - .section-config.active > .collapseable > a:before, - .accordion > dt.open a:before, - .accordion .collapseable.open a:before { - content: '\e02c'; // arrow down icon - } - .section-config > .collapseable > a:hover:before, - .accordion > dt a:hover:before, - .accordion .collapseable > a:hover:before { - color: #7e7e7e; - } - - // PayPal connected - - .section-config.complex .section-config.with-button { - padding:20px 15px; - margin:0 -30px 0 -15px; - border-bottom:1px solid #eae6e0; - } - - .section-config.complex tr:last-child .section-config.with-button { - border-bottom:0; - } - - .section-config.complex .section-config.with-button > .entry-edit-head { - padding: 0 0 0 25px; - border:0; - } - - .section-config.complex .section-config.with-button.enabled > .entry-edit-head:before { - content: "\e01e"; - color:#fff; - background: #65940a; - font-family: "MUI-Icons"; - font-weight: normal; - padding:3px; - font-size: 10px; - width:10px; - height:10px; - line-height: 10px; - overflow: hidden; - border-radius: 8px; - display: block; - float:left; - margin-left:-25px; - margin-top:0; - } - - .section-config.complex .section-config.with-button > .config { - margin:10px -10px; - border:1px solid #d1d0ce; - border-radius: 0; - padding:5px 0; - } - .section-config.complex .section-config.with-button > .config > table > tbody > tr > td { - padding:0; - } - - .section-config.complex .section-config.with-button > .config > table > tbody > tr > td > .section-config > .entry-edit-head { - border:0; - border-radius: 0; - margin-bottom:0; - padding:5px 10px 2px; - border-bottom:1px solid #d1d0ce; - background: transparent; - } - .section-config.complex .section-config.with-button > .config > table > tbody > tr > td > .section-config > .entry-edit-head > a { - padding-left: 22px; - } - .section-config.complex .section-config.with-button > .config > table > tbody > tr > td > .section-config > .entry-edit-head > a:before { - left: 0; - } - .section-config.complex .section-config.with-button > .config > table > tbody > tr:last-child > td > .section-config > .entry-edit-head { - border:0; - } - .section-config.complex .section-config.with-button > .config > table > tbody > tr > td > .section-config > .entry-edit-head a { - border-bottom:0; - } - - .section-config.complex .section-config.with-button > .config > table > tbody > tr > td > .section-config > .config { - border:0; - border-bottom:1px solid #d1d0ce; - border-radius: 0; - margin:0; - padding-bottom:50px; - } - .section-config.complex .section-config.with-button > .config > table > tbody > tr:last-child > td > .section-config > .config { - border-bottom:0; - } - - .section-config .config h4 { - padding-left:25%; - font-size: 18px; - } - - .section-config .config td.label label.enabled:before { - content: "\e01e"; - color:#fff; - background: #65940a; - font-family: "MUI-Icons"; - font-weight: normal; - padding:3px; - font-size: 10px; - width:10px; - height:10px; - line-height: 10px; - overflow: hidden; - border-radius: 8px; - display: block; - float:left; - margin-right:5px; - } - - .section-config.complex .section-config.with-button > .config:before { - content:''; - height: 9px; - width: 20px; - overflow: hidden; - display: block; - position: absolute; - bottom: 100%; - left: 50%; - z-index: 2; - margin-left: -10px; - background: url(../images/subconfig-bg.png) no-repeat 0 0; - } - - .section-config.config-advanced { - padding:30px 0 0; - } - .section-config.config-advanced > .entry-edit-head { - border:0; - padding: 0 0 0 25%; - } - .section-config.config-advanced > .entry-edit-head a { - border:0 !important; - } - .section-config.config-advanced > .config { - padding-left:0!important; - padding-right:0!important; - border:0!important; - border-radius: 0!important; - } - - .section-config.config-advanced > .entry-edit-head a { - margin-left:-22px; - } - - - .section-config.with-button .config-heading strong { - display: block; - .style28(); - margin-bottom:5px; - } - - .section-config.with-button .config-heading .button-container { - margin:15px 0 0; - } - .section-config.with-button .button-container { - line-height: 28px; - } - .section-config.with-button .button-container a { - margin-left:20px; - } - - .section-config.with-button .action-configure span { - display: block; - position: relative; - text-align: center; - } - .section-config.with-button .action-configure .state-opened { - visibility: hidden; - height:0; - overflow: hidden; - } - .section-config.with-button .action-configure.open .state-opened { - visibility: visible; - height:auto; - overflow: auto; - } - .section-config.with-button .action-configure.open .state-closed { - visibility: hidden; - height:0; - overflow: hidden; - } - - .accordion > dt + dd { - display: none; - } - - .accordion > dt + .open:empty { - background: #fff url(../mui/images/ajax-loader-big.gif) no-repeat center; - height: 100px; - } - - // TODO: arrange configuration tables - .accordion .collapseable.disabled { - background: #f1f1f1; - } - - .accordion .collapseable.disabled > a { - cursor: not-allowed; - } - - .accordion .collapseable.disabled > a:before { - content: ''; - } - - .accordion .config { - border: 0; - } - - .accordion .config { - .comment a, - .link-more { - .style3(); - } - } - - .accordion .config legend { - display: none; - } - - .accordion .config table { - width: 100%; - } - - .accordion .config .label { - float: none; - width: 33%; - padding-right: 30px; - text-align: right; - font-size: 14px; - font-weight: 600; - color: #303030; - } - - .accordion .config .value .label { - padding: 6px 5px 0 15px; - vertical-align: top; - width: auto; - } - - .accordion .config .value .label:first-child { - padding-left: 0; - } - - .accordion .config .label label { - padding-top: 7px; - } - - .accordion .config td { - background: none; - border: 0; - padding: 22px 15px 0 0; - vertical-align: top; - } - - .accordion .paypal-selection-simplified { - padding-left: 30px; - } - - .accordion .paypal-selection input[type="checkbox"] { - margin: -4px 7px 0 0; - } - - .accordion .config input[type="text"], - .accordion .config input[type="password"], - .accordion .config select, - .accordion .config textarea { - width: 100%; - } - - .accordion .config input.input-file { - margin-top: 4px; - } - - .accordion .config select.select-date { - width: 27%; - } - - .accordion .config .value { - width: 44%; - padding-right: 40px; - .checkboxes { - list-style: none; - padding: 0; - margin: -3px 0 0; - - li { - margin: 7px 0; - } - - input, - label { - vertical-align: middle; - } - - label { - margin-left: 5px; - } - } - } - - .accordion .config .value.with-tooltip { - padding-top:5px; - } - .accordion .config .value.with-tooltip .tooltip { - position: relative; - top:0; - left:0; - right:0; - bottom:0; - float:right; - margin: 6px -28px 0 0; - } - .accordion .config .value.with-tooltip .tooltip-content { - padding: 18px; - margin: 0 -17px 10px 0; - right: 0; - bottom: 100%; - width: 239px; - max-width: 239px; - font-size: 13px; - line-height: 1.4; - background: #31302b; - background: rgba(49, 48, 43, .8); - border-radius: 5px; - } - .accordion .config .value.with-tooltip .tooltip-content:before { - content: ''; - position: absolute; - width: 0; - height: 0; - top: auto; - bottom:-5px; - left:auto; - right: 20px; - border-left: 5px solid transparent; - border-right: 5px solid transparent; - border-top: 5px solid #31302b; - border-bottom:0; - opacity: .8; - } - - .accordion .config .value.with-tooltip .help { - position: relative; - width:auto; - margin:0; - } - - .accordion .config .scope-label { - color: #999; - font-size: 12px; - letter-spacing: .05em; - padding: 31px 15px 0 0; - } - - .accordion .config .note { - color: #303030; - font-size: 12px; - margin: 5px 0; - } - - .accordion .config .note a { - .style22(); - } - - .accordion .config .system-tooltip-box { - position: absolute; - } - - .accordion .paypal-selection { - margin: 10px; - width: 98%; - } - - .accordion .paypal-selection th { - padding: 6px 10px 7px; - } - - .accordion .paypal-selection { - border-bottom: 2px solid #c0bbaf; - } - - .accordion .paypal-payment-notice { - margin: 10px; - } - - .accordion .custom-options { - border: 1px solid #999; - padding: 0 10px; - margin: 0 0 20px; - } - // // Sales // -------------------------------------- @@ -4872,6 +4324,7 @@ input.no-display, .adminhtml-system-config-edit { .admin__scope-old { .payflow-settings-notice { + margin-top: 2rem; padding: 10px; .important-label { .style32(); @@ -5362,15 +4815,6 @@ input.no-display, } } -.adminhtml-rma-edit { - .admin__scope-old { - .col-product, - .col-sku { - &:extend(.col-70-max all); - } - } -} - // // Products @@ -5799,7 +5243,7 @@ input.no-display, .adminhtml-export-index { .admin__scope-old { .grid-actions, - .grid { + .data-grid { &:extend(.side-paddings-0); } .col-label, @@ -5809,7 +5253,7 @@ input.no-display, .col-code { &:extend(.ellipsis all); } - .grid { + .data-grid { td { vertical-align: middle; } @@ -5817,15 +5261,18 @@ input.no-display, margin: 0 10px 0 5px; width: 37%; } - .input-text-range-date { + .hasDatepicker{ margin: 0 5px; width: 32%; } + .admin__control-support-text { + margin-right: .5rem; + } } - .ui-datepicker-trigger { - display: inline-block; - margin: -3px 10px 0 0; - vertical-align: middle; + .data-grid-checkbox-cell { + padding-right: 1rem; + padding-left: 1rem; + text-align: center; } } } @@ -5926,65 +5373,6 @@ input.no-display, padding-left: 0; padding-right: 0; } - .accordion { - margin: 0 0 8px; - padding: 0; - > dt { - background: #fff; - padding: 5px 18px 2px; - position: relative; - + dd { - display: none; - &.open { - padding: 25px 18px 18px; - display: block; - margin-left: 0; - border-top: 0; - border-radius: 0 0 5px 5px; - } - } - &.open { - margin: 0; - border-bottom: 0; - border-radius: 5px 5px 0 0; - a { - &:before { - content: '\e02c'; // arrow down icon - } - } - } - a { - .style10(); - display: block; - padding: 7px 0 10px 22px; - text-decoration: none; - position: relative; - cursor: pointer; - border-bottom: 1px solid #cac3b4; - i { - .style31(); - } - &:before { - position: absolute; - left: 0; - top: 11px; - font-family: 'MUI-Icons'; - font-style: normal; - speak: none; - font-size: 16px; - font-weight: normal; - -webkit-font-smoothing: antialiased; - content: '\e02a'; // arrow right icon - color: #b2b0ad; - } - &:hover { - &:before { - color: #7e7e7e; - } - } - } - } - } } // ==|== print styles ======================================================= diff --git a/app/design/adminhtml/Magento/backend/web/mui/styles/table.less b/app/design/adminhtml/Magento/backend/web/mui/styles/table.less index 574b9f0754306..3c8e2938e2b1f 100644 --- a/app/design/adminhtml/Magento/backend/web/mui/styles/table.less +++ b/app/design/adminhtml/Magento/backend/web/mui/styles/table.less @@ -4,9 +4,10 @@ // */ // -// Tables -// -------------------------------------- -table { +// Tables +// -------------------------------------- + +table:not(.data-grid .admin__control-table) { > caption { margin-bottom: 5px; } @@ -281,7 +282,6 @@ td.col-updated_at, td.col-customer_since, td.col-session_start_time, td.col-time, -td.col-sku, td.col-type { &:extend(.nowrap all); } diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less index 300a715075c87..7009f22f35d2a 100644 --- a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less @@ -204,13 +204,9 @@ .product-reviews-summary .reviews-actions { .font-size(@font-size__base); } - .product-options-wrapper { - .field { - .note { - display: block; - } - } - } +} + +.product-options-wrapper { .fieldset-product-options-inner { .legend { border: none; @@ -237,10 +233,10 @@ } } } - .datetime-picker { - + .time-picker { - .css(margin-left, @indent__xs); - } + } + .field { + .note { + display: block; } } } diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less index 486f123262140..535a47ff7f9ee 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less @@ -228,6 +228,19 @@ .price { font-weight: @font-weight__bold; } + .price-including-tax, + .price-excluding-tax { + margin: @indent__xs 0; + } + .weee[data-label] { + .font-size(11); + .label { + &:extend(.abs-no-display all); + } + } + .details-qty { + margin-top: @indent__s; + } } .product.options { .tooltip.toggle { diff --git a/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module/_collapsible_navigation.less b/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module/_collapsible_navigation.less index e816173e91ab3..f3ce324df0335 100644 --- a/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module/_collapsible_navigation.less +++ b/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module/_collapsible_navigation.less @@ -3,28 +3,34 @@ // * See COPYING.txt for license details. // */ +// +// Variables +// --------------------------------------------- + @collapsible-nav-background: @sidebar__background-color; -@collapsible-nav-item-hover: @color-gray91; @collapsible-nav-color: false; -@collapsible-nav-current-color: false; -@collapsible-nav-current-font-weight: @font-weight__semibold; @collapsible-nav-current-border: 3px solid transparent; @collapsible-nav-current-border-color: @color-orange-red1; +@collapsible-nav-current-color: false; +@collapsible-nav-current-font-weight: @font-weight__semibold; +@collapsible-nav-item-hover: @color-gray91; +// // -// Common -//-------------------------------------- +// Common +// --------------------------------------------- & when (@media-common = true) { // // Collapsible navigation -//-------------------------------------- +// --------------------------------------------- + .block-collapsible-nav { .content { - padding: 15px 0; .css(background, @collapsible-nav-background); + padding: 15px 0; } .item { margin: 3px 0 0; @@ -32,11 +38,11 @@ margin-top: 0; } a, - strong { - display: block; - padding: 5px 18px 5px 15px; + > strong { border-left: 3px solid transparent; .css(color, @collapsible-nav-color); + display: block; + padding: 5px 18px 5px 15px; } a { text-decoration: none; @@ -47,14 +53,13 @@ &.current { a, strong { - .css(color, @collapsible-nav-current-color); .css(border-color, @collapsible-nav-current-border-color); + .css(color, @collapsible-nav-current-color); .css(font-weight, @collapsible-nav-current-font-weight); } a { .css(border-color, @collapsible-nav-current-border-color); } - } } } @@ -62,8 +67,9 @@ } // -// Desktop -//-------------------------------------- +// Desktop +// --------------------------------------------- + .media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { .block-collapsible-nav { .title { @@ -73,13 +79,14 @@ } // -// Mobile -//-------------------------------------- +// Mobile +// --------------------------------------------- + .media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { .block-collapsible-nav { + left: 0; position: absolute; top: -21px; - left: 0; width: 100%; z-index: 5; .title { diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index ba6f3f714000f..4958cad2cc974 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.5.0|~5.6.0", - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/frontend/Magento/blank/web/css/source/_extends.less b/app/design/frontend/Magento/blank/web/css/source/_extends.less index a05283b439e7c..df818e7003ce2 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_extends.less +++ b/app/design/frontend/Magento/blank/web/css/source/_extends.less @@ -1017,7 +1017,14 @@ position: relative; } input { - margin-right: @indent__s; - width: calc(~"100% - (@{icon-calendar__font-size} + @{indent__s})"); + &:extend(.abs-field-date-input); } } + +// +// Form Field Date Input +//-------------------------------------- +.abs-field-date-input { + margin-right: @indent__s; + width: calc(~"100% - (@{icon-calendar__font-size} + @{indent__s})"); +} diff --git a/app/design/frontend/Magento/blank/web/css/source/_forms.less b/app/design/frontend/Magento/blank/web/css/source/_forms.less index e05a13a7eac2d..2e43d3ee29c0c 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_forms.less +++ b/app/design/frontend/Magento/blank/web/css/source/_forms.less @@ -60,9 +60,15 @@ fieldset.field { border: 0; padding: 0; } + .field { &.date { &:extend(.abs-field-date all); + .time-picker { + display: inline-block; + margin-top: @indent__s; + white-space: nowrap; + } } } @@ -137,7 +143,8 @@ select:focus ~ .tooltip .tooltip-content { .legend { &:extend(.abs-margin-for-forms-desktop all); } - > .field { + > .field, + > .fields > .field { .form-field-type-revert(); margin: 0 0 @form-field__vertical-indent__desktop; } diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/layout/default.xml b/app/design/frontend/Magento/luma/Magento_Catalog/layout/default.xml index 4a8cd3bbcef8a..f74ec11e615e2 100644 --- a/app/design/frontend/Magento/luma/Magento_Catalog/layout/default.xml +++ b/app/design/frontend/Magento/luma/Magento_Catalog/layout/default.xml @@ -9,7 +9,17 @@ - + + + + + + Magento_Catalog/js/view/compare-products + + + + + diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less index e4ba22703343f..110feac0776b8 100644 --- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less @@ -249,15 +249,9 @@ margin-top: @form-field__vertical-indent; } } - .product-options-wrapper { - .field { - .note { - display: block; - .css(margin-top, @indent__xs); - } - } +} - } +.product-options-wrapper { .fieldset-product-options-inner { .legend { border: none; @@ -284,10 +278,11 @@ } } } - .datetime-picker { - + .time-picker { - .css(margin-left, @indent__xs); - } + } + .field { + .note { + display: block; + .css(margin-top, @indent__xs); } } } diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less index 365f03d8f28a5..ddeb77db7fdfd 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less @@ -236,6 +236,19 @@ .price { font-weight: @font-weight__bold; } + .price-including-tax, + .price-excluding-tax { + margin: @indent__xs 0; + } + .weee[data-label] { + .font-size(11); + .label { + &:extend(.abs-no-display all); + } + } + .details-qty { + margin-top: @indent__s; + } } .product { .toggle { diff --git a/app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml b/app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml index a999d2fbf3c6c..41178b9cd8dc6 100644 --- a/app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml +++ b/app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml @@ -14,6 +14,12 @@ + + + 148 + 43 + + diff --git a/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/module/_collapsible_navigation.less b/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/module/_collapsible_navigation.less index 54b37411c7494..8001529dc0263 100644 --- a/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/module/_collapsible_navigation.less +++ b/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/module/_collapsible_navigation.less @@ -3,27 +3,34 @@ // * See COPYING.txt for license details. // */ +// +// Variables +// --------------------------------------------- + @collapsible-nav-background: @sidebar__background-color; -@collapsible-nav-item-hover: @color-gray91; @collapsible-nav-color: @color-gray34; -@collapsible-nav-current-color: @color-black; -@collapsible-nav-current-font-weight: @font-weight__semibold; @collapsible-nav-current-border: 3px solid transparent; @collapsible-nav-current-border-color: @color-orange-red1; +@collapsible-nav-current-color: @color-black; +@collapsible-nav-current-font-weight: @font-weight__semibold; +@collapsible-nav-item-hover: @color-gray91; + +// // -// Common -//-------------------------------------- +// Common +// --------------------------------------------- & when (@media-common = true) { // -// Collapsible navigation -//-------------------------------------- +// Collapsible navigation +// --------------------------------------------- + .block-collapsible-nav { .content { - padding: 15px 0; .css(background, @collapsible-nav-background); + padding: 15px 0; } .item { margin: 3px 0 0; @@ -31,11 +38,11 @@ margin-top: 0; } a, - strong { - display: block; - padding: 5px 18px 5px 15px; + > strong { border-left: 3px solid transparent; .css(color, @collapsible-nav-color); + display: block; + padding: 5px 18px 5px 15px; } a { text-decoration: none; @@ -45,15 +52,14 @@ } &.current { a, - strong { - .css(color, @collapsible-nav-current-color); + > strong { .css(border-color, @collapsible-nav-current-border-color); + .css(color, @collapsible-nav-current-color); .css(font-weight, @collapsible-nav-current-font-weight); } a { .css(border-color, @collapsible-nav-current-border-color); } - } } } @@ -61,8 +67,9 @@ } // -// Desktop -//-------------------------------------- +// Desktop +// --------------------------------------------- + .media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { .block-collapsible-nav { .title { @@ -72,13 +79,14 @@ } // -// Mobile -//-------------------------------------- +// Mobile +// --------------------------------------------- + .media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { .block-collapsible-nav { + left: 0; position: absolute; top: -21px; - left: 0; width: 100%; z-index: 5; .title { diff --git a/app/design/frontend/Magento/luma/composer.json b/app/design/frontend/Magento/luma/composer.json index e6dbafb6dcf76..2681275fa3da9 100644 --- a/app/design/frontend/Magento/luma/composer.json +++ b/app/design/frontend/Magento/luma/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/theme-frontend-blank": "0.74.0-beta9", - "magento/framework": "0.74.0-beta9", + "magento/theme-frontend-blank": "0.74.0-beta11", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/frontend/Magento/luma/web/css/source/_extends.less b/app/design/frontend/Magento/luma/web/css/source/_extends.less index 0773d6313b832..00d74dcf5d074 100644 --- a/app/design/frontend/Magento/luma/web/css/source/_extends.less +++ b/app/design/frontend/Magento/luma/web/css/source/_extends.less @@ -1334,7 +1334,14 @@ &:extend(.abs-add-box-sizing all); } input { - width: calc(~"100% - (@{icon-calendar__font-size} + @{indent__s})"); - margin-right: @indent__s; + &:extend(.abs-field-date-input); } } + +// +// Form Field Date Input +//-------------------------------------- +.abs-field-date-input { + margin-right: @indent__s; + width: calc(~"100% - (@{icon-calendar__font-size} + @{indent__s})"); +} diff --git a/app/etc/di.xml b/app/etc/di.xml index 7ffd8702c787b..00eb93bd1cc5f 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -26,7 +26,7 @@ - + @@ -128,6 +128,10 @@ + + + + @@ -216,6 +220,9 @@ MAGE + + Magento\Framework\Cache\Frontend\Decorator\Logger + Magento\Framework\App\Resource\Proxy diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index b56c8c462c334..f79da26cdc4f5 100644 --- a/app/i18n/magento/de_de/composer.json +++ b/app/i18n/magento/de_de/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-de_de", "description": "German (Germany) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "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 de176931ec16e..baa199192721c 100644 --- a/app/i18n/magento/en_us/composer.json +++ b/app/i18n/magento/en_us/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-en_us", "description": "English (United States) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "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 3099bc74a363b..0ac12ec99b9c7 100644 --- a/app/i18n/magento/es_es/composer.json +++ b/app/i18n/magento/es_es/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-es_es", "description": "Spanish (Spain) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "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 d295bc9dc50d2..1405a998e6cd1 100644 --- a/app/i18n/magento/fr_fr/composer.json +++ b/app/i18n/magento/fr_fr/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-fr_fr", "description": "French (France) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "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 bc988d58ee863..e19a85fcda550 100644 --- a/app/i18n/magento/nl_nl/composer.json +++ b/app/i18n/magento/nl_nl/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-nl_nl", "description": "Dutch (Netherlands) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "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 6b9fe7a7e4f4d..a8400bd4f372f 100644 --- a/app/i18n/magento/pt_br/composer.json +++ b/app/i18n/magento/pt_br/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-pt_br", "description": "Portuguese (Brazil) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "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 bdd085d2cc7ad..adf420e6a064f 100644 --- a/app/i18n/magento/zh_cn/composer.json +++ b/app/i18n/magento/zh_cn/composer.json @@ -1,13 +1,13 @@ { "name": "magento/language-zh_cn", "description": "Chinese (China) language", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta9", + "magento/framework": "0.74.0-beta11", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 4f1fbe0f8d7d0..eb9db275a286f 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento2ce", "description": "Magento 2 (Community Edition)", "type": "project", - "version": "0.74.0-beta9", + "version": "0.74.0-beta11", "license": [ "OSL-3.0", "AFL-3.0" @@ -73,7 +73,6 @@ "magento/module-catalog-search": "self.version", "magento/module-catalog-url-rewrite": "self.version", "magento/module-catalog-widget": "self.version", - "magento/module-centinel": "self.version", "magento/module-checkout": "self.version", "magento/module-checkout-agreements": "self.version", "magento/module-cms": "self.version", @@ -207,8 +206,7 @@ "Magento\\Tools\\": "dev/tools/Magento/Tools/", "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/", "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", - "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/", - "Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/" + "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/" } }, "minimum-stability": "alpha", diff --git a/composer.lock b/composer.lock index 0bba4a83ee70e..4c0af7bd418a6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "33ab1e2a1cf5439c8f387ec55e792a2d", + "hash": "a8044123f71c15a262e59e7addfa52ed", "packages": [ { "name": "composer/composer", @@ -480,17 +480,17 @@ }, { "name": "symfony/console", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272" + "reference": "2343f6d8026306bd330e0c987e4c102483c213e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272", - "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272", + "url": "https://api.github.com/repos/symfony/Console/zipball/2343f6d8026306bd330e0c987e4c102483c213e7", + "reference": "2343f6d8026306bd330e0c987e4c102483c213e7", "shasum": "" }, "require": { @@ -534,21 +534,21 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" + "time": "2015-05-22 14:53:08" }, { "name": "symfony/finder", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99" + "reference": "ffedd3e0ff8155188155e9322fe21b9ee012ac14" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/704c64c8b12c8882640d5c0330a8414b1e06dc99", - "reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99", + "url": "https://api.github.com/repos/symfony/Finder/zipball/ffedd3e0ff8155188155e9322fe21b9ee012ac14", + "reference": "ffedd3e0ff8155188155e9322fe21b9ee012ac14", "shasum": "" }, "require": { @@ -584,21 +584,21 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" + "time": "2015-05-15 13:32:45" }, { "name": "symfony/process", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562" + "reference": "7856d78ab6cce6e59d02d9e1a873441f6bd21306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", - "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", + "url": "https://api.github.com/repos/symfony/Process/zipball/7856d78ab6cce6e59d02d9e1a873441f6bd21306", + "reference": "7856d78ab6cce6e59d02d9e1a873441f6bd21306", "shasum": "" }, "require": { @@ -634,7 +634,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" + "time": "2015-05-15 13:32:45" }, { "name": "tubalmartin/cssmin", @@ -685,13 +685,13 @@ "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendCode.git", - "reference": "cfd5951ff4348e4430850560416c7ddb755f95d3" + "url": "https://github.com/zendframework/zend-code.git", + "reference": "0ed94f842ba60cdc900c46a61bdbd7ac95a3e140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendCode/zipball/cfd5951ff4348e4430850560416c7ddb755f95d3", - "reference": "cfd5951ff4348e4430850560416c7ddb755f95d3", + "url": "https://api.github.com/repos/zendframework/zend-code/zipball/0ed94f842ba60cdc900c46a61bdbd7ac95a3e140", + "reference": "0ed94f842ba60cdc900c46a61bdbd7ac95a3e140", "shasum": "" }, "require": { @@ -700,6 +700,9 @@ }, "require-dev": { "doctrine/common": ">=2.1", + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-stdlib": "self.version" }, "suggest": { @@ -715,7 +718,7 @@ }, "autoload": { "psr-4": { - "Zend\\Code\\": "" + "Zend\\Code\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -723,25 +726,25 @@ "BSD-3-Clause" ], "description": "provides facilities to generate arbitrary code using an object oriented interface", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-code", "keywords": [ "code", "zf2" ], - "time": "2015-04-01 17:59:08" + "time": "2015-03-31 15:39:14" }, { "name": "zendframework/zend-config", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendConfig.git", - "reference": "8682fe4e2923b383bb6472fc84b5796a07589163" + "url": "https://github.com/zendframework/zend-config.git", + "reference": "95f3a4b3fa85d49e6f060183122de4596fa6d29d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendConfig/zipball/8682fe4e2923b383bb6472fc84b5796a07589163", - "reference": "8682fe4e2923b383bb6472fc84b5796a07589163", + "url": "https://api.github.com/repos/zendframework/zend-config/zipball/95f3a4b3fa85d49e6f060183122de4596fa6d29d", + "reference": "95f3a4b3fa85d49e6f060183122de4596fa6d29d", "shasum": "" }, "require": { @@ -749,6 +752,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-filter": "self.version", "zendframework/zend-i18n": "self.version", "zendframework/zend-json": "self.version", @@ -769,7 +775,7 @@ }, "autoload": { "psr-4": { - "Zend\\Config\\": "" + "Zend\\Config\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -777,31 +783,36 @@ "BSD-3-Clause" ], "description": "provides a nested object property based user interface for accessing this configuration data within application code", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-config", "keywords": [ "config", "zf2" ], - "time": "2015-04-01 17:59:31" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-console", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendConsole.git", - "reference": "94ab6663b07e19f20b3319ecf317bd72b6a72dca" + "url": "https://github.com/zendframework/zend-console.git", + "reference": "54823d9ba6f8ce39046384ee5a043b5b3d5f56d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendConsole/zipball/94ab6663b07e19f20b3319ecf317bd72b6a72dca", - "reference": "94ab6663b07e19f20b3319ecf317bd72b6a72dca", + "url": "https://api.github.com/repos/zendframework/zend-console/zipball/54823d9ba6f8ce39046384ee5a043b5b3d5f56d7", + "reference": "54823d9ba6f8ce39046384ee5a043b5b3d5f56d7", "shasum": "" }, "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "suggest": { "zendframework/zend-filter": "To support DefaultRouteMatcher usage", "zendframework/zend-validator": "To support DefaultRouteMatcher usage" @@ -815,32 +826,32 @@ }, "autoload": { "psr-4": { - "Zend\\Console\\": "" + "Zend\\Console\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-console", "keywords": [ "console", "zf2" ], - "time": "2015-04-01 17:59:48" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-di", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendDi.git", - "reference": "0811f2a67ad0b50dfb8d602ed67cde0b82249190" + "url": "https://github.com/zendframework/zend-di.git", + "reference": "b9f8de081adecf71a003a569e9ba76c0a4c00bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendDi/zipball/0811f2a67ad0b50dfb8d602ed67cde0b82249190", - "reference": "0811f2a67ad0b50dfb8d602ed67cde0b82249190", + "url": "https://api.github.com/repos/zendframework/zend-di/zipball/b9f8de081adecf71a003a569e9ba76c0a4c00bf2", + "reference": "b9f8de081adecf71a003a569e9ba76c0a4c00bf2", "shasum": "" }, "require": { @@ -849,6 +860,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-servicemanager": "self.version" }, "suggest": { @@ -863,37 +877,42 @@ }, "autoload": { "psr-4": { - "Zend\\Di\\": "" + "Zend\\Di\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-di", "keywords": [ "di", "zf2" ], - "time": "2015-04-01 18:01:30" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-escaper", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendEscaper.git", - "reference": "65b3328627362b0be1d5e9067bc846511d1fbc96" + "url": "https://github.com/zendframework/zend-escaper.git", + "reference": "15e5769e4fcdb4bf07ebd76500810e7070e23a97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendEscaper/zipball/65b3328627362b0be1d5e9067bc846511d1fbc96", - "reference": "65b3328627362b0be1d5e9067bc846511d1fbc96", + "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/15e5769e4fcdb4bf07ebd76500810e7070e23a97", + "reference": "15e5769e4fcdb4bf07ebd76500810e7070e23a97", "shasum": "" }, "require": { "php": ">=5.3.23" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -903,38 +922,43 @@ }, "autoload": { "psr-4": { - "Zend\\Escaper\\": "" + "Zend\\Escaper\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-escaper", "keywords": [ "escaper", "zf2" ], - "time": "2015-04-01 18:02:07" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-eventmanager", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendEventManager.git", - "reference": "38df5b567d4ff4d22144745c503ba0502d0d5695" + "url": "https://github.com/zendframework/zend-eventmanager.git", + "reference": "58d21c95c7005a527262fd536499195f104e83f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendEventManager/zipball/38df5b567d4ff4d22144745c503ba0502d0d5695", - "reference": "38df5b567d4ff4d22144745c503ba0502d0d5695", + "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/58d21c95c7005a527262fd536499195f104e83f9", + "reference": "58d21c95c7005a527262fd536499195f104e83f9", "shasum": "" }, "require": { "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -944,32 +968,32 @@ }, "autoload": { "psr-4": { - "Zend\\EventManager\\": "" + "Zend\\EventManager\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-event-manager", "keywords": [ "eventmanager", "zf2" ], - "time": "2015-04-01 18:05:26" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-filter", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendFilter.git", - "reference": "b13741a88553351fc52472de529b57b580b8f6f1" + "url": "https://github.com/zendframework/zend-filter.git", + "reference": "6d8aed2da81b62a04747346c4370562cdbe34595" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/b13741a88553351fc52472de529b57b580b8f6f1", - "reference": "b13741a88553351fc52472de529b57b580b8f6f1", + "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/6d8aed2da81b62a04747346c4370562cdbe34595", + "reference": "6d8aed2da81b62a04747346c4370562cdbe34595", "shasum": "" }, "require": { @@ -977,6 +1001,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-crypt": "self.version", "zendframework/zend-servicemanager": "self.version", "zendframework/zend-uri": "self.version" @@ -996,7 +1023,7 @@ }, "autoload": { "psr-4": { - "Zend\\Filter\\": "" + "Zend\\Filter\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1004,25 +1031,25 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed data filters", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-filter", "keywords": [ "filter", "zf2" ], - "time": "2015-04-01 18:09:25" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-form", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendForm.git", - "reference": "09f5bd46ffbf783df22281898e2175b291bd43a3" + "url": "https://github.com/zendframework/zend-form.git", + "reference": "bca0db55718355d25c2c10fdd41a83561f1c94b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendForm/zipball/09f5bd46ffbf783df22281898e2175b291bd43a3", - "reference": "09f5bd46ffbf783df22281898e2175b291bd43a3", + "url": "https://api.github.com/repos/zendframework/zend-form/zipball/bca0db55718355d25c2c10fdd41a83561f1c94b3", + "reference": "bca0db55718355d25c2c10fdd41a83561f1c94b3", "shasum": "" }, "require": { @@ -1031,6 +1058,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-captcha": "self.version", "zendframework/zend-code": "self.version", "zendframework/zend-eventmanager": "self.version", @@ -1061,32 +1091,32 @@ }, "autoload": { "psr-4": { - "Zend\\Form\\": "" + "Zend\\Form\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-form", "keywords": [ "form", "zf2" ], - "time": "2015-04-01 18:09:25" + "time": "2015-03-28 20:29:18" }, { "name": "zendframework/zend-http", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendHttp.git", - "reference": "ee6220609845b32d1b2873c9ac694aef56d508f5" + "url": "https://github.com/zendframework/zend-http.git", + "reference": "9c6047a0bdb3094d3ea07a215ff929cc47de4deb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendHttp/zipball/ee6220609845b32d1b2873c9ac694aef56d508f5", - "reference": "ee6220609845b32d1b2873c9ac694aef56d508f5", + "url": "https://api.github.com/repos/zendframework/zend-http/zipball/9c6047a0bdb3094d3ea07a215ff929cc47de4deb", + "reference": "9c6047a0bdb3094d3ea07a215ff929cc47de4deb", "shasum": "" }, "require": { @@ -1096,6 +1126,11 @@ "zendframework/zend-uri": "self.version", "zendframework/zend-validator": "self.version" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -1105,7 +1140,7 @@ }, "autoload": { "psr-4": { - "Zend\\Http\\": "" + "Zend\\Http\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1113,25 +1148,25 @@ "BSD-3-Clause" ], "description": "provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-http", "keywords": [ "http", "zf2" ], - "time": "2015-04-01 18:09:25" + "time": "2015-03-27 15:46:30" }, { "name": "zendframework/zend-i18n", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendI18n.git", - "reference": "33051775d9a8c341fe3b77d1f3daa0e921e2f4bd" + "url": "https://github.com/zendframework/zend-i18n.git", + "reference": "9aebc5287373a802540d75fe5508417f866c2e52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendI18n/zipball/33051775d9a8c341fe3b77d1f3daa0e921e2f4bd", - "reference": "33051775d9a8c341fe3b77d1f3daa0e921e2f4bd", + "url": "https://api.github.com/repos/zendframework/zend-i18n/zipball/9aebc5287373a802540d75fe5508417f866c2e52", + "reference": "9aebc5287373a802540d75fe5508417f866c2e52", "shasum": "" }, "require": { @@ -1139,6 +1174,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-cache": "self.version", "zendframework/zend-config": "self.version", "zendframework/zend-eventmanager": "self.version", @@ -1167,32 +1205,32 @@ }, "autoload": { "psr-4": { - "Zend\\I18n\\": "" + "Zend\\I18n\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-i18n", "keywords": [ "i18n", "zf2" ], - "time": "2015-04-01 18:09:26" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-inputfilter", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendInputFilter.git", - "reference": "16856fec61f285e41e5492235220a4dec06ab90f" + "url": "https://github.com/zendframework/zend-inputfilter.git", + "reference": "4b1398f3635fae3cc5e873c5bb067274f3d10a93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendInputFilter/zipball/16856fec61f285e41e5492235220a4dec06ab90f", - "reference": "16856fec61f285e41e5492235220a4dec06ab90f", + "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/4b1398f3635fae3cc5e873c5bb067274f3d10a93", + "reference": "4b1398f3635fae3cc5e873c5bb067274f3d10a93", "shasum": "" }, "require": { @@ -1202,6 +1240,9 @@ "zendframework/zend-validator": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-servicemanager": "self.version" }, "suggest": { @@ -1216,32 +1257,32 @@ }, "autoload": { "psr-4": { - "Zend\\InputFilter\\": "" + "Zend\\InputFilter\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-input-filter", "keywords": [ "inputfilter", "zf2" ], - "time": "2015-04-01 18:09:26" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-json", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendJson.git", - "reference": "76aeb27e4baf39799e5ca3cf6f2fdd6748ee930c" + "url": "https://github.com/zendframework/zend-json.git", + "reference": "2d845e151c1b9a237cf1899ac31e17fb10bd1e3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendJson/zipball/76aeb27e4baf39799e5ca3cf6f2fdd6748ee930c", - "reference": "76aeb27e4baf39799e5ca3cf6f2fdd6748ee930c", + "url": "https://api.github.com/repos/zendframework/zend-json/zipball/2d845e151c1b9a237cf1899ac31e17fb10bd1e3f", + "reference": "2d845e151c1b9a237cf1899ac31e17fb10bd1e3f", "shasum": "" }, "require": { @@ -1249,6 +1290,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-http": "self.version", "zendframework/zend-server": "self.version" }, @@ -1266,7 +1310,7 @@ }, "autoload": { "psr-4": { - "Zend\\Json\\": "" + "Zend\\Json\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1274,30 +1318,35 @@ "BSD-3-Clause" ], "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-json", "keywords": [ "json", "zf2" ], - "time": "2015-04-01 18:09:26" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-loader", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendLoader.git", - "reference": "6868b8a0c346f17fb97724c3a63aa2cbf6b94865" + "url": "https://github.com/zendframework/zend-loader.git", + "reference": "65de2c7a56f8eee633c6bf1cfab73e45648880d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendLoader/zipball/6868b8a0c346f17fb97724c3a63aa2cbf6b94865", - "reference": "6868b8a0c346f17fb97724c3a63aa2cbf6b94865", + "url": "https://api.github.com/repos/zendframework/zend-loader/zipball/65de2c7a56f8eee633c6bf1cfab73e45648880d4", + "reference": "65de2c7a56f8eee633c6bf1cfab73e45648880d4", "shasum": "" }, "require": { "php": ">=5.3.23" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -1307,32 +1356,32 @@ }, "autoload": { "psr-4": { - "Zend\\Loader\\": "" + "Zend\\Loader\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-loader", "keywords": [ "loader", "zf2" ], - "time": "2015-04-01 18:09:26" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-log", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendLog.git", - "reference": "2d5d20fd45470506bdaff727c46dc25fe953146e" + "url": "https://github.com/zendframework/zend-log.git", + "reference": "002e3c810cad7e31e51c9895e9e3cb6fbd312cdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendLog/zipball/2d5d20fd45470506bdaff727c46dc25fe953146e", - "reference": "2d5d20fd45470506bdaff727c46dc25fe953146e", + "url": "https://api.github.com/repos/zendframework/zend-log/zipball/002e3c810cad7e31e51c9895e9e3cb6fbd312cdd", + "reference": "002e3c810cad7e31e51c9895e9e3cb6fbd312cdd", "shasum": "" }, "require": { @@ -1341,6 +1390,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-console": "self.version", "zendframework/zend-db": "self.version", "zendframework/zend-escaper": "self.version", @@ -1364,7 +1416,7 @@ }, "autoload": { "psr-4": { - "Zend\\Log\\": "" + "Zend\\Log\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1372,31 +1424,36 @@ "BSD-3-Clause" ], "description": "component for general purpose logging", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-log", "keywords": [ "log", "logging", "zf2" ], - "time": "2015-04-01 18:09:26" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-math", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendMath.git", - "reference": "634123f83ca90b6613f132d0d100e6b5e9890a29" + "url": "https://github.com/zendframework/zend-math.git", + "reference": "f41fe4acfd809c14f2a802d1aa45dec8fcd2cc73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendMath/zipball/634123f83ca90b6613f132d0d100e6b5e9890a29", - "reference": "634123f83ca90b6613f132d0d100e6b5e9890a29", + "url": "https://api.github.com/repos/zendframework/zend-math/zipball/f41fe4acfd809c14f2a802d1aa45dec8fcd2cc73", + "reference": "f41fe4acfd809c14f2a802d1aa45dec8fcd2cc73", "shasum": "" }, "require": { "php": ">=5.3.23" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "suggest": { "ext-bcmath": "If using the bcmath functionality", "ext-gmp": "If using the gmp functionality", @@ -1412,32 +1469,32 @@ }, "autoload": { "psr-4": { - "Zend\\Math\\": "" + "Zend\\Math\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-math", "keywords": [ "math", "zf2" ], - "time": "2015-04-01 18:09:27" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-modulemanager", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendModuleManager.git", - "reference": "cbe16b0eafe734a062ed0182381e64b9c953dccf" + "url": "https://github.com/zendframework/zend-modulemanager.git", + "reference": "af7ae3cd29a1efb73cc66ae1081e606039d5c20f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendModuleManager/zipball/cbe16b0eafe734a062ed0182381e64b9c953dccf", - "reference": "cbe16b0eafe734a062ed0182381e64b9c953dccf", + "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/af7ae3cd29a1efb73cc66ae1081e606039d5c20f", + "reference": "af7ae3cd29a1efb73cc66ae1081e606039d5c20f", "shasum": "" }, "require": { @@ -1446,6 +1503,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-config": "self.version", "zendframework/zend-console": "self.version", "zendframework/zend-loader": "self.version", @@ -1467,32 +1527,32 @@ }, "autoload": { "psr-4": { - "Zend\\ModuleManager\\": "" + "Zend\\ModuleManager\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-module-manager", "keywords": [ "modulemanager", "zf2" ], - "time": "2015-04-01 18:09:27" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-mvc", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendMvc.git", - "reference": "bfff0f5f9e4d925ee13b8c159c9d6ae7e0db5412" + "url": "https://github.com/zendframework/zend-mvc.git", + "reference": "0b4a4a829b30be510a3f215c4ff00c703ee8b431" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendMvc/zipball/bfff0f5f9e4d925ee13b8c159c9d6ae7e0db5412", - "reference": "bfff0f5f9e4d925ee13b8c159c9d6ae7e0db5412", + "url": "https://api.github.com/repos/zendframework/zend-mvc/zipball/0b4a4a829b30be510a3f215c4ff00c703ee8b431", + "reference": "0b4a4a829b30be510a3f215c4ff00c703ee8b431", "shasum": "" }, "require": { @@ -1503,6 +1563,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-authentication": "self.version", "zendframework/zend-console": "self.version", "zendframework/zend-di": "self.version", @@ -1551,32 +1614,32 @@ }, "autoload": { "psr-4": { - "Zend\\Mvc\\": "" + "Zend\\Mvc\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-mvc", "keywords": [ "mvc", "zf2" ], - "time": "2015-04-01 18:09:27" + "time": "2015-03-26 18:55:14" }, { "name": "zendframework/zend-serializer", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendSerializer.git", - "reference": "a46960854d6326f0036d98c9abc7a79e36e25928" + "url": "https://github.com/zendframework/zend-serializer.git", + "reference": "3c531789a9882a5deb721356a7bd2642b65d4b09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendSerializer/zipball/a46960854d6326f0036d98c9abc7a79e36e25928", - "reference": "a46960854d6326f0036d98c9abc7a79e36e25928", + "url": "https://api.github.com/repos/zendframework/zend-serializer/zipball/3c531789a9882a5deb721356a7bd2642b65d4b09", + "reference": "3c531789a9882a5deb721356a7bd2642b65d4b09", "shasum": "" }, "require": { @@ -1586,6 +1649,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-servicemanager": "self.version" }, "suggest": { @@ -1600,7 +1666,7 @@ }, "autoload": { "psr-4": { - "Zend\\Serializer\\": "" + "Zend\\Serializer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1608,25 +1674,25 @@ "BSD-3-Clause" ], "description": "provides an adapter based interface to simply generate storable representation of PHP types by different facilities, and recover", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-serializer", "keywords": [ "serializer", "zf2" ], - "time": "2015-04-01 18:09:28" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-server", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendServer.git", - "reference": "fc73c34490908ba143af3c57c7e166b40c4b9f8e" + "url": "https://github.com/zendframework/zend-server.git", + "reference": "d11ff0bd529d202022823d4accf5983cbd50fc49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendServer/zipball/fc73c34490908ba143af3c57c7e166b40c4b9f8e", - "reference": "fc73c34490908ba143af3c57c7e166b40c4b9f8e", + "url": "https://api.github.com/repos/zendframework/zend-server/zipball/d11ff0bd529d202022823d4accf5983cbd50fc49", + "reference": "d11ff0bd529d202022823d4accf5983cbd50fc49", "shasum": "" }, "require": { @@ -1634,6 +1700,11 @@ "zendframework/zend-code": "self.version", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -1643,38 +1714,41 @@ }, "autoload": { "psr-4": { - "Zend\\Server\\": "" + "Zend\\Server\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-server", "keywords": [ "server", "zf2" ], - "time": "2015-04-01 18:09:28" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-servicemanager", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendServiceManager.git", - "reference": "d3c27c708a148a30608f313a5b7a61a531bd9cb9" + "url": "https://github.com/zendframework/zend-servicemanager.git", + "reference": "57cf99fa5ac08c05a135a8d0d676c52a5e450083" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/d3c27c708a148a30608f313a5b7a61a531bd9cb9", - "reference": "d3c27c708a148a30608f313a5b7a61a531bd9cb9", + "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/57cf99fa5ac08c05a135a8d0d676c52a5e450083", + "reference": "57cf99fa5ac08c05a135a8d0d676c52a5e450083", "shasum": "" }, "require": { "php": ">=5.3.23" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-di": "self.version" }, "suggest": { @@ -1690,32 +1764,32 @@ }, "autoload": { "psr-4": { - "Zend\\ServiceManager\\": "" + "Zend\\ServiceManager\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-service-manager", "keywords": [ "servicemanager", "zf2" ], - "time": "2015-04-01 18:09:28" + "time": "2015-03-23 18:29:14" }, { "name": "zendframework/zend-soap", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendSoap.git", - "reference": "e42b900798ea95a9063fa4922da976d8b3a8ab6f" + "url": "https://github.com/zendframework/zend-soap.git", + "reference": "a599463aba97ce247faf3fb443e3c7858b46449b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendSoap/zipball/e42b900798ea95a9063fa4922da976d8b3a8ab6f", - "reference": "e42b900798ea95a9063fa4922da976d8b3a8ab6f", + "url": "https://api.github.com/repos/zendframework/zend-soap/zipball/a599463aba97ce247faf3fb443e3c7858b46449b", + "reference": "a599463aba97ce247faf3fb443e3c7858b46449b", "shasum": "" }, "require": { @@ -1725,6 +1799,9 @@ "zendframework/zend-uri": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-http": "self.version" }, "suggest": { @@ -1739,38 +1816,41 @@ }, "autoload": { "psr-4": { - "Zend\\Soap\\": "" + "Zend\\Soap\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-soap", "keywords": [ "soap", "zf2" ], - "time": "2015-04-01 18:09:29" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-stdlib", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendStdlib.git", - "reference": "eab586f4c18af3fa63c977611939f1f4a3cf1030" + "url": "https://github.com/zendframework/zend-stdlib.git", + "reference": "cf05c5ba75606e47ffee91cedc72778da46f74c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/eab586f4c18af3fa63c977611939f1f4a3cf1030", - "reference": "eab586f4c18af3fa63c977611939f1f4a3cf1030", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cf05c5ba75606e47ffee91cedc72778da46f74c3", + "reference": "cf05c5ba75606e47ffee91cedc72778da46f74c3", "shasum": "" }, "require": { "php": ">=5.3.23" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-eventmanager": "self.version", "zendframework/zend-filter": "self.version", "zendframework/zend-serializer": "self.version", @@ -1791,32 +1871,32 @@ }, "autoload": { "psr-4": { - "Zend\\Stdlib\\": "" + "Zend\\Stdlib\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-stdlib", "keywords": [ "stdlib", "zf2" ], - "time": "2015-04-01 18:09:29" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-text", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendText.git", - "reference": "35f519e20e575a331c2ee554e5a555a59ce4b9e2" + "url": "https://github.com/zendframework/zend-text.git", + "reference": "d962ea25647b20527f3ca34ae225bbc885dabfc7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendText/zipball/35f519e20e575a331c2ee554e5a555a59ce4b9e2", - "reference": "35f519e20e575a331c2ee554e5a555a59ce4b9e2", + "url": "https://api.github.com/repos/zendframework/zend-text/zipball/d962ea25647b20527f3ca34ae225bbc885dabfc7", + "reference": "d962ea25647b20527f3ca34ae225bbc885dabfc7", "shasum": "" }, "require": { @@ -1824,6 +1904,11 @@ "zendframework/zend-servicemanager": "self.version", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -1833,32 +1918,32 @@ }, "autoload": { "psr-4": { - "Zend\\Text\\": "" + "Zend\\Text\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-text", "keywords": [ "text", "zf2" ], - "time": "2015-04-01 18:09:29" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-uri", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendUri.git", - "reference": "53f5b162b293f80de8b951eece8e08be83c4fe16" + "url": "https://github.com/zendframework/zend-uri.git", + "reference": "bd9e625639415376f6a82551c73328448d7bc7d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendUri/zipball/53f5b162b293f80de8b951eece8e08be83c4fe16", - "reference": "53f5b162b293f80de8b951eece8e08be83c4fe16", + "url": "https://api.github.com/repos/zendframework/zend-uri/zipball/bd9e625639415376f6a82551c73328448d7bc7d1", + "reference": "bd9e625639415376f6a82551c73328448d7bc7d1", "shasum": "" }, "require": { @@ -1866,6 +1951,11 @@ "zendframework/zend-escaper": "self.version", "zendframework/zend-validator": "self.version" }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master" + }, "type": "library", "extra": { "branch-alias": { @@ -1875,7 +1965,7 @@ }, "autoload": { "psr-4": { - "Zend\\Uri\\": "" + "Zend\\Uri\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1883,25 +1973,25 @@ "BSD-3-Clause" ], "description": "a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-uri", "keywords": [ "uri", "zf2" ], - "time": "2015-04-01 18:09:29" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-validator", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendValidator.git", - "reference": "eb678d20256f120a72ca27276bbb2875841701ab" + "url": "https://github.com/zendframework/zend-validator.git", + "reference": "45fac2545a0f2eb66d71cb7966feee481e7c475f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendValidator/zipball/eb678d20256f120a72ca27276bbb2875841701ab", - "reference": "eb678d20256f120a72ca27276bbb2875841701ab", + "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/45fac2545a0f2eb66d71cb7966feee481e7c475f", + "reference": "45fac2545a0f2eb66d71cb7966feee481e7c475f", "shasum": "" }, "require": { @@ -1909,6 +1999,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-db": "self.version", "zendframework/zend-filter": "self.version", "zendframework/zend-i18n": "self.version", @@ -1936,7 +2029,7 @@ }, "autoload": { "psr-4": { - "Zend\\Validator\\": "" + "Zend\\Validator\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1944,25 +2037,25 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed validators", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-validator", "keywords": [ "validator", "zf2" ], - "time": "2015-04-01 18:09:30" + "time": "2015-03-25 20:55:48" }, { "name": "zendframework/zend-view", "version": "2.4.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendView.git", - "reference": "e119b4b5f082af58a96eb206e782b62c193227bf" + "url": "https://github.com/zendframework/zend-view.git", + "reference": "37beb1ad46e530f627b4b6c3716efd728e976ba9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendView/zipball/e119b4b5f082af58a96eb206e782b62c193227bf", - "reference": "e119b4b5f082af58a96eb206e782b62c193227bf", + "url": "https://api.github.com/repos/zendframework/zend-view/zipball/37beb1ad46e530f627b4b6c3716efd728e976ba9", + "reference": "37beb1ad46e530f627b4b6c3716efd728e976ba9", "shasum": "" }, "require": { @@ -1972,6 +2065,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-authentication": "self.version", "zendframework/zend-escaper": "self.version", "zendframework/zend-feed": "self.version", @@ -2010,7 +2106,7 @@ }, "autoload": { "psr-4": { - "Zend\\View\\": "" + "Zend\\View\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2018,12 +2114,12 @@ "BSD-3-Clause" ], "description": "provides a system of helpers, output filters, and variable escaping", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-view", "keywords": [ "view", "zf2" ], - "time": "2015-04-01 18:09:30" + "time": "2015-03-25 20:55:48" } ], "packages-dev": [ @@ -2083,16 +2179,16 @@ }, { "name": "fabpot/php-cs-fixer", - "version": "v1.8", + "version": "v1.8.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "93c723fe0c50ed54292006e7249a4c1173cf5847" + "reference": "c1e28e95a978e967dade5469a4bf88162faa67bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/93c723fe0c50ed54292006e7249a4c1173cf5847", - "reference": "93c723fe0c50ed54292006e7249a4c1173cf5847", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c1e28e95a978e967dade5469a4bf88162faa67bf", + "reference": "c1e28e95a978e967dade5469a4bf88162faa67bf", "shasum": "" }, "require": { @@ -2133,7 +2229,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2015-05-04 17:06:20" + "time": "2015-05-29 06:10:12" }, { "name": "league/climate", @@ -2287,20 +2383,20 @@ }, { "name": "phpmd/phpmd", - "version": "2.2.2", + "version": "2.2.3", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "7dc4a6b5c07b119ab5da7960b56303fa6855eb84" + "reference": "5eeb5a4d39c8304910b33ae49f8813905346cc35" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/7dc4a6b5c07b119ab5da7960b56303fa6855eb84", - "reference": "7dc4a6b5c07b119ab5da7960b56303fa6855eb84", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/5eeb5a4d39c8304910b33ae49f8813905346cc35", + "reference": "5eeb5a4d39c8304910b33ae49f8813905346cc35", "shasum": "" }, "require": { - "pdepend/pdepend": "2.0.*", + "pdepend/pdepend": "~2.0", "php": ">=5.3.0", "symfony/config": ">=2.4", "symfony/dependency-injection": ">=2.4", @@ -2345,20 +2441,20 @@ "phpmd", "pmd" ], - "time": "2015-03-26 07:47:05" + "time": "2015-05-27 18:16:57" }, { "name": "phpunit/php-code-coverage", - "version": "2.0.16", + "version": "2.0.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c" + "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c", - "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3", + "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3", "shasum": "" }, "require": { @@ -2407,7 +2503,7 @@ "testing", "xunit" ], - "time": "2015-04-11 04:35:00" + "time": "2015-05-25 05:11:59" }, { "name": "phpunit/php-file-iterator", @@ -2667,16 +2763,16 @@ }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.1", + "version": "2.3.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "74ffb87f527f24616f72460e54b595f508dccb5c" + "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", - "reference": "74ffb87f527f24616f72460e54b595f508dccb5c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7", + "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7", "shasum": "" }, "require": { @@ -2718,7 +2814,7 @@ "mock", "xunit" ], - "time": "2015-04-02 05:36:41" + "time": "2015-05-29 05:19:18" }, { "name": "sebastian/comparator", @@ -3170,17 +3266,17 @@ }, { "name": "symfony/config", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25" + "reference": "2696c5bc7c31485a482c10865d713de9fcc7aa31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25", - "reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25", + "url": "https://api.github.com/repos/symfony/Config/zipball/2696c5bc7c31485a482c10865d713de9fcc7aa31", + "reference": "2696c5bc7c31485a482c10865d713de9fcc7aa31", "shasum": "" }, "require": { @@ -3217,21 +3313,21 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" + "time": "2015-05-15 13:32:45" }, { "name": "symfony/dependency-injection", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "b575c160af001d3525ee733085bcc4ec7c8e1b51" + "reference": "d244c4e3ee9caf6d9aa34c77aaa6f0e0da8904be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/b575c160af001d3525ee733085bcc4ec7c8e1b51", - "reference": "b575c160af001d3525ee733085bcc4ec7c8e1b51", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/d244c4e3ee9caf6d9aa34c77aaa6f0e0da8904be", + "reference": "d244c4e3ee9caf6d9aa34c77aaa6f0e0da8904be", "shasum": "" }, "require": { @@ -3278,11 +3374,11 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" + "time": "2015-05-12 14:25:36" }, { "name": "symfony/event-dispatcher", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", @@ -3341,17 +3437,17 @@ }, { "name": "symfony/filesystem", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde" + "reference": "1f8429f72a5bfa58b33fd96824bea146fc4b3f49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/f73904bd2dae525c42ea1f0340c7c98480ecacde", - "reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/1f8429f72a5bfa58b33fd96824bea146fc4b3f49", + "reference": "1f8429f72a5bfa58b33fd96824bea146fc4b3f49", "shasum": "" }, "require": { @@ -3387,11 +3483,11 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-05-08 00:09:07" + "time": "2015-05-15 13:32:45" }, { "name": "symfony/stopwatch", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Stopwatch", "source": { "type": "git", @@ -3441,7 +3537,7 @@ }, { "name": "symfony/yaml", - "version": "v2.6.7", + "version": "v2.6.8", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", @@ -3497,7 +3593,6 @@ "phpmd/phpmd": 0 }, "prefer-stable": true, - "prefer-lowest": false, "platform": { "php": "~5.5.0|~5.6.0" }, diff --git a/dev/shell/cron.sh b/dev/shell/cron.sh deleted file mode 100755 index 08613ffb25c41..0000000000000 --- a/dev/shell/cron.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Copyright © 2015 Magento. All rights reserved. -# See COPYING.txt for license details. -# location of the php binary -if [ ! "$1" = "" ] ; then -CRONSCRIPT=$1 -else -CRONSCRIPT=pub/cron.php -fi - -PHP_BIN=`which php` - -# absolute path to magento installation -INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'`"../../" - -# prepend the intallation path if not given an absolute path -if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then - if ! ps auxwww | grep "$INSTALLDIR""$CRONSCRIPT" | grep -v grep 1>/dev/null 2>/dev/null ; then - $PHP_BIN "$INSTALLDIR""$CRONSCRIPT" & - fi -else - if ! ps auxwww | grep " $CRONSCRIPT" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then - $PHP_BIN $CRONSCRIPT & - fi -fi diff --git a/dev/tests/api-functional/config/install-config-mysql.php.dist b/dev/tests/api-functional/config/install-config-mysql.php.dist index 535cfb7232e8f..2f19ce10e8050 100644 --- a/dev/tests/api-functional/config/install-config-mysql.php.dist +++ b/dev/tests/api-functional/config/install-config-mysql.php.dist @@ -9,22 +9,22 @@ return [ 'language' => 'en_US', 'timezone' => 'America/Los_Angeles', 'currency' => 'USD', - 'db_host' => 'localhost', - 'db_name' => 'magento_functional_tests', - 'db_user' => 'root', - 'db_password' => '', - 'backend_frontname' => 'backend', - 'base_url' => 'http://localhost/', - 'use_secure' => '0', - 'use_rewrites' => '0', - 'admin_lastname' => 'Admin', - 'admin_firstname' => 'Admin', - 'admin_email' => 'admin@example.com', - 'admin_user' => 'admin', - 'admin_password' => '123123q', - 'admin_use_security_key' => '0', + 'db-host' => 'localhost', + 'db-name' => 'magento_functional_tests', + 'db-user' => 'root', + 'db-password' => '', + 'backend-frontname' => 'backend', + 'base-url' => 'http://localhost/', + 'use-secure' => '0', + 'use-rewrites' => '0', + 'admin-lastname' => 'Admin', + 'admin-firstname' => 'Admin', + 'admin-email' => 'admin@example.com', + 'admin-user' => 'admin', + 'admin-password' => '123123q', + 'admin-use-security-key' => '0', /* PayPal has limitation for order number - 20 characters. 10 digits prefix + 8 digits number is good enough */ - 'sales_order_increment_prefix' => time(), - 'session_save' => 'db', - 'cleanup_database' => true, + 'sales-order-increment-prefix' => time(), + 'session-save' => 'db', + 'cleanup-database' => true, ]; diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php index e7151d3a15aff..d59fc83193eb2 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/OauthHelper.php @@ -36,8 +36,8 @@ public static function getConsumerCredentials($date = null) { $integration = self::_createIntegration('all'); $objectManager = Bootstrap::getObjectManager(); - /** @var $oauthService \Magento\Integration\Service\V1\Oauth */ - $oauthService = $objectManager->get('Magento\Integration\Service\V1\Oauth'); + /** @var $oauthService \Magento\Integration\Api\OauthServiceInterface */ + $oauthService = $objectManager->get('Magento\Integration\Api\OauthServiceInterface'); $consumer = $oauthService->loadConsumer($integration->getConsumerId()); $url = TESTS_BASE_URL; $consumer->setCallbackUrl($url); @@ -111,8 +111,8 @@ public static function getApiAccessCredentials($resources = null, Integration $i if (!self::$_apiCredentials) { $integration = $integrationModel === null ? self::_createIntegration($resources) : $integrationModel; $objectManager = Bootstrap::getObjectManager(); - /** @var \Magento\Integration\Service\V1\Oauth $oauthService */ - $oauthService = $objectManager->get('Magento\Integration\Service\V1\Oauth'); + /** @var \Magento\Integration\Api\OauthServiceInterface $oauthService */ + $oauthService = $objectManager->get('Magento\Integration\Api\OauthServiceInterface'); $oauthService->createAccessToken($integration->getConsumerId()); $accessToken = $oauthService->getAccessToken($integration->getConsumerId()); if (!$accessToken) { @@ -175,8 +175,8 @@ protected static function _rmRecursive($dir, $doSaveRoot = false) protected static function _createIntegration($resources) { $objectManager = Bootstrap::getObjectManager(); - /** @var $integrationService \Magento\Integration\Service\V1\IntegrationInterface */ - $integrationService = $objectManager->get('Magento\Integration\Service\V1\IntegrationInterface'); + /** @var $integrationService \Magento\Integration\Api\IntegrationServiceInterface */ + $integrationService = $objectManager->get('Magento\Integration\Api\IntegrationServiceInterface'); $params = ['name' => 'Integration' . microtime()]; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php index f39b0c78f14d9..d022864b2b9c7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php @@ -6,6 +6,7 @@ */ namespace Magento\Catalog\Api; +use Magento\Framework\Api\Data\ImageContentInterface; use Magento\TestFramework\Helper\Bootstrap; class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestFramework\TestCase\WebapiAbstract @@ -110,9 +111,9 @@ public function testCreate() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image' + ImageContentInterface::BASE64_ENCODED_DATA => base64_encode(file_get_contents($this->testImagePath)), + ImageContentInterface::TYPE => 'image/jpeg', + ImageContentInterface::NAME => 'test_image.jpg' ] ]; @@ -142,9 +143,9 @@ public function testCreateWithNotDefaultStoreId() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', + 'base64_encoded_data' => base64_encode(file_get_contents($this->testImagePath)), + 'type' => 'image/jpeg', + 'name' => 'test_image.jpg', ] ]; @@ -283,9 +284,9 @@ public function testCreateThrowsExceptionIfThereIsNoStoreWithProvidedStoreId() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', + 'base64_encoded_data' => base64_encode(file_get_contents($this->testImagePath)), + 'type' => 'image/jpeg', + 'name' => 'test_image.jpg', ] ]; @@ -307,9 +308,9 @@ public function testCreateThrowsExceptionIfProvidedContentIsNotBase64Encoded() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => $encodedContent, - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', + 'base64_encoded_data' => $encodedContent, + 'type' => 'image/jpeg', + 'name' => 'test_image.jpg', ] ]; @@ -331,9 +332,9 @@ public function testCreateThrowsExceptionIfProvidedContentIsNotAnImage() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => $encodedContent, - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', + 'base64_encoded_data' => $encodedContent, + 'type' => 'image/jpeg', + 'name' => 'test_image.jpg', ] ]; @@ -355,9 +356,9 @@ public function testCreateThrowsExceptionIfProvidedImageHasWrongMimeType() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => $encodedContent, - 'mime_type' => 'wrong_mime_type', - 'name' => 'test_image', + 'base64_encoded_data' => $encodedContent, + 'type' => 'wrong_mime_type', + 'name' => 'test_image.jpg', ] ]; @@ -379,9 +380,9 @@ public function testCreateThrowsExceptionIfTargetProductDoesNotExist() 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', + 'base64_encoded_data' => base64_encode(file_get_contents($this->testImagePath)), + 'type' => 'image/jpeg', + 'name' => 'test_image.jpg', ] ]; @@ -402,8 +403,8 @@ public function testCreateThrowsExceptionIfProvidedImageNameContainsForbiddenCha 'types' => ['image'], 'disabled' => false, 'content' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', + 'base64_encoded_data' => base64_encode(file_get_contents($this->testImagePath)), + 'type' => 'image/jpeg', 'name' => 'test/\\{}|:"<>', // Cannot contain \ / : * ? " < > | ] ]; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php index a0f06e0ce7aac..5472f12af1b2b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php @@ -314,8 +314,8 @@ public function testProductWithMediaGallery() $testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg'; $encodedImage = base64_encode(file_get_contents($testImagePath)); //create a product with media gallery - $filename1 = 'tiny1' . time(); - $filename2 = 'tiny2' . time(); + $filename1 = 'tiny1' . time() . '.jpg'; + $filename2 = 'tiny2' . time() . '.jpeg'; $productData = $this->getSimpleProductData(); $productData['media_gallery_entries'] = [ [ @@ -324,9 +324,9 @@ public function testProductWithMediaGallery() 'label' => 'tiny1', 'types' => [], 'content' => [ - 'mime_type' => 'image/jpeg', + 'type' => 'image/jpeg', 'name' => $filename1, - 'entry_data' => $encodedImage, + 'base64_encoded_data' => $encodedImage, ] ], [ @@ -335,9 +335,9 @@ public function testProductWithMediaGallery() 'label' => 'tiny2', 'types' => ['image', 'small_image'], 'content' => [ - 'mime_type' => 'image/jpeg', + 'type' => 'image/jpeg', 'name' => $filename2, - 'entry_data' => $encodedImage, + 'base64_encoded_data' => $encodedImage, ] ], ]; @@ -355,14 +355,14 @@ public function testProductWithMediaGallery() 'position' => 1, 'disabled' => true, 'types' => [], - 'file' => '/t/i/' . $filename1 . '.jpg', + 'file' => '/t/i/' . $filename1, ], [ 'label' => 'tiny2', 'position' => 2, 'disabled' => false, 'types' => ['image', 'small_image'], - 'file' => '/t/i/' . $filename2 . '.jpg', + 'file' => '/t/i/' . $filename2, ], ]; $this->assertEquals($expectedValue, $mediaGalleryEntries); @@ -374,7 +374,7 @@ public function testProductWithMediaGallery() 'position' => 1, 'disabled' => false, 'types' => ['image', 'small_image'], - 'file' => '/t/i/' . $filename1 . '.jpg', + 'file' => '/t/i/' . $filename1, ], ]; $response = $this->updateProduct($response); @@ -387,7 +387,7 @@ public function testProductWithMediaGallery() 'position' => 1, 'disabled' => false, 'types' => ['image', 'small_image'], - 'file' => '/t/i/' . $filename1 . '.jpg', + 'file' => '/t/i/' . $filename1, ] ]; $this->assertEquals($expectedValue, $mediaGalleryEntries); diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php new file mode 100644 index 0000000000000..79bd2d5ed3d2f --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php @@ -0,0 +1,276 @@ +accountManagement = Bootstrap::getObjectManager()->get( + 'Magento\Customer\Api\AccountManagementInterface' + ); + + $this->customerHelper = new CustomerHelper(); + + $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( + 'Magento\Framework\Reflection\DataObjectProcessor' + ); + + $this->imageFactory = Bootstrap::getObjectManager()->get('Magento\Framework\Api\ImageContentFactory'); + + $this->fileSystem = Bootstrap::getObjectManager()->get('Magento\Framework\Filesystem'); + } + + public function tearDown() + { + if (!empty($this->currentCustomerId)) { + foreach ($this->currentCustomerId as $customerId) { + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $customerId, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE, + ], + 'soap' => [ + 'service' => CustomerRepositoryTest::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => CustomerRepositoryTest::SERVICE_NAME . 'DeleteById', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, ['customerId' => $customerId]); + + $this->assertTrue($response); + } + } + unset($this->accountManagement); + $mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA); + $mediaDirectory->delete(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); + } + + /** + * Create customer with a sample image file + */ + protected function createCustomerWithDefaultImageAttribute() + { + $testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg'; + $imageData = base64_encode(file_get_contents($testImagePath)); + $image = $this->imageFactory->create() + ->setType('image/jpeg') + ->setName('sample.jpeg') + ->setBase64EncodedData($imageData); + + $imageData = $this->dataObjectProcessor->buildOutputDataArray( + $image, + '\Magento\Framework\Api\Data\ImageContentInterface' + ); + return $this->createCustomerWithImageAttribute($imageData); + } + + /** + * Create customer with image attribute + * + * @param array $imageData + * @return array Customer data as array + */ + protected function createCustomerWithImageAttribute($imageData) + { + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'CreateAccount', + ], + ]; + + $customerData = $this->customerHelper->createSampleCustomerDataObject(); + + $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); + $customerDataArray['custom_attributes'][] = [ + 'attribute_code' => 'customer_image', + 'value' => $imageData, + ]; + $requestData = [ + 'customer' => $customerDataArray, + 'password' => \Magento\TestFramework\Helper\Customer::PASSWORD + ]; + $customerData = $this->_webApiCall($serviceInfo, $requestData); + + return $customerData; + } + + protected function verifyImageAttribute($customAttributeArray, $expectedFileName) + { + $imageAttributeFound = false; + foreach ($customAttributeArray as $customAttribute) { + if ($customAttribute[AttributeValue::ATTRIBUTE_CODE] == 'customer_image') { + $this->assertContains($expectedFileName, $customAttribute[AttributeValue::VALUE]); + $mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA); + $customerMediaPath = $mediaDirectory->getAbsolutePath(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); + $imageAttributeFound = file_exists($customerMediaPath . $customAttribute[AttributeValue::VALUE]); + $this->assertTrue($imageAttributeFound, 'Expected file was not created'); + } + } + if (!$imageAttributeFound) { + $this->fail('Expected image attribute missing.'); + } + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php + */ + public function testCreateCustomerWithImageAttribute() + { + $customerData = $this->createCustomerWithDefaultImageAttribute(); + $this->currentCustomerId[] = $customerData['id']; + $this->verifyImageAttribute($customerData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES], 'sample.jpeg'); + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php + */ + public function testCreateCustomerWithInvalidImageAttribute() + { + $image = $this->imageFactory->create() + ->setType('image/jpeg') + ->setName('sample.jpeg') + ->setBase64EncodedData('INVALID_IMAGE_DATA'); + + $imageData = $this->dataObjectProcessor->buildOutputDataArray( + $image, + '\Magento\Framework\Api\Data\ImageContentInterface' + ); + $expectedMessage = 'The image content must be valid base64 encoded data.'; + try { + $this->createCustomerWithImageAttribute($imageData); + } catch (\SoapFault $e) { + $this->assertContains( + $expectedMessage, + $e->getMessage(), + "Exception message does not match" + ); + } catch (\Exception $e) { + $errorObj = $this->processRestExceptionResult($e); + $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals(HTTPExceptionCodes::HTTP_BAD_REQUEST, $e->getCode()); + } + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php + */ + public function testUpdateCustomerWithImageAttribute() + { + $customerDataArray = $this->createCustomerWithDefaultImageAttribute(); + $previousCustomerData = $customerDataArray; + + $testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'buttons.png'; + $imageData = base64_encode(file_get_contents($testImagePath)); + $image = $this->imageFactory->create() + ->setType('image/png') + ->setName('buttons.png') + ->setBase64EncodedData($imageData); + $imageData = $this->dataObjectProcessor->buildOutputDataArray( + $image, + '\Magento\Framework\Api\Data\ImageContentInterface' + ); + + //Replace image attribute + $customerDataArray['custom_attributes'][1] = [ + 'attribute_code' => 'customer_image', + 'value' => $imageData, + ]; + $requestData = [ + 'customer' => $customerDataArray, + 'password' => \Magento\TestFramework\Helper\Customer::PASSWORD + ]; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . "/{$customerDataArray[CustomerInterface::ID]}", + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, + ], + 'soap' => [ + 'service' => 'customerCustomerRepositoryV1', + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => 'customerCustomerRepositoryV1Save', + ], + ]; + $customerData = $this->_webApiCall($serviceInfo, $requestData); + $this->verifyImageAttribute($customerData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES], 'buttons.png'); + + //Verify that the previous image is deleted + $mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA); + $customerMediaPath = $mediaDirectory->getAbsolutePath(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER); + $previousImagePath = + $previousCustomerData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES][1][AttributeValue::VALUE]; + $this->assertFalse(file_exists($customerMediaPath . $previousImagePath)); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php index f45db3e964533..5eaefa8effba4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php @@ -272,6 +272,7 @@ protected function getFirstFixtureAddressData() 'default_shipping' => true, 'customer_id' => '1', 'region' => ['region' => 'Alabama', 'region_id' => 1, 'region_code' => 'AL'], + 'region_id' => 1, ]; } @@ -295,6 +296,7 @@ protected function getSecondFixtureAddressData() 'default_shipping' => false, 'customer_id' => '1', 'region' => ['region' => 'Alabama', 'region_id' => 1, 'region_code' => 'AL'], + 'region_id' => 1, ]; } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index 998e7414785ea..e1cbe53152c37 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -747,6 +747,7 @@ protected function getFirstFixtureAddressData() 'default_shipping' => true, 'customer_id' => '1', 'region' => ['region' => 'Alabama', 'region_id' => 1, 'region_code' => 'AL'], + 'region_id' => 1, ]; } } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php index 22958a4c00f49..3413a3a671867 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php @@ -141,6 +141,7 @@ protected function getFirstFixtureAddressData() 'default_shipping' => true, 'customer_id' => '1', 'region' => ['region' => 'Alabama', 'region_id' => 1, 'region_code' => 'AL'], + 'region_id' => 1, ]; } @@ -164,6 +165,7 @@ protected function getSecondFixtureAddressData() 'default_shipping' => false, 'customer_id' => '1', 'region' => ['region' => 'Alabama', 'region_id' => 1, 'region_code' => 'AL'], + 'region_id' => 1, ]; } } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/_files/buttons.png b/dev/tests/api-functional/testsuite/Magento/Customer/Api/_files/buttons.png new file mode 100644 index 0000000000000..1e53560e0aa7b Binary files /dev/null and b/dev/tests/api-functional/testsuite/Magento/Customer/Api/_files/buttons.png differ diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/_files/test_image.jpg b/dev/tests/api-functional/testsuite/Magento/Customer/Api/_files/test_image.jpg new file mode 100644 index 0000000000000..ed6e4decf1509 Binary files /dev/null and b/dev/tests/api-functional/testsuite/Magento/Customer/Api/_files/test_image.jpg differ diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php index 656da53f38e84..4c6ff5ed4465b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php @@ -920,26 +920,12 @@ public function getListForAbsentProductProvider() ] ]; - $sampleExpectation = [ - 'fields' => [ - 'title' => 'Downloadable Product Sample Title', - 'sort_order' => 0, - 'sample_file' => '/f/u/jellyfish_1_4.jpg', - 'sample_type' => 'file' - ] - ]; - return [ 'links' => [ '/downloadable-links', - 'GetLinks', + 'GetList', $linkExpectation, ], - 'samples' => [ - '/downloadable-links/samples', - 'GetSamples', - $sampleExpectation, - ], ]; } } diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php index 0a1bba69a8989..dfd7ee356eb76 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php @@ -515,4 +515,56 @@ public function testDeleteThrowsExceptionIfThereIsNoDownloadableSampleWithGivenI $this->_webApiCall($this->deleteServiceInfo, $requestData); } + + /** + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable_with_files.php + * @dataProvider getListForAbsentProductProvider + */ + public function testGetList($urlTail, $method, $expectations) + { + $sku = 'downloadable-product'; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/products/' . $sku . $urlTail, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => 'downloadableSampleRepositoryV1', + 'serviceVersion' => 'V1', + 'operation' => 'downloadableSampleRepositoryV1' . $method, + ], + ]; + + $requestData = ['sku' => $sku]; + + $list = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertEquals(1, count($list)); + + $link = reset($list); + foreach ($expectations['fields'] as $index => $value) { + $this->assertEquals($value, $link[$index]); + } + } + + public function getListForAbsentProductProvider() + { + $sampleExpectation = [ + 'fields' => [ + 'title' => 'Downloadable Product Sample Title', + 'sort_order' => 0, + 'sample_file' => '/f/u/jellyfish_1_4.jpg', + 'sample_type' => 'file' + ] + ]; + + return [ + 'samples' => [ + '/downloadable-links/samples', + 'GetList', + $sampleExpectation, + ], + ]; + } } diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php similarity index 95% rename from dev/tests/api-functional/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php index 8fbb4d0ed2786..6710e3ee8084b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Framework\Exception\InputException; use Magento\Integration\Model\Oauth\Token as TokenModel; @@ -14,7 +14,7 @@ use Magento\Framework\Webapi\Exception as HTTPExceptionCodes; /** - * api-functional test for \Magento\Integration\Service\V1\AdminTokenService. + * api-functional test for \Magento\Integration\Model\AdminTokenService. */ class AdminTokenServiceTest extends WebapiAbstract { @@ -24,7 +24,7 @@ class AdminTokenServiceTest extends WebapiAbstract const RESOURCE_PATH_CUSTOMER_TOKEN = "/V1/integration/customer/token"; /** - * @var AdminTokenServiceInterface + * @var \Magento\Integration\Api\AdminTokenServiceInterface */ private $tokenService; @@ -44,7 +44,7 @@ class AdminTokenServiceTest extends WebapiAbstract public function setUp() { $this->_markTestAsRestOnly(); - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Model\AdminTokenService'); $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); } diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php similarity index 96% rename from dev/tests/api-functional/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php rename to dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php index 021c102a19d25..5e31104da1607 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Customer\Api\AccountManagementInterface; use Magento\Framework\Exception\InputException; @@ -15,7 +15,7 @@ use Magento\Framework\Webapi\Exception as HTTPExceptionCodes; /** - * api-functional test for \Magento\Integration\Service\V1\CustomerTokenService. + * api-functional test for \Magento\Integration\Model\CustomerTokenService. */ class CustomerTokenServiceTest extends WebapiAbstract { @@ -50,7 +50,7 @@ class CustomerTokenServiceTest extends WebapiAbstract public function setUp() { $this->_markTestAsRestOnly(); - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\CustomerTokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Model\CustomerTokenService'); $this->customerAccountManagement = Bootstrap::getObjectManager()->get( 'Magento\Customer\Api\AccountManagementInterface' ); diff --git a/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php b/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php index 40df513266184..6fd8259d418b2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php @@ -17,8 +17,8 @@ class IntegrationTest extends \Magento\TestFramework\TestCase\WebapiAbstract protected function setUp() { $objectManager = Bootstrap::getObjectManager(); - /** @var $integrationService \Magento\Integration\Service\V1\IntegrationInterface */ - $integrationService = $objectManager->get('Magento\Integration\Service\V1\IntegrationInterface'); + /** @var $integrationService \Magento\Integration\Api\IntegrationServiceInterface */ + $integrationService = $objectManager->get('Magento\Integration\Api\IntegrationServiceInterface'); $params = [ 'all_resources' => true, diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/AddressDetailsManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/AddressDetailsManagementTest.php new file mode 100644 index 0000000000000..9081283ffa462 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/AddressDetailsManagementTest.php @@ -0,0 +1,76 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + */ + public function testSaveAddresses() + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); + $quote->load('test_order_1', 'reserved_order_id'); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . 'mine/addresses', + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'SaveAddresses', + ], + ]; + + $addressData = [ + 'firstname' => 'John', + 'lastname' => 'Smith', + 'email' => 'cat@dog.com', + 'company' => 'eBay Inc', + 'street' => ['Typical Street', 'Tiny House 18'], + 'city' => 'Big City', + 'region_id' => 12, + 'region' => 'California', + 'region_code' => 'CA', + 'postcode' => '0985432', + 'country_id' => 'US', + 'telephone' => '88776655', + 'fax' => '44332255', + ]; + $requestData = [ + 'cart_id' => $quote->getId(), + 'billingAddress' => $addressData, + 'shippingAddress' => $addressData + ]; + + $response = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertArrayHasKey('shipping_methods', $response); + $this->assertCount(1, $response['shipping_methods']); + $this->assertEquals('flatrate', $response['shipping_methods'][0]['method_code']); + + $this->assertArrayHasKey('payment_methods', $response); + $this->assertCount(2, $response['payment_methods']); + $this->assertEquals('checkmo', $response['payment_methods'][0]['code']); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php index 8d6c238db91f5..4cc58bed391e4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php @@ -37,12 +37,11 @@ public function testGetAddress() $address = $quote->getBillingAddress(); $data = [ - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), AddressInterface::KEY_REGION => $address->getRegion(), AddressInterface::KEY_REGION_ID => $address->getRegionId(), AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_STREET => $address->getStreet(), AddressInterface::KEY_COMPANY => $address->getCompany(), AddressInterface::KEY_TELEPHONE => $address->getTelephone(), @@ -50,7 +49,12 @@ public function testGetAddress() AddressInterface::KEY_CITY => $address->getCity(), AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail() + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() + ]; $cartId = $quote->getId(); @@ -68,7 +72,11 @@ public function testGetAddress() ]; $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); + $response = $this->_webApiCall($serviceInfo, $requestData); + + asort($data); + asort($response); + $this->assertEquals($data, $response); } /** @@ -141,9 +149,9 @@ public function testGetMyAddress() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -154,12 +162,11 @@ public function testGetMyAddress() $address = $quote->getBillingAddress(); $data = [ - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), AddressInterface::KEY_REGION => $address->getRegion(), AddressInterface::KEY_REGION_ID => $address->getRegionId(), AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_STREET => $address->getStreet(), AddressInterface::KEY_COMPANY => $address->getCompany(), AddressInterface::KEY_TELEPHONE => $address->getTelephone(), @@ -167,7 +174,12 @@ public function testGetMyAddress() AddressInterface::KEY_CITY => $address->getCity(), AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail() + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() + ]; $serviceInfo = [ @@ -178,7 +190,11 @@ public function testGetMyAddress() ], ]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo)); + $response = $this->_webApiCall($serviceInfo); + + asort($data); + asort($response); + $this->assertEquals($data, $response); } /** @@ -189,9 +205,9 @@ public function testSetMyAddress() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php index b8ec4629f3581..3b80525adfa33 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php @@ -93,9 +93,9 @@ public function testCreateEmptyCartAndGetCartForCustomer() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -376,9 +376,9 @@ public function testPlaceOrderForMyCart() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -407,9 +407,9 @@ public function testPlaceOrderForMyCart() public function testGetCartForCustomer() { // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php index 406b755d77dd1..1380a7251302f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartTotalRepositoryTest.php @@ -55,14 +55,14 @@ public function testGetTotals() $shippingAddress = $quote->getShippingAddress(); $data = [ - Totals::KEY_BASE_GRAND_TOTAL => $quote->getBaseGrandTotal(), Totals::KEY_GRAND_TOTAL => $quote->getGrandTotal(), - Totals::KEY_BASE_SUBTOTAL => $quote->getBaseSubtotal(), + Totals::KEY_BASE_GRAND_TOTAL => $quote->getBaseGrandTotal(), Totals::KEY_SUBTOTAL => $quote->getSubtotal(), - Totals::KEY_BASE_SUBTOTAL_WITH_DISCOUNT => $quote->getBaseSubtotalWithDiscount(), - Totals::KEY_SUBTOTAL_WITH_DISCOUNT => $quote->getSubtotalWithDiscount(), + Totals::KEY_BASE_SUBTOTAL => $quote->getBaseSubtotal(), Totals::KEY_DISCOUNT_AMOUNT => $shippingAddress->getDiscountAmount(), Totals::KEY_BASE_DISCOUNT_AMOUNT => $shippingAddress->getBaseDiscountAmount(), + Totals::KEY_SUBTOTAL_WITH_DISCOUNT => $quote->getSubtotalWithDiscount(), + Totals::KEY_BASE_SUBTOTAL_WITH_DISCOUNT => $quote->getBaseSubtotalWithDiscount(), Totals::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), Totals::KEY_BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), Totals::KEY_SHIPPING_DISCOUNT_AMOUNT => $shippingAddress->getShippingDiscountAmount(), @@ -83,8 +83,12 @@ public function testGetTotals() $requestData = ['cartId' => $cartId]; $data = $this->formatTotalsData($data); - - $this->assertEquals($data, $this->_webApiCall($this->getServiceInfoForTotalsService($cartId), $requestData)); + $actual = $this->_webApiCall($this->getServiceInfoForTotalsService($cartId), $requestData); + unset($actual['items'][0]['options']); + if (array_key_exists('extension_attributes', $actual)) { + unset($actual['extension_attributes']); + } + $this->assertEquals($data, $actual); } /** @@ -151,24 +155,27 @@ protected function getQuoteItemTotalsData(\Magento\Quote\Model\Quote $quote) { $items = $quote->getAllItems(); $item = array_shift($items); - return [ - ItemTotals::KEY_PRICE => $item->getPrice(), - ItemTotals::KEY_BASE_PRICE => $item->getBasePrice(), + ItemTotals::KEY_ITEM_ID => $item->getItemId(), + ItemTotals::KEY_PRICE => intval($item->getPrice()), + ItemTotals::KEY_BASE_PRICE => intval($item->getBasePrice()), ItemTotals::KEY_QTY => $item->getQty(), - ItemTotals::KEY_ROW_TOTAL => $item->getRowTotal(), - ItemTotals::KEY_BASE_ROW_TOTAL => $item->getBaseRowTotal(), - ItemTotals::KEY_ROW_TOTAL_WITH_DISCOUNT => $item->getRowTotalWithDiscount(), - ItemTotals::KEY_TAX_AMOUNT => $item->getTaxAmount(), - ItemTotals::KEY_BASE_TAX_AMOUNT => $item->getBaseTaxAmount(), - ItemTotals::KEY_TAX_PERCENT => $item->getTaxPercent(), - ItemTotals::KEY_DISCOUNT_AMOUNT => $item->getDiscountAmount(), - ItemTotals::KEY_BASE_DISCOUNT_AMOUNT => $item->getBaseDiscountAmount(), - ItemTotals::KEY_DISCOUNT_PERCENT => $item->getDiscountPercent(), - ItemTotals::KEY_PRICE_INCL_TAX => $item->getPriceInclTax(), - ItemTotals::KEY_BASE_PRICE_INCL_TAX => $item->getBasePriceInclTax(), - ItemTotals::KEY_ROW_TOTAL_INCL_TAX => $item->getRowTotalInclTax(), - ItemTotals::KEY_BASE_ROW_TOTAL_INCL_TAX => $item->getBaseRowTotalInclTax(), + ItemTotals::KEY_ROW_TOTAL => intval($item->getRowTotal()), + ItemTotals::KEY_BASE_ROW_TOTAL => intval($item->getBaseRowTotal()), + ItemTotals::KEY_ROW_TOTAL_WITH_DISCOUNT => intval($item->getRowTotalWithDiscount()), + ItemTotals::KEY_TAX_AMOUNT => intval($item->getTaxAmount()), + ItemTotals::KEY_BASE_TAX_AMOUNT => intval($item->getBaseTaxAmount()), + ItemTotals::KEY_TAX_PERCENT => intval($item->getTaxPercent()), + ItemTotals::KEY_DISCOUNT_AMOUNT => intval($item->getDiscountAmount()), + ItemTotals::KEY_BASE_DISCOUNT_AMOUNT => intval($item->getBaseDiscountAmount()), + ItemTotals::KEY_DISCOUNT_PERCENT => intval($item->getDiscountPercent()), + ItemTotals::KEY_PRICE_INCL_TAX => intval($item->getPriceInclTax()), + ItemTotals::KEY_BASE_PRICE_INCL_TAX => intval($item->getBasePriceInclTax()), + ItemTotals::KEY_ROW_TOTAL_INCL_TAX => intval($item->getRowTotalInclTax()), + ItemTotals::KEY_BASE_ROW_TOTAL_INCL_TAX => intval($item->getBaseRowTotalInclTax()), + ItemTotals::KEY_WEEE_TAX_APPLIED_AMOUNT => $item->getWeeeTaxAppliedAmount(), + ItemTotals::KEY_WEEE_TAX_APPLIED => $item->getWeeeTaxApplied(), + ItemTotals::KEY_NAME => $item->getName(), ]; } @@ -180,9 +187,9 @@ public function testGetMyTotals() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -202,14 +209,14 @@ public function testGetMyTotals() $shippingAddress = $quote->getShippingAddress(); $data = [ - Totals::KEY_BASE_GRAND_TOTAL => $quote->getBaseGrandTotal(), Totals::KEY_GRAND_TOTAL => $quote->getGrandTotal(), - Totals::KEY_BASE_SUBTOTAL => $quote->getBaseSubtotal(), + Totals::KEY_BASE_GRAND_TOTAL => $quote->getBaseGrandTotal(), Totals::KEY_SUBTOTAL => $quote->getSubtotal(), - Totals::KEY_BASE_SUBTOTAL_WITH_DISCOUNT => $quote->getBaseSubtotalWithDiscount(), - Totals::KEY_SUBTOTAL_WITH_DISCOUNT => $quote->getSubtotalWithDiscount(), + Totals::KEY_BASE_SUBTOTAL => $quote->getBaseSubtotal(), Totals::KEY_DISCOUNT_AMOUNT => $shippingAddress->getDiscountAmount(), Totals::KEY_BASE_DISCOUNT_AMOUNT => $shippingAddress->getBaseDiscountAmount(), + Totals::KEY_SUBTOTAL_WITH_DISCOUNT => $quote->getSubtotalWithDiscount(), + Totals::KEY_BASE_SUBTOTAL_WITH_DISCOUNT => $quote->getBaseSubtotalWithDiscount(), Totals::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), Totals::KEY_BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), Totals::KEY_SHIPPING_DISCOUNT_AMOUNT => $shippingAddress->getShippingDiscountAmount(), @@ -228,7 +235,11 @@ public function testGetMyTotals() ]; $data = $this->formatTotalsData($data); - - $this->assertEquals($data, $this->_webApiCall($serviceInfo)); + $actual = $this->_webApiCall($serviceInfo); + unset($actual['items'][0]['options']); + if (array_key_exists('extension_attributes', $actual)) { + unset($actual['extension_attributes']); + } + $this->assertEquals($data, $actual); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php index e6c8a97b918c4..114aa55136979 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CouponManagementTest.php @@ -157,9 +157,9 @@ public function testGetMyCoupon() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -187,9 +187,9 @@ public function testDeleteMyCoupon() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -219,9 +219,9 @@ public function testSetMyCouponThrowsExceptionIfCouponDoesNotExist() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -252,9 +252,9 @@ public function testSetMyCouponSuccess() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php index 58e551fe3cb5f..cbf99b7f9922c 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php @@ -45,12 +45,11 @@ public function testGetAddress() $address = $quote->getBillingAddress(); $data = [ - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), AddressInterface::KEY_REGION => $address->getRegion(), AddressInterface::KEY_REGION_ID => $address->getRegionId(), AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_STREET => $address->getStreet(), AddressInterface::KEY_COMPANY => $address->getCompany(), AddressInterface::KEY_TELEPHONE => $address->getTelephone(), @@ -58,7 +57,11 @@ public function testGetAddress() AddressInterface::KEY_CITY => $address->getCity(), AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail() + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook(), ]; $cartId = $this->getQuoteMaskedId($quote->getId()); @@ -76,7 +79,11 @@ public function testGetAddress() ]; $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); + $response = $this->_webApiCall($serviceInfo, $requestData); + + asort($data); + asort($response); + $this->assertEquals($data, $response); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php index 1ecbfbc80e108..85417b70b1673 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartTotalRepositoryTest.php @@ -54,6 +54,7 @@ protected function getQuoteMaskedId($quoteId) */ public function testGetTotals() { + $this->markTestSkipped('Will be fixed after MAGETWO-35573'); /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); $quote->load('test_order_1', 'reserved_order_id'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php index 3a4dd1be8bcdf..2e01c93f13a3f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php @@ -73,7 +73,10 @@ public function testGetAddress() AddressInterface::KEY_CITY => $address->getCity(), AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail() + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() ]; $cartId = $this->getQuoteMaskedId($quote->getId()); @@ -91,7 +94,11 @@ public function testGetAddress() ]; $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); + $response = $this->_webApiCall($serviceInfo, $requestData); + + asort($data); + asort($response); + $this->assertEquals($data, $response); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php index 8e985047cef20..d329d3e7ff2c4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php @@ -62,7 +62,9 @@ public function testSetMethod() $quoteIdMask->load($cartId, 'quote_id'); //Use masked cart Id $cartId = $quoteIdMask->getMaskedId(); - + $shippingAddress = $this->quote->getShippingAddress(); + $shippingAddress->setCollectShippingRates(true); + $shippingAddress->collectTotals()->save(); $requestData = [ 'cartId' => $cartId, 'carrierCode' => 'flatrate', @@ -163,6 +165,8 @@ public function testGetMethod() $cartId = $quoteIdMask->getMaskedId(); $shippingAddress = $quote->getShippingAddress(); + $shippingAddress->setCollectShippingRates(true); + $shippingAddress->collectTotals()->save(); list($carrierCode, $methodCode) = explode('_', $shippingAddress->getShippingMethod()); list($carrierTitle, $methodTitle) = explode(' - ', $shippingAddress->getShippingDescription()); $data = [ @@ -173,10 +177,13 @@ public function testGetMethod() ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), ShippingMethodInterface::KEY_AVAILABLE => true, + ShippingMethodInterface::KEY_ERROR_MESSAGE => null, ]; - $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), $requestData)); + $actual = $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), $requestData); + unset($actual[ShippingMethodInterface::KEY_PRICE_EXCL_TAX]); + unset($actual[ShippingMethodInterface::KEY_PRICE_INCL_TAX ]); + $this->assertEquals($data, $actual); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php index b4aa67ab9fa7d..6cf9dacdbb0b1 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/PaymentMethodManagementTest.php @@ -381,9 +381,9 @@ protected function getPaymentMethodFieldsForAssert() */ protected function getCustomerToken() { - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); return $token; diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php index 9a8db29b15a7a..b789a1d403190 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php @@ -37,12 +37,11 @@ public function testGetAddress() $address = $quote->getShippingAddress(); $data = [ - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), AddressInterface::KEY_REGION => $address->getRegion(), AddressInterface::KEY_REGION_ID => $address->getRegionId(), AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_STREET => $address->getStreet(), AddressInterface::KEY_COMPANY => $address->getCompany(), AddressInterface::KEY_TELEPHONE => $address->getTelephone(), @@ -50,9 +49,13 @@ public function testGetAddress() AddressInterface::KEY_CITY => $address->getCity(), AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail() - ]; + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() + ]; $cartId = $quote->getId(); $serviceInfo = [ @@ -68,7 +71,11 @@ public function testGetAddress() ]; $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($serviceInfo, $requestData)); + $response = $this->_webApiCall($serviceInfo, $requestData); + + asort($data); + asort($response); + $this->assertEquals($data, $response); } /** @@ -218,9 +225,9 @@ public function testGetMyAddress() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -232,12 +239,11 @@ public function testGetMyAddress() $address = $quote->getShippingAddress(); $addressData = [ - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), AddressInterface::KEY_REGION => $address->getRegion(), AddressInterface::KEY_REGION_ID => $address->getRegionId(), AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), AddressInterface::KEY_STREET => $address->getStreet(), AddressInterface::KEY_COMPANY => $address->getCompany(), AddressInterface::KEY_TELEPHONE => $address->getTelephone(), @@ -245,7 +251,12 @@ public function testGetMyAddress() AddressInterface::KEY_CITY => $address->getCity(), AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail() + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() + ]; $serviceInfo = [ @@ -257,7 +268,11 @@ public function testGetMyAddress() ]; $requestData = []; - $this->assertEquals($addressData, $this->_webApiCall($serviceInfo, $requestData)); + $response = $this->_webApiCall($serviceInfo, $requestData); + + asort($addressData); + asort($response); + $this->assertEquals($addressData, $response); } /** @@ -270,9 +285,9 @@ public function testSetMyAddress() $this->_markTestAsRestOnly(); // get customer ID token - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php index 60865f081c99f..2246a1bd2ac08 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php @@ -53,7 +53,9 @@ public function testSetMethod() { $this->quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = $this->getServiceInfo(); - + $shippingAddress = $this->quote->getShippingAddress(); + $shippingAddress->setCollectShippingRates(true); + $shippingAddress->collectTotals()->save(); $requestData = [ 'cartId' => $this->quote->getId(), 'carrierCode' => 'flatrate', @@ -127,9 +129,9 @@ public function testSetMethodForMyCart() $this->quote->load('test_order_1', 'reserved_order_id'); - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -146,7 +148,9 @@ public function testSetMethodForMyCart() 'carrierCode' => 'flatrate', 'methodCode' => 'flatrate', ]; // cartId 999 will be overridden - + $shippingAddress = $this->quote->getShippingAddress(); + $shippingAddress->setCollectShippingRates(true); + $shippingAddress->collectTotals()->save(); $result = $this->_webApiCall($serviceInfo, $requestData); $this->assertEquals(true, $result); @@ -166,27 +170,38 @@ public function testSetMethodForMyCart() */ public function testGetMethod() { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); + $this->quote->load('test_order_1', 'reserved_order_id'); - $cartId = $quote->getId(); + /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */ + $shippingMethodManagementService = $this->objectManager->create( + 'Magento\Quote\Api\ShippingMethodManagementInterface' + ); - $shippingAddress = $quote->getShippingAddress(); + $shippingAddress = $this->quote->getShippingAddress(); + $shippingAddress->setCollectShippingRates(true); + $shippingAddress->collectTotals()->save(); list($carrierCode, $methodCode) = explode('_', $shippingAddress->getShippingMethod()); list($carrierTitle, $methodTitle) = explode(' - ', $shippingAddress->getShippingDescription()); + $shippingMethod = $shippingMethodManagementService->get($this->quote->getId()); + $data = [ ShippingMethodInterface::KEY_CARRIER_CODE => $carrierCode, ShippingMethodInterface::KEY_METHOD_CODE => $methodCode, ShippingMethodInterface::KEY_CARRIER_TITLE => $carrierTitle, ShippingMethodInterface::KEY_METHOD_TITLE => $methodTitle, - ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), + ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), ShippingMethodInterface::KEY_AVAILABLE => true, + ShippingMethodInterface::KEY_ERROR_MESSAGE => null, + ShippingMethodInterface::KEY_PRICE_EXCL_TAX => $shippingMethod->getPriceExclTax(), + ShippingMethodInterface::KEY_PRICE_INCL_TAX => $shippingMethod->getPriceInclTax(), ]; - $requestData = ["cartId" => $cartId]; - $this->assertEquals($data, $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), $requestData)); + $requestData = ["cartId" => $this->quote->getId()]; + $this->assertEquals( + $data, + $this->_webApiCall($this->getSelectedMethodServiceInfo($this->quote->getId()), $requestData) + ); } /** @@ -215,7 +230,7 @@ public function testGetMethodOfCartWithNoShippingMethod() /** * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_shipping_method.php */ public function testGetMethodForMyCart() { @@ -223,17 +238,16 @@ public function testGetMethodForMyCart() $this->quote->load('test_order_1', 'reserved_order_id'); - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */ - $shippingMethodManagementService = $this->objectManager->create( - 'Magento\Quote\Api\ShippingMethodManagementInterface' - ); - $shippingMethodManagementService->set($this->quote->getId(), 'flatrate', 'flatrate'); + $shippingAddress = $this->quote->getShippingAddress(); + $shippingAddress->setCollectShippingRates(true); + $shippingAddress->collectTotals()->save(); $serviceInfo = [ 'rest' => [ @@ -289,13 +303,14 @@ public function testGetList() */ public function testGetListForMyCart() { + $this->markTestSkipped('Will be fixed after MAGETWO-35573'); $this->_markTestAsRestOnly(); $this->quote->load('test_order_1', 'reserved_order_id'); - /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */ + /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Service\V1\CustomerTokenServiceInterface' + 'Magento\Integration\Api\CustomerTokenServiceInterface' ); $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); @@ -326,6 +341,9 @@ public function testGetListForMyCart() ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingMethod->getAmount(), ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingMethod->getBaseAmount(), ShippingMethodInterface::KEY_AVAILABLE => $shippingMethod->getAvailable(), + ShippingMethodInterface::KEY_ERROR_MESSAGE => null, + ShippingMethodInterface::KEY_PRICE_EXCL_TAX => $shippingMethod->getPriceExclTax(), + ShippingMethodInterface::KEY_PRICE_INCL_TAX => $shippingMethod->getPriceInclTax(), ]; $this->assertEquals($expectedData, $result[0]); diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index c71c6fd429166..62706ed5abb25 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc24", + "magento/mtf": "1.0.0-rc25", "php": "~5.5.0|~5.6.0", "phpunit/phpunit": "4.1.0", "phpunit/phpunit-selenium": ">=1.2", diff --git a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php index 39d384533ef6d..de6160134035b 100644 --- a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php +++ b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php @@ -7,7 +7,7 @@ namespace Magento\Mtf\App\State; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\DeploymentConfig; @@ -44,14 +44,24 @@ public function clearInstance() $dirList = \Magento\Mtf\ObjectManagerFactory::getObjectManager() ->get('Magento\Framework\Filesystem\DirectoryList'); - $reader = new Reader($dirList); + $configFilePool = \Magento\Mtf\ObjectManagerFactory::getObjectManager() + ->get('\Magento\Framework\Config\File\ConfigFilePool'); + + $reader = new Reader($dirList, $configFilePool); $deploymentConfig = new DeploymentConfig($reader); - $dbConfig = $deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $dbInfo = $dbConfig['connection']['default']; - $host = $dbInfo['host']; - $user = $dbInfo['username']; - $password = $dbInfo['password']; - $database = $dbInfo['dbname']; + $host = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_HOST + ); + $user = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_USER + ); + $password = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_PASSWORD + ); + $database = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_NAME + ); $fileName = MTF_BP . '/' . $database . '.sql'; if (!file_exists($fileName)) { diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/OptgroupselectElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/OptgroupselectElement.php index 7d8d230174032..ad04a53bd7b9c 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/OptgroupselectElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/OptgroupselectElement.php @@ -13,13 +13,6 @@ */ class OptgroupselectElement extends SelectElement { - /** - * Option locator. - * - * @var string - */ - protected $optionByIndex = './/option'; - /** * Option group selector. * @@ -44,14 +37,7 @@ public function getValue() { $this->eventManager->dispatchEvent(['get_value'], [(string)$this->getAbsoluteSelector()]); - $selectedLabel = ''; - $labels = $this->getElements($this->optionByIndex, Locator::SELECTOR_XPATH); - foreach ($labels as $label) { - if ($label->isSelected()) { - $selectedLabel = $label->getText(); - break; - } - } + $selectedLabel = parent::getValue(); if ($selectedLabel == '') { throw new \Exception('Selected value has not been found in optgroup select.'); } diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectstoreElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectstoreElement.php index 2147e8eeabd9d..32d1b11119a75 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectstoreElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectstoreElement.php @@ -13,13 +13,6 @@ */ class SelectstoreElement extends SelectElement { - /** - * Option locator - * - * @var string - */ - protected $optionByIndex = './/optgroup/option[%d]'; - /** * Store option group selector. * 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 index dbc8efa6e71cc..006da9cb0f663 100755 --- 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 @@ -273,7 +273,7 @@ public function getTabElement($tabName) * Open tab * * @param string $tabName - * @return Tab + * @return FormTabs */ public function openTab($tabName) { 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 40d04bc0fd76f..9989b092a6ec8 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 @@ -88,7 +88,7 @@ abstract class Grid extends Block * * @var string */ - protected $massactionAction = '#massaction-select'; + protected $massactionAction = '[data-menu="grid-mass-select"]'; /** * Massaction 'Submit' button @@ -132,13 +132,6 @@ abstract class Grid extends Block */ protected $option = '[name="status"]'; - /** - * Filter button - * - * @var string - */ - protected $filterButton = '[data-action="grid-filter-expand"]'; - /** * Active class * @@ -172,14 +165,14 @@ abstract class Grid extends Block * * @var string */ - protected $actionNextPage = '.pager .action-next'; + protected $actionNextPage = '[class*=data-grid-pager] .action-next'; /** * Locator for disabled next page action * * @var string */ - protected $actionNextPageDisabled = '.pager .action-next.disabled'; + protected $actionNextPageDisabled = '[class*=data-grid-pager] .action-next.disabled'; /** * First row selector @@ -188,6 +181,13 @@ abstract class Grid extends Block */ protected $firstRowSelector = ''; + /** + * Selector for no records row. + * + * @var string + */ + protected $noRecords = '[data-role="row"] .empty-text'; + /** * Get backend abstract block * @@ -231,7 +231,6 @@ private function prepareForSearch(array $filters) */ public function search(array $filter) { - $this->openFilterBlock(); $this->resetFilter(); $this->prepareForSearch($filter); $this->_rootElement->find($this->searchButton, Locator::SELECTOR_CSS)->click(); @@ -246,7 +245,6 @@ public function search(array $filter) */ public function searchAndOpen(array $filter) { - $this->openFilterBlock(); $this->search($filter); $rowItem = $this->_rootElement->find($this->rowItem, Locator::SELECTOR_CSS); if ($rowItem->isVisible()) { @@ -297,7 +295,6 @@ protected function waitForElement() */ public function searchAndSelect(array $filter) { - $this->openFilterBlock(); $this->search($filter); $selectItem = $this->_rootElement->find($this->selectItem); if ($selectItem->isVisible()) { @@ -312,8 +309,7 @@ public function searchAndSelect(array $filter) */ public function resetFilter() { - $this->openFilterBlock(); - $this->_rootElement->find($this->resetButton, Locator::SELECTOR_CSS)->click(); + $this->_rootElement->find($this->resetButton)->click(); $this->waitLoader(); } @@ -328,6 +324,9 @@ public function resetFilter() */ public function massaction(array $items, $action, $acceptAlert = false, $massActionSelection = '') { + if ($this->_rootElement->find($this->noRecords)->isVisible()) { + return; + } if (!is_array($action)) { $action = [$action => '-']; } @@ -370,7 +369,6 @@ protected function massActionSubmit($acceptAlert) */ protected function getRow(array $filter, $isSearchable = true, $isStrict = true) { - $this->openFilterBlock(); if ($isSearchable) { $this->search($filter); } @@ -428,7 +426,6 @@ public function isRowVisible(array $filter, $isSearchable = true, $isStrict = tr */ public function sortGridByField($field, $sort = "desc") { - $this->openFilterBlock(); $sortBlock = $this->_rootElement->find(sprintf($this->sortLink, $field, $sort)); if ($sortBlock->isVisible()) { $sortBlock->click(); @@ -436,28 +433,6 @@ public function sortGridByField($field, $sort = "desc") } } - /** - * Open Filter Block - * - * @return void - */ - protected function openFilterBlock() - { - $this->getTemplateBlock()->waitForElementNotVisible($this->loader); - - $toggleFilterButton = $this->_rootElement->find($this->filterButton); - $searchButton = $this->_rootElement->find($this->searchButton); - if ($toggleFilterButton->isVisible() && !$searchButton->isVisible()) { - $toggleFilterButton->click(); - $browser = $this->_rootElement; - $browser->waitUntil( - function () use ($searchButton) { - return $searchButton->isVisible() ? true : null; - } - ); - } - } - /** * Click to next page action link * diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml index b0c8be8dae155..f714aa05f443d 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml @@ -7,7 +7,7 @@ --> - + general 1 @@ -58,6 +58,57 @@ + + + general + 1 + + DE Store + + + general + 1 + + 630-371-7008 + + + general + 1 + Germany + DE + + + general + 1 + Berlin + 82 + + + general + 1 + + 10789 + + + general + 1 + + Berlin + + + general + 1 + + Augsburger Strabe 41 + + + general + 1 + + 111607872 + + + default diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php index b3286de48a5bd..20688802c899c 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php @@ -50,7 +50,7 @@ class Option extends Form * * @var string */ - protected $removeSelection = 'button.delete'; + protected $removeSelection = '.col-actions .action-delete'; /** * Get grid for assigning products for bundle option diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/ValidateOrderOfProductTypeTest.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/ValidateOrderOfProductTypeTest.xml new file mode 100644 index 0000000000000..11d8f9b03228c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/ValidateOrderOfProductTypeTest.xml @@ -0,0 +1,14 @@ + + + + + + Bundle Product + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/AttributeForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/AttributeForm.php index 2f83b72385835..d80a7e7545894 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/AttributeForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/AttributeForm.php @@ -24,7 +24,7 @@ class AttributeForm extends FormTabs * * @var string */ - protected $closedToggle = '//*[contains(@class,"collapsable-wrapper") and not(contains(@class,"opened"))]//strong'; + protected $closedToggle = '.admin__collapsible-block-wrapper:not(.opened) [data-toggle="collapse"]'; /** * Properties tab selector. @@ -87,7 +87,7 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element */ protected function expandAllToggles() { - $closedToggles = $this->_rootElement->getElements($this->closedToggle, Locator::SELECTOR_XPATH); + $closedToggles = $this->_rootElement->getElements($this->closedToggle); foreach ($closedToggles as $toggle) { $toggle->click(); } 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 d2eae40e95ed2..95b79ed21380b 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 @@ -13,34 +13,40 @@ use Magento\Catalog\Test\Block\AbstractConfigureBlock; /** - * Class Configure - * Adminhtml catalog product composite configure block + * Adminhtml catalog product composite configure block. */ class Configure extends AbstractConfigureBlock { /** - * Custom options CSS selector + * Configure form selector. + * + * @var string + */ + protected $configureForm = '#product_composite_configure_form'; + + /** + * Custom options CSS selector. * * @var string */ protected $customOptionsSelector = '#product_composite_configure_fields_options'; /** - * Selector for "Ok" button + * Selector for "Ok" button. * * @var string */ protected $okButton = '.ui-button.action-primary'; /** - * Backend abstract block + * Backend abstract block. * * @var string */ protected $templateBlock = './ancestor::body'; /** - * Set quantity + * Set quantity. * * @param int $qty * @return void @@ -51,7 +57,7 @@ public function setQty($qty) } /** - * Fill in the option specified for the product + * Fill in the option specified for the product. * * @param FixtureInterface $product * @return void @@ -61,15 +67,17 @@ public function configProduct(FixtureInterface $product) /** @var CatalogProductSimple $product */ $checkoutData = $product->getCheckoutData(); + $this->waitForFormVisible(); $this->fillOptions($product); if (isset($checkoutData['qty'])) { $this->setQty($checkoutData['qty']); } $this->clickOk(); + $this->waitForFormNotVisible(); } /** - * Click "Ok" button + * Click "Ok" button. * * @return void */ @@ -80,7 +88,39 @@ public function clickOk() } /** - * Get backend abstract block + * Wait for form is visible. + * + * @return void + */ + protected function waitForFormVisible() + { + $context = $this->_rootElement; + $selector = $this->configureForm; + return $this->browser->waitUntil( + function () use ($context, $selector) { + return $context->find($selector)->isVisible() ? true : null; + } + ); + } + + /** + * Wait for form is not visible. + * + * @return void + */ + protected function waitForFormNotVisible() + { + $context = $this->_rootElement; + $selector = $this->configureForm; + return $this->browser->waitUntil( + function () use ($context, $selector) { + return $context->find($selector)->isVisible() ? null : true; + } + ); + } + + /** + * Get backend abstract block. * * @return \Magento\Backend\Test\Block\Template */ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php index d6943bf14db79..39e76e2c98eec 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php @@ -6,8 +6,9 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action; +use Magento\Mtf\Fixture\FixtureInterface; use Magento\Backend\Test\Block\Widget\Form; -use Magento\Mtf\Client\Locator; +use Magento\Mtf\Client\Element\SimpleElement; /** * Product attribute massaction edit page. @@ -15,30 +16,22 @@ class Attribute extends Form { /** - * CSS selector for 'save' button. + * Fill the root form. * - * @var string + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return $this */ - protected $saveButton = '[data-ui-id="page-actions-toolbar-save-button"]'; - - /** - * XPath selector for checkbox that enables price editing. - * - * @var string - */ - protected $priceFieldEnablerSelector = '//*[@id="attribute-price-container"]/div[1]/div/label//*[@type="checkbox"]'; - - /** - * Enable price field editing. - * - * @return void - */ - public function enablePriceEdit() + public function fill(FixtureInterface $fixture, SimpleElement $element = null) { - $this->_rootElement->find( - $this->priceFieldEnablerSelector, - Locator::SELECTOR_XPATH, - 'checkbox' - )->setValue('Yes'); + $data = $fixture->getData(); + foreach ($data as $name => $dataValue) { + $fields['toggle_' . $name] = 'Yes'; + $fields[$name] = $dataValue; + } + $mapping = $this->dataMapping($fields); + $this->_fill($mapping, $element); + + return $this; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.xml index feea6a25ae1bd..209181c25de8b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.xml @@ -8,6 +8,10 @@ attributes - + + [name='toggle_price'] + checkbox + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/FormPageActions.php new file mode 100644 index 0000000000000..dd0843e19d04c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/FormPageActions.php @@ -0,0 +1,20 @@ +getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertEquals( + $expectedMessage, + $actualMessage, + 'Wrong success message is displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Mass update success message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTypeOrderOnCreate.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTypeOrderOnCreate.php new file mode 100644 index 0000000000000..9a7ce8eba8c17 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTypeOrderOnCreate.php @@ -0,0 +1,44 @@ +open(); + ksort($menu); + \PHPUnit_Framework_Assert::assertEquals( + implode("\n", $menu), + $catalogProductIndex->getGridPageActionBlock()->getTypeList(), + 'Order and filling of types on product page not equals to incoming data.' + ); + } + + /** + * Success message is displayed. + * + * @return string + */ + public function toString() + { + return 'Order and types of product on product page equals to incoming data.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductActionAttributeEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductActionAttributeEdit.xml new file mode 100644 index 0000000000000..103fede3c914a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductActionAttributeEdit.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductActionAttributeEdit.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductActionAttributeEdit.php deleted file mode 100644 index 96ffb35c54577..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductActionAttributeEdit.php +++ /dev/null @@ -1,42 +0,0 @@ -getMagentoCatalogAdminhtmlProductEditActionAttribute( - $this->_browser->find($this->attributesFormBlock, Locator::SELECTOR_CSS) - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigData.xml new file mode 100644 index 0000000000000..a109f2a62caf8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigData.xml @@ -0,0 +1,27 @@ + + + + + + + default + 0 + Yes + 1 + + + + + default + 0 + No + 0 + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml index e84f0409dada6..6bb452fe69149 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml @@ -456,7 +456,7 @@ 10 Yes 1 - test_type:acceptance_test + test_type:acceptance_test, stable:no diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php new file mode 100644 index 0000000000000..ea7f49ced512b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.php @@ -0,0 +1,127 @@ + Catalog. + * 3. Find Product (from preconditions) in Products grid. + * 4. Select Product's check-box. + * 5. Select "Update Attributes" value in "Select Product Actions" drop-down list. + * 6. Click on the "Submit" button. + * 7. Open "Attributes" tab. + * 8. Fill data. + * 9. Click on the "Save" button. + * 10. Perform asserts. + * + * @group Products_(MX) + * @ZephyrId MAGETWO-21128 + */ +class MassProductUpdateTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'MX'; + /* end tags */ + + /** + * Product page with a grid. + * + * @var CatalogProductIndex + */ + protected $productGrid; + + /** + * Page to update a product. + * + * @var CatalogProductActionAttributeEdit + */ + protected $attributeMassActionPage; + + /** + * Configuration data. + * + * @var string + */ + protected $configData; + + /** + * Injection data. + * + * @param CatalogProductIndex $productGrid + * @param CatalogProductActionAttributeEdit $attributeMassActionPage + * @return void + */ + public function __inject( + CatalogProductIndex $productGrid, + CatalogProductActionAttributeEdit $attributeMassActionPage + ) { + $this->productGrid = $productGrid; + $this->attributeMassActionPage = $attributeMassActionPage; + } + + /** + * Run mass update product simple entity test. + * + * @param CatalogProductSimple $initialProduct + * @param CatalogProductSimple $product + * @param string $configData + * @return array + */ + public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData) + { + $this->markTestIncomplete('Bug: MAGETWO-37154'); + $this->configData = $configData; + + // Preconditions + $initialProduct->persist(); + + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $configData] + )->run(); + + // Steps + $this->productGrid->open(); + $this->productGrid->getProductGrid()->updateAttributes([['sku' => $initialProduct->getSku()]]); + $this->attributeMassActionPage->getAttributesBlockForm()->fill($product); + $this->attributeMassActionPage->getFormPageActions()->save(); + $data = array_merge($initialProduct->getData(), $product->getData()); + $product = $this->objectManager->create( + 'Magento\Catalog\Test\Fixture\CatalogProductSimple', + ['data' => $data] + ); + + return [ + 'category' => $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0], + 'product' => $product, + ]; + } + + /** + * Clear data after test. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData, 'rollback' => true] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.xml new file mode 100644 index 0000000000000..b00facf21e2b5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/MassProductUpdateTest.xml @@ -0,0 +1,19 @@ + + + + + + product_flat + simple_10_dollar + 1.99 + + + + + + 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 e97c6a4a317c2..eb5308c13e926 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 @@ -13,8 +13,6 @@ use Magento\Mtf\TestCase\Injectable; /** - * Test Flow: - * * Precondition: * 1. Category is created. * 2. Product is created and assigned to created category. @@ -28,7 +26,7 @@ * 6. Perform asserts. * * @group Products_(MX) - * @ZephyrId MAGETWO-23544 + * @ZephyrId MAGETWO-23544, MAGETWO-21125 */ class UpdateSimpleProductEntityTest extends Injectable { @@ -39,21 +37,28 @@ class UpdateSimpleProductEntityTest extends Injectable /* end tags */ /** - * Product page with a grid + * Product page with a grid. * * @var CatalogProductIndex */ protected $productGrid; /** - * Page to update a product + * Page to update a product. * * @var CatalogProductEdit */ protected $editProductPage; /** - * Injection data + * Configuration data. + * + * @var string + */ + protected $configData; + + /** + * Injection data. * * @param CatalogProductIndex $productGrid * @param CatalogProductEdit $editProductPage @@ -68,14 +73,16 @@ public function __inject( } /** - * Run update product simple entity test + * Run update product simple entity test. * * @param CatalogProductSimple $initialProduct * @param CatalogProductSimple $product + * @param string $configData * @return array */ - public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product) + public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData = '') { + $this->configData = $configData; // Preconditions $initialProduct->persist(); $initialCategory = $initialProduct->hasData('category_ids') @@ -85,6 +92,11 @@ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $initialCategory; + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $configData] + )->run(); + // Steps $filter = ['sku' => $initialProduct->getSku()]; @@ -95,4 +107,19 @@ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple return ['category' => $category]; } + + /** + * Clear data after test. + * + * @return void + */ + public function tearDown() + { + if ($this->configData) { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData, 'rollback' => true] + )->run(); + } + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml index 8ce489042245b..73e20318e0035 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml @@ -138,5 +138,17 @@ + + Edit product with enabled flat + product_flat + simple_10_dollar + Simple Product %isolation% + sku_simple_product_%isolation% + 1.99 + - + default + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.php new file mode 100644 index 0000000000000..4547ffd8a1081 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.php @@ -0,0 +1,37 @@ + Catalog. + * + * @group Products_(MX) + * @ZephyrId MAGETWO-37146 + */ +class ValidateOrderOfProductTypeTest extends Injectable +{ + /* tags */ + const MVP = 'no'; + const DOMAIN = 'MX'; + /* end tags */ + + /** + * Open catalog product index page. + * + * @param CatalogProductIndex $catalogProductIndex + * @return void + */ + public function test(CatalogProductIndex $catalogProductIndex) + { + $catalogProductIndex->open(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.xml new file mode 100644 index 0000000000000..c1dcd2fb2d63c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.xml @@ -0,0 +1,16 @@ + + + + + + Simple Product + Virtual Product + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.php index 82611c683d511..ae3394249f932 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityFromProductPageTest.php @@ -6,10 +6,7 @@ namespace Magento\Catalog\Test\TestCase\ProductAttribute; -use Magento\Catalog\Test\Fixture\CatalogProductAttribute; -use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Mtf\Fixture\FixtureFactory; -use Magento\Mtf\ObjectManager; use Magento\Mtf\TestCase\Scenario; /** @@ -40,13 +37,6 @@ class CreateProductAttributeEntityFromProductPageTest extends Scenario const TO_MAINTAIN = 'yes'; /* end tags */ - /** - * CatalogProductAttribute fixture. - * - * @var CatalogProductAttribute - */ - protected $attribute; - /** * Prepare data for test. * @@ -66,25 +56,10 @@ public function __prepare(FixtureFactory $fixtureFactory) /** * Run CreateProductAttributeEntity from product page test. * - * @param CatalogProductAttribute $attribute * @return void */ - public function test(CatalogProductAttribute $attribute) + public function test() { - $this->attribute = $attribute; $this->executeScenario(); } - - /** - * Delete attribute after test. - * - * @return void - */ - public function tearDown() - { - ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\TestStep\DeleteAttributeStep', - ['attribute' => $this->attribute] - )->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php index 38bda956505c9..16a6485f4103a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php @@ -6,8 +6,6 @@ namespace Magento\Catalog\Test\TestCase\ProductAttribute; -use Magento\Catalog\Test\Fixture\CatalogProductAttribute; -use Magento\Mtf\ObjectManager; use Magento\Mtf\TestCase\Scenario; /** @@ -29,35 +27,13 @@ class CreateProductAttributeEntityTest extends Scenario const DOMAIN = 'MX'; /* end tags */ - /** - * CatalogProductAttribute object. - * - * @var CatalogProductAttribute - */ - protected $attribute; - /** * Run CreateProductAttributeEntity test. * - * @param CatalogProductAttribute $productAttribute * @return array */ - public function testCreateProductAttribute(CatalogProductAttribute $productAttribute) + public function testCreateProductAttribute() { - $this->attribute = $productAttribute; $this->executeScenario(); } - - /** - * Delete attribute after test. - * - * @return void - */ - public function tearDown() - { - ObjectManager::getInstance()->create( - 'Magento\Catalog\Test\TestStep\DeleteAttributeStep', - ['attribute' => $this->attribute] - )->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php index 5a717e86f09e5..b1994e6b362d3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php @@ -12,18 +12,16 @@ use Magento\Mtf\TestCase\Injectable; /** - * Test Creation for Delete Attribute Set (Product Template) - * * Preconditions: - * 1. Create Product template, based on Default - * 2. Create product attribute and add to created template + * 1. Create Product template, based on Default. + * 2. Create product attribute and add to created template. * * Test Flow: * 1. Log in to Backend. - * 2. Go to Stores > Attributes > Product - * 3. Search product attribute in grid by given data - * 4. Open this attribute by clicking - * 5. Click on the "Delete Attribute" button + * 2. Go to Stores > Attributes > Product. + * 3. Search product attribute in grid by given data. + * 4. Open this attribute by clicking. + * 5. Click on the "Delete Attribute" button. * 6. Perform all assertions. * * @group Product_Attributes_(MX) @@ -37,21 +35,21 @@ class DeleteAssignedToTemplateProductAttributeTest extends Injectable /* end tags */ /** - * Catalog Product Attribute index page + * Catalog Product Attribute index page. * * @var CatalogProductAttributeIndex */ protected $attributeIndex; /** - * Catalog Product Attribute new page + * Catalog Product Attribute new page. * * @var CatalogProductAttributeNew */ protected $attributeNew; /** - * Inject pages + * Inject pages. * * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew @@ -64,7 +62,7 @@ public function __inject(CatalogProductAttributeIndex $attributeIndex, CatalogPr } /** - * Run DeleteAssignedToTemplateProductAttribute test + * Run test. * * @param CatalogAttributeSet $productTemplate * @return array @@ -73,19 +71,14 @@ public function test(CatalogAttributeSet $productTemplate) { // Precondition $productTemplate->persist(); + $attribute = $productTemplate->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]; // Steps - $filter = [ - 'attribute_code' => $productTemplate - ->getDataFieldConfig('assigned_attributes')['source'] - ->getAttributes()[0] - ->getAttributeCode(), - ]; - + $filter = ['attribute_code' => $attribute->getAttributeCode()]; $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen($filter); $this->attributeNew->getPageActions()->delete(); - return ['productTemplate' => $productTemplate]; + return ['productTemplate' => $productTemplate, 'attribute' => $attribute]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php index 0c028ca6a4802..8665338166eb9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php @@ -60,8 +60,11 @@ public function __construct( */ public function run() { - $filter = ['attribute_code' => $this->attribute->getAttributeCode()]; - if ($this->catalogProductAttributeIndex->open()->getGrid()->isRowVisible($filter)) { + $filter = $this->attribute->hasData('attribute_code') + ? ['attribute_code' => $this->attribute->getAttributeCode()] + : ['frontend_label' => $this->attribute->getFrontendLabel()]; + $this->catalogProductAttributeIndex->open(); + if ($this->catalogProductAttributeIndex->getGrid()->isRowVisible($filter)) { $this->catalogProductAttributeIndex->getGrid()->searchAndOpen($filter); $this->catalogProductAttributeNew->getPageActions()->delete(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php index 0651b72bc377f..55c0d87167004 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/SaveAttributeStep.php @@ -7,7 +7,9 @@ namespace Magento\Catalog\Test\TestStep; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeNew; +use Magento\Mtf\ObjectManager; use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; /** * Save attribute on attribute page. @@ -21,13 +23,34 @@ class SaveAttributeStep implements TestStepInterface */ protected $attributeNew; + /** + * Product attribute fixture. + * + * @var CatalogProductAttribute + */ + protected $attribute; + + /** + * Object manager instance. + * + * @var ObjectManager + */ + protected $objectManager; + /** * @constructor * @param CatalogProductAttributeNew $attributeNew + * @param CatalogProductAttribute $attribute + * @param ObjectManager $objectManager */ - public function __construct(CatalogProductAttributeNew $attributeNew) - { + public function __construct( + CatalogProductAttributeNew $attributeNew, + CatalogProductAttribute $attribute, + ObjectManager $objectManager + ) { $this->attributeNew = $attributeNew; + $this->attribute = $attribute; + $this->objectManager = $objectManager; } /** @@ -39,4 +62,17 @@ public function run() { $this->attributeNew->getPageActions()->save(); } + + /** + * Delete attribute after test. + * + * @return void + */ + public function cleanup() + { + $this->objectManager->create( + 'Magento\Catalog\Test\TestStep\DeleteAttributeStep', + ['attribute' => $this->attribute] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml index e4906b15087c9..943aeda7e3423 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml @@ -6,139 +6,149 @@ */ --> - - - high - - - - - middle - - - - - high - - - - - high - - - - - high - - - - - middle - - - - - high - - - - - middle - - - - - middle - - - - - high - - - - - middle - - - - - middle - - - - - high - - - - - middle - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - - - - high - - + + + high + + + + + middle + + + + + high + + + + + high + + + + + high + + + + + middle + + + + + high + + + + + middle + + + + + middle + + + + + high + + + + + middle + + + + + middle + + + + + high + + + + + middle + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + + + + high + + diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php index 18815f160fa7f..dac358d1f9907 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\CatalogRule\Test\Fixture\CatalogRule; use Magento\Catalog\Test\Fixture\CatalogProductSimple; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; /** * Steps: @@ -90,13 +90,13 @@ public function testCreate( * * @param CatalogRule $catalogPriceRule * @param Customer|null $customer - * @return CustomerGroupInjectable + * @return CustomerGroup */ public function applyCustomerGroup(CatalogRule $catalogPriceRule, Customer $customer = null) { if ($customer !== null) { $customer->persist(); - /** @var \Magento\Customer\Test\Fixture\CustomerGroupInjectable $customerGroup */ + /** @var \Magento\Customer\Test\Fixture\CustomerGroup $customerGroup */ $customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup(); $catalogPriceRule = $this->fixtureFactory->createByCode( 'catalogRule', diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php index 3cf247de49fd1..82215f4f64f24 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php @@ -28,17 +28,26 @@ class CreateCatalogRuleStep implements TestStepInterface */ protected $fixtureFactory; + /** + * Delete all catalog rules step. + * + * @var $deleteAllCatalogRule + */ + protected $deleteAllCatalogRule; + /** * Preparing step properties * * @constructor * @param FixtureFactory $fixtureFactory * @param string $catalogRule + * @param DeleteAllCatalogRulesStep $deleteRule */ - public function __construct(FixtureFactory $fixtureFactory, $catalogRule) + public function __construct(FixtureFactory $fixtureFactory, DeleteAllCatalogRulesStep $deleteRule, $catalogRule) { $this->fixtureFactory = $fixtureFactory; $this->catalogRule = $catalogRule; + $this->deleteAllCatalogRule = $deleteRule; } /** @@ -59,4 +68,14 @@ public function run() } return $result; } + + /** + * Delete all catalog rule. + * + * @return void + */ + public function cleanup() + { + $this->deleteAllCatalogRule->run(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/AbstractReview.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/AbstractReview.php index 837db893bd4ca..93eab1a28d433 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/AbstractReview.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/AbstractReview.php @@ -31,21 +31,21 @@ abstract class AbstractReview extends Block * * @var string */ - protected $grandTotal = '[class="grand totals"] span'; + protected $grandTotal = '[class="grand totals"] td>strong'; /** * Grand total excluding tax search mask. * * @var string */ - protected $grandTotalExclTax = '[class="grand totals excl"] span'; + protected $grandTotalExclTax = '[class="grand totals excl"] td>strong'; /** * Grand total including tax search mask. * * @var string */ - protected $grandTotalInclTax = '[class="grand totals incl"] span'; + protected $grandTotalInclTax = '[class="grand totals incl"] td>strong'; /** * Subtotal search mask. diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.php index 6f5ecebf39996..018dcbcac4b92 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.php @@ -41,21 +41,17 @@ class Billing extends Form * Fill billing address * * @param Address $billingAddress - * @param Customer $customer * @param bool $isShippingAddress * @return void */ public function fillBilling( Address $billingAddress = null, - Customer $customer = null, $isShippingAddress = false ) { if ($billingAddress) { + sleep(5); $this->fill($billingAddress); } - if ($customer) { - $this->fill($customer); - } if ($isShippingAddress) { $this->_rootElement->find($this->useForShipping)->click(); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.xml index e62c88853e3b2..fb375006aac53 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Billing.xml @@ -6,14 +6,16 @@ */ --> - billing + billingAddress - + + [name='customerDetails[email]'] + - [id='billing:street1'] + [name='billingAddress[street][0]'] @@ -24,11 +26,5 @@ select - - [name='billing[customer_password]'] - - - [name='billing[confirm_password]'] - diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php index 3825719ad4eec..c56571f76038f 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php @@ -61,9 +61,6 @@ public function checkoutMethod(FixtureInterface $fixture) /** @var Checkout $fixture */ if ($fixture->isRegisteredCustomer()) { $this->loginCustomer($fixture->getCustomer()); - } elseif ($fixture->getCustomer()) { - $this->registerCustomer(); - $this->clickContinue(); } else { $this->guestCheckout(); $this->clickContinue(); @@ -77,19 +74,10 @@ public function checkoutMethod(FixtureInterface $fixture) */ public function guestCheckout() { + $this->waitForElementVisible($this->guestCheckout); $this->_rootElement->find($this->guestCheckout)->click(); } - /** - * Register customer during checkout - * - * @return void - */ - public function registerCustomer() - { - $this->_rootElement->find($this->registerCustomer)->click(); - } - /** * Login customer during checkout * diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml index d816ce5af0323..ab69d6ad7f6a1 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml @@ -8,21 +8,34 @@ shipping - - - - + + [name='shippingAddress[firstname]'] + + + [name='shippingAddress[lastname]'] + + + [name='shippingAddress[company]'] + - [id='billing:street1'] + [name='shippingAddress[street][0]'] - + + [name='shippingAddress[city]'] + select + [name='shippingAddress[region_id]'] - + + [name='shippingAddress[postcode]'] + select + [name='shippingAddress[country_id]'] - + + [name='shippingAddress[telephone]'] + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/Method.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/Method.php index 8842ad897a8af..7943ce406d378 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/Method.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/Method.php @@ -21,7 +21,7 @@ class Method extends Block * * @var string */ - protected $shippingMethod = '//dt[text()="%s"]/following-sibling::*//label/span[contains(text(), "%s")]'; + protected $shippingMethod = '//dt[text()="%s"]/following-sibling::*//label/span[contains(text()[2], "%s")]'; /** * Continue checkout button diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml index f847834c0a8c6..253de1616fe69 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml @@ -7,7 +7,7 @@ --> - + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php index 7d406644d97a7..579ddf3473cbd 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php @@ -8,7 +8,6 @@ use Magento\Checkout\Test\Page\CheckoutOnepage; use Magento\Customer\Test\Fixture\Address; -use Magento\Customer\Test\Fixture\Customer; use Magento\Mtf\TestStep\TestStepInterface; /** @@ -31,13 +30,6 @@ class FillBillingInformationStep implements TestStepInterface */ protected $billingAddress; - /** - * Customer fixture - * - * @var Customer - */ - protected $customer; - /** * Checkout method * @@ -49,18 +41,15 @@ class FillBillingInformationStep implements TestStepInterface * @constructor * @param CheckoutOnepage $checkoutOnepage * @param Address $billingAddress - * @param Customer $customer * @param string $checkoutMethod */ public function __construct( CheckoutOnepage $checkoutOnepage, Address $billingAddress, - Customer $customer, $checkoutMethod ) { $this->checkoutOnepage = $checkoutOnepage; $this->billingAddress = $billingAddress; - $this->customer = $customer; $this->checkoutMethod = $checkoutMethod; } @@ -71,8 +60,7 @@ public function __construct( */ public function run() { - $customer = $this->checkoutMethod === 'register' ? $this->customer : null; - $this->checkoutOnepage->getBillingBlock()->fillBilling($this->billingAddress, $customer); + $this->checkoutOnepage->getBillingBlock()->fillBilling($this->billingAddress); $this->checkoutOnepage->getBillingBlock()->clickContinue(); } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectCheckoutMethodStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectCheckoutMethodStep.php index b7a24b61d368d..97c2f87e365b2 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectCheckoutMethodStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectCheckoutMethodStep.php @@ -61,11 +61,6 @@ public function run() $checkoutMethodBlock = $this->checkoutOnepage->getLoginBlock(); switch ($this->checkoutMethod) { case 'guest': - $checkoutMethodBlock->guestCheckout(); - $checkoutMethodBlock->clickContinue(); - break; - case 'register': - $checkoutMethodBlock->registerCustomer(); $checkoutMethodBlock->clickContinue(); break; case 'login': diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Adminhtml/AgreementGrid.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Adminhtml/AgreementGrid.php index 5fc30624db9f1..cce5116de13af 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Adminhtml/AgreementGrid.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Adminhtml/AgreementGrid.php @@ -26,7 +26,7 @@ class AgreementGrid extends Grid * * @var string */ - protected $firstRowSelector = '//tr[./td[contains(@class, "col-name")]][1]'; + protected $firstRowSelector = '//tbody/tr[./td[contains(@class, "col-name")]][1]'; /** * Filters array mapping diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Onepage/AgreementReview.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Onepage/AgreementReview.php index b8e534a350720..2f40ef1c72661 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Onepage/AgreementReview.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Onepage/AgreementReview.php @@ -35,7 +35,7 @@ class AgreementReview extends Review * * @var string */ - protected $agreementCheckbox = './/input[contains(@id, "agreement")]'; + protected $agreementCheckbox = 'input[name^=checkoutAgreements]'; /** * Get notification massage @@ -55,7 +55,7 @@ public function getNotificationMassage() */ public function setAgreement($value) { - $this->_rootElement->find($this->agreementCheckbox, Locator::SELECTOR_XPATH, 'checkbox')->setValue($value); + $this->_rootElement->find($this->agreementCheckbox, Locator::SELECTOR_CSS, 'checkbox')->setValue($value); } /** diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php index f14298e28858e..a7ed49c05f2b8 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermAbsentOnCheckout.php @@ -62,7 +62,6 @@ public function processAssert( $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout(); - $checkoutOnepage->getLoginBlock()->guestCheckout(); $checkoutOnepage->getLoginBlock()->clickContinue(); $checkoutOnepage->getBillingBlock()->fill($billingAddress); $checkoutOnepage->getBillingBlock()->clickContinue(); diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php index 88ff6d2e36a33..10ae2224ea7ce 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Constraint/AssertTermOnCheckout.php @@ -74,7 +74,6 @@ public function processAssert( $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout(); - $checkoutOnepage->getLoginBlock()->guestCheckout(); $checkoutOnepage->getLoginBlock()->clickContinue(); $checkoutOnepage->getBillingBlock()->fill($billingAddress); $checkoutOnepage->getBillingBlock()->clickContinue(); diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml index 3779944b780d7..d82cb340f1cb2 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/CreateTermEntityTest.xml @@ -7,7 +7,7 @@ --> - + Create enabled term entity with text value catalogProductSimple::default name%isolation% @@ -19,11 +19,11 @@ Flat Rate Fixed checkmo - - - + + + - + Create enabled term entity with HTML value catalogProductSimple::default name%isolation% @@ -35,11 +35,11 @@ Flat Rate Fixed checkmo - - - + + + - + Create enabled term entity with text value catalogProductSimple::default name%isolation% @@ -51,11 +51,11 @@ Flat Rate Fixed checkmo - - - + + + - + Create disabled term entity catalogProductSimple::default name%isolation% @@ -67,11 +67,11 @@ Flat Rate Fixed checkmo - - - + + + - + Create enabled term, check with multishipping catalogProductSimple::default, catalogProductSimple::default name%isolation% @@ -83,8 +83,8 @@ Flat Rate Fixed checkmo - - + + diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml index fff2b08680703..7fb6d83370663 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/DeleteTermEntityTest.xml @@ -7,15 +7,15 @@ --> - + catalogProductSimple::default term_enabled_text Flat Rate Fixed checkmo - - - + + + diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml index 9da8de2a0ffb1..c293d7996e2a3 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestCase/UpdateTermEntityTest.xml @@ -7,7 +7,7 @@ --> - + catalogProductSimple::default term_disabled_text name%isolation% @@ -19,11 +19,11 @@ Flat Rate Fixed checkmo - - - + + + - + catalogProductSimple::default term_disabled_html name%isolation% @@ -35,11 +35,11 @@ Flat Rate Fixed checkmo - - - + + + - + catalogProductSimple::default term_enabled_text name%isolation% @@ -51,9 +51,9 @@ Flat Rate Fixed checkmo - - - + + + diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php index 99fe29e6517c8..640ba98e83d3a 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php @@ -6,12 +6,12 @@ namespace Magento\Cms\Test\Block\Adminhtml\Block; -use Magento\Backend\Test\Block\Widget\Grid; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; /** - * Adminhtml Cms Block management grid. + * Backend Data Grid for managing "CMS Block" entities. */ -class CmsGrid extends Grid +class CmsGrid extends DataGrid { /** * Filters array mapping. @@ -19,46 +19,37 @@ class CmsGrid extends Grid * @var array */ protected $filters = [ + 'block_id_from' => [ + 'selector' => '[name="filters[block_id][from]"]', + ], + 'block_id_to' => [ + 'selector' => '[name="filters[block_id][to]"]', + ], 'title' => [ - 'selector' => '[name="params[filters][title]"]', + 'selector' => '[name="filters[title]"]', ], 'identifier' => [ - 'selector' => '[name="params[filters][identifier]"]', + 'selector' => '[name="filters[identifier]"]', + ], + 'store_id' => [ + 'selector' => '[name="filters[store_id]"]', + 'input' => 'selectstore' ], 'is_active' => [ - 'selector' => '[name="params[filters][is_active]"]', + 'selector' => '[name="filters[is_active]"]', 'input' => 'select', ], 'creation_time_from' => [ - 'selector' => '[name="params[filters][creation_time][from]"]', + 'selector' => '[name="filters[creation_time][from]"]', + ], + 'creation_time_to' => [ + 'selector' => '[name="filters[creation_time][to]"]', ], 'update_time_from' => [ - 'selector' => '[name="params[filters][update_time][from]"]', + 'selector' => '[name="filters[update_time][from]"]', ], - 'store_id' => [ - 'selector' => '[name="params[filters][store_id]"]', - 'input' => 'selectstore' + 'update_time_to' => [ + 'selector' => '[name="filters[update_time][to]"]', ], ]; - - /** - * Locator value for 'Search' button. - * - * @var string - */ - protected $searchButton = '[data-action="grid-filter-apply"]'; - - /** - * Locator value for 'Reset' button. - * - * @var string - */ - protected $resetButton = '[data-action="grid-filter-reset"]'; - - /** - * Locator value for link in action column. - * - * @var string - */ - protected $editLink = '.action-menu-item'; } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php index b111912748e06..e2e0547c44309 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php @@ -6,55 +6,70 @@ namespace Magento\Cms\Test\Block\Adminhtml\Page; -use Magento\Backend\Test\Block\Widget\Grid as ParentGrid; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; use Magento\Mtf\Client\Locator; /** - * Backend Cms Page grid. + * Backend Data Grid for managing "CMS Page" entities. */ -class Grid extends ParentGrid +class Grid extends DataGrid { - /** - * Locator value for 'Search' button. - * - * @var string - */ - protected $searchButton = '[data-action="grid-filter-apply"]'; - - /** - * Locator value for 'Reset' button. - * - * @var string - */ - protected $resetButton = '[data-action="grid-filter-reset"]'; - - /** - * Locator value for link in action column. - * - * @var string - */ - protected $editLink = '[data-action="grid-row-edit"]'; - - /** - * 'Preview' cms page link. - * - * @var string - */ - protected $previewCmsPage = "//a[contains(text(),'Preview')]"; - /** * Filters array mapping. * * @var array */ protected $filters = [ + 'page_id_from' => [ + 'selector' => '[name="filters[page_id][from]"]', + ], + 'page_id_to' => [ + 'selector' => '[name="filters[page_id][to]"]', + ], 'title' => [ - 'selector' => '[name="params[filters][title]"]', + 'selector' => '[name="filters[title]"]', + ], + 'identifier' => [ + 'selector' => '[name="filters[identifier]"]', + ], + 'page_layout' => [ + 'selector' => '[name="filters[page_layout]"]', + 'input' => 'select', + ], + 'store_id' => [ + 'selector' => '[name="filters[store_id]"]', + 'input' => 'selectstore' + ], + 'is_active' => [ + 'selector' => '[name="filters[is_active]"]', + 'input' => 'select', + ], + 'creation_time_from' => [ + 'selector' => '[name="filters[creation_time][from]"]', + ], + 'creation_time_to' => [ + 'selector' => '[name="filters[creation_time][to]"]', + ], + 'update_time_from' => [ + 'selector' => '[name="filters[update_time][from]"]', + ], + 'update_time_to' => [ + 'selector' => '[name="filters[update_time][to]"]', + ], + 'under_version_control' => [ + 'selector' => '[name="filters[under_version_control]"]', ], ]; /** - * Search item and open it on front. + * Locator value for "Preview" link inside action column. + * + * @var string + */ + protected $previewCmsPage = '.action-menu-item'; + + /** + * Search item and open it on Frontend. * * @param array $filter * @throws \Exception @@ -65,7 +80,7 @@ public function searchAndPreview(array $filter) $this->search($filter); $rowItem = $this->_rootElement->find($this->rowItem); if ($rowItem->isVisible()) { - $rowItem->find($this->previewCmsPage, Locator::SELECTOR_XPATH)->click(); + $rowItem->find($this->previewCmsPage)->click(); $this->waitForElement(); } else { throw new \Exception('Searched item was not found.'); diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockIndex.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockIndex.xml index 7f0434e5c6573..061442f63a80e 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockIndex.xml @@ -9,6 +9,6 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageIndex.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageIndex.xml index 44247cb0b2157..4672b7a44134d 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageIndex.xml @@ -8,7 +8,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.php index 0dea51c1d46fe..ef19839183592 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.php @@ -30,6 +30,7 @@ class CreateCmsPageEntityTest extends Injectable const DOMAIN = 'PS'; const TEST_TYPE = 'acceptance_test'; const TO_MAINTAIN = 'yes'; + const STABLE = 'no'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/Fixture/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Config/Test/Fixture/ConfigData.xml index 6e7a87ccfda8d..564a0942002ee 100644 --- a/dev/tests/functional/tests/app/Magento/Config/Test/Fixture/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Config/Test/Fixture/ConfigData.xml @@ -6,29 +6,29 @@ */ --> - - - - - - - default - - - 0 - - - general - - - - - + + + + + + + default + + + 0 + + + general + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php b/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php index 1a0137d106bb6..81cd63e33bc18 100644 --- a/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php +++ b/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php @@ -75,4 +75,15 @@ public function run() return ['config' => $result]; } + + /** + * Rollback configuration. + * + * @return void + */ + public function cleanup() + { + $this->rollback = true; + $this->run(); + } } 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 index 8f778738a972d..56bf124310227 100755 --- 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 @@ -23,7 +23,7 @@ class Config extends Tab * * @var string */ - protected $variationsTabTrigger = '[data-panel="product-variations"] .title span'; + protected $variationsTabTrigger = '[data-target="#super_config-content"][data-toggle="collapse"] span'; /** * Selector for content "Variations" tab. 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 index a86c1eb0631c3..9008800f6dd2e 100644 --- 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 @@ -104,7 +104,7 @@ class Attribute extends Form * * @var string */ - protected $attributeTitle = '.title > span'; + protected $attributeTitle = '[data-toggle="collapse"]'; /** * Selector for attribute content diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/ValidateOrderOfProductTypeTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/ValidateOrderOfProductTypeTest.xml new file mode 100644 index 0000000000000..0e4d0a0b3427d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/ValidateOrderOfProductTypeTest.xml @@ -0,0 +1,14 @@ + + + + + + Configurable Product + + + diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php index d5d1c887a484c..dd274d5fc172f 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php @@ -16,7 +16,42 @@ class CurrencyRateForm extends Form { /** - * Fill currency rate form. + * Locator value for "Messages" block. + * + * @var string + */ + protected $message = '#messages'; + + /** + * Locator value for "Import" button. + * + * @var string + */ + protected $importButton = '[data-ui-id$="import-button"]'; + + /** + * Click on the "Import" button. + * + * @throws \Exception + * @return void + */ + public function clickImportButton() + { + $this->_rootElement->find($this->importButton)->click(); + + //Wait message + $browser = $this->browser; + $selector = $this->message; + $browser->waitUntil( + function () use ($browser, $selector) { + $message = $browser->find($selector); + return $message->isVisible() ? true : null; + } + ); + } + + /** + * Fill "Currency Rates" form. * * @param FixtureInterface $fixture * @param SimpleElement|null $element diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/GridPageActions.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/GridPageActions.php deleted file mode 100644 index ee7d3fcc64116..0000000000000 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/GridPageActions.php +++ /dev/null @@ -1,50 +0,0 @@ -_rootElement->find($this->importButton)->click(); - - //Wait message - $browser = $this->browser; - $selector = $this->message; - $browser->waitUntil( - function () use ($browser, $selector) { - $message = $browser->find($selector); - return $message->isVisible() ? true : null; - } - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/CurrencySymbolForm.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/CurrencySymbolForm.php index 020ae28779832..2f758e545f482 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/CurrencySymbolForm.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/CurrencySymbolForm.php @@ -22,7 +22,7 @@ class CurrencySymbolForm extends Form * * @var string */ - protected $currencyRow = '//tr[td/label[@for="custom_currency_symbol%s"]]'; + protected $currencyRow = '//div[input[@id="custom_currency_symbol%s"]]'; /** * Fill the root form diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml index efcc314043ecb..800e5342f6232 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml @@ -7,9 +7,8 @@ --> - - + diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php index 157b6dae2e1a1..5be6ff8e8e5da 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php @@ -79,7 +79,7 @@ protected function importCurrencyRate($configData) // Import Exchange Rates for currencies $this->currencyIndex->open(); - $this->currencyIndex->getGridPageActions()->clickImportButton(); + $this->currencyIndex->getCurrencyRateForm()->clickImportButton(); if ($this->currencyIndex->getMessagesBlock()->isVisibleMessage('warning')) { throw new \Exception($this->currencyIndex->getMessagesBlock()->getWarningMessages()); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php index a0e2f3f5e30ed..6a034af9855a4 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php @@ -44,6 +44,13 @@ class CustomerForm extends FormTabs */ protected $fieldWrapperControl = './/*[contains(@class, "admin__field")]/*[contains(@class,"control")]'; + /** + * Selector for wainting tab content to load. + * + * @var string + */ + protected $tabReadiness = '.admin__page-nav-item._active._loading'; + /** * Fill Customer forms on tabs by customer, addresses data. * @@ -137,4 +144,18 @@ protected function waitFields() /* Wait for field's control block is visible in the form */ $this->waitForElementVisible($this->fieldWrapperControl, Locator::SELECTOR_XPATH); } + + /** + * Open tab. + * + * @param string $tabName + * @return CustomerForm + */ + public function openTab($tabName) + { + parent::openTab($tabName); + $this->waitForElementNotVisible($this->tabReadiness); + + return $this; + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForgotPasswordSuccessMessage.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForgotPasswordSuccessMessage.php new file mode 100644 index 0000000000000..834e6cca76548 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForgotPasswordSuccessMessage.php @@ -0,0 +1,53 @@ +getEmail() + ); + + \PHPUnit_Framework_Assert::assertEquals( + $message, + $customerLogin->getMessages()->getSuccessMessages(), + 'Wrong forgot password message is displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Customer forgot password message is present on customer account forgot password page.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForm.php index f9c4156f68997..a5bd1c2d3f04c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerForm.php @@ -13,8 +13,7 @@ use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertCustomerForm - * + * Assert customer data on customer backend form. */ class AssertCustomerForm extends AbstractConstraint { @@ -23,7 +22,7 @@ class AssertCustomerForm extends AbstractConstraint /* end tags */ /** - * Skipped fields for verify data + * Skipped fields for verify data. * * @var array */ @@ -32,10 +31,11 @@ class AssertCustomerForm extends AbstractConstraint 'password', 'password_confirmation', 'is_subscribed', + 'address' ]; /** - * Assert that displayed customer data on edit page(backend) equals passed from fixture + * Assert that displayed customer data on edit page(backend) equals passed from fixture. * * @param Customer $customer * @param CustomerIndex $pageCustomerIndex @@ -81,7 +81,7 @@ public function processAssert( } /** - * Verify data in form equals to passed from fixture + * Verify data in form equals to passed from fixture. * * @param array $dataFixture * @param array $dataForm @@ -111,7 +111,6 @@ protected function verify(array $dataFixture, array $dataForm) } else { $result[] = "\naddress #{$key} {$name}: Field absent. Expected value \"{$value}\""; } - } } @@ -119,7 +118,7 @@ protected function verify(array $dataFixture, array $dataForm) } /** - * Text success verify Customer form + * Text success verify Customer form. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupForm.php index 6cc186ea9e5e6..ebbf23d4f1061 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupForm.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Constraint; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew; use Magento\Mtf\Constraint\AbstractConstraint; @@ -34,15 +34,15 @@ class AssertCustomerGroupForm extends AbstractConstraint * * @param CustomerGroupIndex $customerGroupIndex * @param CustomerGroupNew $customerGroupNew - * @param CustomerGroupInjectable $customerGroup - * @param CustomerGroupInjectable $customerGroupOriginal + * @param CustomerGroup $customerGroup + * @param CustomerGroup $customerGroupOriginal * @return void */ public function processAssert( CustomerGroupIndex $customerGroupIndex, CustomerGroupNew $customerGroupNew, - CustomerGroupInjectable $customerGroup, - CustomerGroupInjectable $customerGroupOriginal = null + CustomerGroup $customerGroup, + CustomerGroup $customerGroupOriginal = null ) { $data = ($customerGroupOriginal !== null) ? array_merge($customerGroupOriginal->getData(), $customerGroup->getData()) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupInGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupInGrid.php index 1d938173f9ec8..3af2b399215d8 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupInGrid.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Constraint; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -22,12 +22,12 @@ class AssertCustomerGroupInGrid extends AbstractConstraint /** * Assert that customer group in grid * - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroup * @param CustomerGroupIndex $customerGroupIndex * @return void */ public function processAssert( - CustomerGroupInjectable $customerGroup, + CustomerGroup $customerGroup, CustomerGroupIndex $customerGroupIndex ) { $customerGroupIndex->open(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupNotInGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupNotInGrid.php index eb40eb438bd42..a864f5f172b85 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupNotInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupNotInGrid.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Constraint; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -18,12 +18,12 @@ class AssertCustomerGroupNotInGrid extends AbstractConstraint /** * Assert that customer group not in grid * - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroup * @param CustomerGroupIndex $customerGroupIndex * @return void */ public function processAssert( - CustomerGroupInjectable $customerGroup, + CustomerGroup $customerGroup, CustomerGroupIndex $customerGroupIndex ) { $customerGroupIndex->open(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php index a01afa3abbcd6..b06fc4feddb1f 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Constraint; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerIndexNew; @@ -22,14 +22,14 @@ class AssertCustomerGroupOnCustomerForm extends AbstractConstraint * Assert that customer group find on account information page * * @param FixtureFactory $fixtureFactory - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroup * @param CustomerIndexNew $customerIndexNew * @param CustomerIndex $customerIndex * @return void */ public function processAssert( FixtureFactory $fixtureFactory, - CustomerGroupInjectable $customerGroup, + CustomerGroup $customerGroup, CustomerIndexNew $customerIndexNew, CustomerIndex $customerIndex ) { diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/Address.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/Address.php index ce4b8c6562b63..b381e4d910818 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/Address.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/Address.php @@ -49,18 +49,18 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, array $this->params = $params; if (isset($data['presets'])) { - $data['presets'] = explode(',', $data['presets']); + $data['presets'] = array_map('trim', explode(',', $data['presets'])); foreach ($data['presets'] as $value) { - /** @var AddressFixture $addresses*/ - $addresses = $fixtureFactory->createByCode('address', ['dataSet' => $value]); - $this->data[] = $addresses->getData(); - $this->addressesFixture[] = $addresses; + /** @var AddressFixture $address*/ + $address = $fixtureFactory->createByCode('address', ['dataSet' => $value]); + $this->data[] = $address->getData(); + $this->addressesFixture[] = $address; } } elseif (empty($data['presets']) && !empty($data['addresses'])) { - foreach ($data['addresses'] as $addresses) { - /** @var AddressFixture $addresses */ - $this->data[] = $addresses->getData(); - $this->addressesFixture[] = $addresses; + foreach ($data['addresses'] as $address) { + /** @var AddressFixture $address */ + $this->data[] = $address->getData(); + $this->addressesFixture[] = $address; } } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/GroupId.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/GroupId.php index 6c39f68fc7591..592fe020ec132 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/GroupId.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/Customer/GroupId.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Fixture\Customer; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\Fixture\FixtureInterface; @@ -48,15 +48,15 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, array { $this->params = $params; if (isset($data['dataSet'])) { - /** @var CustomerGroupInjectable $customerGroup */ - $customerGroup = $fixtureFactory->createByCode('customerGroupInjectable', ['dataSet' => $data['dataSet']]); + /** @var CustomerGroup $customerGroup */ + $customerGroup = $fixtureFactory->createByCode('customerGroup', ['dataSet' => $data['dataSet']]); if (!$customerGroup->hasData('customer_group_id')) { $customerGroup->persist(); } $this->data = $customerGroup->getCustomerGroupCode(); $this->customerGroupFixture = $customerGroup; } - if (isset($data['customerGroup']) && $data['customerGroup'] instanceof CustomerGroupInjectable) { + if (isset($data['customerGroup']) && $data['customerGroup'] instanceof CustomerGroup) { $this->data = $data['customerGroup']->getCustomerGroupCode(); $this->customerGroupFixture = $data['customerGroup']; } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroup.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroup.php deleted file mode 100644 index f905b2dca6795..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroup.php +++ /dev/null @@ -1,67 +0,0 @@ -_data['fields']['id']['value'] = Factory::getApp()->magentoCustomerCreateCustomerGroup($this); - } - - /** - * Initialize fixture data - */ - protected function _initData() - { - $this->_data = [ - 'fields' => [ - 'code' => [ - 'value' => 'Test group %isolation%', - ], - 'tax_class' => [ - 'value' => 'Retail Customer', - 'input_value' => 3, - ], - ], - ]; - $this->_defaultConfig = []; - - $this->_repository = Factory::getRepositoryFactory() - ->getMagentoCustomerCustomerGroup($this->_dataConfig, $this->_data); - } - - /** - * Get group name - * - * @return string - */ - public function getGroupName() - { - return $this->getData('fields/code/value'); - } - - /** - * Get group id - * - * @return string - */ - public function getGroupId() - { - return $this->getData('fields/id/value'); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroup.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroup.xml new file mode 100644 index 0000000000000..46083535c8cde --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroup.xml @@ -0,0 +1,26 @@ + + + + + + customer_code_%isolation% + + customer_tax_class + + + + customer_code_%isolation% + + + + customer_tax_class + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroupInjectable.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroupInjectable.xml deleted file mode 100644 index cec2cec3a7461..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerGroupInjectable.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - customer_code_%isolation% - - customer_tax_class - - - - customer_code_%isolation% - - - - customer_tax_class - - - - - diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomerGroup.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomerGroup.php deleted file mode 100644 index dadc4e66523bb..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomerGroup.php +++ /dev/null @@ -1,99 +0,0 @@ -getData('fields'); - foreach ($data as $key => $values) { - $value = $this->getValue($values); - if (null === $value) { - continue; - } - $data[$key] = $value; - } - - return $data; - } - - /** - * Retrieve field value or return null if value does not exist - * - * @param array $values - * @return null|mixed - */ - protected function getValue($values) - { - if (!isset($values['value'])) { - return null; - } - return isset($values['input_value']) ? $values['input_value'] : $values['value']; - } - - /** - * Execute handler - * - * @param FixtureInterface $fixture [optional] - * @return mixed - */ - public function persist(FixtureInterface $fixture = null) - { - /** @var \Magento\Customer\Test\Fixture\CustomerGroup $fixture*/ - $params = $this->prepareData($fixture); - $url = $_ENV['app_backend_url'] . $this->saveUrl; - $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); - $curl->addOption(CURLOPT_HEADER, 1); - $curl->write(CurlInterface::POST, $url, '1.0', [], $params); - $response = $curl->read(); - $curl->close(); - - return $this->findId($response, $fixture->getGroupName()); - } - - /** - * Find id of new customer group in response - * - * @param $response - * @param $name - * @return string - */ - protected function findId($response, $name) - { - $regExp = '~/customer/group/edit/id/(\d+)(?=.*?' . $name . ')~s'; - preg_match_all($regExp, $response, $matches); - $result = ''; - if (!empty($matches[1])) { - $result = array_pop($matches[1]); - } - return $result; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroupInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/Curl.php similarity index 84% rename from dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroupInjectable/Curl.php rename to dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/Curl.php index f2f7c1b52e6d8..c03e8bb75b17a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroupInjectable/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/Curl.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Customer\Test\Handler\CustomerGroupInjectable; +namespace Magento\Customer\Test\Handler\CustomerGroup; use Magento\Backend\Test\Handler\Extractor; use Magento\Mtf\Fixture\FixtureInterface; @@ -14,20 +14,19 @@ use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator; /** - * Class Curl - * Curl handler for creating customer group + * Curl handler for creating customer group. */ -class Curl extends AbstractCurl implements CustomerGroupInjectableInterface +class Curl extends AbstractCurl implements CustomerGroupInterface { /** - * Url for saving data + * Url for saving data. * * @var string */ protected $saveUrl = 'customer/group/save/'; /** - * POST request for creating Customer Group + * POST request for creating Customer Group. * * @param FixtureInterface $fixture * @return array|mixed @@ -50,11 +49,11 @@ public function persist(FixtureInterface $fixture = null) ); } - return ['customer_group_id' => $this->getCustomerGroupId($data, $response)]; + return ['customer_group_id' => $this->getCustomerGroupId($data)]; } /** - * Get id after creating Customer Group + * Get id after creating Customer Group. * * @param array $data * @return int|null diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/CustomerGroupInterface.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/CustomerGroupInterface.php new file mode 100644 index 0000000000000..91fdab59b34b5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/CustomerGroupInterface.php @@ -0,0 +1,17 @@ +London 444-44-444-44 584451913 - - - - Dmytro - Aponasenko - Culver City - 1 Main St - 90230 - United States - Culver City + Yes + Yes diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/ConfigData.xml new file mode 100644 index 0000000000000..8a8254f1e6a59 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/ConfigData.xml @@ -0,0 +1,64 @@ + + + + + + + customer + 1 + Yes + 1 + + + customer + 1 + Billing Address + billing + + + customer + 1 + + Valid VAT ID Domestic %isolation% + + + customer + 1 + + Valid VAT ID Intra %isolation% + + + customer + 1 + + Invalid VAT ID %isolation% + + + customer + 1 + + Error VAT ID %isolation% + + + customer + 1 + Yes + 1 + + + + + + customer + 1 + No + 0 + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml index 3261040052d7d..a3eb0e57b62a6 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml @@ -194,5 +194,16 @@ address_UK_default_billing_address + + + John + Doe%isolation% + John.Doe%isolation%@example.com + 123123q + 123123q + + address_UK_with_VAT + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroup.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroup.php deleted file mode 100644 index a54e62a838b7c..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroup.php +++ /dev/null @@ -1,80 +0,0 @@ -_data['default'] = [ - 'config' => $defaultConfig, - 'data' => $defaultData, - ]; - - $this->_data['valid_vat_id_domestic'] = $this->getValidDomestic($this->_data['default']); - $this->_data['valid_vat_id_union'] = $this->getValidUnion($this->_data['default']); - $this->_data['invalid_vat_id'] = $this->getInvalid($this->_data['default']); - $this->_data['validation_error'] = $this->getError($this->_data['default']); - } - - /** - * Get Valid Domestic VAT group data - * - * @param array $defaultData - * @return array - */ - protected function getValidDomestic(array $defaultData) - { - $defaultData['data']['fields']['code']['value'] = 'Valid VAT ID-Domestic%isolation%'; - return $defaultData; - } - - /** - * Get Valid Union VAT group data - * - * @param array $defaultData - * @return array - */ - protected function getValidUnion(array $defaultData) - { - $defaultData['data']['fields']['code']['value'] = 'ValidVATID-IntraUnion%isolation%'; - return $defaultData; - } - - /** - * Get Invalid VAT group data - * - * @param array $defaultData - * @return array - */ - protected function getInvalid(array $defaultData) - { - $defaultData['data']['fields']['code']['value'] = 'Invalid VAT ID%isolation%'; - return $defaultData; - } - - /** - * Get Error group data - * - * @param array $defaultData - * @return array - */ - protected function getError(array $defaultData) - { - $defaultData['data']['fields']['code']['value'] = 'Validation Error Group%isolation%'; - return $defaultData; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroupInjectable.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroup.xml similarity index 64% rename from dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroupInjectable.xml rename to dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroup.xml index 0ac1bbdda5d59..6f495c88b95e7 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroupInjectable.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerGroup.xml @@ -6,7 +6,7 @@ */ --> - + 1 General @@ -50,5 +50,33 @@ retail_customer + + + Valid VAT ID Domestic %isolation% + + retail_customer + + + + + Valid VAT ID Intra %isolation% + + retail_customer + + + + + Invalid VAT ID %isolation% + + retail_customer + + + + + Error VAT ID %isolation% + + retail_customer + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php new file mode 100644 index 0000000000000..4389e18c61643 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/AbstractApplyVatIdTest.php @@ -0,0 +1,127 @@ + 'valid_vat_id_domestic', + 'valid_intra_union_group' => 'valid_vat_id_intra_union', + 'invalid_group' => 'invalid_vat_id', + 'error_group' => 'validation_error_vat_id' + ]; + + /** + * Customer groups for VAT ID configuration. + * + * @var array + */ + protected $vatGroups = []; + + /** + * Inject fixture factory class and create customer groups. + * + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->fixtureFactory = $fixtureFactory; + + foreach ($this->vatGroupDataSets as $group => $dataSet) { + /** @var CustomerGroup $groupFixture */ + $groupFixture = $this->fixtureFactory->createByCode('customerGroup', ['dataSet' => $dataSet]); + $groupFixture->persist(); + $this->vatGroups[$group] = $groupFixture; + } + } + + /** + * Prepare VAT ID confguration. + * + * @param ConfigData $vatConfig + * @param string $customerGroup + * @return void + */ + protected function prepareVatConfig(ConfigData $vatConfig, $customerGroup) + { + $groupConfig = [ + 'customer/create_account/viv_domestic_group' => [ + 'value' => $this->vatGroups['valid_domestic_group']->getCustomerGroupId() + ], + 'customer/create_account/viv_intra_union_group' => [ + 'value' => $this->vatGroups['valid_intra_union_group']->getCustomerGroupId() + ], + 'customer/create_account/viv_invalid_group' => [ + 'value' => $this->vatGroups['invalid_group']->getCustomerGroupId() + ], + 'customer/create_account/viv_error_group' => [ + 'value' => $this->vatGroups['error_group']->getCustomerGroupId() + ] + ]; + $vatConfig = $this->fixtureFactory->createByCode( + 'configData', + ['data' => array_replace_recursive($vatConfig->getSection(), $groupConfig)] + ); + $vatConfig->persist(); + + $customerData = array_merge( + $this->customer->getData(), + ['group_id' => ['value' => $this->vatGroups[$customerGroup]->getCustomerGroupCode()]], + ['address' => ['addresses' => $this->customer->getDataFieldConfig('address')['source']->getAddresses()]] + ); + $this->customer = $this->fixtureFactory->createByCode('customer', ['data' => $customerData]); + } + + /** + * Disable VAT id configuration. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData, 'rollback' => true] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php new file mode 100644 index 0000000000000..3ab5ad0d9b33e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.php @@ -0,0 +1,104 @@ + Address Book. + * 4. Update Default Billing Address with specified VAT number. + * 5. Save Customer Address. + * 6. Perform assertions. + * + * @group VAT_ID_(CS) + * @ZephyrId MAGETWO-12447 + */ +class ApplyVatIdTest extends AbstractApplyVatIdTest +{ + /* tags */ + const MVP = 'no'; + const DOMAIN = 'CS'; + const TEST_TYPE = '3rd_party_test'; + /* end tags */ + + /** + * Customer account page. + * + * @var CustomerAccountIndex + */ + protected $customerAccountIndex; + + /** + * Customer account edit address page. + * + * @var CustomerAddressEdit + */ + protected $customerAddressEdit; + + /** + * Inject pages. + * + * @param CustomerAccountIndex $customerAccountIndex + * @param CustomerAddressEdit $customerAddressEdit + * @return void + */ + public function __inject(CustomerAccountIndex $customerAccountIndex, CustomerAddressEdit $customerAddressEdit) + { + $this->customerAccountIndex = $customerAccountIndex; + $this->customerAddressEdit = $customerAddressEdit; + } + + /** + * Enable Automatic Assignment of Customers to Appropriate VAT Group. + * + * @param Customer $customer + * @param Address $vatId + * @param ConfigData $vatConfig + * @param string $configData + * @param string $customerGroup + * @return array + */ + public function test( + Customer $customer, + Address $vatId, + ConfigData $vatConfig, + $configData, + $customerGroup + ) { + // Preconditions + $this->configData = $configData; + $this->customer = $customer; + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData] + )->run(); + $this->customer->persist(); + $this->prepareVatConfig($vatConfig, $customerGroup); + + // Steps + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $this->customer] + )->run(); + $this->customerAccountIndex->getDashboardAddress()->editBillingAddress(); + $this->customerAddressEdit->getEditForm()->fill($vatId); + $this->customerAddressEdit->getEditForm()->saveAddress(); + + return ['customer' => $this->customer]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.xml new file mode 100644 index 0000000000000..94af84c9ee9de --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ApplyVatIdTest.xml @@ -0,0 +1,31 @@ + + + + + + MAGETWO-12447: Enable Automatic Assignment of Customers to Appropriate VAT Group (valid Intra-Union group). + enable_VAT_on_frontend + store_information_DE_with_VAT, enable_VAT_on_frontend + customer_UK_1_default_billing_address + 584451913 + valid_intra_union_group + + + + + MAGETWO-12447: Enable Automatic Assignment of Customers to Appropriate VAT Group (invalid VAT ID group). + enable_VAT_on_frontend + store_information_DE_with_VAT, enable_VAT_on_frontend + customer_UK_1_default_billing_address + 123456789 + invalid_group + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.php index ac44139514246..12ccabb6c501c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\TestCase; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew; use Magento\Mtf\TestCase\Injectable; @@ -62,10 +62,10 @@ public function __inject( /** * Create customer group * - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroup */ public function testCreateCustomerGroup( - CustomerGroupInjectable $customerGroup + CustomerGroup $customerGroup ) { //Steps $this->customerGroupIndex->open(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php index dda7cbc0c85ec..7b3cfefbf139c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\TestCase; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew; use Magento\Mtf\TestCase\Injectable; @@ -67,10 +67,10 @@ public function __inject( /** * Delete Customer Group * - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroup * @return void */ - public function test(CustomerGroupInjectable $customerGroup) + public function test(CustomerGroup $customerGroup) { // Precondition $customerGroup->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.php index 6d77b740a4d74..8e961286ee484 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.php @@ -6,37 +6,44 @@ namespace Magento\Customer\Test\TestCase; -use Magento\Mtf\Factory\Factory; -use Magento\Mtf\TestCase\Functional; +use Magento\Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\CustomerAccountForgotPassword; /** - * Reset password on frontend + * Precondition: + * 1. Customer is created. + * + * Steps: + * 1. Open forgot password page. + * 2. Fill e-mail. + * 3. Click forgot password button. + * 4. Check forgot password message. + * + * @group Customer_(CS) + * @ZephyrId MAGETWO-37145 */ -class ForgotPasswordOnFrontendTest extends Functional +class ForgotPasswordOnFrontendTest extends Injectable { + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + /** - * Reset password on frontend + * Create customer. + * + * @param Customer $customer + * @param CustomerAccountForgotPassword $forgotPassword + * @return void */ - public function testForgotPassword() + public function test(Customer $customer, CustomerAccountForgotPassword $forgotPassword) { - // Create Customer - $customer = $this->objectManager->getInstance()->create( - 'Magento\Customer\Test\Fixture\Customer', - ['dataSet' => 'customer_US_1'] - ); + // Precondition $customer->persist(); - $customerAccountLoginPage = Factory::getPageFactory()->getCustomerAccountLogin(); - $forgotPasswordPage = Factory::getPageFactory()->getCustomerAccountForgotpassword(); - $forgotPasswordPage->open(); - - $forgotPasswordPage->getForgotPasswordForm()->resetForgotPassword($customer); - - //Verifying - $message = sprintf( - 'If there is an account associated with %s you will receive an email with a link to reset your password.', - $customer->getEmail() - ); - $this->assertContains($message, $customerAccountLoginPage->getMessages()->getSuccessMessages()); + // Steps + $forgotPassword->open(); + $forgotPassword->getForgotPasswordForm()->resetForgotPassword($customer); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.xml new file mode 100644 index 0000000000000..28a5aa51e2f9b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.xml @@ -0,0 +1,15 @@ + + + + + + customer_US_1 + + + + 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 index 1ad32642a33cd..d253c87f9ffad 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\TestCase; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; use Magento\Mtf\TestCase\Injectable; @@ -81,10 +81,10 @@ public function __inject(CustomerIndex $customerIndex) * Mass assign customer group * * @param Customer $customer - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroup * @return void */ - public function test(Customer $customer, CustomerGroupInjectable $customerGroup) + public function test(Customer $customer, CustomerGroup $customerGroup) { // Steps $customerGroup->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php index 3a0bd67548232..c28cfc03061c3 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php @@ -60,6 +60,7 @@ public function __inject( $this->customerAccountLogout = $customerAccountLogout; $this->customerAccountCreate = $customerAccountCreate; $this->cmsIndex = $cmsIndex; + $this->customerAccountLogout->open(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerGroupEntityTest.php index 4d96a298f3951..4eb6952aec409 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerGroupEntityTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\TestCase; -use Magento\Customer\Test\Fixture\CustomerGroupInjectable; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerGroupNew; use Magento\Mtf\TestCase\Injectable; @@ -68,13 +68,13 @@ public function __inject( /** * Update Customer Group * - * @param CustomerGroupInjectable $customerGroupOriginal - * @param CustomerGroupInjectable $customerGroup + * @param CustomerGroup $customerGroupOriginal + * @param CustomerGroup $customerGroup * @return void */ public function test( - CustomerGroupInjectable $customerGroupOriginal, - CustomerGroupInjectable $customerGroup + CustomerGroup $customerGroupOriginal, + CustomerGroup $customerGroup ) { // Precondition $customerGroupOriginal->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/CreateCustomerStep.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/CreateCustomerStep.php index a98e2da6adab1..7e59cf6be6a8c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/CreateCustomerStep.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/CreateCustomerStep.php @@ -29,13 +29,22 @@ class CreateCustomerStep implements TestStepInterface */ protected $persistCustomer = true; + /** + * Logout customer on frontend step. + * + * @var LogoutCustomerOnFrontendStep + */ + protected $logoutCustomerOnFrontend; + /** * @constructor + * @param LogoutCustomerOnFrontendStep $logout * @param Customer $customer * @param string $checkoutMethod */ - public function __construct(Customer $customer, $checkoutMethod = '') + public function __construct(LogoutCustomerOnFrontendStep $logout, Customer $customer, $checkoutMethod = '') { + $this->logoutCustomerOnFrontend = $logout; $this->customer = $customer; if ($checkoutMethod === 'register' || $checkoutMethod === 'guest') { $this->persistCustomer = false; @@ -55,4 +64,14 @@ public function run() return ['customer' => $this->customer]; } + + /** + * Logout customer on fronted. + * + * @return void + */ + public function cleanup() + { + $this->logoutCustomerOnFrontend->run(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LoginCustomerOnFrontendStep.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LoginCustomerOnFrontendStep.php index e3a0175611ca1..95561a50fd930 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LoginCustomerOnFrontendStep.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LoginCustomerOnFrontendStep.php @@ -37,20 +37,30 @@ class LoginCustomerOnFrontendStep implements TestStepInterface */ protected $customerAccountLogin; + /** + * Logout customer on frontend step. + * + * @var LogoutCustomerOnFrontendStep + */ + protected $logoutCustomerOnFrontend; + /** * @constructor * @param CmsIndex $cmsIndex * @param CustomerAccountLogin $customerAccountLogin + * @param LogoutCustomerOnFrontendStep $logoutCustomerOnFrontend * @param Customer $customer */ public function __construct( CmsIndex $cmsIndex, CustomerAccountLogin $customerAccountLogin, + LogoutCustomerOnFrontendStep $logoutCustomerOnFrontend, Customer $customer ) { $this->cmsIndex = $cmsIndex; $this->customerAccountLogin = $customerAccountLogin; $this->customer = $customer; + $this->logoutCustomerOnFrontend = $logoutCustomerOnFrontend; } /** @@ -70,5 +80,16 @@ public function run() $this->cmsIndex->getLinksBlock()->openLink("Log In"); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); $this->customerAccountLogin->getLoginBlock()->login($this->customer); + $this->cmsIndex->getCmsPageBlock()->waitPageInit(); + } + + /** + * Logout customer on fronted. + * + * @return void + */ + public function cleanup() + { + $this->logoutCustomerOnFrontend->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/curl/di.xml index 303133bdea2b4..a4bfc8b95f1d9 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/curl/di.xml @@ -7,5 +7,5 @@ --> - + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml index 7b7e790a0fc41..2c077cd9213c7 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml @@ -6,34 +6,39 @@ */ --> - - - middle - - - - - middle - - - - - middle - - - - - middle - - - - - high - - - - - high - - + + + middle + + + + + middle + + + + + middle + + + + + middle + + + + + high + + + + + high + + + + + high + + diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/ValidateOrderOfProductTypeTest.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/ValidateOrderOfProductTypeTest.xml new file mode 100644 index 0000000000000..651822824cf66 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/ValidateOrderOfProductTypeTest.xml @@ -0,0 +1,14 @@ + + + + + + Downloadable Product + + + diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php index 037331074bd67..d888fa31e8ef2 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts.php @@ -43,7 +43,7 @@ class AssociatedProducts extends Tab * * @var string */ - protected $deleteButton = '.delete'; + protected $deleteButton = '[data-role="delete"]'; /** * Get search grid @@ -104,6 +104,8 @@ public function fillFormTab(array $fields, SimpleElement $element = null) * @param array|null $fields * @param SimpleElement|null $element * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getDataFormTab($fields = null, SimpleElement $element = null) { diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/ValidateOrderOfProductTypeTest.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/ValidateOrderOfProductTypeTest.xml new file mode 100644 index 0000000000000..d49505396782a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/ValidateOrderOfProductTypeTest.xml @@ -0,0 +1,14 @@ + + + + + + Grouped Product + + + diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessInstall.php b/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessInstall.php index 2f7039d86953e..07ce519b594d3 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessInstall.php +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessInstall.php @@ -57,6 +57,7 @@ public function processAssert(Install $installPage, InstallConfig $installConfig $allData[$key] = isset($value['value']) ? $value['value'] : $value; } + $allData['web'] = (isset($allData['https']) ? $allData['https'] : $allData['web']); $allData['admin'] = $allData['web'] . $allData['admin'] . '/'; foreach ($this->adminFieldsList as $field) { diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/Constraint/AssertIntegrationResourcesPopup.php b/dev/tests/functional/tests/app/Magento/Integration/Test/Constraint/AssertIntegrationResourcesPopup.php index 7c72e99e67d34..90f5f099fb3ea 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/Constraint/AssertIntegrationResourcesPopup.php +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/Constraint/AssertIntegrationResourcesPopup.php @@ -61,8 +61,8 @@ protected function verifyResources(array $formResources, array $fixtureResources if (!empty($diff)) { $errorMessage = sprintf( "Resources are not equal.\nExpected: %s\nActual: %s", - implode(",\n", $fixtureResources), - implode(",\n", $formResources) + implode(",\n", $formResources), + implode(",\n", $topFormResources) ); } diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/Repository/Integration.xml b/dev/tests/functional/tests/app/Magento/Integration/Test/Repository/Integration.xml index 2a64187ab3245..4fe24f70c1da6 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/Repository/Integration.xml +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/Repository/Integration.xml @@ -16,13 +16,14 @@ Sales Products Customers - My Account - Marketing - Content - Reports - Stores - System - Global Search + Carts + My Account + Marketing + Content + Reports + Stores + System + Global Search diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Block/Checkout/Addresses.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Block/Checkout/Addresses.php index 0f19a6214f0a9..8b8b16cd4f5e4 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Block/Checkout/Addresses.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Block/Checkout/Addresses.php @@ -48,7 +48,7 @@ public function selectAddresses($bindings) { foreach ($bindings as $key => $value) { $this->_rootElement->find( - '//tr[//a[text()="' . $key . '"]]/following-sibling::*//select', + '//tr[.//a[text()="' . $key . '"]]//select[contains(@name,"[address]")]', Locator::SELECTOR_XPATH, 'select' )->setValue($value); diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php index 1ff01795ef352..f7ebe72418561 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/TestStep/FillCustomerAddressesStep.php @@ -71,12 +71,14 @@ public function __construct( */ public function run() { + $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses(); $bindings = []; + foreach ($this->products as $key => $product) { $productName = $product->getName(); $addressRender = $this->objectManeger->create( '\Magento\Customer\Test\Block\Address\Renderer', - ['address' => $this->customer->getAddress()[$key], 'type' => 'oneline'] + ['address' => $addresses[$key], 'type' => 'oneline'] ); $bindings[$productName] = $addressRender->render(); } diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Template/Grid.php b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Template/Grid.php index 972317cb5c7a2..9f1389d67a834 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Template/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Template/Grid.php @@ -37,7 +37,7 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid * * @var string */ - protected $action = '.action-select'; + protected $action = '.col-actions [class*="control-select"]'; /** * Action for newsletter template diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/Totals/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/Totals/Grid.php index 3bf9e419499f8..ea6551b8eaab7 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/Totals/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/Totals/Grid.php @@ -67,7 +67,7 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid protected function getRow(array $filter, $isSearchable = true, $isStrict = true) { $this->date = sprintf($this->date, $filter['date']); - $location = '//div[@class="grid"]//tr[((preceding-sibling::' . sprintf($this->preceding, $filter['date']) + $location = '//table//tr[((preceding-sibling::' . sprintf($this->preceding, $filter['date']) . ' and following-sibling::' . $this->following . ') or ' . $this->date . ') and '; unset($filter['date']); $rows = []; diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php index da229325e70c0..7eb3c3c97cbe9 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertCouponReportResult.php @@ -34,16 +34,16 @@ public function processAssert(SalesCouponReportView $salesCouponReportView, Orde $discount = $data['price']['discount'] != 0 ? '-' . $currency . number_format($data['price']['discount'], 2) : $currency . '0.00'; - $roleName = $data['coupon_code']->getName(); + $couponCode = $data['coupon_code']->getCouponCode(); $filter = [ - 'coupon_code' => $data['coupon_code']->getCouponCode(), - 'rule_name' => $roleName, + 'coupon_code' => $couponCode, + 'rule_name' => $data['coupon_code']->getName(), 'subtotal' => $currency . number_format($data['price']['subtotal'], 2), 'discount' => $discount, ]; \PHPUnit_Framework_Assert::assertTrue( $salesCouponReportView->getGridBlock()->isRowVisible($filter, false), - "Coupon '$roleName' is not visible." + "Coupon with code - '$couponCode' is not visible." ); } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml index 8dc602074b43b..7f7eedb651962 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/Bestsellers.xml @@ -10,6 +10,6 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml index 6b09e1eea717d..c51b3b5f61d3c 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml @@ -8,7 +8,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/RefundsReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/RefundsReport.xml index d9178313fb69b..ef3d8424e1909 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/RefundsReport.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/RefundsReport.xml @@ -10,6 +10,6 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesInvoiceReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesInvoiceReport.xml index 80d2d491cf977..245a21f9aaec0 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesInvoiceReport.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesInvoiceReport.xml @@ -10,6 +10,6 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesReport.xml index 5ca316b71b414..63f26114a2546 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesReport.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesReport.xml @@ -10,6 +10,6 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesTaxReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesTaxReport.xml index 39eb397bf1a4d..04b999e099978 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesTaxReport.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/SalesTaxReport.xml @@ -9,6 +9,6 @@ - + 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 index f71fd73490e3a..15078aca2addf 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php @@ -70,7 +70,6 @@ public function __inject(CustomerIndex $customerIndexPage, CustomerAccounts $cus */ public function test(Customer $customer, array $customersReport) { - $this->markTestIncomplete('Bug: MAGETWO-35037'); // Preconditions $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All'); diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.xml index 34fdf9bb40968..9d23f499e401e 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.xml @@ -33,6 +33,7 @@ default + 0 m/d/Y 12:00 a+1 day m/d/Y 12:00 a+1 day Day diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Rating/Grid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Rating/Grid.php index 67a5eeec54596..4d59bcf272e79 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Rating/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Rating/Grid.php @@ -28,10 +28,10 @@ class Grid extends AbstractGrid */ protected $filters = [ 'rating_code' => [ - 'selector' => '.filter [name="rating_code"]', + 'selector' => '[name="rating_code"]', ], 'is_active' => [ - 'selector' => '.filter [name="is_active"]', + 'selector' => '[name="is_active"]', 'input' => 'select', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php index b2030524e5eec..782298c972060 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php @@ -85,7 +85,7 @@ class Create extends Block * * @var string */ - protected $updateItems = '#order-items_grid button[onclick="order.itemsUpdate()"]'; + protected $updateItems = '[onclick="order.itemsUpdate()"]'; /** * 'Add Selected Product(s) to Order' button. diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Store.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Store.php index d1ca2a6925a1e..f37068a27706e 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Store.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Store.php @@ -25,6 +25,13 @@ class Store extends Block */ protected $templateBlock = './ancestor::body'; + /** + * Locator value for specified Store control. + * + * @var string + */ + protected $store = '//label[contains(., "%s")]/preceding-sibling::*'; + /** * Get backend abstract block * @@ -48,7 +55,7 @@ public function selectStoreView(StoreFixture $fixture = null) return; } $storeName = $fixture == null ? 'Default Store View' : $fixture->getName(); - $selector = '//label[text()="' . $storeName . '"]/preceding-sibling::*'; + $selector = sprintf($this->store, $storeName); $this->_rootElement->find($selector, Locator::SELECTOR_XPATH, 'checkbox')->setValue('Yes'); $this->getTemplateBlock()->waitLoader(); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Status/Assign/AssignForm.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Status/Assign/AssignForm.xml index 3427f2b225734..72cc2d486b9d1 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Status/Assign/AssignForm.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Status/Assign/AssignForm.xml @@ -9,10 +9,10 @@ - select + strictselect checkbox diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php index 741eeaabdab3c..74b4874e35845 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php @@ -17,7 +17,7 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid * * @var string */ - protected $editLink = 'td[data-column="increment_id"]'; + protected $editLink = 'tbody td[data-column="increment_id"]'; /** * Filters array mapping diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php index 4e22f9ce2dfb8..f3d14af7526e8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php @@ -24,7 +24,7 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid * * @var string */ - protected $invoiceId = 'td[data-column="increment_id"]'; + protected $invoiceId = 'tbody td[data-column="increment_id"]'; /** * Filters array mapping diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments/Grid.php index 5fa33144c2fd0..c643e010ca4c2 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Shipments/Grid.php @@ -24,7 +24,7 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid * * @var string */ - protected $shipmentId = 'td[data-column="real_shipment_id"]'; + protected $shipmentId = 'tbody td[data-column="real_shipment_id"]'; /** * Filters array mapping diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php index 810651a68c964..fd5040e771571 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderInOrdersGridOnFrontend.php @@ -49,11 +49,11 @@ public function processAssert( 'id' => $order->hasData('id') ? $order->getId() : $orderId, 'status' => $statusToCheck === null ? $status : $statusToCheck, ]; - $customerLogin = $objectManager->create( + + $objectManager->create( 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', ['customer' => $customer] - ); - $customerLogin->run(); + )->run(); $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders'); $errorMessage = implode(', ', $filter); \PHPUnit_Framework_Assert::assertTrue( diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php index 6ca945fa82e3a..f35278c78f1d6 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php @@ -46,7 +46,7 @@ public function processAssert( ]; $grid->search($filter); $filter['amount_from'] = number_format($amount[$key]['grand_creditmemo_total'], 2); - $filter['amount_to'] = number_format($amount[$key]['grand_creditmemo_total'], 2); + unset($filter['amount_to']); \PHPUnit_Framework_Assert::assertTrue( $grid->isRowVisible($filter, false, false), 'Credit memo is absent on credit memos tab.' diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesCreditMemoView.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesCreditMemoView.xml index a2353d3245e96..fa60f5f5b8802 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesCreditMemoView.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesCreditMemoView.xml @@ -6,7 +6,7 @@ */ --> - - - + + + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php index 148ccff6b0733..f75105b141332 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php @@ -132,6 +132,7 @@ public function test( 'orderStatus', ['data' => array_merge($orderStatus->getData(), $orderStatusState)] ); + $this->orderStatus = $orderStatus; // Steps: $this->orderStatusIndex->open(); @@ -141,9 +142,6 @@ public function test( $assertion->processAssert($this->orderStatusIndex); $order->persist(); - - // Prepare data for tear down - $this->orderStatus = $orderStatus; $this->order = $order; return [ @@ -160,8 +158,12 @@ public function test( */ public function tearDown() { - $this->orderIndex->open()->getSalesOrderGrid()->massaction([['id' => $this->order->getId()]], 'Cancel'); - $filter = ['label' => $this->orderStatus->getLabel()]; - $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter); + if ($this->order) { + $this->orderIndex->open()->getSalesOrderGrid()->massaction([['id' => $this->order->getId()]], 'Cancel'); + } + if ($this->orderStatus) { + $filter = ['label' => $this->orderStatus->getLabel()]; + $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter); + } } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php index 67700cfedc82f..c95042db6b0a0 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php @@ -47,21 +47,4 @@ public function test() { $this->executeScenario(); } - - /** - * Disable enabled config after test. - * - * @return void - */ - public function tearDown() - { - if (isset($this->currentVariation['arguments']['configData'])) { - $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => $this->currentVariation['arguments']['configData'], 'rollback' => true] - )->run(); - } - $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); - $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php index 1e7e13da8b55a..f4eb3d91aae1c 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php @@ -70,7 +70,6 @@ public function test() */ public function tearDown() { - $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); $this->browser->closeWindow(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php index 2706971f12810..1ecc886219ca9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php @@ -41,21 +41,4 @@ public function test() { $this->executeScenario(); } - - /** - * Disable enabled config after test. - * - * @return void - */ - public function tearDown() - { - if (isset($this->currentVariation['arguments']['configData'])) { - $setConfigStep = $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => $this->currentVariation['arguments']['configData'], 'rollback' => true] - ); - $setConfigStep->run(); - } - $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php index bda908faf2677..c9b0fc0283473 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php @@ -28,17 +28,26 @@ class CreateSalesRuleStep implements TestStepInterface */ protected $fixtureFactory; + /** + * Delete all Sales Rule on backend. + * + * @var DeleteAllSalesRuleStep + */ + protected $deleteAllSalesRule; + /** * Preparing step properties. * * @constructor * @param FixtureFactory $fixtureFactory + * @param DeleteAllSalesRuleStep $deleteRule * @param string $salesRule */ - public function __construct(FixtureFactory $fixtureFactory, $salesRule = null) + public function __construct(FixtureFactory $fixtureFactory, DeleteAllSalesRuleStep $deleteRule, $salesRule = null) { $this->fixtureFactory = $fixtureFactory; $this->salesRule = $salesRule; + $this->deleteAllSalesRule = $deleteRule; } /** @@ -60,4 +69,14 @@ public function run() return $result; } + + /** + * Delete all sales rule. + * + * @return void + */ + public function cleanup() + { + $this->deleteAllSalesRule->run(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Grid.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Grid.php index 8923aa8d311fb..c6754087307d1 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Grid.php @@ -49,7 +49,7 @@ class Grid extends GridInterface * * @var string */ - protected $firstRowSelector = '//tr[./td[contains(@class, "col-name")]][1]'; + protected $firstRowSelector = '//tbody/tr[./td[contains(@class, "col-name")]][1]'; /** * Check if specific row exists in grid diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/ConfigData.xml index 62f7c6f168f63..e8cd16287bce0 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/ConfigData.xml @@ -136,6 +136,117 @@ + + + tax + 1 + None + 0 + + + tax + 1 + Total + TOTAL_BASE_CALCULATION + + + tax + 1 + Excluding Tax + 0 + + + tax + 1 + Excluding Tax + 0 + + + tax + 1 + Before Discount + 0 + + + tax + 1 + Excluding Tax + 0 + + + tax + 1 + No + 0 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + No + 0 + + + tax + 1 + No + 0 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + Excluding Tax + 1 + + + tax + 1 + No + 0 + + + tax @@ -434,7 +545,7 @@ tax 1 - + UNIT_BASE_CALCULATION @@ -686,7 +797,7 @@ tax 1 - + 0 @@ -725,7 +836,7 @@ tax 1 - + 0 diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml index e5330551dbd44..801382ccf4b17 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml @@ -147,5 +147,26 @@ 0 0 + + + Tax Rule %isolation% + + + uk_full_tax_rate + + + + + retail_customer + + + + + taxable_goods + + + 0 + 0 + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php new file mode 100644 index 0000000000000..6365a5c42087a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.php @@ -0,0 +1,133 @@ +checkoutCart = $checkoutCart; + } + + /** + * Automatic Apply Tax Based on VAT ID. + * + * @param ConfigData $vatConfig + * @param OrderInjectable $order + * @param TaxRule $taxRule + * @param Cart $cart + * @param string $configData + * @param string $customerGroup + * @return array + */ + public function test( + ConfigData $vatConfig, + OrderInjectable $order, + TaxRule $taxRule, + Cart $cart, + $configData, + $customerGroup + ) { + // Preconditions + $this->configData = $configData; + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData] + )->run(); + $taxRule->persist(); + // Prepare data + $this->customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer(); + $address = $this->customer->getDataFieldConfig('address')['source']->getAddresses()[0]; + $this->prepareVatConfig($vatConfig, $customerGroup); + $poducts = $order->getEntityId()['products']; + $cart = $this->fixtureFactory->createByCode( + 'cart', + ['data' => array_merge($cart->getData(), ['items' => ['products' => $poducts]])] + ); + + // Steps + $order->persist(); + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $this->customer] + )->run(); + $this->objectManager->create( + 'Magento\Checkout\Test\TestStep\AddProductsToTheCartStep', + $order->getEntityId() + )->run(); + $this->checkoutCart->open(); + $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); + $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address); + $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); + + return [ + 'customer' => $this->customer, + 'address' => $address, + 'orderId' => $order->getId(), + 'cart' => $cart, + 'products' => $poducts + ]; + } + + /** + * Delete tax rules and disable VAT configuration. + * + * @return void + */ + public function tearDown() + { + parent::tearDown(); + $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.xml new file mode 100644 index 0000000000000..46afe8448d32a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.xml @@ -0,0 +1,32 @@ + + + + + + MAGETWO-13436: Automatic Apply Tax Based on VAT ID. + enable_VAT_on_frontend + default_tax_configuration, flatrate, checkmo, store_information_DE_with_VAT, enable_VAT_on_frontend + address_UK_with_VAT + default + catalogProductSimple::product_10_dollar + customer_UK_address_with_VAT + address_UK_with_VAT + retailer_uk_full_tax_rule + valid_intra_union_group + 10 + 2 + 12 + + 17 + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php index ddfd3ab0508cc..6afab8526a2d8 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php @@ -7,7 +7,6 @@ namespace Magento\Tax\Test\TestCase; use Magento\Mtf\TestCase\Scenario; -use Magento\Mtf\ObjectManager; /** * Steps: @@ -54,22 +53,4 @@ public function test() { $this->executeScenario(); } - - /** - * Tear down after each test. - * - * @return void - */ - public function tearDown() - { - $this->objectManager->create('\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); - $this->objectManager->create('\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); - $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); - - // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331 - $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => 'default_tax_configuration'] - )->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php index b394a7b3783fd..a0f5183841333 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php @@ -28,17 +28,26 @@ class CreateTaxRuleStep implements TestStepInterface */ protected $fixtureFactory; + /** + * Delete all Tax Rule on backend. + * + * @var DeleteAllTaxRulesStep + */ + protected $deleteAllTaxRule; + /** * Preparing step properties. * * @constructor * @param FixtureFactory $fixtureFactory + * @param DeleteAllTaxRulesStep $deleteTaxRule * @param string $taxRule */ - public function __construct(FixtureFactory $fixtureFactory, $taxRule = null) + public function __construct(FixtureFactory $fixtureFactory, DeleteAllTaxRulesStep $deleteTaxRule, $taxRule = null) { $this->fixtureFactory = $fixtureFactory; $this->taxRule = $taxRule; + $this->deleteAllTaxRule = $deleteTaxRule; } /** @@ -63,4 +72,14 @@ public function run() return $result; } + + /** + * Delete all tax rule. + * + * @return void + */ + public function cleanup() + { + $this->deleteAllTaxRule->run(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php new file mode 100644 index 0000000000000..786403928d656 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -0,0 +1,90 @@ +_rootElement->find($this->appliedFiltersList); + if ($chipsHolder->isVisible()) { + parent::resetFilter(); + } + } + + /** + * Open "Filter" block. + * + * @return void + */ + protected function openFilterBlock() + { + $this->getTemplateBlock()->waitForElementNotVisible($this->loader); + + $toggleFilterButton = $this->_rootElement->find($this->filterButton); + $searchButton = $this->_rootElement->find($this->searchButton); + if ($toggleFilterButton->isVisible() && !$searchButton->isVisible()) { + $toggleFilterButton->click(); + $browser = $this->_rootElement; + $browser->waitUntil( + function () use ($searchButton) { + return $searchButton->isVisible() ? true : null; + } + ); + } + } + + /** + * Search item using Data Grid Filter. + * + * @param array $filter + * @return void + */ + public function search(array $filter) + { + $this->openFilterBlock(); + parent::search($filter); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php index 570f597f47de9..7ea8d153f585f 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php @@ -25,7 +25,7 @@ class WidgetGrid extends AbstractGrid * * @var string */ - protected $firstRowSelector = '//tr[./td[contains(@class, "col-title")]][1]/td'; + protected $firstRowSelector = '//tbody//tr[@data-role="row"]/td[contains(@class, "col-title")][1]'; /** * Filters array mapping. 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 index fd2a372a44473..db52e68e51d0d 100644 --- 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 @@ -104,7 +104,7 @@ protected function getRow(array $filter, $isSearchable = true, $isStrict = true) if ($isSearchable) { $this->search($filter); } - $location = '//div[@class="grid"]//tr['; + $location = '//tr['; $rowTemplate = 'td[contains(.,normalize-space("%s"))]'; $rows = []; foreach ($filter as $value) { diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml index 1f74e74f5eee2..b3147a50d26c4 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml @@ -19,5 +19,8 @@ + + + diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic.xml index 5caf8c85d2d31..459cdc5125379 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic.xml @@ -15,7 +15,7 @@ - + diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_cs.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_cs.xml index e2868c61dd81e..90bd37fa95380 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_cs.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_cs.xml @@ -14,6 +14,8 @@ + + diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx.xml index a89cca04ba59d..03730f6897cb8 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx.xml @@ -14,6 +14,8 @@ + + diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_ps.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_ps.xml index 2a99294b46bad..18054e3881d4d 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_ps.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_ps.xml @@ -14,6 +14,8 @@ + + diff --git a/dev/tests/integration/etc/install-config-mysql.php.dist b/dev/tests/integration/etc/install-config-mysql.php.dist index 0d8fb591eb144..3cbe5eed4e976 100644 --- a/dev/tests/integration/etc/install-config-mysql.php.dist +++ b/dev/tests/integration/etc/install-config-mysql.php.dist @@ -5,15 +5,15 @@ */ return [ - 'db_host' => 'localhost', - 'db_user' => 'root', - 'db_password' => '', - 'db_name' => 'magento_integration_tests', - 'db_prefix' => '', - 'backend_frontname' => 'backend', - 'admin_user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, - 'admin_password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, - 'admin_email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, - 'admin_firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, - 'admin_lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, + 'db-host' => 'localhost', + 'db-user' => 'root', + 'db-password' => '', + 'db-name' => 'magento_integration_tests', + 'db-prefix' => '', + 'backend-frontname' => 'backend', + 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, + 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, + 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, + 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, + 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, ]; diff --git a/dev/tests/integration/etc/install-config-mysql.travis.php.dist b/dev/tests/integration/etc/install-config-mysql.travis.php.dist index a0e25fd80384b..ac8eeb0bbbacc 100644 --- a/dev/tests/integration/etc/install-config-mysql.travis.php.dist +++ b/dev/tests/integration/etc/install-config-mysql.travis.php.dist @@ -5,15 +5,15 @@ */ return [ - 'db_host' => '127.0.0.1', - 'db_user' => 'travis', - 'db_password' => '', - 'db_name' => 'magento_integration_tests', - 'db_prefix' => 'travis_', - 'backend_frontname' => 'backend', - 'admin_user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, - 'admin_password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, - 'admin_email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, - 'admin_firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, - 'admin_lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, + 'db-host' => '127.0.0.1', + 'db-user' => 'travis', + 'db-password' => '', + 'db-name' => 'magento_integration_tests', + 'db-prefix' => 'travis_', + 'backend-frontname' => 'backend', + 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, + 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, + 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, + 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, + 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, ]; diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 41e57ac4359e8..7c652997b1fb3 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -5,12 +5,11 @@ */ namespace Magento\TestFramework; -use Magento\Framework\Code\Generator\FileResolver; use Magento\Framework\Autoload\AutoloaderInterface; use Magento\Framework\Filesystem; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; use Magento\Framework\App\DeploymentConfig\Reader; /** @@ -157,7 +156,8 @@ public function __construct( \Magento\Framework\App\State::PARAM_MODE => $appMode ]; $driverPool = new \Magento\Framework\Filesystem\DriverPool; - $this->_factory = new \Magento\TestFramework\ObjectManagerFactory($this->dirList, $driverPool); + $configFilePool = new \Magento\Framework\Config\File\ConfigFilePool; + $this->_factory = new \Magento\TestFramework\ObjectManagerFactory($this->dirList, $driverPool, $configFilePool); $this->_configDir = $this->dirList->getPath(DirectoryList::CONFIG); $this->globalConfigFile = $globalConfigFile; @@ -172,20 +172,31 @@ public function getDbInstance() { if (null === $this->_db) { if ($this->isInstalled()) { - $reader = new Reader($this->dirList); + $configPool = new \Magento\Framework\Config\File\ConfigFilePool(); + $reader = new Reader($this->dirList, $configPool); $deploymentConfig = new DeploymentConfig($reader, []); - $dbConfig = $deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $dbInfo = $dbConfig['connection']['default']; - $host = $dbInfo['host']; - $user = $dbInfo['username']; - $password = $dbInfo['password']; - $dbName = $dbInfo['dbname']; + $host = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_HOST + ); + $user = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_USER + ); + $password = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_PASSWORD + ); + $dbName = $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_NAME + ); } else { $installConfig = $this->getInstallConfig(); - $host = $installConfig['db_host']; - $user = $installConfig['db_user']; - $password = $installConfig['db_password']; - $dbName = $installConfig['db_name']; + $host = $installConfig['db-host']; + $user = $installConfig['db-user']; + $password = $installConfig['db-password']; + $dbName = $installConfig['db-name']; } $this->_db = new Db\Mysql( $host, @@ -391,7 +402,7 @@ public function cleanup() * @see \Magento\Setup\Mvc\Bootstrap\InitParamListener::BOOTSTRAP_PARAM */ $this->_shell->execute( - 'php -f %s setup:uninstall -n --magento_init_params=%s', + 'php -f %s setup:uninstall -n --magento-init-params=%s', [BP . '/bin/magento', $this->getInitParamsQuery()] ); } @@ -478,7 +489,7 @@ private function getInstallCliParams() * Literal value is used instead of constant, because autoloader is not integrated with Magento Setup app * @see \Magento\Setup\Mvc\Bootstrap\InitParamListener::BOOTSTRAP_PARAM */ - $params['magento_init_params'] = $this->getInitParamsQuery(); + $params['magento-init-params'] = $this->getInitParamsQuery(); $result = []; foreach ($params as $key => $value) { if (!empty($value)) { diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index e499e0d929ae1..763011a315b36 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -54,7 +54,7 @@ public function restore(ObjectManager $objectManager, $directoryList, array $arg $objectManager->configure($this->_primaryConfigData); $objectManager->addSharedInstance($this->directoryList, 'Magento\Framework\App\Filesystem\DirectoryList'); $objectManager->addSharedInstance($this->directoryList, 'Magento\Framework\Filesystem\DirectoryList'); - $deploymentConfig = $this->createDeploymentConfig($directoryList, $arguments); + $deploymentConfig = $this->createDeploymentConfig($directoryList, $this->configFilePool, $arguments); $this->factory->setArguments($arguments); $objectManager->addSharedInstance($deploymentConfig, 'Magento\Framework\App\DeploymentConfig'); $objectManager->addSharedInstance( diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php index 5c04e9f144011..0c6d65b52543f 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php @@ -8,6 +8,8 @@ use Magento\Framework\App\Cache\State; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\App\Filesystem\DirectoryList; class MassActionTest extends \Magento\Backend\Utility\Controller { @@ -22,7 +24,7 @@ public static function setUpBeforeClass() { /** @var \Magento\Framework\App\DeploymentConfig $config */ $config = Bootstrap::getObjectManager()->get('Magento\Framework\App\DeploymentConfig'); - self::$typesConfig = $config->getConfigData(State::CACHE_KEY); + self::$typesConfig = $config->get(State::CACHE_KEY); } protected function tearDown() @@ -87,9 +89,11 @@ public function testMassDisableAction($typesToDisable = []) */ protected function getCacheStates() { - $configPath = Bootstrap::getInstance()->getAppTempDir() . '/etc/config.php'; + $configFilePool = new ConfigFilePool(); + $configPath = Bootstrap::getInstance()->getAppTempDir() . '/'. DirectoryList::CONFIG .'/' + . $configFilePool->getPath($configFilePool::APP_ENV); $configData = eval(str_replace('objectManager->create('Magento\Catalog\Model\Resource\Eav\Attribute'); - $model->load($attributeCode, 'attribute_code'); + $model->loadByCode(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); /** @var \Magento\Framework\Registry $coreRegistry */ $coreRegistry = $this->objectManager->get('\Magento\Framework\Registry'); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php index 75f5172727328..6f775b962bf01 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -18,8 +18,9 @@ class CategoryTest extends \Magento\Backend\Utility\Controller * @param array $inputData * @param array $defaultAttributes * @param array $attributesSaved + * @param bool $isSuccess */ - public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = []) + public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = [], $isSuccess = true) { /** @var $store \Magento\Store\Model\Store */ $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); @@ -31,10 +32,12 @@ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved $this->getRequest()->setParam('id', 2); $this->dispatch('backend/catalog/category/save'); - $this->assertSessionMessages( - $this->equalTo(['You saved the category.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS - ); + if ($isSuccess) { + $this->assertSessionMessages( + $this->equalTo(['You saved the category.']), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + } /** @var $category \Magento\Catalog\Model\Category */ $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( @@ -214,8 +217,8 @@ public function saveActionDataProvider() 'is_anchor' => '1', 'custom_apply_to_products' => '0', 'custom_design' => 'Magento/blank', - 'custom_design_from' => '', - 'custom_design_to' => '', + 'custom_design_from' => '5/21/2015', + 'custom_design_to' => '5/29/2015', 'page_layout' => '', 'custom_layout_update' => '', ], @@ -257,10 +260,58 @@ public function saveActionDataProvider() 'meta_keywords' => 'Custom keywords', 'meta_description' => 'Custom meta description', 'custom_layout_update' => null, - 'custom_design_from' => null, - 'custom_design_to' => null, + 'custom_design_from' => '2015-05-21 00:00:00', + 'custom_design_to' => '2015-05-29 00:00:00', 'filter_price_range' => null ], + ], + 'incorrect datefrom' => [ + [ + 'general' => [ + 'id' => '2', + 'path' => '1/2', + 'name' => 'Custom Name', + 'is_active' => '0', + 'description' => 'Custom Description', + 'meta_title' => 'Custom Title', + 'meta_keywords' => 'Custom keywords', + 'meta_description' => 'Custom meta description', + 'include_in_menu' => '0', + 'url_key' => 'default-category', + 'display_mode' => 'PRODUCTS', + 'landing_page' => '1', + 'is_anchor' => '1', + 'custom_apply_to_products' => '0', + 'custom_design' => 'Magento/blank', + 'custom_design_from' => '5/29/2015', + 'custom_design_to' => '5/21/2015', + 'page_layout' => '', + 'custom_layout_update' => '', + ], + 'use_config' => [0 => 'available_sort_by', 1 => 'default_sort_by', 2 => 'filter_price_range'], + ], + [ + 'name' => false, + 'default_sort_by' => false, + 'display_mode' => false, + 'meta_title' => false, + 'custom_design' => false, + 'page_layout' => false, + 'is_active' => false, + 'include_in_menu' => false, + 'landing_page' => false, + 'custom_apply_to_products' => false, + 'available_sort_by' => false, + 'description' => false, + 'meta_keywords' => false, + 'meta_description' => false, + 'custom_layout_update' => false, + 'custom_design_from' => false, + 'custom_design_to' => false, + 'filter_price_range' => false + ], + [], + false ] ]; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php index 866b94dd29cf8..f45f0cce8e855 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php @@ -50,7 +50,6 @@ protected function setUp() */ public function testProductUpdate() { - $this->markTestSkipped('Incomplete due to MAGETWO-21369'); $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Catalog\Model\CategoryFactory'); $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php index a83bb8be1c9fe..9b91abf2a13cb 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php @@ -70,17 +70,11 @@ public function testExport() */ public function testExportStockItemAttributesAreFilled() { - $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $fileWrite = $this->getMock('Magento\Framework\Filesystem\File\Write', [], [], '', false); $directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - - $filesystemMock->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryMock)); - $directoryMock->expects($this->any())->method('getParentDirectory')->will($this->returnValue('some#path')); - $directoryMock->expects($this->any())->method('isWritable')->will($this->returnValue(true)); - $directoryMock->expects($this->any())->method('isFile')->will($this->returnValue(true)); - $directoryMock->expects( $this->any() )->method( @@ -88,6 +82,10 @@ public function testExportStockItemAttributesAreFilled() )->will( $this->returnValue('some string read from file') ); + $directoryMock->expects($this->once())->method('openFile')->will($this->returnValue($fileWrite)); + + $filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $filesystemMock->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryMock)); $exportAdapter = new \Magento\ImportExport\Model\Export\Adapter\Csv($filesystemMock); diff --git a/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php deleted file mode 100644 index 4198c84681aa2..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php +++ /dev/null @@ -1,26 +0,0 @@ -get('Magento\Payment\Helper\Data'); - /** @var $paymentInfo \Magento\Payment\Model\Info */ - $paymentInfo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Payment\Model\Info' - ); - $paymentInfo->setMethod('checkmo'); - $result = $block->getInfoBlock($paymentInfo); - $this->assertInstanceOf('Magento\OfflinePayments\Block\Info\Checkmo', $result); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php deleted file mode 100644 index 1393897214b24..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php +++ /dev/null @@ -1,47 +0,0 @@ -get('Magento\Framework\App\State') - ->setAreaCode('frontend'); - $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\View\LayoutInterface' - )->createBlock( - 'Magento\Checkout\Block\Cart\Sidebar' - ); - $this->_block->addChild('renderer.list', '\Magento\Framework\View\Element\RendererList'); - $this->_block->getChildBlock( - 'renderer.list' - )->addChild( - 'default', - '\Magento\Checkout\Block\Cart\Item\Renderer', - ['template' => 'cart/item/default.phtml'] - ); - } - - public function testGetCacheKeyInfo() - { - $this->assertEquals( - [ - 'BLOCK_TPL', - 'default', - $this->_block->getTemplateFile(), - 'template' => null, - 'item_renders' => 'default|Magento\Checkout\Block\Cart\Item\Renderer|cart/item/default.phtml', - ], - $this->_block->getCacheKeyInfo() - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php index 03ca572e66200..567ad6ec03b14 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php @@ -22,33 +22,6 @@ protected function setUp() ); } - /** - * Covers onepage payment.phtml templates - */ - public function testIndexAction() - { - $this->dispatch('checkout/onepage/index'); - $html = $this->getResponse()->getBody(); - $this->assertContains('
    4. assertSelectEquals('[id="checkout-shipping-method-load"]', '', 1, $html); - $this->assertSelectEquals('[id="checkout-payment-method-load"]', '', 1, $html); - $this->assertSelectCount('form[id="co-billing-form"][action=""]', 1, $html); - $this->assertSelectCount('form[id="co-payment-form"] input[name="form_key"]', 1, $html); - } - - public function testShippingMethodAction() - { - $this->dispatch('checkout/onepage/shippingMethod'); - $this->assertContains('no quotes are available', $this->getResponse()->getBody()); - } - - public function testReviewAction() - { - $this->dispatch('checkout/onepage/review'); - $this->assertContains('Place Order', $this->getResponse()->getBody()); - $this->assertContains('checkout-review', $this->getResponse()->getBody()); - } - public function testSaveOrderActionWithoutFormKey() { $this->dispatch('checkout/onepage/saveOrder'); diff --git a/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/EncryptedTest.php b/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/EncryptedTest.php new file mode 100644 index 0000000000000..4975a1cb7fa57 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/EncryptedTest.php @@ -0,0 +1,58 @@ +create('Magento\Config\Model\Config\Backend\Encrypted'); + $model->setPath('carriers/usps/password'); + $model->setScopeId(0); + $model->setScope('default'); + $model->setScopeCode(''); + $model->setValue($originalValue); + $model->save(); + + // Pass in the obscured value + $model->setPath('carriers/usps/password'); + $model->setScopeId(0); + $model->setScope('default'); + $model->setScopeCode(''); + $model->setValue('*****'); + $model->save(); + + //Verify original value is not changed for obscured value + $value = $model->load($model->getId())->getValue(); + $this->assertEquals($originalValue, $value, 'Original value is not expected to change.'); + + // Verify if actual value is changed + $changedValue = 'newPassword'; + + $model->setPath('carriers/usps/password'); + $model->setScopeId(0); + $model->setScope('default'); + $model->setScopeCode(''); + $model->setValue($changedValue); + $model->save(); + + //Verify original value is changed + $value = $model->load($model->getId())->getValue(); + $this->assertEquals($changedValue, $value, 'Original value is expected to change.'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php index 3f76c9f0dd2b9..16cfa26b08873 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Api/AddressRepositoryTest.php @@ -56,7 +56,7 @@ protected function setUp() ->setFirstname('John') ->setLastname('Smith') ->setCompany('CompanyName') - ->setCustomAttributes([]); + ->setRegionId(1); /* XXX: would it be better to have a clear method for this? */ $address2 = $this->_addressFactory->create() @@ -70,7 +70,7 @@ protected function setUp() ->setTelephone('3234676') ->setFirstname('John') ->setLastname('Smith') - ->setCustomAttributes([]); + ->setRegionId(1); $this->_expectedAddresses = [$address, $address2]; } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php deleted file mode 100644 index 26af7cc8df239..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php +++ /dev/null @@ -1,52 +0,0 @@ -customerSession = $objectManager->get('Magento\Customer\Model\Session'); - $this->block = $objectManager->get( - 'Magento\Framework\View\LayoutInterface' - )->createBlock( - 'Magento\Customer\Block\Account\Dashboard\Newsletter', - '', - ['customerSession' => $this->customerSession] - ); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetSubscriptionObject() - { - $this->customerSession->setCustomerId(1); - - $subscriber = $this->block->getSubscriptionObject(); - $this->assertInstanceOf('Magento\Newsletter\Model\Subscriber', $subscriber); - $this->assertFalse($subscriber->isSubscribed()); - } -} 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 f7160adb6c3af..f4887bb251ad4 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 @@ -81,7 +81,10 @@ public function testGetGridParentHtml() ->disableOriginalConstructor() ->getMock(); $this->_block->setCollection($mockCollection); - $this->assertContains("
      ", $this->_block->getGridParentHtml()); + $this->assertContains( + "
      _block->getGridParentHtml() + ); } public function testGetRowUrl() @@ -94,8 +97,8 @@ public function testGetRowUrl() public function testGetHtml() { $html = $this->_block->toHtml(); - $this->assertContains("
      ", $html); - $this->assertContains("
      ", $html); + $this->assertContains("
      assertContains("
      assertContains("customer_cart_gridJsObject = new varienGrid('customer_cart_grid',", $html); $this->assertContains( "backend/customer/cart_product_composite_cart/configure/customer_id/" . self::CUSTOMER_ID_VALUE, diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php index 2f66f52ff06ad..5bbdca87782a2 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php @@ -56,8 +56,11 @@ public function testGetHtml() ); $html = $this->_block->toHtml(); - $this->assertContains("
      ", $html); - $this->assertContains("
      ", $html); + $this->assertContains("
      assertRegExp( + '/
      assertContains("customer_cart_grid1JsObject = new varienGrid('customer_cart_grid1',", $html); $this->assertContains("backend/customer/cart_product_composite_cart/configure/website_id/1", $html); } @@ -76,8 +79,11 @@ public function testGetHtmlNoCustomer() ); $html = $this->_block->toHtml(); - $this->assertContains("
      ", $html); - $this->assertContains("
      ", $html); + $this->assertContains("
      assertRegExp( + '/
      assertContains("customer_cart_gridJsObject = new varienGrid('customer_cart_grid',", $html); $this->assertContains("backend/customer/cart_product_composite_cart/configure/key/", $html); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index da3a723a0db75..a52fef8b40a43 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -543,7 +543,7 @@ public function testCartAction() $this->getRequest()->setParam('id', 1)->setParam('website_id', 1)->setPostValue('delete', 1); $this->dispatch('backend/customer/index/cart'); $body = $this->getResponse()->getBody(); - $this->assertContains('
      ', $body); + $this->assertContains('
      getRequest()->setParam('id', 1); $this->dispatch('backend/customer/index/productReviews'); $body = $this->getResponse()->getBody(); - $this->assertContains('
      ', $body); + $this->assertContains('
      setRegion( $regionFactory->create()->setRegionCode('AL')->setRegion('Alabama')->setRegionId(1) ) + ->setRegionId(1) ->setCompany('CompanyName') ->setStreet(['Green str, 67']) ->setTelephone('3468676') @@ -96,6 +97,7 @@ protected function setUp() ->setRegion( $regionFactory->create()->setRegionCode('AL')->setRegion('Alabama')->setRegionId(1) ) + ->setRegionId(1) ->setCompany('Company') ->setStreet(['Black str, 48']) ->setCity('CityX') diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php index 672e0e17c6cc4..79e257d0f6488 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php @@ -75,25 +75,16 @@ public function testGetNestedOptionsCustomAttributesMetadata() public function testGetCustomAttributesMetadataWithAttributeNamedCustomAttribute() { $customAttributesMetadata = $this->_service->getCustomAttributesMetadata(); - $customAttributeCodeOne = 'custom_attribute1'; - $customAttributeFound = false; - $customAttributeCodeTwo = 'custom_attribute2'; - $customAttributesFound = false; + $expectedCustomAttributeCodeArray = ['custom_attribute1', 'custom_attribute2', 'customer_image']; + $actual = []; foreach ($customAttributesMetadata as $attribute) { - if ($attribute->getAttributeCode() == $customAttributeCodeOne) { - $customAttributeFound = true; - } - if ($attribute->getAttributeCode() == $customAttributeCodeTwo) { - $customAttributesFound = true; - } - } - if (!$customAttributeFound) { - $this->fail("Custom attribute declared in the config not found."); + $actual[] = $attribute->getAttributeCode(); } - if (!$customAttributesFound) { - $this->fail("Custom attributes declared in the config not found."); - } - $this->assertCount(3, $customAttributesMetadata, "Invalid number of attributes returned."); + $this->assertEquals( + $expectedCustomAttributeCodeArray, + array_intersect($expectedCustomAttributeCodeArray, $actual), + "Expected attributes not returned from the service." + ); } /** diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php index 57af42127e1c5..3c2e285709e08 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/AddressRepositoryTest.php @@ -52,25 +52,25 @@ protected function setUp() ->setCustomerId('1') ->setPostcode('75477') ->setRegion($region) + ->setRegionId(1) ->setStreet(['Green str, 67']) ->setTelephone('3468676') ->setCity('CityM') ->setFirstname('John') ->setLastname('Smith') - ->setCompany('CompanyName') - ->setCustomAttributes([]); + ->setCompany('CompanyName'); $address2 = $this->_addressFactory->create() ->setId('2') ->setCountryId('US') ->setCustomerId('1') ->setPostcode('47676') ->setRegion($region) + ->setRegionId(1) ->setStreet(['Black str, 48']) ->setCity('CityX') ->setTelephone('3234676') ->setFirstname('John') - ->setLastname('Smith') - ->setCustomAttributes([]); + ->setLastname('Smith'); $this->_expectedAddresses = [$address, $address2]; } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute.php index a20e7d490157b..e3ab1bef7a454 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute.php @@ -48,3 +48,25 @@ ); $model2->save(); + +$model3 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); + +$model3->setName( + 'customer_image' +)->setEntityTypeId( + 1 +)->setIsUserDefined( + 1 +)->setAttributeSetId( + 1 +)->setAttributeGroupId( + 1 +)->setFrontendInput( + 'image' +)->setFrontendLabel( + 'customer_image' +)->setSortOrder( + 1223 +)->setBackendType("varchar"); + +$model3->save(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute_rollback.php new file mode 100644 index 0000000000000..dddae379de580 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_custom_attribute_rollback.php @@ -0,0 +1,15 @@ +create('Magento\Customer\Model\Attribute'); +$model->load('custom_attribute1', 'attribute_code')->delete(); + +$model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); +$model2->load('custom_attribute2', 'attribute_code')->delete(); + +$model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); +$model2->load('customer_image', 'attribute_code')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/DatabaseTest.php b/dev/tests/integration/testsuite/Magento/DatabaseTest.php index 4058fcb2b444a..77e767b03f9a2 100644 --- a/dev/tests/integration/testsuite/Magento/DatabaseTest.php +++ b/dev/tests/integration/testsuite/Magento/DatabaseTest.php @@ -21,7 +21,7 @@ public function testDuplicateKeys() $db = Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); $command = $checkerPath . ' -d ' . $db->getSchema() - . ' h=' . $db->getHost()['db_host'] . ',u=' . $db->getUser() . ',p=' . $db->getPassword(); + . ' h=' . $db->getHost()['db-host'] . ',u=' . $db->getUser() . ',p=' . $db->getPassword(); exec($command, $output, $exitCode); $this->assertEquals(0, $exitCode); diff --git a/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/_files/_inline_page_original.html b/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/_files/_inline_page_original.html index e3c11e7a927d0..a32813490ebfc 100644 --- a/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/_files/_inline_page_original.html +++ b/dev/tests/integration/testsuite/Magento/DesignEditor/Model/Translate/_files/_inline_page_original.html @@ -8,7 +8,7 @@ "http://www.w3.org/TR/html4/loose.dtd"> - {{{shown_0}}{{translated_0}}{{original_0}}{{scope_0}}} + Test Page Title
      diff --git a/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMainTest.php similarity index 93% rename from dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php rename to dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMainTest.php index 7ab902da2f613..3e8b1f30a0c2a 100644 --- a/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMainTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Eav\Block\Adminhtml\Attribute\Edit\Main; -class AbstractTest extends \PHPUnit_Framework_TestCase +class AbstractMainTest extends \PHPUnit_Framework_TestCase { /** * @magentoAppIsolation enabled @@ -38,7 +38,7 @@ public function testPrepareForm() $objectManager->get('Magento\Eav\Helper\Data'), $objectManager->get('Magento\Config\Model\Config\Source\YesnoFactory'), $objectManager->get('Magento\Eav\Model\Adminhtml\System\Config\Source\InputtypeFactory'), - $objectManager->get('Magento\Eav\Model\Entity\Attribute\Config') + $objectManager->get('Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker') ] )->setLayout( $objectManager->create('Magento\Framework\View\Layout') diff --git a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/File/WriteTest.php b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/File/WriteTest.php index 67c671e2f253f..6defca2aa919a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/File/WriteTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/File/WriteTest.php @@ -81,7 +81,7 @@ public function writeProvider() ['new1.csv', 'w', 'write check', 11], ['new3.csv', 'a', 'write check', 11], ['new5.csv', 'x', 'write check', 11], - ['new7.csv', 'c', 'write check', 11] + ['new7.csv', 'c', 'write check', 11], ]; } @@ -117,20 +117,21 @@ public function writeAndReadProvider() ['new2.csv', 'w+', 'write check', 11], ['new4.csv', 'a+', 'write check', 11], ['new6.csv', 'x+', 'write check', 11], - ['new8.csv', 'c+', 'write check', 11] + ['new8.csv', 'c+', 'write check', 11], ]; } /** * Writes one CSV row to the file. * - * @dataProvider csvProvider + * @dataProvider csvDataProvider + * @param array $expectedData * @param string $path * @param array $data * @param string $delimiter * @param string $enclosure */ - public function testWriteCsv($path, array $data, $delimiter = ',', $enclosure = '"') + public function testWriteCsv($expectedData, $path, array $data, $delimiter = ',', $enclosure = '"') { $file = $this->getFileInstance($path, 'w+'); $result = $file->writeCsv($data, $delimiter, $enclosure); @@ -138,7 +139,7 @@ public function testWriteCsv($path, array $data, $delimiter = ',', $enclosure = $read = $file->readCsv($result, $delimiter, $enclosure); $file->close(); $this->removeCurrentFile(); - $this->assertEquals($data, $read); + $this->assertEquals($expectedData, $read); } /** @@ -146,11 +147,12 @@ public function testWriteCsv($path, array $data, $delimiter = ',', $enclosure = * * @return array */ - public function csvProvider() + public function csvDataProvider() { return [ - ['newcsv1.csv', ['field1', 'field2'], ',', '"'], - ['newcsv1.csv', ['field1', 'field2'], '%', '@'] + [['field1', 'field2'], 'newcsv1.csv', ['field1', 'field2'], ',', '"'], + [['field1', 'field2'], 'newcsv1.csv', ['field1', 'field2'], '%', '@'], + [[' =field1', 'field2'], 'newcsv1.csv', ['=field1', 'field2'], '%', '@'], ]; } @@ -201,7 +203,7 @@ private function getFileInstance($path, $mode) [ 'path' => $this->currentFilePath, 'driver' => new \Magento\Framework\Filesystem\Driver\File(), - 'mode' => $mode + 'mode' => $mode, ] ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/ProfilerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/ProfilerTest.php index 066cd1a237817..31f4beeb2c7ee 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/ProfilerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/ProfilerTest.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\Model\Resource\Db; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; class ProfilerTest extends \PHPUnit_Framework_TestCase { @@ -46,7 +46,7 @@ protected function _getConnectionRead() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $reader = $objectManager->get('Magento\Framework\App\DeploymentConfig'); - $dbConfig = $reader->getConfigData(ConfigOptionsList::KEY_DB); + $dbConfig = $reader->getConfigData(ConfigOptionsListConstants::KEY_DB); $connectionConfig = $dbConfig['connection']['default']; $connectionConfig['profiler'] = [ 'class' => 'Magento\Framework\Model\Resource\Db\Profiler', diff --git a/dev/tests/integration/testsuite/Magento/Framework/Url/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Framework/Url/Helper/DataTest.php index a582be47759fb..ce94b1e855a8a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Url/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Url/Helper/DataTest.php @@ -23,12 +23,12 @@ protected function setUp() public function testGetCurrentBase64Url() { - $this->assertEquals('aHR0cDovL2xvY2FsaG9zdA,,', $this->_helper->getCurrentBase64Url()); + $this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MQ,,', $this->_helper->getCurrentBase64Url()); } public function testGetEncodedUrl() { - $this->assertEquals('aHR0cDovL2xvY2FsaG9zdA,,', $this->_helper->getEncodedUrl()); + $this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MQ,,', $this->_helper->getEncodedUrl()); $this->assertEquals('aHR0cDovL2V4YW1wbGUuY29tLw,,', $this->_helper->getEncodedUrl('http://example.com/')); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/_files/Magento/ModuleA/view/adminhtml/product/product.css b/dev/tests/integration/testsuite/Magento/Framework/View/_files/Magento/ModuleA/view/adminhtml/product/product.css index 88aa062ced50c..c7310b1e87937 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/_files/Magento/ModuleA/view/adminhtml/product/product.css +++ b/dev/tests/integration/testsuite/Magento/Framework/View/_files/Magento/ModuleA/view/adminhtml/product/product.css @@ -493,10 +493,6 @@ width: 43%; } -#configurable-attributes-container { - margin-bottom: 23px; -} - #configurable-attributes-container .col-name { width: 65%; } diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/WebapiTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/WebapiTest.php new file mode 100644 index 0000000000000..350f66ca4a00e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/WebapiTest.php @@ -0,0 +1,93 @@ +registry = $objectManager->get('Magento\Framework\Registry'); + } + + protected function tearDown() + { + $this->registry->unregister(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION); + parent::tearDown(); + } + + public function testGetSelectedResourcesJsonEmpty() + { + $expectedResult = '[]'; + $this->assertEquals($expectedResult, $this->createApiTabBlock()->getSelectedResourcesJson()); + } + + public function testGetSelectedResourcesJson() + { + $expectedResult = '["Magento_Backend::dashboard",'; + $this->registry->register( + IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION, + $this->getFixtureIntegration()->getData() + ); + $this->assertContains($expectedResult, $this->createApiTabBlock()->getSelectedResourcesJson()); + } + + public function testGetResourcesTreeJson() + { + $expectedResult = '[{"attr":{"data-id":"Magento_Backend::dashboard"},"data":"Dashboard","children":[],"state":'; + $this->registry->register( + IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION, + $this->getFixtureIntegration()->getData() + ); + $this->assertContains($expectedResult, $this->createApiTabBlock()->getResourcesTreeJson()); + } + + public function testCanShowTabNegative() + { + $this->assertFalse($this->createApiTabBlock()->canShowTab()); + } + + public function testCanShowTabPositive() + { + $integrationData = $this->getFixtureIntegration()->getData(); + $integrationData[Integration::SETUP_TYPE] = Integration::TYPE_CONFIG; + $this->registry->register(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData); + $this->assertTrue($this->createApiTabBlock()->canShowTab()); + } + + /** + * @return \Magento\Integration\Block\Adminhtml\Integration\Activate\Permissions\Tab\Webapi + */ + protected function createApiTabBlock() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + return $objectManager->create( + 'Magento\Integration\Block\Adminhtml\Integration\Activate\Permissions\Tab\Webapi' + ); + } + + /** + * @return Integration + */ + protected function getFixtureIntegration() + { + /** @var $integration Integration */ + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $integration = $objectManager->create('Magento\Integration\Model\Integration'); + return $integration->load('Fixture Integration', 'name'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Edit/FormTest.php new file mode 100644 index 0000000000000..eb34c66f4a762 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Edit/FormTest.php @@ -0,0 +1,69 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + /** @var $layout \Magento\Framework\View\Layout */ + $layout = $this->objectManager->create('Magento\Framework\View\LayoutInterface'); + $this->block = $layout->createBlock('Magento\Integration\Block\Adminhtml\Integration\Edit\Form'); + } + + /** + * @magentoAppArea adminhtml + */ + public function testToHtmlNoExistingIntegrationData() + { + $this->assertContains( + '', + $this->block->toHtml() + ); + } + + /** + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + */ + public function testToHtmlWithIntegrationData() + { + /** @var \Magento\Framework\Registry $coreRegistry */ + $coreRegistry = $this->objectManager->get('\Magento\Framework\Registry'); + $coreRegistry->unregister(Integration::REGISTRY_KEY_CURRENT_INTEGRATION); + $id = 'idValue'; + $integrationData = [ + \Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info::DATA_ID => $id, + ]; + $coreRegistry->register(Integration::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData); + + $html = $this->block->toHtml(); + + $this->assertRegExp( + "//", + $html + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php new file mode 100644 index 0000000000000..ad2a359477730 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php @@ -0,0 +1,118 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + /** @var $layout \Magento\Framework\View\Layout */ + $layout = $this->objectManager->create('Magento\Framework\View\LayoutInterface'); + $this->block = $layout->createBlock('Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info'); + $this->block->addChild('integration_tokens', 'Magento\Integration\Block\Adminhtml\Integration\Tokens'); + } + + /** + * @magentoAppArea adminhtml + */ + public function testToHtmlNoExistingIntegrationData() + { + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + } + + /** + * @magentoAppArea adminhtml + */ + public function testToHtmlWithIntegrationData() + { + /** @var \Magento\Framework\Registry $coreRegistry */ + $coreRegistry = $this->objectManager->get('\Magento\Framework\Registry'); + $coreRegistry->unregister(Integration::REGISTRY_KEY_CURRENT_INTEGRATION); + $name = 'nameExample'; + $email = 'admin@example.com'; + $endpoint = 'exampleEndpoint'; + $identityLinkUrl = 'identityLinkUrl'; + $integrationData = [ + Info::DATA_ID => '1', + Info::DATA_NAME => $name, + Info::DATA_EMAIL => 'admin@example.com', + Info::DATA_ENDPOINT => 'exampleEndpoint', + Info::DATA_IDENTITY_LINK_URL => 'identityLinkUrl', + Info::DATA_SETUP_TYPE => IntegrationModel::TYPE_MANUAL, + ]; + $coreRegistry->register(Integration::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData); + + $html = $this->block->toHtml(); + + $this->assertRegExp( + "//", + $html + ); + $this->assertRegExp( + "//", + $html + ); + $this->assertRegExp( + "//", + $html + ); + $this->assertRegExp( + "//", + $html + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + $this->assertRegExp( + '//', + $this->block->toHtml() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/EditTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/EditTest.php new file mode 100644 index 0000000000000..96fa9da52d625 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/EditTest.php @@ -0,0 +1,123 @@ +editBlock = Bootstrap::getObjectManager() + ->create('Magento\Integration\Block\Adminhtml\Integration\Edit'); + } + + public function testGetHeaderTextNewIntegration() + { + $this->assertEquals('New Integration', $this->editBlock->getHeaderText()->getText()); + $buttonList = Bootstrap::getObjectManager() + ->get('Magento\Backend\Block\Widget\Context') + ->getButtonList() + ->getItems(); + + // Assert that there is a 'save' and 'activate' button when creating a new integration + $haveSaveButton = false; + foreach ($buttonList as $button) { + foreach ($button as $key => $value) { + if ($key === 'save') { + $haveSaveButton = true; + $this->assertNotNull($value->getDataByKey('options')); + $this->assertEquals( + 'activate', + $value->getDataByKey('options')['save_activate']['id'], + "'Activate' button is expected when creating a new integration." + ); + } + } + } + $this->assertTrue($haveSaveButton, "'Save' button is expected when creating a new integration."); + } + + public function testGetHeaderTextEditIntegration() + { + $integrationId = 1; + $integrationName = 'Test Name'; + + $integrationData = [ + Integration::ID => $integrationId, + Integration::NAME => $integrationName, + ]; + + /** @var \Magento\Framework\Registry $registry */ + $registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry->register(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData); + + $headerText = $this->editBlock->getHeaderText(); + $this->assertEquals("Edit Integration '%1'", $headerText->getText()); + $this->assertEquals($integrationName, $headerText->getArguments()[0]); + + // Tear down + $registry->unregister(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION); + } + + public function testGetHeaderTextEditIntegrationConfigType() + { + $integrationId = 2; + $integrationName = 'Test Name 2'; + + $integrationData = [ + Integration::ID => $integrationId, + Integration::NAME => $integrationName, + Integration::SETUP_TYPE => Integration::TYPE_CONFIG + ]; + + /** @var \Magento\Framework\Registry $registry */ + $registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + $registry->register(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData); + + /** @var \Magento\Integration\Block\Adminhtml\Integration\Edit $editBlock */ + $editBlock = Bootstrap::getObjectManager() + ->create('Magento\Integration\Block\Adminhtml\Integration\Edit'); + + $headerText = $editBlock->getHeaderText(); + $this->assertEquals("Edit Integration '%1'", $headerText->getText()); + $this->assertEquals($integrationName, $headerText->getArguments()[0]); + + $buttonList = Bootstrap::getObjectManager() + ->get('Magento\Backend\Block\Widget\Context') + ->getButtonList() + ->getItems(); + + // Assert that 'save' button is removed for integration of config type + foreach ($buttonList as $button) { + $this->assertFalse(array_key_exists('save', $button)); + } + + // Tear down + $registry->unregister(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION); + } + + public function testGetFormActionUrl() + { + $baseUrl = Bootstrap::getObjectManager()->get('Magento\Framework\Url')->getBaseUrl(); + $this->assertContains($baseUrl, $this->editBlock->getFormActionUrl()); + + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/GridTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/GridTest.php new file mode 100644 index 0000000000000..2d7e4a62290da --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/GridTest.php @@ -0,0 +1,39 @@ +gridBlock = Bootstrap::getObjectManager() + ->create('Magento\Integration\Block\Adminhtml\Integration\Grid'); + } + + public function testGetRowClickCallback() + { + $this->assertEquals('', $this->gridBlock->getRowClickCallback()); + } + + public function testGetRowInitCallback() + { + $this->assertEquals('', $this->gridBlock->getRowInitCallback()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/TokensTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/TokensTest.php new file mode 100644 index 0000000000000..224fcf5888042 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Integration/TokensTest.php @@ -0,0 +1,101 @@ +tokensBlock = Bootstrap::getObjectManager() + ->create('Magento\Integration\Block\Adminhtml\Integration\Tokens'); + } + + public function testGetFormFields() + { + $expectedData = [ + [ + 'name' => Tokens::DATA_CONSUMER_KEY, + 'type' => 'text', + 'metadata' => [ + 'label' => __('Consumer Key'), + 'name' => Tokens::DATA_CONSUMER_KEY, + 'readonly' => true, + ], + ], + [ + 'name' => Tokens::DATA_CONSUMER_SECRET, + 'type' => 'text', + 'metadata' => [ + 'label' => __('Consumer Secret'), + 'name' => Tokens::DATA_CONSUMER_SECRET, + 'readonly' => true, + ] + ], + [ + 'name' => Tokens::DATA_TOKEN, + 'type' => 'text', + 'metadata' => ['label' => __('Access Token'), 'name' => Tokens::DATA_TOKEN, 'readonly' => true] + ], + [ + 'name' => Tokens::DATA_TOKEN_SECRET, + 'type' => 'text', + 'metadata' => [ + 'label' => __('Access Token Secret'), + 'name' => Tokens::DATA_TOKEN_SECRET, + 'readonly' => true, + ] + ] + ]; + $this->assertEquals($expectedData, $this->tokensBlock->getFormFields()); + } + + public function testToHtml() + { + $htmlContent = $this->tokensBlock->toHtml(); + + $this->assertContains('name="consumer_key"', $htmlContent); + $this->assertContains( + 'Consumer Key', + $htmlContent, + "HTML content of token block should contain information about 'Consumer Key'." + ); + + $this->assertContains('name="consumer_secret"', $htmlContent); + $this->assertContains( + 'Consumer Secret', + $htmlContent, + "HTML content of token block should contain information about 'Consumer Secret'." + ); + + $this->assertContains('name="token"', $htmlContent); + $this->assertContains( + 'Access Token', + $htmlContent, + "HTML content of token block should contain information about 'Access Token'." + ); + + $this->assertContains('name="token_secret"', $htmlContent); + $this->assertContains( + 'Access Token Secret', + $htmlContent, + "HTML content of token block should contain information about 'Access Token Secret'." + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Button/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Button/DeleteTest.php new file mode 100644 index 0000000000000..e9d686d0eb35e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Button/DeleteTest.php @@ -0,0 +1,75 @@ +get('Magento\Framework\App\Request\Http'); + $request->setRouteName('adminhtml')->setControllerName('integration'); + $this->deleteButtonBlock = $objectManager->create( + 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Button\Delete' + ); + $column = $objectManager->create('Magento\Backend\Block\Widget\Grid\Column'); + $this->deleteButtonBlock->setColumn($column); + } + + public function testRender() + { + $integration = $this->getFixtureIntegration(); + $buttonHtml = $this->deleteButtonBlock->render($integration); + $this->assertContains('title="Remove"', $buttonHtml); + $this->assertContains( + 'onclick="this.setAttribute(\'data-url\', ' + . '\'http://localhost/index.php/backend/admin/integration/delete/id/' + . $integration->getId(), + $buttonHtml + ); + $this->assertNotContains('disabled', $buttonHtml); + } + + public function testRenderDisabled() + { + $integration = $this->getFixtureIntegration(); + $integration->setSetupType(Integration::TYPE_CONFIG); + $buttonHtml = $this->deleteButtonBlock->render($integration); + $this->assertContains('title="Uninstall the extension to remove this integration"', $buttonHtml); + $this->assertContains( + 'onclick="this.setAttribute(\'data-url\', ' + . '\'http://localhost/index.php/backend/admin/integration/delete/id/' + . $integration->getId(), + $buttonHtml + ); + $this->assertContains('disabled="disabled"', $buttonHtml); + } + + /** + * @return Integration + */ + protected function getFixtureIntegration() + { + /** @var $integration Integration */ + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $integration = $objectManager->create('Magento\Integration\Model\Integration'); + return $integration->load('Fixture Integration', 'name'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Button/EditTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Button/EditTest.php new file mode 100644 index 0000000000000..1a407f784e769 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Button/EditTest.php @@ -0,0 +1,68 @@ +get('Magento\Framework\App\Request\Http'); + $request->setRouteName('adminhtml')->setControllerName('integration'); + $this->editButtonBlock = $objectManager->create( + 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Button\Edit' + ); + $column = $objectManager->create('Magento\Backend\Block\Widget\Grid\Column'); + $this->editButtonBlock->setColumn($column); + } + + public function testRenderEdit() + { + $integration = $this->getFixtureIntegration(); + $buttonHtml = $this->editButtonBlock->render($integration); + $this->assertContains('title="Edit"', $buttonHtml); + $this->assertContains('class="action edit"', $buttonHtml); + $this->assertContains( + 'onclick="window.location.href=\'http://localhost/index.php/backend/admin/integration/edit/id/' + . $integration->getId(), + $buttonHtml + ); + } + + public function testRenderView() + { + $integration = $this->getFixtureIntegration(); + $integration->setSetupType(Integration::TYPE_CONFIG); + $buttonHtml = $this->editButtonBlock->render($integration); + $this->assertContains('title="View"', $buttonHtml); + $this->assertContains('class="action info"', $buttonHtml); + } + + /** + * @return Integration + */ + protected function getFixtureIntegration() + { + /** @var $integration Integration */ + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $integration = $objectManager->create('Magento\Integration\Model\Integration'); + return $integration->load('Fixture Integration', 'name'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Link/ActivateTest.php b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Link/ActivateTest.php new file mode 100644 index 0000000000000..a78d4ac548118 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Link/ActivateTest.php @@ -0,0 +1,105 @@ +activateLinkBlock = $objectManager->create( + 'Magento\Integration\Block\Adminhtml\Widget\Grid\Column\Renderer\Link\Activate' + ); + $column = $objectManager->create('Magento\Backend\Block\Widget\Grid\Column'); + $this->activateLinkBlock->setColumn($column); + } + + public function testRenderActivate() + { + $integration = $this->getFixtureIntegration(); + $buttonHtml = $this->activateLinkBlock->render($integration); + $this->assertContains('href="javascript:void(0);"', $buttonHtml); + $this->assertContains('title="Activate"', $buttonHtml); + $this->assertContains('data-row-id="' . $integration->getId() . '"', $buttonHtml); + $this->assertContains('data-row-dialog="permissions"', $buttonHtml); + $this->assertContains('data-row-is-reauthorize="0"', $buttonHtml); + $this->assertContains('data-row-is-token-exchange="0"', $buttonHtml); + $this->assertContains('onclick="integration.popup.show(this);', $buttonHtml); + $this->assertContains('>Activate', $buttonHtml); + } + + public function testRenderReauthorize() + { + $integration = $this->getFixtureIntegration(); + $integration->setStatus(Integration::STATUS_ACTIVE); + $buttonHtml = $this->activateLinkBlock->render($integration); + $this->assertContains('href="javascript:void(0);"', $buttonHtml); + $this->assertContains('title="Reauthorize"', $buttonHtml); + $this->assertContains('data-row-id="' . $integration->getId() . '"', $buttonHtml); + $this->assertContains('data-row-dialog="permissions"', $buttonHtml); + $this->assertContains('data-row-is-reauthorize="1"', $buttonHtml); + $this->assertContains('data-row-is-token-exchange="0"', $buttonHtml); + $this->assertContains('onclick="integration.popup.show(this);', $buttonHtml); + $this->assertContains('>Reauthorize', $buttonHtml); + } + + /** + * @param string $endpoint + * @param string $identityLinkUrl + * @param int $expectedResult + * @dataProvider renderTokenExchangeProvider + */ + public function testRenderTokenExchange($endpoint, $identityLinkUrl, $expectedResult) + { + $integration = $this->getFixtureIntegration(); + $integration->setStatus(Integration::STATUS_ACTIVE); + $integration->setEndpoint($endpoint); + $integration->setIdentityLinkUrl($identityLinkUrl); + $buttonHtml = $this->activateLinkBlock->render($integration); + $this->assertContains('href="javascript:void(0);"', $buttonHtml); + $this->assertContains('title="Reauthorize"', $buttonHtml); + $this->assertContains('data-row-id="' . $integration->getId() . '"', $buttonHtml); + $this->assertContains('data-row-dialog="permissions"', $buttonHtml); + $this->assertContains('data-row-is-reauthorize="1"', $buttonHtml); + $this->assertContains('data-row-is-token-exchange="' . $expectedResult . '"', $buttonHtml); + $this->assertContains('onclick="integration.popup.show(this);', $buttonHtml); + $this->assertContains('>Reauthorize', $buttonHtml); + } + + public function renderTokenExchangeProvider() + { + return [ + ['http://example.com/endpoint', 'http://example.com/identity', 1], + ['', null, 0], + ['http://example.com/endpoint', '', 0], + [null, 'http://example.com/identity', 0], + ]; + } + + /** + * @return Integration + */ + protected function getFixtureIntegration() + { + /** @var $integration Integration */ + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $integration = $objectManager->create('Magento\Integration\Model\Integration'); + return $integration->load('Fixture Integration', 'name'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php b/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php index bf6f4954d107b..eec5ee556e9cd 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php @@ -9,6 +9,7 @@ /** * \Magento\Integration\Controller\Adminhtml\Integration * + * @magentoDataFixture Magento/Integration/_files/integration_all_permissions.php * @magentoAppArea adminhtml * @magentoDbIsolation enabled */ @@ -20,7 +21,10 @@ class IntegrationTest extends \Magento\Backend\Utility\Controller protected function setUp() { parent::setUp(); - $this->_createDummyIntegration(); + /** @var $integration \Magento\Integration\Model\Integration */ + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $integration = $objectManager->create('Magento\Integration\Model\Integration'); + $this->_integration = $integration->load('Fixture Integration', 'name'); } public function testIndexAction() @@ -100,20 +104,4 @@ public function testSaveActionNewIntegration() ); $this->assertRedirect($this->stringContains('backend/admin/integration/index/')); } - - /** - * Creates a dummy integration for use in dispatched methods under testing - */ - private function _createDummyIntegration() - { - /** @var $factory \Magento\Integration\Model\IntegrationFactory */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $factory = $objectManager->create('Magento\Integration\Model\IntegrationFactory'); - $this->_integration = $factory->create()->setName(md5(rand()))->save(); - - /** Grant permissions to integrations */ - /** @var \Magento\Integration\Service\V1\AuthorizationService $authorizationService */ - $authorizationService = $objectManager->create('Magento\Integration\Service\V1\AuthorizationService'); - $authorizationService->grantAllPermissions($this->_integration->getId()); - } } diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php similarity index 93% rename from dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php rename to dev/tests/integration/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php index 66db4751cc695..f7cf66f678e77 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Framework\Exception\InputException; use Magento\Integration\Model\Oauth\Token as TokenModel; @@ -12,12 +12,12 @@ use Magento\User\Model\User as UserModel; /** - * Test class for \Magento\Integration\Service\V1\AdminTokenService. + * Test class for \Magento\Integration\Model\AdminTokenService. */ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase { /** - * @var AdminTokenServiceInterface + * @var \Magento\Integration\Api\AdminTokenServiceInterface */ private $tokenService; @@ -36,7 +36,7 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Model\AdminTokenService'); $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); } diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Model/AuthorizationServiceTest.php similarity index 98% rename from dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php rename to dev/tests/integration/testsuite/Magento/Integration/Model/AuthorizationServiceTest.php index 5f801e0110921..2cc1315710f5f 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Model/AuthorizationServiceTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Authorization\Model\UserContextInterface; @@ -29,7 +29,7 @@ protected function setUp() $loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->disableOriginalConstructor()->getMock(); $loggerMock->expects($this->any())->method('critical')->will($this->returnSelf()); $this->_service = $objectManager->create( - 'Magento\Integration\Service\V1\AuthorizationService', + 'Magento\Integration\Model\AuthorizationService', [ 'logger' => $loggerMock ] diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php similarity index 94% rename from dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php rename to dev/tests/integration/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php index d4227003eecd6..477c755e9a1cf 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Integration\Service\V1; +namespace Magento\Integration\Model; use Magento\Customer\Api\AccountManagementInterface; use Magento\Framework\Exception\InputException; @@ -12,7 +12,7 @@ use Magento\TestFramework\Helper\Bootstrap; /** - * Test class for \Magento\Integration\Service\V1\CustomerTokenService. + * Test class for \Magento\Integration\Model\CustomerTokenService. */ class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +36,7 @@ class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\CustomerTokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Model\CustomerTokenService'); $this->accountManagement = Bootstrap::getObjectManager()->get( 'Magento\Customer\Api\AccountManagementInterface' ); diff --git a/dev/tests/integration/testsuite/Magento/Integration/_files/integration_all_permissions.php b/dev/tests/integration/testsuite/Magento/Integration/_files/integration_all_permissions.php new file mode 100644 index 0000000000000..07323c01c1bb6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/_files/integration_all_permissions.php @@ -0,0 +1,15 @@ +create('Magento\Integration\Model\Integration'); +$integration->setName('Fixture Integration')->save(); + +/** Grant permissions to integrations */ +/** @var \Magento\Integration\Api\AuthorizationServiceInterface */ +$authorizationService = $objectManager->create('Magento\Integration\Api\AuthorizationServiceInterface'); +$authorizationService->grantAllPermissions($integration->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Integration/_files/integration_all_permissions_rollback.php b/dev/tests/integration/testsuite/Magento/Integration/_files/integration_all_permissions_rollback.php new file mode 100644 index 0000000000000..fdba605dfa7de --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/_files/integration_all_permissions_rollback.php @@ -0,0 +1,13 @@ +create('Magento\Integration\Model\Integration'); +$integration->load('Fixture Integration', 'name'); +if ($integration->getId()) { + $integration->delete(); +} diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php index 71dc720b07192..cf332c55e852f 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php @@ -40,7 +40,7 @@ public function testRead() $expected = [ 'credit_cards' => ['SO' => 'Solo', 'SM' => 'Switch/Maestro'], 'groups' => ['any_payment' => 'Any Payment'], - 'methods' => ['checkmo' => ['allow_multiple_address' => 1, 'allow_multiple_with_3dsecure' => 1]], + 'methods' => ['checkmo' => ['allow_multiple_address' => 1]], ]; $this->assertEquals($expected, $result); } @@ -58,7 +58,7 @@ public function testMergeCompleteAndPartial() 'credit_cards' => ['AE' => 'American Express', 'SM' => 'Switch/Maestro', 'SO' => 'Solo'], 'groups' => ['any_payment' => 'Any Payment Methods', 'offline' => 'Offline Payment Methods'], 'methods' => [ - 'checkmo' => ['allow_multiple_address' => 1, 'allow_multiple_with_3dsecure' => 1], + 'checkmo' => ['allow_multiple_address' => 1], 'deny-method' => ['allow_multiple_address' => 0], ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml index 82113715ec1c1..0b6abf4ceaf28 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml @@ -23,7 +23,6 @@ 1 - 1 diff --git a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Sales/Sales/GridTest.php b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Sales/Sales/GridTest.php index 5462dd5b09991..d9a4d886c26c1 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Sales/Sales/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Sales/Sales/GridTest.php @@ -80,7 +80,7 @@ public function testGetCountTotals($from, $to, $expectedResult) $block->setFilterData($filterData); $block->toHtml(); - $this->assertEquals($block->getCountTotals(), $expectedResult); + $this->assertEquals($expectedResult, $block->getCountTotals()); } /** @@ -90,9 +90,10 @@ public function testGetCountTotals($from, $to, $expectedResult) */ public function getCountTotalsDataProvider() { + $time = time(); return [ - [date("Y-m-d", time() + 24 * 60 * 60), date("Y-m-d", time() + 48 * 60 * 60), false], - [date("Y-m-d", time() - 24 * 60 * 60), date("Y-m-d", time() + 24 * 60 * 60), true], + [date("Y-m-d", $time + 48 * 60 * 60), date("Y-m-d", $time + 72 * 60 * 60), false], + [date("Y-m-d", $time - 48 * 60 * 60), date("Y-m-d", $time + 48 * 60 * 60), true], [null, null, false], ]; } diff --git a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php new file mode 100644 index 0000000000000..b8805203654f5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php @@ -0,0 +1,38 @@ +get('Magento\Framework\View\LayoutInterface'); + /** @var Grid $grid */ + $grid = $layout->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid'); + $grid->getRequest()->setParams(['filter' => base64_encode(urlencode('email=customer@example.com'))]); + $result = $grid->getPreparedCollection(); + + $this->assertCount(1, $result->getItems()); + /** @var Quote $quote */ + $quote = $result->getFirstItem(); + $this->assertEquals('customer@example.com', $quote->getCustomerEmail()); + $this->assertEquals(10.00, $quote->getSubtotal()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/GridTestAbstract.php b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/GridTestAbstract.php new file mode 100644 index 0000000000000..42c3700c1d1a5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/GridTestAbstract.php @@ -0,0 +1,32 @@ +create('Magento\Customer\Api\CustomerRepositoryInterface'); + $customerData = $customerRepository->getById(1); + + /** @var Quote $quoteFixture */ + $quoteFixture = $objectManager->create('Magento\Quote\Model\Quote'); + $quoteFixture->load('test01', 'reserved_order_id'); + $quoteFixture->setIsActive(true); + $quoteFixture->setCustomer($customerData); + $quoteFixture->save(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Product/GridTest.php b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Product/GridTest.php new file mode 100644 index 0000000000000..204b1b64c7106 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Product/GridTest.php @@ -0,0 +1,39 @@ +get('Magento\Framework\View\LayoutInterface'); + /** @var Grid $grid */ + $grid = $layout->createBlock('Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid'); + $result = $grid->getPreparedCollection(); + + $this->assertCount(1, $result->getItems()); + /** @var Item $quoteItem */ + $quoteItem = $result->getFirstItem(); + $this->assertInstanceOf('Magento\Quote\Model\Quote\Item', $quoteItem); + + $this->assertEquals(1, $quoteItem->getProductId()); + $this->assertEquals('Simple Product', $quoteItem->getName()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Reports/Controller/Adminhtml/Report/Product/ViewedTest.php b/dev/tests/integration/testsuite/Magento/Reports/Controller/Adminhtml/Report/Product/ViewedTest.php index d5040c34d3fe2..959036372f20c 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/Controller/Adminhtml/Report/Product/ViewedTest.php +++ b/dev/tests/integration/testsuite/Magento/Reports/Controller/Adminhtml/Report/Product/ViewedTest.php @@ -34,17 +34,6 @@ public function testExecuteWithError() $this->dispatch('backend/reports/report_product/viewed/filter/' . 'cGVyaW9kX3R5cGU9ZGF5JmZyb209NyUyRjElMkY2NyZ0bz1odG1sJTIwZm90bSZzaG93X2VtcHR5X3Jvd3M9MA=='); $actual = $this->getResponse()->getBody(); - - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - - /** @var $messageManager \Magento\Framework\Message\Manager */ - $messageManager = $objectManager->get('Magento\Framework\Message\Manager'); - - $this->assertContains( - 'An error occurred while showing the product views report.', - (string)$messageManager->getMessages()->getLastAddedMessage()->getText() - ); - $this->assertEquals('', $actual); } } diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/FormTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/FormTest.php deleted file mode 100644 index e1d3c2c021b63..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Review/Block/FormTest.php +++ /dev/null @@ -1,44 +0,0 @@ -get('Magento\Framework\App\RequestInterface')->setParam('id', 1); - - $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Customer\Model\Session'); - /** @var \Magento\Customer\Api\AccountManagementInterface $service */ - $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Api\AccountManagementInterface' - ); - $customer = $service->authenticate('customer@example.com', 'password'); - $session->setCustomerDataAsLoggedIn($customer); - $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Review\Block\Form'); - /** @var \Magento\Framework\Escaper $escaper */ - $escaper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\Escaper'); - $this->assertStringMatchesFormat( - '%A%A', - $block->toHtml() - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Review/Model/Resource/Rating/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Review/Model/Resource/Rating/CollectionTest.php new file mode 100644 index 0000000000000..d5a9161cb4184 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Model/Resource/Rating/CollectionTest.php @@ -0,0 +1,57 @@ +collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Review\Model\Resource\Rating\Collection' + ); + } + + /** + * @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php + */ + public function testAddEntitySummaryToItem() + { + $ratingData = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Framework\Registry') + ->registry('rating_data'); + + $result = $this->collection->addEntitySummaryToItem($ratingData->getEntityId(), $ratingData->getStoreId()); + $this->assertEquals($this->collection, $result); + } + + /** + * @magentoDbIsolation enabled + */ + public function testAddEntitySummaryToItemEmpty() + { + foreach ($this->collection->getItems() as $item) { + $item->delete(); + } + $this->collection->clear(); + $result = $this->collection->addEntitySummaryToItem(1, 1); + $this->assertEquals($this->collection, $result); + } + + public function testAddStoreData() + { + $this->collection->addStoreData(); + } + + public function testSetStoreFilter() + { + $this->collection->setStoreFilter(1); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Model/Resource/RatingTest.php b/dev/tests/integration/testsuite/Magento/Review/Model/Resource/RatingTest.php new file mode 100644 index 0000000000000..910fb6b0c42ef --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Model/Resource/RatingTest.php @@ -0,0 +1,80 @@ +get('Magento\Store\Model\StoreManagerInterface') + ->getStore()->getId(); + + $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Review\Model\Rating'); + $rating->setData([ + 'rating_code' => 'Test Rating', + 'position' => 0, + 'is_active' => true, + 'entity_id' => 1 + ]); + $rating->setRatingCodes([$storeId => 'Test Rating']); + $rating->setStores([$storeId]); + $rating->save(); + $this->id = $rating->getId(); + } + + /** + * @magentoDbIsolation enabled + */ + public function testRatingLoad() + { + $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Review\Model\Rating'); + $rating->load($this->id); + $this->assertEquals('Test Rating', $rating->getRatingCode()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testRatingEdit() + { + $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Review\Model\Rating'); + $rating->load($this->id); + $this->assertEquals('Test Rating', $rating->getRatingCode()); + $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Store\Model\StoreManagerInterface') + ->getStore()->getId(); + $rating->setRatingCode('Test Rating Edited'); + $rating->setRatingCodes([$storeId => 'Test Rating Edited']); + $rating->save(); + + $this->assertEquals('Test Rating Edited', $rating->getRatingCode()); + $this->assertEquals([$storeId => 'Test Rating Edited'], $rating->getRatingCodes()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testRatingSaveWithError() + { + $this->setExpectedException('Exception', 'Rolled back transaction has not been completed correctly'); + $rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Review\Model\Rating'); + $rating->load($this->id); + $rating->setRatingCodes([222 => 'Test Rating Edited']); + $rating->save(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Model/Resource/Review/ReviewTest.php b/dev/tests/integration/testsuite/Magento/Review/Model/Resource/Review/ReviewTest.php new file mode 100644 index 0000000000000..7a1216f6717e0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Model/Resource/Review/ReviewTest.php @@ -0,0 +1,64 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->resource = $this->objectManager->get('Magento\Framework\App\Resource'); + $this->adapter = $this->resource->getConnection('core_read'); + $this->reviewCollection = $this->objectManager->create('Magento\Review\Model\Resource\Review\Collection'); + $this->reviewResource = $this->objectManager->create('Magento\Review\Model\Resource\Review'); + } + + /** + * @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php + */ + public function testAggregate() + { + $rating = $this->reviewCollection->getFirstItem(); + $this->reviewResource->aggregate($rating); + + $select = $this->adapter->select()->from($this->resource->getTableName('review_entity_summary')); + $result = $this->adapter->fetchRow($select); + + $this->assertEquals(1, $result['reviews_count']); + $this->assertEquals(40, $result['rating_summary']); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/customer_review_with_rating.php b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review_with_rating.php new file mode 100644 index 0000000000000..9de0a3b0a52ae --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review_with_rating.php @@ -0,0 +1,66 @@ +loadArea( + \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE +); + +require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; + +$storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + ->getStore()->getId(); + +$review = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Review\Model\Review', + ['data' => [ + 'customer_id' => $customer->getId(), + 'title' => 'Review Summary', + 'detail' => 'Review text', + 'nickname' => 'Nickname', + ]] +); + +$review + ->setEntityId($review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE)) + ->setEntityPkValue($product->getId()) + ->setStatusId(\Magento\Review\Model\Review::STATUS_APPROVED) + ->setStoreId($storeId) + ->setStores([$storeId]) + ->save(); + +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry')->register( + 'review_data', + $review +); + +/** @var \Magento\Review\Model\Resource\Review\Collection $ratingCollection */ +$ratingCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + '\Magento\Review\Model\Rating' +)->getCollection() + ->setPageSize(2) + ->setCurPage(1); + +foreach ($ratingCollection as $rating) { + $rating->setStores([$storeId])->setIsActive(1)->save(); +} + +foreach ($ratingCollection as $rating) { + $ratingOption = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('\Magento\Review\Model\Rating\Option') + ->getCollection() + ->setPageSize(1) + ->setCurPage(2) + ->addRatingFilter($rating->getId()) + ->getFirstItem(); + $rating->setReviewId($review->getId()) + ->addOptionVote($ratingOption->getId(), $product->getId()); +} + +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry')->register( + 'rating_data', + $ratingCollection->getFirstItem() +); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php deleted file mode 100644 index abc779c1a6816..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php +++ /dev/null @@ -1,98 +0,0 @@ -get('Magento\Customer\Model\Session'); - $fixtureCustomerId = 1; - $customerSession->setCustomerId($fixtureCustomerId); - /** @var \Magento\Framework\App\Http\Context $httpContext */ - $httpContext = $objectManager->get('Magento\Framework\App\Http\Context'); - $httpContext->setValue(Context::CONTEXT_AUTH, true, false); - - /** Execute SUT implicitly: initOrders() is called in the construct */ - /** @var \Magento\Sales\Block\Reorder\Sidebar $sidebarBlock */ - $sidebarBlock = $objectManager->create('Magento\Sales\Block\Reorder\Sidebar'); - - /** Ensure that customer orders were selected for the block */ - $customerOrders = $sidebarBlock->getOrders(); - $this->assertEquals(1, $customerOrders->count(), 'Invalid orders quantity.'); - $order = $customerOrders->getFirstItem(); - $this->assertEquals($fixtureCustomerId, $order->getCustomerId(), 'Customer ID in order is invalid.'); - $fixtureOrderIncrementId = '100000001'; - $this->assertEquals($fixtureOrderIncrementId, $order->getIncrementId(), 'Order increment ID is invalid.'); - } - - /** - * @magentoDataFixture Magento/Sales/_files/order_with_customer.php - * @magentoAppIsolation enabled - * @magentoDbIsolation enabled - */ - public function testInitOrdersCustomerWithoutOrders() - { - /** Preconditions */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Customer\Model\Session $customerSession */ - $customerSession = $objectManager->get('Magento\Customer\Model\Session'); - $secondCustomer = $this->createSecondCustomer(); - $customerSession->setCustomerId($secondCustomer->getId()); - /** @var \Magento\Framework\App\Http\Context $httpContext */ - $httpContext = $objectManager->get('Magento\Framework\App\Http\Context'); - $httpContext->setValue(Context::CONTEXT_AUTH, true, false); - - /** Execute SUT implicitly: initOrders() is called in the construct */ - /** @var \Magento\Sales\Block\Reorder\Sidebar $sidebarBlock */ - $sidebarBlock = $objectManager->create('Magento\Sales\Block\Reorder\Sidebar'); - - /** Ensure that customer orders were selected for the block */ - $customerOrders = $sidebarBlock->getOrders(); - $this->assertEquals(0, $customerOrders->count(), 'Filter by customer is applied to collection incorrectly.'); - } - - /* - * Create customer which does not have any orders associated with him. - * - * Please note that tests which use this method must have DB isolation enabled. - * - * @return \Magento\Customer\Model\Customer - */ - public function createSecondCustomer() - { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $objectManager->create('Magento\Customer\Model\Customer'); - $customer->setWebsiteId(1) - ->setEntityId(2) - ->setEntityTypeId(1) - ->setAttributeSetId(0) - ->setEmail('customer2@search.example.com') - ->setPassword('password') - ->setGroupId(1) - ->setStoreId(1) - ->setIsActive(1) - ->setFirstname('Firstname2') - ->setLastname('Lastname2') - ->setDefaultBilling(2) - ->setDefaultShipping(2) - ->setCreatedAt('2010-02-28 15:52:26'); - $customer->isObjectNew(true); - $customer->save(); - return $customer; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php index 0a35f0488948b..9514e649404e0 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php @@ -33,8 +33,8 @@ public function testLoadBlockActionData() $this->getRequest()->setParam('json', 1); $this->dispatch('backend/sales/order_create/loadBlock'); $html = $this->getResponse()->getBody(); - $this->assertContains('
      ', $html); - $this->assertContains('
      ', $html); + $this->assertContains('
      assertContains('
      assertContains('id=\"shipping-method-overlay\"', $html); $this->assertContains('id=\"coupons:code\"', $html); } @@ -57,8 +57,8 @@ public function loadBlockActionsDataProvider() 'shipping_method' => ['shipping_method', 'id=\"shipping-method-overlay\"'], 'billing_method' => ['billing_method', '
      '], 'newsletter' => ['newsletter', 'name=\"newsletter:subscribe\"'], - 'search' => ['search', '
      '], - 'search_grid' => ['search', '
      '] + 'search' => ['search', '
      ['search', '
      dispatch('backend/sales/order/index'); - $this->assertContains('Total 0 records found', $this->getResponse()->getBody()); + $this->assertContains('No records found.', $this->getResponse()->getBody()); } /** @@ -22,7 +22,10 @@ public function testIndexAction() public function testIndexActionWithOrder() { $this->dispatch('backend/sales/order/index'); - $this->assertContains('Total 1 records found', $this->getResponse()->getBody()); + $this->assertRegExp( + '/\s*1\s*<\/span>\s*records found.\s*/', + $this->getResponse()->getBody() + ); } /** diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/OrderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/OrderTest.php index 890462879d0be..21592c5930598 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/OrderTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/OrderTest.php @@ -83,7 +83,8 @@ public function testSaveOrder() /** @var \Magento\Sales\Model\Order $order */ $order = $this->objectManager->create('Magento\Sales\Model\Order'); $order->setIncrementId($this->orderIncrementId) - ->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true) + ->setState(\Magento\Sales\Model\Order::STATE_PROCESSING) + ->setStatus($order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING)) ->setSubtotal(100) ->setBaseSubtotal(100) ->setBaseGrandTotal(100) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php index dfd4511b37c4b..aff60e6a8e85f 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php @@ -29,13 +29,16 @@ $orderItem->setBasePrice($product->getPrice()); $orderItem->setPrice($product->getPrice()); $orderItem->setRowTotal($product->getPrice()); +$orderItem->setProductType('simple'); /** @var \Magento\Sales\Model\Order $order */ $order = $objectManager->create('Magento\Sales\Model\Order'); $order->setIncrementId( '100000001' )->setState( - \Magento\Sales\Model\Order::STATE_PROCESSING, true + \Magento\Sales\Model\Order::STATE_PROCESSING +)->setStatus( + $order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING) )->setSubtotal( 100 )->setBaseSubtotal( 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 4d4c2d92a90b0..a16178c0c48bd 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 @@ -33,7 +33,9 @@ $order->setIncrementId( '100000004' )->setState( - \Magento\Sales\Model\Order::STATE_PROCESSING, true + \Magento\Sales\Model\Order::STATE_PROCESSING +)->setStatus( + $order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING) )->setSubtotal( 100 )->setBaseSubtotal( 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 c476e27898e83..b38b7c4f54d79 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php @@ -4,12 +4,14 @@ * See COPYING.txt for license details. */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea( \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE ); /** @var $product \Magento\Catalog\Model\Product */ -$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); +$product = $objectManager->create('Magento\Catalog\Model\Product'); $product->setTypeId('virtual') ->setId(1) ->setAttributeSetId(4) @@ -29,10 +31,7 @@ $addressData = include __DIR__ . '/address_data.php'; -$billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Quote\Model\Quote\Address', - ['data' => $addressData] -); +$billingAddress = $objectManager->create('Magento\Quote\Model\Quote\Address', ['data' => $addressData]); $billingAddress->setAddressType('billing'); $shippingAddress = clone $billingAddress; @@ -40,13 +39,11 @@ $shippingAddress->setShippingMethod('flatrate_flatrate'); /** @var $quote \Magento\Quote\Model\Quote */ -$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Quote\Model\Quote'); +$quote = $objectManager->create('Magento\Quote\Model\Quote'); $quote->setCustomerIsGuest( true )->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' - )->getStore()->getId() + $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId() )->setReservedOrderId( '100000001' )->setBillingAddress( @@ -67,34 +64,22 @@ $quote->save(); $quote->setCustomerEmail('admin@example.com'); -$quoteManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteManagement'); +$quoteManagement = $objectManager->create('Magento\Quote\Model\QuoteManagement'); $order = $quoteManagement->submit($quote, ['increment_id' => '100000001']); -$orderItems = $order->getAllItems(); - /** @var $item \Magento\Sales\Model\Order\Item */ -$item = $orderItems[0]; +$item = $order->getAllItems()[0]; -/** @var $invoice \Magento\Sales\Model\Order\Invoice */ -$invoice = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Service\Order', - ['order' => $order] -)->prepareInvoice( - [$item->getId() => 10] -); +/** @var \Magento\Sales\Model\Service\Order $orderService */ +$orderService = $objectManager->create('Magento\Sales\Model\Service\Order', ['order' => $order]); +/** @var $invoice \Magento\Sales\Model\Order\Invoice */ +$invoice = $orderService->prepareInvoice([$item->getId() => 10]); $invoice->register(); $invoice->save(); -$creditmemo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Service\Order', - ['order' => $order] -)->prepareInvoiceCreditmemo( - $invoice, - ['qtys' => [$item->getId() => 5]] -); +$creditmemo = $orderService->prepareInvoiceCreditmemo($invoice, ['qtys' => [$item->getId() => 5]]); foreach ($creditmemo->getAllItems() as $creditmemoItem) { //Workaround to return items to stock @@ -104,13 +89,10 @@ $creditmemo->register(); $creditmemo->save(); -$transactionSave = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\DB\Transaction' -)->addObject( - $creditmemo -)->addObject( - $creditmemo->getOrder() -); +/** @var \Magento\Framework\DB\Transaction $transactionSave */ +$transactionSave = $objectManager->create('Magento\Framework\DB\Transaction') + ->addObject($creditmemo) + ->addObject($creditmemo->getOrder()); if ($creditmemo->getInvoice()) { $transactionSave->addObject($creditmemo->getInvoice()); } diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowFrameworkCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowFrameworkCommandTest.php new file mode 100644 index 0000000000000..7a986a3c7ee0e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowFrameworkCommandTest.php @@ -0,0 +1,57 @@ +create('Magento\Framework\App\Filesystem\DirectoryList', ['root' => BP]); + $this->command = new DependenciesShowFrameworkCommand($directoryList); + $this->commandTester = new CommandTester($this->command); + } + + public function tearDown() + { + if (file_exists(__DIR__ . '/_files/output/framework.csv')) { + unlink(__DIR__ . '/_files/output/framework.csv'); + } + } + + public function testExecute() + { + $this->commandTester->execute( + ['--directory' => __DIR__ . '/_files/root', '--output' => __DIR__ . '/_files/output/framework.csv'] + ); + $this->assertEquals('Report successfully processed.' . PHP_EOL, $this->commandTester->getDisplay()); + $this->assertFileEquals( + __DIR__ . '/_files/expected/framework.csv', + __DIR__ . '/_files/output/framework.csv' + ); + } + + public function testExecuteInvalidDirectory() + { + $this->commandTester->execute(['--directory' => '/invalid/path']); + $this->assertContains( + 'Please check the path you provided. Dependencies report generator failed with error:', + $this->commandTester->getDisplay() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowModulesCircularCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowModulesCircularCommandTest.php new file mode 100644 index 0000000000000..9fc5e9dbecdae --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowModulesCircularCommandTest.php @@ -0,0 +1,55 @@ +command = new DependenciesShowModulesCircularCommand(); + $this->commandTester = new CommandTester($this->command); + } + + public function tearDown() + { + if (file_exists(__DIR__ . '/_files/output/circular.csv')) { + unlink(__DIR__ . '/_files/output/circular.csv'); + } + } + + public function testExecute() + { + $this->commandTester->execute( + ['--directory' => __DIR__ . '/_files/root', '--output' => __DIR__ . '/_files/output/circular.csv'] + ); + $this->assertEquals('Report successfully processed.' . PHP_EOL, $this->commandTester->getDisplay()); + $this->assertFileEquals( + __DIR__ . '/_files/expected/circular.csv', + __DIR__ . '/_files/output/circular.csv' + ); + } + + public function testExecuteInvalidDirectory() + { + $this->commandTester->execute(['--directory' => '/invalid/path']); + $this->assertContains( + 'Please check the path you provided. Dependencies report generator failed with error:', + $this->commandTester->getDisplay() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowModulesCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowModulesCommandTest.php new file mode 100644 index 0000000000000..6d0c16225cd5c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/DependenciesShowModulesCommandTest.php @@ -0,0 +1,55 @@ +command = new DependenciesShowModulesCommand(); + $this->commandTester = new CommandTester($this->command); + } + + public function tearDown() + { + if (file_exists(__DIR__ . '/_files/output/modules.csv')) { + unlink(__DIR__ . '/_files/output/modules.csv'); + } + } + + public function testExecute() + { + $this->commandTester->execute( + ['--directory' => __DIR__ . '/_files/root', '--output' => __DIR__ . '/_files/output/modules.csv'] + ); + $this->assertEquals('Report successfully processed.' . PHP_EOL, $this->commandTester->getDisplay()); + $this->assertFileEquals( + __DIR__ . '/_files/expected/modules.csv', + __DIR__ . '/_files/output/modules.csv' + ); + } + + public function testExecuteInvalidDirectory() + { + $this->commandTester->execute(['--directory' => '/invalid/path']); + $this->assertContains( + 'Please check the path you provided. Dependencies report generator failed with error:', + $this->commandTester->getDisplay() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/circular.csv b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/circular.csv new file mode 100644 index 0000000000000..6d00c9f481554 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/circular.csv @@ -0,0 +1,9 @@ +"Circular dependencies:","Total number of chains" +"","2" + +"Circular dependencies for each module:","" +"magento/module-a","1" +"magento/module-a->magento/module-b->magento/module-a" + +"magento/module-b","1" +"magento/module-b->magento/module-a->magento/module-b" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/framework.csv b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/framework.csv new file mode 100644 index 0000000000000..b6abb23cd683f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/framework.csv @@ -0,0 +1,9 @@ +"Dependencies of framework:","Total number" +"","2" + +"Dependencies for each module:","" +"Magento\A","1" +" -- Magento\Framework","1" + +"Magento\B","1" +" -- Magento\Framework","1" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/modules.csv b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/modules.csv new file mode 100644 index 0000000000000..41deca9466eca --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expected/modules.csv @@ -0,0 +1,9 @@ +"","All","Hard","Soft" +"Total number of dependencies","2","2","0" + +"Dependencies for each module:","All","Hard","Soft" +"magento/module-a","1","1","0" +" -- magento/module-b","","1","0" + +"magento/module-b","1","1","0" +" -- magento/module-a","","1","0" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/A/Model/Foo.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/A/Model/Foo.php new file mode 100644 index 0000000000000..25f20265a9c35 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/A/Model/Foo.php @@ -0,0 +1,17 @@ + - - - - - - + diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/B/Model/Foo.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/B/Model/Foo.php new file mode 100644 index 0000000000000..843ade228dd53 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/B/Model/Foo.php @@ -0,0 +1,17 @@ + + + + + diff --git a/dev/tests/integration/testsuite/Magento/ToolkitFramework/ApplicationTest.php b/dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixtureModelTest.php similarity index 59% rename from dev/tests/integration/testsuite/Magento/ToolkitFramework/ApplicationTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixtureModelTest.php index 64c7f8867cb40..57b314dd57ea1 100644 --- a/dev/tests/integration/testsuite/Magento/ToolkitFramework/ApplicationTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixtureModelTest.php @@ -3,12 +3,15 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework; + +namespace Magento\Setup\Fixtures; + +use Magento\TestFramework\Helper\Bootstrap; /** * Class Application test */ -class ApplicationTest extends \Magento\TestFramework\Indexer\TestCase +class FixtureModelTest extends \Magento\TestFramework\Indexer\TestCase { /** * Profile generator working directory @@ -24,31 +27,28 @@ class ApplicationTest extends \Magento\TestFramework\Indexer\TestCase public static function setUpBeforeClass() { - self::$_generatorWorkingDir = realpath(__DIR__ . '/../../../../../tools/performance-toolkit'); + self::$_generatorWorkingDir = realpath(__DIR__ . '/../../../../../../../setup/src/Magento/Setup/Fixtures'); + copy( + self::$_generatorWorkingDir . '/tax_rates.csv', + self::$_generatorWorkingDir . '/tax_rates.csv.bak' + ); copy( - self::$_generatorWorkingDir . '/fixtures/tax_rates.csv', - self::$_generatorWorkingDir . '/fixtures/tax_rates.csv.bak' + __DIR__ . '/_files/tax_rates.csv', + self::$_generatorWorkingDir . '/tax_rates.csv' ); - copy(__DIR__ . '/_files/tax_rates.csv', self::$_generatorWorkingDir . '/fixtures/tax_rates.csv'); parent::setUpBeforeClass(); } public function testTest() { - $config = \Magento\ToolkitFramework\Config::getInstance(); - $config->loadConfig(__DIR__ . '/_files/small.xml'); - /** @var \Magento\TestFramework\Application $itfApplication */ + $reindexCommand = Bootstrap::getObjectManager()->get('Magento\Indexer\Console\Command\IndexerReindexCommand'); + $parser = Bootstrap::getObjectManager()->get('Magento\Framework\Xml\Parser'); $itfApplication = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication(); - $shell = $this->getMock('Magento\Framework\Shell', [], [], '', false); - - $application = new \Magento\ToolkitFramework\Application( - $itfApplication->getTempDir(), - $shell, - $itfApplication->getInitParams() - ); + $model = new FixtureModel($reindexCommand, $parser, $itfApplication->getInitParams()); + $model->loadConfig(__DIR__ . '/_files/small.xml'); + $model->initObjectManager(); - $application->bootstrap(); - foreach ($application->loadFixtures()->getFixtures() as $fixture) { + foreach ($model->loadFixtures()->getFixtures() as $fixture) { $fixture->execute(); } } @@ -56,13 +56,13 @@ public function testTest() public static function tearDownAfterClass() { parent::tearDownAfterClass(); - unlink(self::$_generatorWorkingDir . '/fixtures/tax_rates.csv'); + unlink(self::$_generatorWorkingDir . '/tax_rates.csv'); rename( - self::$_generatorWorkingDir . '/fixtures/tax_rates.csv.bak', - self::$_generatorWorkingDir . '/fixtures/tax_rates.csv' + self::$_generatorWorkingDir . '/tax_rates.csv.bak', + self::$_generatorWorkingDir . '/tax_rates.csv' ); /** @var $appCache \Magento\Framework\App\Cache */ - $appCache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache'); + $appCache = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache'); $appCache->clean( [ \Magento\Eav\Model\Cache\Type::CACHE_TAG, diff --git a/dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/small.xml b/dev/tests/integration/testsuite/Magento/Setup/Fixtures/_files/small.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/small.xml rename to dev/tests/integration/testsuite/Magento/Setup/Fixtures/_files/small.xml diff --git a/dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/tax_rates.csv b/dev/tests/integration/testsuite/Magento/Setup/Fixtures/_files/tax_rates.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/ToolkitFramework/_files/tax_rates.csv rename to dev/tests/integration/testsuite/Magento/Setup/Fixtures/_files/tax_rates.csv diff --git a/dev/tests/integration/testsuite/Magento/Setup/Model/ConfigOptionsListCollectorTest.php b/dev/tests/integration/testsuite/Magento/Setup/Model/ConfigOptionsListCollectorTest.php index 2563503251e03..b44318dab1c67 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Model/ConfigOptionsListCollectorTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Model/ConfigOptionsListCollectorTest.php @@ -27,18 +27,36 @@ public function testCollectOptionsLists() $fullModuleListMock = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); $fullModuleListMock->expects($this->once())->method('getNames')->willReturn(['Magento_Backend']); + $dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); + $configGenerator = $this->getMock('Magento\Setup\Model\ConfigGenerator', [], [], '', false); + + $setupOptions = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create( + 'Magento\Setup\Model\ConfigOptionsList', + [ + 'configGenerator' => $configGenerator, + 'dbValidator' => $dbValidator + ] + ); + + $serviceLocator = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface'); + + $serviceLocator->expects($this->once()) + ->method('get') + ->with('Magento\Setup\Model\ConfigOptionsList') + ->willReturn($setupOptions); + /** @var \Magento\Setup\Model\ConfigOptionsListCollector $object */ $object = $objectManager->create( 'Magento\Setup\Model\ConfigOptionsListCollector', [ 'objectManagerProvider' => $this->objectManagerProvider, 'fullModuleList' => $fullModuleListMock, + 'serviceLocator' => $serviceLocator ] ); $result = $object->collectOptionsLists(); - - $setupOptions = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\Config\ConfigOptionsList'); + $backendOptions = new \Magento\Backend\Setup\ConfigOptionsList(); $expected = [ 'setup' => $setupOptions, diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/CircularTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/CircularTest.php similarity index 85% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/CircularTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/CircularTest.php index 6f00de7adac0b..01bac7a189596 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/CircularTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/CircularTest.php @@ -3,14 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Test\Tools\Dependency; - -use Magento\Tools\Dependency\Circular; +namespace Magento\Setup\Module\Dependency; class CircularTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Circular + * @var Circular */ protected $circular; diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Composer/JsonTest.php similarity index 88% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Composer/JsonTest.php index 684c24f7b933b..173148154fc7f 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Composer/JsonTest.php @@ -3,9 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Test\Tools\Dependency\Parser\Composer; - -use Magento\Tools\Dependency\Parser\Composer\Json; +namespace Magento\Setup\Module\Dependency\Parser\Composer; class JsonTest extends \PHPUnit_Framework_TestCase { @@ -15,7 +13,7 @@ class JsonTest extends \PHPUnit_Framework_TestCase protected $fixtureDir; /** - * @var \Magento\Tools\Dependency\Parser\Composer\Json + * @var Json */ protected $parser; diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Config/XmlTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php similarity index 82% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Config/XmlTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php index cdf12497059a9..d9439764258b6 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Config/XmlTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Parser/Config/XmlTest.php @@ -3,9 +3,8 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Test\Tools\Dependency\Parser\Config; +namespace Magento\Setup\Module\Dependency\Parser\Config; -use Magento\Tools\Dependency\Parser\Config\Xml; class XmlTest extends \PHPUnit_Framework_TestCase { @@ -15,7 +14,7 @@ class XmlTest extends \PHPUnit_Framework_TestCase protected $fixtureDir; /** - * @var \Magento\Tools\Dependency\Parser\Config\Xml + * @var Xml */ protected $parser; diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/CircularTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/CircularTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/CircularTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/CircularTest.php index 0fa0180dc786d..ce72ffc46b1c9 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/CircularTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/CircularTest.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Test\Tools\Dependency\Report; +namespace Magento\Setup\Module\Dependency\Report; -use Magento\Tools\Dependency\ServiceLocator; +use Magento\Setup\Module\Dependency\ServiceLocator; class CircularTest extends \PHPUnit_Framework_TestCase { @@ -20,7 +20,7 @@ class CircularTest extends \PHPUnit_Framework_TestCase protected $sourceFilename; /** - * @var \Magento\Tools\Dependency\Report\BuilderInterface + * @var BuilderInterface */ protected $builder; diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/DependencyTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/DependencyTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/DependencyTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/DependencyTest.php index 2c672d400375b..3c896043ae3be 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/DependencyTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/DependencyTest.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Test\Tools\Dependency\Report; +namespace Magento\Setup\Module\Dependency\Report; -use Magento\Tools\Dependency\ServiceLocator; +use Magento\Setup\Module\Dependency\ServiceLocator; class DependencyTest extends \PHPUnit_Framework_TestCase { @@ -20,7 +20,7 @@ class DependencyTest extends \PHPUnit_Framework_TestCase protected $sourceFilename; /** - * @var \Magento\Tools\Dependency\Report\BuilderInterface + * @var BuilderInterface */ protected $builder; diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/FrameworkTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/FrameworkTest.php similarity index 93% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/FrameworkTest.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/FrameworkTest.php index 15ef53dd86247..ba4021dd6c1c8 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Report/FrameworkTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/Report/FrameworkTest.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Test\Tools\Dependency\Report; +namespace Magento\Setup\Module\Dependency\Report; -use Magento\Tools\Dependency\ServiceLocator; +use Magento\Setup\Module\Dependency\ServiceLocator; class FrameworkTest extends \PHPUnit_Framework_TestCase { @@ -25,7 +25,7 @@ class FrameworkTest extends \PHPUnit_Framework_TestCase protected $sourceFilename; /** - * @var \Magento\Tools\Dependency\Report\BuilderInterface + * @var BuilderInterface */ protected $builder; diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/Model.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Model/Model.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/Model.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Model/Model.php diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/etc/module.xml b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/etc/module.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/etc/module.xml rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/etc/module.xml diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/view/frontend/template.phtml b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/view/frontend/template.phtml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/view/frontend/template.phtml rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/view/frontend/template.phtml diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer1.json b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer1.json similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer1.json rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer1.json diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer2.json b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer2.json similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer2.json rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer2.json diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer3.json b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer3.json similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer3.json rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer3.json diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer4.json b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer4.json similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer4.json rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer4.json diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer5.json b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer5.json similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer5.json rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer5.json diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/circular-dependencies.csv b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/circular-dependencies.csv new file mode 100644 index 0000000000000..4b83254473bcb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/circular-dependencies.csv @@ -0,0 +1,9 @@ +"Circular dependencies:","Total number of chains" +"","2" + +"Circular dependencies for each module:","" +"magento/module-module1","1" +"magento/module-module1->magento/module-module2->magento/module-module1" + +"magento/module-module2","1" +"magento/module-module2->magento/module-module1->magento/module-module2" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/dependencies.csv b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/dependencies.csv new file mode 100644 index 0000000000000..9ab2ef5f53021 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/dependencies.csv @@ -0,0 +1,10 @@ +"","All","Hard","Soft" +"Total number of dependencies","3","2","1" + +"Dependencies for each module:","All","Hard","Soft" +"magento/module-module1","2","1","1" +" -- magento/module-module2","","1","0" +" -- magento/module-backend","","0","1" + +"magento/module-module2","1","1","0" +" -- magento/module-module3","","1","0" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/framework-dependencies.csv b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/framework-dependencies.csv new file mode 100644 index 0000000000000..8b681bd873577 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/framework-dependencies.csv @@ -0,0 +1,8 @@ +"Dependencies of framework:","Total number" +"","3" + +"Dependencies for each module:","" +"Magento\FirstModule","3" +" -- Magento\LibFirst","1" +" -- Magento\LibSecond","2" +" -- Magento\Third","1" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-circular-dependencies.csv b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-circular-dependencies.csv new file mode 100644 index 0000000000000..6397730cd9f52 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-circular-dependencies.csv @@ -0,0 +1,2 @@ +"Circular dependencies:","Total number of chains" +"","0" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-dependencies.csv b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-dependencies.csv new file mode 100644 index 0000000000000..e1b73bda97599 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-dependencies.csv @@ -0,0 +1,2 @@ +"","All","Hard","Soft" +"Total number of dependencies","0","0","0" diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-framework-dependencies.csv b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-framework-dependencies.csv new file mode 100644 index 0000000000000..2c5a00595d4c7 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/expected/without-framework-dependencies.csv @@ -0,0 +1,2 @@ +"Dependencies of framework:","Total number" +"","0" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/module1.xml b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/module1.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/module1.xml rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/module1.xml diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/module2.xml b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/module2.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/module2.xml rename to dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/module2.xml diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Centinel/StateFactoryTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Centinel/StateFactoryTest.php deleted file mode 100644 index 60b907404a94c..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Centinel/StateFactoryTest.php +++ /dev/null @@ -1,62 +0,0 @@ -_getFactoryTypes(); - $ccTypes = $this->_getCcTypes(); - - $definedTypes = array_intersect($factoryTypes, $ccTypes); - - $this->assertEquals( - $factoryTypes, - $definedTypes, - 'Some factory types are missing from payments config.' . "\nMissing types: " . implode( - ',', - array_diff($factoryTypes, $definedTypes) - ) - ); - } - - /** - * Get factory, find list of types it has - * - * @return array string[] factoryTypes - */ - private function _getFactoryTypes() - { - /** @var \Magento\Centinel\Model\StateFactory $stateFactory */ - $stateFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Centinel\Model\StateFactory' - ); - $reflectionObj = new \ReflectionClass($stateFactory); - $stateMapProp = $reflectionObj->getProperty('_stateClassMap'); - $stateMapProp->setAccessible(true); - $stateClassMap = $stateMapProp->getValue($stateFactory); - $factoryTypes = array_keys($stateClassMap); - return $factoryTypes; - } - - /** - * Get config, find list of types it has - * - * @return array string[] ccTypes - */ - private function _getCcTypes() - { - /** @var \Magento\Payment\Model\Config $paymentConfig */ - $paymentConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Payment\Model\Config' - ); - $ccTypes = array_keys($paymentConfig->getCcTypes()); - return $ccTypes; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php index d224cd6d346e3..38c0d46aae2e4 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/LayoutFilesTest.php @@ -98,8 +98,6 @@ protected function isSkippedArgument(array $argumentData) $typeAttr => 'object', 'value' => 'Magento\CustomerSegment\Model\Resource\Segment\Report\Detail\Collection' ], - [$typeAttr => 'helper', 'helper' => 'Magento\Pbridge\Helper\Data::getReviewButtonTemplate'], - [$typeAttr => 'helper', 'helper' => 'Magento\Pbridge\Helper\Data::getContinueButtonTemplate'], [$typeAttr => 'options', 'model' => 'Magento\Solr\Model\Adminhtml\Search\Grid\Options'], [$typeAttr => 'options', 'model' => 'Magento\Logging\Model\Resource\Grid\ActionsGroup'], [$typeAttr => 'options', 'model' => 'Magento\Logging\Model\Resource\Grid\Actions'], diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/circular-dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/circular-dependencies.csv deleted file mode 100644 index 1d29bfdb31a21..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/circular-dependencies.csv +++ /dev/null @@ -1,9 +0,0 @@ -"Circular dependencies:";"Total number of chains" -"";"2" - -"Circular dependencies for each module:";"" -"magento/module-module1";"1" -"magento/module-module1->magento/module-module2->magento/module-module1" - -"magento/module-module2";"1" -"magento/module-module2->magento/module-module1->magento/module-module2" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv deleted file mode 100644 index bce8d9c13d29a..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv +++ /dev/null @@ -1,10 +0,0 @@ -"";"All";"Hard";"Soft" -"Total number of dependencies";"3";"2";"1" - -"Dependencies for each module:";"All";"Hard";"Soft" -"magento/module-module1";"2";"1";"1" -" -- magento/module-module2";"";"1";"0" -" -- magento/module-backend";"";"0";"1" - -"magento/module-module2";"1";"1";"0" -" -- magento/module-module3";"";"1";"0" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/framework-dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/framework-dependencies.csv deleted file mode 100644 index d20a242e069ac..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/framework-dependencies.csv +++ /dev/null @@ -1,8 +0,0 @@ -"Dependencies of framework:";"Total number" -"";"3" - -"Dependencies for each module:";"" -"Magento\FirstModule";"3" -" -- Magento\LibFirst";"1" -" -- Magento\LibSecond";"2" -" -- Magento\Third";"1" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-circular-dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-circular-dependencies.csv deleted file mode 100644 index 2861dd888e2e1..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-circular-dependencies.csv +++ /dev/null @@ -1,2 +0,0 @@ -"Circular dependencies:";"Total number of chains" -"";"0" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-dependencies.csv deleted file mode 100644 index a1ca40ac82b64..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-dependencies.csv +++ /dev/null @@ -1,2 +0,0 @@ -"";"All";"Hard";"Soft" -"Total number of dependencies";"0";"0";"0" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-framework-dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-framework-dependencies.csv deleted file mode 100644 index 71bbbf8497821..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/without-framework-dependencies.csv +++ /dev/null @@ -1,2 +0,0 @@ -"Dependencies of framework:";"Total number" -"";"0" diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/ProcessorTest.php b/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/ProcessorTest.php deleted file mode 100644 index 4d9cf1941daab..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/ProcessorTest.php +++ /dev/null @@ -1,128 +0,0 @@ -markTestSkipped('XSL extension needed for XSLT Processor test'); - } - $this->_testDir = realpath(__DIR__ . '/_files') . '/'; - - /** @var Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\Filesystem'); - $this->_varDir = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR)->getAbsolutePath('references/'); - mkdir($this->_varDir, 0777, true); - - $this->_formatter = new Formatter(); - $this->_dictionaryPath = $this->_varDir . 'references.xml'; - - $this->_processor = new Processor($this->_formatter, $this->_dictionaryPath); - } - - public function tearDown() - { - \Magento\Framework\System\Dirs::rm($this->_varDir); - } - - public function testGetReferences() - { - $this->_processor->getReferences([$this->_testDir . 'layoutValid.xml']); - $this->_processor->writeToFile(); - $expected = << - - - - - - - - - -EOF; - $this->assertEquals($expected, file_get_contents($this->_dictionaryPath)); - } - - public function testGetReferencesWithConflictNames() - { - $this->_processor->getReferences([$this->_testDir . 'layoutInvalid.xml']); - $this->_processor->writeToFile(); - $expected = << - - - - - - - - - - -EOF; - $this->assertEquals($expected, file_get_contents($this->_dictionaryPath)); - } - - public function testUpdateReferences() - { - $testFile = $this->_varDir . 'layoutValid.xml'; - copy($this->_testDir . 'layoutValid.xml', $testFile); - - $layouts = [$testFile]; - $this->_processor->getReferences($layouts); - $this->_processor->writeToFile(); - $expected = << - - - - - - - - - -EOF; - $this->assertEquals($expected, file_get_contents($this->_dictionaryPath)); - - $this->_processor->updateReferences($layouts); - $this->assertFileEquals($this->_testDir . 'layoutValidExpectUpdated.xml', $testFile); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutInvalid.xml b/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutInvalid.xml deleted file mode 100644 index cae977ec34240..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutInvalid.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutValid.xml b/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutValid.xml deleted file mode 100644 index f1923bea6beff..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutValid.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutValidExpectUpdated.xml b/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutValidExpectUpdated.xml deleted file mode 100644 index 7c6f0bf2e48ea..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Layout/Reference/_files/layoutValidExpectUpdated.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/HeaderTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/HeaderTest.php deleted file mode 100644 index a8cf6c4476c7c..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/HeaderTest.php +++ /dev/null @@ -1,71 +0,0 @@ -context = $objectManager->get('Magento\Framework\App\Http\Context'); - $this->context->setValue(Context::CONTEXT_AUTH, false, false); - - //Setup customer session - $customerIdFromFixture = 1; - $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session'); - /** @var $customerService \Magento\Customer\Api\CustomerRepositoryInterface */ - $customerService = Bootstrap::getObjectManager() - ->create('Magento\Customer\Api\CustomerRepositoryInterface'); - $customerData = $customerService->getById($customerIdFromFixture); - $customerSession->setCustomerDataObject($customerData); - - //Create block and inject customer session - $this->block = $objectManager->create( - 'Magento\Theme\Block\Html\Header', - ['customerSession' => $customerSession] - ); - } - - /** - * Test default welcome message when customer is not logged in - */ - public function testGetWelcomeDefault() - { - $this->assertEquals('Default welcome msg!', $this->block->getWelcome()); - } - - /** - * Test welcome message when customer is logged in - */ - public function testGetWelcomeLoggedIn() - { - $this->context->setValue(Context::CONTEXT_AUTH, true, false); - $this->assertEquals('Welcome, John Smith!', $this->block->getWelcome()); - } -} 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 65c7948cd5a8b..72df2422c7b55 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 @@ -21,8 +21,8 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller */ public function testInvalidateSingleToken() { - /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ - $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + /** @var \Magento\Integration\Api\AdminTokenServiceInterface $tokenService */ + $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Api\AdminTokenServiceInterface'); /** @var \Magento\Integration\Model\Oauth\Token $tokenModel */ $tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); /** @var \Magento\User\Model\User $userModel */ @@ -47,8 +47,8 @@ public function testInvalidateSingleToken() */ public function testInvalidateMultipleTokens() { - /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ - $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + /** @var \Magento\Integration\Api\AdminTokenServiceInterface $tokenService */ + $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Api\AdminTokenServiceInterface'); /** @var \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory $tokenModelCollectionFactory */ $tokenModelCollectionFactory = Bootstrap::getObjectManager()->get( diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php index f7de99380e842..f6fa885742220 100644 --- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php @@ -245,6 +245,6 @@ public function testValidateActionError() $body = $this->getResponse()->getBody(); $this->assertContains('{"error":1,"html_message":', $body); - $this->assertContains('Please correct this email address: \"example@domain.cim\"', $body); + $this->assertContains("'domain.cim' is not a valid hostname for email address 'example@domain.cim'", $body); } } diff --git a/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php b/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php index 8b1d329150edc..c423caff57b1e 100644 --- a/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php +++ b/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php @@ -36,7 +36,7 @@ protected function setUp() $attribute->expects($this->any())->method('getAttributeCodesByFrontendType')->will( $this->returnValue(['price']) ); - $attributeFactory = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', [], [], '', false); + $attributeFactory = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', ['create'], [], '', false); $attributeFactory->expects($this->any())->method('create')->will($this->returnValue($attribute)); $this->_model = $objectManager->create( 'Magento\Weee\Model\Tax', diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractBlockTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractBlockTest.php index 17d6ab73271c2..8b440b8527acd 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractBlockTest.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Block/AbstractBlockTest.php @@ -20,7 +20,6 @@ protected function setUp() [ $objectManager->get('Magento\Catalog\Block\Product\Context'), $objectManager->get('Magento\Framework\App\Http\Context'), - $objectManager->get('Magento\Catalog\Api\ProductRepositoryInterface'), ] ); } diff --git a/dev/tests/js/jasmine/assets/apply/templates/node.html b/dev/tests/js/jasmine/assets/apply/templates/node.html index f694083783e00..3c6895d98c381 100644 --- a/dev/tests/js/jasmine/assets/apply/templates/node.html +++ b/dev/tests/js/jasmine/assets/apply/templates/node.html @@ -5,6 +5,6 @@ */ -->
      -
      +
      ='<%= JSON.stringify(nodeData) %>'>
      \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js new file mode 100644 index 0000000000000..2931003459f9d --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js @@ -0,0 +1,106 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Ui/js/grid/controls/bookmarks/bookmarks' +], function (Bookmarks) { + 'use strict'; + describe('ui/js/grid/controls/bookmarks/bookmarks', function () { + var BookmarksElement, returnContextOfItself; + beforeEach(function () { + BookmarksElement = Bookmarks(); + }); + it('has initObservable method', function () { + returnContextOfItself = BookmarksElement.initObservable(); + expect(BookmarksElement.initObservable).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has initStorage method', function () { + BookmarksElement.initStorage(); + expect(BookmarksElement.initStorage).toHaveBeenCalled(); + }); + it('has initElement method', function () { + BookmarksElement.initElement(); + expect(BookmarksElement.initElement).toHaveBeenCalled(); + }); + it('has initViews method', function () { + returnContextOfItself = BookmarksElement.initViews(); + expect(BookmarksElement.initViews).toHaveBeenCalled(); + expect(BookmarksElement.activeIndex).toBe(''); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has createView method', function () { + returnContextOfItself = BookmarksElement.createView(); + expect(BookmarksElement.createView).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has createNewView method', function () { + returnContextOfItself = BookmarksElement.createNewView(); + expect(BookmarksElement.createNewView).toHaveBeenCalled(); + expect(BookmarksElement.createView).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has removeView method', function () { + returnContextOfItself = BookmarksElement.removeView(); + expect(BookmarksElement.removeView).toHaveBeenCalled(); + expect(BookmarksElement.removeStored).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has saveView method', function () { + returnContextOfItself = BookmarksElement.saveView(); + expect(BookmarksElement.saveView).toHaveBeenCalled(); + expect(BookmarksElement.hasChanges).toHaveBeenCalled(); + expect(BookmarksElement.store).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has saveCurrent method', function () { + returnContextOfItself = BookmarksElement.saveCurrent(); + expect(BookmarksElement.saveCurrent).toHaveBeenCalled(); + expect(BookmarksElement.store).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has checkChanges method', function () { + returnContextOfItself = BookmarksElement.checkChanges(); + expect(BookmarksElement.checkChanges).toHaveBeenCalled(); + expect(BookmarksElement.activeView).toHaveBeenCalled(); + expect(BookmarksElement.hasChanges).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(BookmarksElement); + }); + it('has getSaved method', function () { + returnContextOfItself = BookmarksElement.saveCurrent(); + expect(BookmarksElement.getSaved).toHaveBeenCalled(); + expect(BookmarksElement.activeView).toHaveBeenCalled(); + expect(BookmarksElement.getSaved).toHaveBeenCalled(); + }); + it('has getDefault method', function () { + BookmarksElement.getDefault(); + expect(BookmarksElement.getDefault).toHaveBeenCalled(); + }); + it('has defaultPolyfill method', function () { + BookmarksElement.saveCurrent(); + expect(BookmarksElement.defaultPolyfill).toHaveBeenCalled(); + expect(BookmarksElement.activeView).toHaveBeenCalled(); + expect(BookmarksElement.checkChanges).toHaveBeenCalled(); + }); + it('has onActiveChange method', function () { + BookmarksElement.saveCurrent(); + expect(BookmarksElement.onActiveChange).toHaveBeenCalled(); + expect(BookmarksElement.store).toHaveBeenCalled(); + expect(BookmarksElement.activeView).toHaveBeenCalled(); + expect(BookmarksElement.hasChanges).toHaveBeenCalled(); + expect(BookmarksElement.initialSet).toBeFalsy(); + }); + it('has onDataChange method', function () { + BookmarksElement.onDataChange(); + expect(BookmarksElement.onDataChange).toHaveBeenCalled(); + expect(BookmarksElement.saveCurrent).toHaveBeenCalled(); + expect(BookmarksElement.activeView).toHaveBeenCalled(); + }); + it('has onEditingChange method', function () { + BookmarksElement.onEditingChange(); + expect(BookmarksElement.onEditingChange).toHaveBeenCalled(); + }); + }); +}); \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js new file mode 100644 index 0000000000000..1fae8832c2d0b --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js @@ -0,0 +1,44 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Ui/js/grid/controls/bookmarks/storage', + 'Magento_Ui/js/lib/storage' +], function (bookmarkStorage,storage) { + 'use strict'; + + describe('ui/js/grid/controls/bookmarks/storage', function () { + + it('has getter method', function () { + spyOn(storage, 'get'); + bookmarkStorage.get(); + expect(storage.get).toHaveBeenCalled(); + bookmarkStorage.get(1, 2, 3); + expect(storage.get).toHaveBeenCalledWith(1, 2, 3); + bookmarkStorage.get('string'); + expect(storage.get).toHaveBeenCalledWith('string'); + }); + + it('has setter method', function () { + spyOn(storage, 'set'); + bookmarkStorage.set(); + expect(storage.set).toHaveBeenCalled(); + bookmarkStorage.set(1,2); + expect(storage.set).toHaveBeenCalledWith(1,2); + bookmarkStorage.set('path', 'value'); + expect(storage.set).toHaveBeenCalledWith('path', 'value'); + }); + it('has remove method', function () { + spyOn(storage, 'remove'); + bookmarkStorage.remove(); + expect(storage.remove).toHaveBeenCalled(); + bookmarkStorage.remove(1,2); + expect(storage.remove).toHaveBeenCalledWith(1,2); + bookmarkStorage.remove('path'); + expect(storage.remove).toHaveBeenCalledWith('path'); + }); + + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js new file mode 100644 index 0000000000000..f5a590046a723 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js @@ -0,0 +1,67 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Ui/js/grid/controls/bookmarks/view' +], function (BookmarkView) { + 'use strict'; + describe('ui/js/grid/controls/bookmarks/view', function () { + var view, returnContextOfItself; + beforeEach(function(){ + view = BookmarkView(); + }); + it('has initObservable method', function () { + returnContextOfItself = view.initObservable(); + expect(view.initObservable).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(view); + }); + it('has getSaved method', function () { + view.getSaved(); + expect(view.getSaved).toHaveBeenCalled(); + }); + it('has getData method', function () { + view.getData(); + expect(view.getData).toHaveBeenCalled(); + }); + it('has setData method', function () { + returnContextOfItself = view.setData(); + expect(view.setData).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(view); + }); + it('has setLabel method', function () { + returnContextOfItself = view.setLabel(); + expect(view.setLabel).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(view); + }); + it('has startEdit method', function () { + returnContextOfItself = view.startEdit(); + expect(view.startEdit).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(view); + }); + it('has endEdit method', function () { + returnContextOfItself = view.endEdit(); + expect(view.endEdit).toHaveBeenCalled(); + expect(returnContextOfItself).toBe(view); + }); + it('has save method', function () { + view.save(); + expect(view.save).toHaveBeenCalled(); + expect(view.isNew).toBeFalsy(); + }); + it('has checkChanges method', function () { + view.checkChanges(); + expect(view.checkChanges).toHaveBeenCalled(); + expect(view.changed).toHaveBeenCalled(); + }); + it('has onActivate method', function () { + view.onActivate(); + expect(view.onActivate).toHaveBeenCalled(); + }); + it('has onActiveChange method', function () { + view.onActiveChange(); + expect(view.onActiveChange).toHaveBeenCalled(); + }); + }) +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js new file mode 100644 index 0000000000000..790bb022cf6dd --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js @@ -0,0 +1,176 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore', + 'Magento_Ui/js/grid/filters/filters' +], function (_, Filters) { + 'use strict'; + + describe('ui/js/grid/filters/filters', function () { + var filters; + + beforeEach(function () { + filters = new Filters({ + elems: [], + index: 'index', + name: 'name', + indexField: 'id', + dataScope: 'scope', + provider: 'provider' + }); + }); + + it('Default state - Select no fields.', function () { + expect(filters.elems()).toEqual([]); + filters.elems.push({id:1}); + filters.elems.push({id:1}); + expect(filters.elems()).not.toEqual([]); + }); + it('Checks if specified filter is active.', function () { + var filter = {id: 1}; + + expect(filters.isFilterActive(filter)).toBe(false); + filters.active().push(filter); + expect(filters.isFilterActive(filter)).toBe(true); + }); + it('Tells whether specified filter should be visible.', function () { + var filter = { + visible: function () { + return false; + } + }; + + expect(filters.isFilterVisible(filter)).toBe(false); + filters.active().push(filter); + expect(filters.isFilterActive(filter)).toBe(true); + filter.visible = function() { + return true; + }; + expect(filters.isFilterActive(filter)).toBe(true); + filters.active().pop(); + expect(filters.isFilterActive(filter)).toBe(false); + }); + it('Checks if collection has visible filters.', function () { + var filter = { + visible: function () { + return false; + } + }; + + filters.elems.push(filter); + expect(filters.hasVisible()).toBe(false); + filter.visible = function() { + return true; + }; + filters.elems.push(filter); + expect(filters.hasVisible()).toBe(true); + filters.elems.removeAll(); + expect(filters.hasVisible()).toBe(false); + filters.active().push(filter); + expect(filters.hasVisible()).toBe(false); + }); + it('Tells whether filters panel should be opened.', function () { + var filter = { + visible: function () { + return false; + } + }; + + filters.opened(false); + filters.elems.push(filter); + expect(filters.isOpened()).toBe(false); + filter.visible = function() { + return true; + }; + filters.elems.push(filter); + filters.opened(true); + expect(filters.isOpened()).toBe(true); + filters.elems.removeAll(); + expect(filters.isOpened()).toBe(false); + filters.active().push(filter); + expect(filters.isOpened()).toBe(false); + }); + it('Resets filters to the last applied state.', function () { + filters.applied = {}; + filters.filters = {}; + filters.cancel(); + expect(filters.filters).toEqual(filters.filters); + filters.filters = {id:1}; + filters.cancel(); + expect(filters.filters).toEqual({}); + filters.applied = {id:1}; + filters.cancel(); + expect(filters.filters).toEqual(filters.applied); + }); + it('Sets filters data to the applied state.', function () { + filters.applied = {}; + filters.filters = {}; + filters.apply(); + expect(filters.applied).toEqual({}); + filters.filters = {}; + filters.applied = {id:2}; + filters.apply(); + expect(filters.applied).toEqual({}); + filters.filters = {id:1}; + filters.applied = {}; + filters.apply(); + expect(filters.applied).toEqual({id:1}); + filters.filters = {id:1}; + filters.applied = {id:2}; + filters.apply(); + expect(filters.applied).toEqual({id:1}); + }); + it('Clears filters data.', function () { + var elem = { + value: '', + clear: function() { + this.value = ''; + return this.value; + } + }; + + filters.active.push(elem); + filters.applied = {}; + filters.filters = {}; + filters.clear(); + expect(filters.active.first().value).toEqual(''); + filters.active.first().value = 1; + filters.clear(); + expect(filters.active.first().value).toEqual(''); + }); + it('Set active elements where exist value from elems.', function () { + var elem = { + hasData: function() { + return false; + } + }; + + filters.elems.push(elem); + filters.extractActive(); + expect(filters.active().length).toEqual(0); + elem.hasData = function() { + return true; + }; + filters.elems.removeAll(); + filters.elems().push(elem); + filters.extractActive(); + expect(filters.active().length).toEqual(1); + }); + it('Set previews from argument elements.', function () { + var elem = { + getPreview: function() { + return true; + } + }; + + filters.extractPreviews(filters.elems); + expect(filters.previews().length).toEqual(0); + filters.elems.push(elem); + filters.extractPreviews(filters.elems); + expect(filters.previews().length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js new file mode 100644 index 0000000000000..59e46e213d7c7 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js @@ -0,0 +1,78 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore', + 'Magento_Ui/js/grid/filters/group' +], function (_, Group) { + 'use strict'; + + describe('ui/js/grid/filters/filters', function () { + var group; + + beforeEach(function () { + group = new Group({ + elems: [], + index: 'index', + name: 'name', + indexField: 'id', + dataScope: 'scope', + provider: 'provider' + }); + }); + + it('Default state - Select no fields.', function () { + expect(group.elems()).toEqual([]); + group.elems.push({id:1}, {id:1}); + expect(group.elems()).not.toEqual([]); + }); + it('Check for reset elements.', function () { + var elem = { + value: false, + reset: function() { + this.value = true; + } + }; + + group.elems.push(elem); + expect(group.reset()).toBe(group); + expect(group.elems.first().value).toBe(true); + }); + it('Check for clear elements.', function () { + var elem = { + value: 'text', + clear: function() { + this.value = ''; + } + }; + + group.elems.push(elem); + expect(group.clear()).toBe(group); + expect(group.elems.first().value).toEqual(''); + }); + it('Check if some elements has data.', function () { + var elem = { + hasData: function() { + return true; + } + }; + + expect(group.hasData()).toBe(false); + group.elems.push(elem); + expect(group.hasData()).toBe(true); + }); + it('Get preview from child elements.', function () { + var elem = { + getPreview: function() { + return true; + } + }; + + expect(group.getPreview()).toEqual([]); + group.elems.push(elem, elem); + expect(group.getPreview()).toEqual([true, true]); + }); + }); +}); diff --git a/dev/tests/performance/benchmark.jmx b/dev/tests/performance/benchmark.jmx index 9ebd36053e18e..77934c61897c5 100644 --- a/dev/tests/performance/benchmark.jmx +++ b/dev/tests/performance/benchmark.jmx @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + @@ -53,14 +53,14 @@ ${__P(admin_path,backend)} = - - admin_user - ${__P(admin_user,admin)} + + admin-user + ${__P(admin-user,admin)} = - - admin_password - ${__P(admin_password,123123q)} + + admin-password + ${__P(admin-password,123123q)} = @@ -259,14 +259,14 @@ true - ${admin_password} + ${admin-password} = true login[password] true - ${admin_user} + ${admin-user} = true login[username] @@ -539,6 +539,26 @@ false + + + + + + + + + + + + ${base_path}customer/section/load/?sections=messages,cart + GET + true + false + true + false + false + + @@ -551,24 +571,21 @@ - <div>* This product is out of stock.</div> + This product is out of stock. Assertion.response_data false 6 - - false - //*[@class='counter-number']/text()=1 - false - false - true - false - true - true - Make sure that minicart was refreshed - + + + "summary_count":1 + + Assertion.response_data + false + 2 + @@ -685,6 +702,26 @@ false + + + + + + + + + + + + ${base_path}customer/section/load/?sections=messages,cart + GET + true + false + true + false + false + + @@ -697,24 +734,21 @@ - <div>* We don't have as many &quot;${configurable_product_name}&quot; as you requested.</div> + We don't have as many &quot;${configurable_product_name}&quot; as you requested. Assertion.response_data false 6 - - false - //*[@class='counter-number']/text()=2 - false - false - true - false - true - true - Make sure that minicart was refreshed - + + + "summary_count":2 + + Assertion.response_data + false + 2 + @@ -833,169 +867,24 @@ - - false - //div[span='1'][h2='Billing Information'] - false - false - true - false - true - true - + + false + cart_id + "quoteData":{"entity_id":"([^'"]+)", + $1$ + + 1 + - - - ${sleep_between_steps} - - - - - - - true - - = - true - billing[address_id] - - - true - Fayetteville - = - true - billing[city] - - - true - - = - true - billing[company] - - - true - US - = - true - billing[country_id] - - - true - - = - true - billing[fax] - - - true - Anthony - = - true - billing[firstname] - - - true - Nealy - = - true - billing[lastname] - - - true - 123123 - = - true - billing[postcode] - - - true - Arkansas - = - true - billing[region] - - - true - 5 - = - true - billing[region_id] - - - true - 123 Freedom Blvd. #123 - = - true - billing[street][] - - - true - - = - true - billing[street][] - - - true - 022-333-4455 - = - true - billing[telephone] - - - true - 1 - = - true - billing[use_for_shipping] - - - true - 0 - = - true - billing[save_in_address_book] - - - true - 1 - = - true - ajax - - - true - 1 - = - true - isAjax - - - - - - - - - - ${base_path}checkout/onepage/saveBilling/ - POST - true - false - true - false - false - - - - + - "goto_section":"shipping + ^.+$ Assertion.response_data false - 2 + 1 + variable + cart_id @@ -1003,43 +892,20 @@ ${sleep_between_steps} - - + + true + - - true - quote_item - = - true - giftoptions[1496][type] - - - true - quote - = - true - giftoptions[451][type] - - - true - shipping_method - flatrate_flatrate - = - true - - - true - 1 - = - true - ajax - - - true - 1 + + false + {"shippingAddress":{"company":"","fax":"","city":"Culver City","firstname":"Name","lastname":"Lastname" +,"street":{"0":"10441 Jefferson Blvd, ste 200","1":""},"telephone":"1-310-945-0345","postcode":"90232" +,"region_id":"12","country_id":"US","region":"","save_in_address_book":"1","email":"test@example.com" +,"same_as_billing":1},"billingAddress":{"company":"","fax":"","city":"Culver City","firstname":"Name" +,"lastname":"Lastname","street":{"0":"10441 Jefferson Blvd, ste 200","1":""},"telephone":"1-310-945-0345" +,"postcode":"90232","region_id":"12","country_id":"US","region":"","save_in_address_book":"1","email" +:"test@example.com","same_as_billing":1},"additionalData":{"extensionAttributes":{}}} = - true - isAjax @@ -1047,9 +913,9 @@ - - - ${base_path}checkout/onepage/saveShippingMethod/ + http + UTF-8 + ${base_path}rest/default/V1/carts/mine/addresses POST true false @@ -1059,9 +925,30 @@ - + + + + Referer + http://mage2.com/checkout/onepage/ + + + Content-Type + application/json; charset=UTF-8 + + + X-Requested-With + XMLHttpRequest + + + Accept + application/json + + + + + - "goto_section":"payment" + {"shipping_methods": Assertion.response_data false @@ -1073,36 +960,16 @@ ${sleep_between_steps} - - + + true + - - true - payment[method] - checkmo - = - true - - - true - ${form_key} - = - true - form_key - - - true - 1 - = - true - ajax - - - true - 1 + + false + {"cartId":"${cart_id}","paymentMethod":{"method":"checkmo","po_number":null,"cc_owner" +:null,"cc_number":null,"cc_type":null,"cc_exp_year":null,"cc_exp_month":null,"additional_data":null} +,"shippingCarrierCode":"flatrate","shippingMethodCode":"flatrate"} = - true - isAjax @@ -1110,10 +977,10 @@ - - - ${base_path}checkout/onepage/savePayment/ - POST + http + UTF-8 + ${base_path}rest/default/V1/carts/mine/collect-totals + PUT true false true @@ -1122,9 +989,30 @@ + + + + Referer + http://mage2.com/checkout/onepage/ + + + Content-Type + application/json; charset=UTF-8 + + + Accept + application/json + + + X-Requested-With + XMLHttpRequest + + + + - "goto_section":"review" + {"grand_total": Assertion.response_data false @@ -1137,36 +1025,13 @@ - + true + - - true - payment[method] - checkmo - = - true - - - true - ${form_key} - = - true - form_key - false - - - true - 1 - = - true - ajax - - - true - 1 + + false + = - true - isAjax @@ -1174,10 +1039,10 @@ - - - ${base_path}checkout/onepage/saveOrder/ - POST + http + UTF-8 + ${base_path}rest/default/V1/carts/mine/order + PUT true false true @@ -1186,13 +1051,34 @@ + + + + Referer + http://mage2.com/checkout/onepage/ + + + Content-Type + application/json; charset=UTF-8 + + + Accept + application/json + + + X-Requested-With + XMLHttpRequest + + + + - {"success":true,"error":false} + ^"\d+"$ Assertion.response_data false - 2 + 1 diff --git a/dev/tests/performance/config.php.dist b/dev/tests/performance/config.php.dist index e145b9768ffe2..38d6e0430601f 100644 --- a/dev/tests/performance/config.php.dist +++ b/dev/tests/performance/config.php.dist @@ -13,23 +13,23 @@ return array( 'language' => 'en_US', 'timezone' => 'America/Los_Angeles', 'currency' => 'USD', - 'db_host' => 'localhost', - 'db_name' => 'magento', - 'db_user' => 'root', - 'db_password' => '', - 'use_secure' => '0', - 'use_secure_admin' => '0', - 'use_rewrites' => '0', - 'admin_lastname' => 'Admin', - 'admin_firstname' => 'Admin', - 'admin_email' => 'admin@example.com', - 'admin_user' => 'admin', - 'admin_password' => '123123q', - 'admin_use_security_key' => '0', - 'backend_frontname' => 'backend', + 'db-host' => 'localhost', + 'db-name' => 'magento', + 'db-user' => 'root', + 'db-password' => '', + 'use-secure' => '0', + 'use-secure-admin' => '0', + 'use-rewrites' => '0', + 'admin-lastname' => 'Admin', + 'admin-firstname' => 'Admin', + 'admin-email' => 'admin@example.com', + 'admin-user' => 'admin', + 'admin-password' => '123123q', + 'admin-use-security-key' => '0', + 'backend-frontname' => 'backend', ), 'options_no_value' => array( - 'cleanup_database', + 'cleanup-database', ), ), ), diff --git a/dev/tests/performance/framework/Magento/TestFramework/Application.php b/dev/tests/performance/framework/Magento/TestFramework/Application.php index bd192386c9d74..031ad7194e98a 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Application.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Application.php @@ -156,7 +156,7 @@ protected function _install() // Populate install options with global options $baseUrl = 'http://' . $this->_config->getApplicationUrlHost() . $this->_config->getApplicationUrlPath(); - $installOptions = array_merge($installOptions, ['base_url' => $baseUrl, 'base_url_secure' => $baseUrl]); + $installOptions = array_merge($installOptions, ['base-url' => $baseUrl, 'base-url-secure' => $baseUrl]); $installCmd = 'php -f %s setup:install'; $installCmdArgs = [$this->_script]; foreach ($installOptions as $optionName => $optionValue) { diff --git a/dev/tests/performance/framework/Magento/TestFramework/Performance/Config.php b/dev/tests/performance/framework/Magento/TestFramework/Performance/Config.php index bd01b881c6bb9..65287f5656bac 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Performance/Config.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Performance/Config.php @@ -117,7 +117,7 @@ protected function _validateData(array $configData) } // Validate admin options data - $requiredAdminKeys = ['admin_user', 'admin_password', 'backend_frontname']; + $requiredAdminKeys = ['admin-user', 'admin-password', 'backend-frontname']; foreach ($requiredAdminKeys as $requiredKeyName) { if (empty($configData['application']['installation']['options'][$requiredKeyName])) { throw new \Magento\Framework\Exception\LocalizedException( @@ -277,9 +277,9 @@ protected function _getFixedScenarioArguments() \Magento\TestFramework\Performance\Scenario::ARG_HOST => $this->getApplicationUrlHost(), \Magento\TestFramework\Performance\Scenario::ARG_PATH => $this->getApplicationUrlPath(), \Magento\TestFramework\Performance\Scenario::ARG_BASEDIR => $this->getApplicationBaseDir(), - \Magento\TestFramework\Performance\Scenario::ARG_BACKEND_FRONTNAME => $options['backend_frontname'], - \Magento\TestFramework\Performance\Scenario::ARG_ADMIN_USER => $options['admin_user'], - \Magento\TestFramework\Performance\Scenario::ARG_ADMIN_PASSWORD => $options['admin_password'], + \Magento\TestFramework\Performance\Scenario::ARG_BACKEND_FRONTNAME => $options['backend-frontname'], + \Magento\TestFramework\Performance\Scenario::ARG_ADMIN_USER => $options['admin-user'], + \Magento\TestFramework\Performance\Scenario::ARG_ADMIN_PASSWORD => $options['admin-password'], 'jmeter.save.saveservice.output_format' => 'xml', ]; } diff --git a/dev/tests/performance/framework/Magento/TestFramework/Performance/Scenario.php b/dev/tests/performance/framework/Magento/TestFramework/Performance/Scenario.php index ab19c64f5aebe..0cdbfe20936fd 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Performance/Scenario.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Performance/Scenario.php @@ -24,11 +24,11 @@ class Scenario const ARG_BASEDIR = 'basedir'; - const ARG_ADMIN_USER = 'admin_user'; + const ARG_ADMIN_USER = 'admin-user'; - const ARG_ADMIN_PASSWORD = 'admin_password'; + const ARG_ADMIN_PASSWORD = 'admin-password'; - const ARG_BACKEND_FRONTNAME = 'backend_frontname'; + const ARG_BACKEND_FRONTNAME = 'backend-frontname'; /**#@-*/ diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/ConfigTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/ConfigTest.php index 39685b5889412..50794f66c1cee 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/ConfigTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/ConfigTest.php @@ -144,9 +144,9 @@ public function testGetInstallOptions() $expectedOptions = [ 'option1' => 'value 1', 'option2' => 'value 2', - 'backend_frontname' => 'backend', - 'admin_user' => 'admin', - 'admin_password' => 'password1', + 'backend-frontname' => 'backend', + 'admin-user' => 'admin', + 'admin-password' => 'password1', ]; $this->assertEquals($expectedOptions, $this->_object->getInstallOptions()); } diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_dist/config.php.dist b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_dist/config.php.dist index 6db1c505bff49..239c3a60bec11 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_dist/config.php.dist +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_dist/config.php.dist @@ -10,9 +10,9 @@ return array( 'url_path' => '/', 'installation' => array( 'options' => array( - 'backend_frontname' => 'backend', - 'admin_user' => 'admin', - 'admin_password' => 'password1', + 'backend-frontname' => 'backend', + 'admin-user' => 'admin', + 'admin-password' => 'password1', ), ), ), diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php index 463b896d34d68..07a1a86c76dec 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php @@ -10,9 +10,9 @@ 'url_path' => '/', 'installation' => [ 'options' => [ - 'backend_frontname' => 'backend', - 'admin_user' => 'admin', - 'admin_password' => 'password1', + 'backend-frontname' => 'backend', + 'admin-user' => 'admin', + 'admin-password' => 'password1', ], ], ], diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php.dist b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php.dist index 577aadcc45bac..a1b5c16c55297 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php.dist +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/bootstrap/config_normal/config.php.dist @@ -10,9 +10,9 @@ return array( 'url_path' => '/', 'installation' => array( 'options' => array( - 'backend_frontname' => 'backend', - 'admin_user' => 'admin', - 'admin_password' => 'password1', + 'backend-frontname' => 'backend', + 'admin-user' => 'admin', + 'admin-password' => 'password1', ), ), ), diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/config_data.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/config_data.php index eaa852c5e31a6..f74eb069d8eac 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/config_data.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/config_data.php @@ -12,9 +12,9 @@ 'options' => [ 'option1' => 'value 1', 'option2' => 'value 2', - 'backend_frontname' => 'backend', - 'admin_user' => 'admin', - 'admin_password' => 'password1', + 'backend-frontname' => 'backend', + 'admin-user' => 'admin', + 'admin-password' => 'password1', ], ], ], diff --git a/dev/tests/performance/testsuite/backend.jmx b/dev/tests/performance/testsuite/backend.jmx index 7108005cdfa54..e3e9dd82a55d3 100644 --- a/dev/tests/performance/testsuite/backend.jmx +++ b/dev/tests/performance/testsuite/backend.jmx @@ -20,17 +20,17 @@ ADMIN_PATH - ${__P(path,/)}${__P(backend_frontname,backend)}/ + ${__P(path,/)}${__P(backend-frontname,backend)}/ = ADMIN_USER - ${__P(admin_user,admin)} + ${__P(admin-user,admin)} = ADMIN_PASSWORD - ${__P(admin_password,123123q)} + ${__P(admin-password,123123q)} = diff --git a/dev/tests/performance/testsuite/checkout.jmx b/dev/tests/performance/testsuite/checkout.jmx index aa9c58a401a7a..6306e47f71ab4 100644 --- a/dev/tests/performance/testsuite/checkout.jmx +++ b/dev/tests/performance/testsuite/checkout.jmx @@ -40,17 +40,17 @@ ADMIN_PATH - ${__P(path,/)}${__P(backend_frontname,backend)}/ + ${__P(path,/)}${__P(backend-frontname,backend)}/ = ADMIN_USER - ${__P(admin_user,admin)} + ${__P(admin-user,admin)} = ADMIN_PASSWORD - ${__P(admin_password,123123q)} + ${__P(admin-password,123123q)} = diff --git a/dev/tests/performance/testsuite/product_edit.jmx b/dev/tests/performance/testsuite/product_edit.jmx index 384381cac015b..c4b2ced13478c 100644 --- a/dev/tests/performance/testsuite/product_edit.jmx +++ b/dev/tests/performance/testsuite/product_edit.jmx @@ -20,7 +20,7 @@ ADMIN_PATH - ${__P(path,/)}${__P(backend_frontname,backend)}/ + ${__P(path,/)}${__P(backend-frontname,backend)}/ = @@ -35,12 +35,12 @@ ADMIN_USER - ${__P(admin_user,admin)} + ${__P(admin-user,admin)} = ADMIN_PASSWORD - ${__P(admin_password,123123q)} + ${__P(admin-password,123123q)} = diff --git a/dev/tests/performance/testsuite/reusable/admin_login.jmx b/dev/tests/performance/testsuite/reusable/admin_login.jmx index 57f291edb6a81..9d6eb8fb2cb2e 100644 --- a/dev/tests/performance/testsuite/reusable/admin_login.jmx +++ b/dev/tests/performance/testsuite/reusable/admin_login.jmx @@ -155,17 +155,17 @@ ADMIN_PATH - ${__P(path,/)}${__P(backend_frontname,backend)}/ + ${__P(path,/)}${__P(backend-frontname,backend)}/ = ADMIN_USER - ${__P(admin_user,admin)} + ${__P(admin-user,admin)} = ADMIN_PASSWORD - ${__P(admin_password,123123q)} + ${__P(admin-password,123123q)} = diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php index 579fb058e01af..25c4330d93bb1 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php @@ -8,7 +8,7 @@ namespace Magento\Test\Integrity; use Magento\Framework\App\Utility\Files; -use Magento\Tools\Dependency\Circular; +use Magento\Setup\Module\Dependency\Circular; class CircularDependencyTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt index f2da646093c8b..0c24996b5c4c3 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Library/_files/blacklist.txt @@ -78,3 +78,5 @@ lib/internal/Magento/Framework/Url/SecurityInfo.php lib/internal/Magento/Framework/Url/RouteParamsResolver.php lib/internal/Magento/Framework/View/Url/Config.php lib/internal/Magento/Framework/View/Asset/Config.php + +lib/internal/Magento/Framework/Locale/Format.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt index 564d756255d7e..3166dba750ba6 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt @@ -37,4 +37,5 @@ lib/internal/Magento/Framework/App/Utility lib/internal/Magento/Framework/Url lib/internal/Magento/Framework/UrlInterface lib/internal/Magento/Framework/Xml +lib/internal/Magento/Framework/XsltProcessor lib/internal/Magento/Framework diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index f15f6f424a7c8..bddf077931048 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -86,9 +86,11 @@ lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsR lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForArgumentSequence.php lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForTypeDuplication.php dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php -dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php -dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/Model.php -dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php +dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php +dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Model/Model.php +dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php +dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/A/Model/Foo.php +dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code/Magento/B/Model/Foo.php dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceFactory.php dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceInterceptor.php dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 1310a906961d1..9f59d0c66a3c6 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -68,4 +68,6 @@ Model3 \Magento\Mtf\Util\Generate\GenerateResult \Magento\Mtf\Util\Generate\Repository\Resource \Magento\Mtf\Client\Element -\Magento\Mtf\TestSuite\AppState \ No newline at end of file +\Magento\Mtf\TestSuite\AppState +\Magento\Framework\A +\Magento\Framework\B \ No newline at end of file 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 old mode 100755 new mode 100644 index 59cf16d245655..cfa0609a65846 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -37,12 +37,16 @@ ['Mage_Admin_Model_Resource_Rules_Collection', 'Magento\Authorization\Model\Resource\Rules\Collection'], [ 'Mage_Admin_Model_Resource_Permissions_Collection', - 'Magento\Authorization\Model\Resource\Permissions\Collection' + 'Magento\Authorization\Model\Resource\Permissions\Collection', ], ['Mage_Adminhtml_Block_Abstract', 'Magento\Backend\Block\AbstractBlock'], ['Mage_Adminhtml_Block_Backup_Grid'], ['Mage_Adminhtml_Block_Cache_Grid'], ['Mage_Adminhtml_Block_Catalog'], + [ + 'Magento\Catalog\Model\Resource\Category\Attribute\Source\Mode', + 'Magento\Catalog\Model\Category\Attribute\Source\Mode', + ], ['Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Grid'], ['Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid'], ['Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group_Grid'], @@ -103,11 +107,11 @@ ['Magento\Sales\Block\Adminhtml\Order\Shipment\Create\Form', 'Magento\Shipping\Block\Adminhtml\Create\Form'], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\Create\Items', - 'Magento\Shipping\Block\Adminhtml\Create\Items' + 'Magento\Shipping\Block\Adminhtml\Create\Items', ], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\View\Comments', - 'Magento\Shipping\Block\Adminhtml\View\Comments' + 'Magento\Shipping\Block\Adminhtml\View\Comments', ], ['Magento\Sales\Block\Adminhtml\Order\Shipment\View\Form', 'Magento\Shipping\Block\Adminhtml\View\Form'], ['Magento\Sales\Block\Adminhtml\Order\Shipment\View\Items', 'Magento\Shipping\Block\Adminhtml\View\Items'], @@ -126,62 +130,62 @@ ['Mage_Adminhtml_Block_System_Config_Tabs', 'Magento\Config\Block\System\Config\Tabs'], [ 'Mage_Adminhtml_Block_System_Config_System_Storage_Media_Synchronize', - 'Magento\MediaStorage\Block\System\Config\System\Storage\Media\Synchronize' + 'Magento\MediaStorage\Block\System\Config\System\Storage\Media\Synchronize', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Fieldset_Modules_DisableOutput', - 'Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput' + 'Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Regexceptions', - 'Magento\Config\Block\System\Config\Form\Field\Regexceptions' + 'Magento\Config\Block\System\Config\Form\Field\Regexceptions', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Notification', - 'Magento\Config\Block\System\Config\Form\Field\Notification' + 'Magento\Config\Block\System\Config\Form\Field\Notification', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Heading', - 'Magento\Config\Block\System\Config\Form\Field\Heading' + 'Magento\Config\Block\System\Config\Form\Field\Heading', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Datetime', - 'Magento\Config\Block\System\Config\Form\Field\Datetime' + 'Magento\Config\Block\System\Config\Form\Field\Datetime', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract', - 'Magento\Config\Block\System\Config\Form\Field\Array\AbstractArray' + 'Magento\Config\Block\System\Config\Form\Field\Array\AbstractArray', ], ['Mage_Adminhtml_Block_System_Config_Form_Fieldset', 'Magento\Config\Block\System\Config\Form\Fieldset'], ['Mage_Adminhtml_Block_System_Config_Form_Field', 'Magento\Config\Block\System\Config\Form\Field'], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Import', - 'Magento\Config\Block\System\Config\Form\Field\Import' + 'Magento\Config\Block\System\Config\Form\Field\Import', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Image', - 'Magento\Config\Block\System\Config\Form\Field\Image' + 'Magento\Config\Block\System\Config\Form\Field\Image', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Export', - 'Magento\Config\Block\System\Config\Form\Field\Export' + 'Magento\Config\Block\System\Config\Form\Field\Export', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Select_Allowspecific', - 'Magento\Config\Block\System\Config\Form\Field\Select\Allowspecific' + 'Magento\Config\Block\System\Config\Form\Field\Select\Allowspecific', ], ['Mage_Adminhtml_Block_System_Config_Form_Field_File', 'Magento\Config\Block\System\Config\Form\Field\File'], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Select_Flatproduct', - 'Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select\Flatproduct' + 'Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select\Flatproduct', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Field_Select_Flatcatalog', - 'Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select\Flatcatalog' + 'Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select\Flatcatalog', ], [ 'Mage_Adminhtml_Block_System_Config_Form_Fieldset_Order_Statuses', - 'Magento\Sales\Block\Adminhtml\System\Config\Form\Fieldset\Order\Statuses' + 'Magento\Sales\Block\Adminhtml\System\Config\Form\Fieldset\Order\Statuses', ], ['Mage_Adminhtml_Block_System_Config_Dwstree', 'Magento\Config\Block\System\Config\Dwstree'], ['Mage_Adminhtml_Block_System_Config_Switcher', 'Magento\Config\Block\System\Config\Switcher'], @@ -190,35 +194,35 @@ ['Magento\Adminhtml\Block\System\Email\Template\Edit', 'Magento\Email\Block\Adminhtml\Template\Edit'], [ 'Magento\Adminhtml\Block\System\Email\Template\Edit\Form', - 'Magento\Email\Block\Adminhtml\Template\Edit\Form' + 'Magento\Email\Block\Adminhtml\Template\Edit\Form', ], ['Magento\Adminhtml\Block\System\Email\Template\Preview', 'Magento\Email\Block\Adminhtml\Template\Preview'], ['Mage_Adminhtml_Block_System_Email_Template_Grid'], [ 'Magento\Adminhtml\Block\System\Email\Template\Grid\Renderer\Action', - 'Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Action' + 'Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Action', ], [ 'Magento\Adminhtml\Block\System\Email\Template\Grid\Renderer\Sender', - 'Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Sender' + 'Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Sender', ], [ 'Magento\Adminhtml\Block\System\Email\Template\Grid\Renderer\Type', - 'Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Type' + 'Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Type', ], [ 'Magento\Adminhtml\Block\System\Email\Template\Grid\Filter\Type', - 'Magento\Email\Block\Adminhtml\Template\Grid\Filter\Type' + 'Magento\Email\Block\Adminhtml\Template\Grid\Filter\Type', ], ['Mage_Adminhtml_Block_System_Variable_Grid'], ['Mage_Adminhtml_Block_Store_Switcher', 'Magento\Backend\Block\Store\Switcher'], [ 'Mage_Adminhtml_Block_Store_Switcher_Form_Renderer_Fieldset', - 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset' + 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset', ], [ 'Mage_Adminhtml_Block_Store_Switcher_Form_Renderer_Fieldset_Element', - 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' + 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element', ], ['Mage_Adminhtml_Block_Tag_Tag_Edit'], ['Mage_Adminhtml_Block_Tag_Tag_Edit_Form'], @@ -235,131 +239,131 @@ ['Mage_Adminhtml_Model_System_Config_Source_Shipping_Allowedmethods'], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Password_Link_Expirationperiod', - 'Magento\Config\Model\Config\Backend\Admin\Password\Link\Expirationperiod' + 'Magento\Config\Model\Config\Backend\Admin\Password\Link\Expirationperiod', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Custom', - 'Magento\Config\Model\Config\Backend\Admin\Custom' + 'Magento\Config\Model\Config\Backend\Admin\Custom', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Custompath', - 'Magento\Config\Model\Config\Backend\Admin\Custompath' + 'Magento\Config\Model\Config\Backend\Admin\Custompath', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Observer', - 'Magento\Config\Model\Config\Backend\Admin\Observer' + 'Magento\Config\Model\Config\Backend\Admin\Observer', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Robots', - 'Magento\Config\Model\Config\Backend\Admin\Robots' + 'Magento\Config\Model\Config\Backend\Admin\Robots', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Usecustom', - 'Magento\Config\Model\Config\Backend\Admin\Usecustom' + 'Magento\Config\Model\Config\Backend\Admin\Usecustom', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Usecustompath', - 'Magento\Config\Model\Config\Backend\Admin\Custompath' + 'Magento\Config\Model\Config\Backend\Admin\Custompath', ], [ 'Magento\Backend\Model\Config\Backend\Admin\Usecustompath', - 'Magento\Config\Model\Config\Backend\Admin\Custompath' + 'Magento\Config\Model\Config\Backend\Admin\Custompath', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Admin_Usesecretkey', - 'Magento\Config\Model\Config\Backend\Admin\Usesecretkey' + 'Magento\Config\Model\Config\Backend\Admin\Usesecretkey', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Catalog_Inventory_Managestock', - 'Magento\CatalogInventory\Model\Config\Backend\Managestock' + 'Magento\CatalogInventory\Model\Config\Backend\Managestock', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Catalog_Search_Type', - 'Magento\CatalogSearch\Model\Config\Backend\Search\Type' + 'Magento\CatalogSearch\Model\Config\Backend\Search\Type', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Currency_Abstract', - 'Magento\Config\Model\Config\Backend\Currency\AbstractCurrency' + 'Magento\Config\Model\Config\Backend\Currency\AbstractCurrency', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Currency_Allow', - 'Magento\Config\Model\Config\Backend\Currency\Allow' + 'Magento\Config\Model\Config\Backend\Currency\Allow', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Currency_Base', - 'Magento\Config\Model\Config\Backend\Currency\Base' + 'Magento\Config\Model\Config\Backend\Currency\Base', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Currency_Cron', - 'Magento\Config\Model\Config\Backend\Currency\Cron' + 'Magento\Config\Model\Config\Backend\Currency\Cron', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Currency_Default', - 'Magento\Config\Model\Config\Backend\Currency\DefaultCurrency' + 'Magento\Config\Model\Config\Backend\Currency\DefaultCurrency', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Customer_Address_Street', - 'Magento\Customer\Model\Config\Backend\Address\Street' + 'Magento\Customer\Model\Config\Backend\Address\Street', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Customer_Password_Link_Expirationperiod', - 'Magento\Customer\Model\Config\Backend\Password\Link\Expirationperiod' + 'Magento\Customer\Model\Config\Backend\Password\Link\Expirationperiod', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Customer_Show_Address', - 'Magento\Customer\Model\Config\Backend\Show\Address' + 'Magento\Customer\Model\Config\Backend\Show\Address', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Customer_Show_Customer', - 'Magento\Customer\Model\Config\Backend\Show\Customer' + 'Magento\Customer\Model\Config\Backend\Show\Customer', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Design_Exception', - 'Magento\Config\Model\Config\Backend\Design\Exception' + 'Magento\Config\Model\Config\Backend\Design\Exception', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Email_Address', - 'Magento\Config\Model\Config\Backend\Email\Address' + 'Magento\Config\Model\Config\Backend\Email\Address', ], ['Mage_Adminhtml_Model_System_Config_Backend_Email_Logo', 'Magento\Config\Model\Config\Backend\Email\Logo'], [ 'Mage_Adminhtml_Model_System_Config_Backend_Email_Sender', - 'Magento\Config\Model\Config\Backend\Email\Sender' + 'Magento\Config\Model\Config\Backend\Email\Sender', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Image_Adapter', - 'Magento\Config\Model\Config\Backend\Image\Adapter' + 'Magento\Config\Model\Config\Backend\Image\Adapter', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Image_Favicon', - 'Magento\Config\Model\Config\Backend\Image\Favicon' + 'Magento\Config\Model\Config\Backend\Image\Favicon', ], ['Mage_Adminhtml_Model_System_Config_Backend_Image_Pdf', 'Magento\Config\Model\Config\Backend\Image\Pdf'], [ 'Mage_Adminhtml_Model_System_Config_Backend_Locale_Timezone', - 'Magento\Config\Model\Config\Backend\Locale\Timezone' + 'Magento\Config\Model\Config\Backend\Locale\Timezone', ], ['Mage_Adminhtml_Model_System_Config_Backend_Log_Cron', 'Magento\Config\Model\Config\Backend\Log\Cron'], ['Mage_Adminhtml_Model_System_Config_Backend_Price_Scope'], [ 'Mage_Adminhtml_Model_System_Config_Backend_Product_Alert_Cron', - 'Magento\Cron\Model\Config\Backend\Product\Alert' + 'Magento\Cron\Model\Config\Backend\Product\Alert', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Seo_Product', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array', - 'Magento\Config\Model\Config\Backend\Serialized\Array' + 'Magento\Config\Model\Config\Backend\Serialized\Array', ], [ 'Mage_Adminhtml_Model_System_Config_Backend_Shipping_Tablerate', - 'Magento\OfflineShipping\Model\Config\Backend\Tablerate' + 'Magento\OfflineShipping\Model\Config\Backend\Tablerate', ], ['Mage_Adminhtml_Model_System_Config_Backend_Sitemap_Cron', 'Magento\Cron\Model\Config\Backend\Sitemap'], [ 'Mage_Adminhtml_Model_System_Config_Backend_Storage_Media_Database', - 'Magento\MediaStorage\Model\Config\Backend\Storage\Media\Database' + 'Magento\MediaStorage\Model\Config\Backend\Storage\Media\Database', ], ['Mage_Adminhtml_Model_System_Config_Backend_Baseurl', 'Magento\Config\Model\Config\Backend\Baseurl'], ['Mage_Adminhtml_Model_System_Config_Backend_Cache', 'Magento\Config\Model\Config\Backend\Cache'], @@ -378,196 +382,196 @@ ['Mage_Adminhtml_Model_System_Config_Backend_Translate', 'Magento\Config\Model\Config\Backend\Translate'], [ 'Mage_Adminhtml_Model_System_Config_Clone_Media_Image', - 'Magento\Catalog\Model\Config\CatalogClone\Media\Image' + 'Magento\Catalog\Model\Config\CatalogClone\Media\Image', ], ['Mage_Adminhtml_Model_System_Config_Source_Admin_Page', 'Magento\Config\Model\Config\Source\Admin\Page'], [ 'Mage_Adminhtml_Model_System_Config_Source_Catalog_Search_Type', - 'Magento\CatalogSearch\Model\Config\Source\Search\Type' + 'Magento\CatalogSearch\Model\Config\Source\Search\Type', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Catalog_GridPerPage', - 'Magento\Catalog\Model\Config\Source\GridPerPage' + 'Magento\Catalog\Model\Config\Source\GridPerPage', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Catalog_ListMode', - 'Magento\Catalog\Model\Config\Source\ListMode' + 'Magento\Catalog\Model\Config\Source\ListMode', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Catalog_ListPerPage', - 'Magento\Catalog\Model\Config\Source\ListPerPage' + 'Magento\Catalog\Model\Config\Source\ListPerPage', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Catalog_ListSort', - 'Magento\Catalog\Model\Config\Source\ListSort' + 'Magento\Catalog\Model\Config\Source\ListSort', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Catalog_TimeFormat', - 'Magento\Catalog\Model\Config\Source\TimeFormat' + 'Magento\Catalog\Model\Config\Source\TimeFormat', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Cms_Wysiwyg_Enabled', - 'Magento\Cms\Model\Config\Source\Wysiwyg\Enabled' + 'Magento\Cms\Model\Config\Source\Wysiwyg\Enabled', ], ['Mage_Adminhtml_Model_System_Config_Source_Cms_Page', 'Magento\Cms\Model\Config\Source\Page'], [ 'Mage_Adminhtml_Model_System_Config_Source_Country_Full', - 'Magento\Directory\Model\Config\Source\Country\Full' + 'Magento\Directory\Model\Config\Source\Country\Full', ], ['Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency', 'Magento\Cron\Model\Config\Source\Frequency'], [ 'Mage_Adminhtml_Model_System_Config_Source_Currency_Service', - 'Magento\Config\Model\Config\Source\Currency' + 'Magento\Config\Model\Config\Source\Currency', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Customer_Address_Type', - 'Magento\Customer\Model\Config\Source\Address\Type' + 'Magento\Customer\Model\Config\Source\Address\Type', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect', - 'Magento\Customer\Model\Config\Source\Group\Multiselect' + 'Magento\Customer\Model\Config\Source\Group\Multiselect', ], ['Mage_Adminhtml_Model_System_Config_Source_Customer_Group', 'Magento\Customer\Model\Config\Source\Group'], ['Mage_Adminhtml_Model_System_Config_Source_Date_Short', 'Magento\Config\Model\Config\Source\Date\Short'], ['Mage_Adminhtml_Model_System_Config_Source_Design_Package'], [ 'Mage_Adminhtml_Model_System_Config_Source_Design_Robots', - 'Magento\Config\Model\Config\Source\Design\Robots' + 'Magento\Config\Model\Config\Source\Design\Robots', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup', - 'Magento\Config\Model\Config\Source\Dev\Dbautoup' + 'Magento\Config\Model\Config\Source\Dev\Dbautoup', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Email_Identity', - 'Magento\Config\Model\Config\Source\Email\Identity' + 'Magento\Config\Model\Config\Source\Email\Identity', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Email_Method', - 'Magento\Config\Model\Config\Source\Email\Method' + 'Magento\Config\Model\Config\Source\Email\Method', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Email_Smtpauth', - 'Magento\Config\Model\Config\Source\Email\Smtpauth' + 'Magento\Config\Model\Config\Source\Email\Smtpauth', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Email_Template', - 'Magento\Config\Model\Config\Source\Email\Template' + 'Magento\Config\Model\Config\Source\Email\Template', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Image_Adapter', - 'Magento\Config\Model\Config\Source\Image\Adapter' + 'Magento\Config\Model\Config\Source\Image\Adapter', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Locale_Country', - 'Magento\Config\Model\Config\Source\Locale\Country' + 'Magento\Config\Model\Config\Source\Locale\Country', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Locale_Currency_All', - 'Magento\Config\Model\Config\Source\Locale\Currency\All' + 'Magento\Config\Model\Config\Source\Locale\Currency\All', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Locale_Currency', - 'Magento\Config\Model\Config\Source\Locale\Currency' + 'Magento\Config\Model\Config\Source\Locale\Currency', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Locale_Timezone', - 'Magento\Config\Model\Config\Source\Locale\Timezone' + 'Magento\Config\Model\Config\Source\Locale\Timezone', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Locale_Weekdays', - 'Magento\Config\Model\Config\Source\Locale\Weekdays' + 'Magento\Config\Model\Config\Source\Locale\Weekdays', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Notification_Frequency', - 'Magento\AdminNotification\Model\Config\Source\Frequency' + 'Magento\AdminNotification\Model\Config\Source\Frequency', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Order_Status_New', - 'Magento\Sales\Model\Config\Source\Order\Status\NewStatus' + 'Magento\Sales\Model\Config\Source\Order\Status\NewStatus', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Order_Status_Newprocessing', - 'Magento\Sales\Model\Config\Source\Order\Status\Newprocessing' + 'Magento\Sales\Model\Config\Source\Order\Status\Newprocessing', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Order_Status_Processing', - 'Magento\Sales\Model\Config\Source\Order\Status\Processing' + 'Magento\Sales\Model\Config\Source\Order\Status\Processing', ], ['Mage_Adminhtml_Model_System_Config_Source_Order_Status', 'Magento\Sales\Model\Config\Source\Order\Status'], [ 'Mage_Adminhtml_Model_System_Config_Source_Payment_Allmethods', - 'Magento\Payment\Model\Config\Source\Allmethods' + 'Magento\Payment\Model\Config\Source\Allmethods', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Payment_Allowedmethods', - 'Magento\Payment\Model\Config\Source\Allowedmethods' + 'Magento\Payment\Model\Config\Source\Allowedmethods', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Payment_Allspecificcountries', - 'Magento\Payment\Model\Config\Source\Allspecificcountries' + 'Magento\Payment\Model\Config\Source\Allspecificcountries', ], ['Mage_Adminhtml_Model_System_Config_Source_Payment_Cctype', 'Magento\Payment\Model\Config\Source\Cctype'], ['Mage_Adminhtml_Model_System_Config_Source_Price_Scope', 'Magento\Catalog\Model\Config\Source\Price\Scope'], ['Mage_Adminhtml_Model_System_Config_Source_Price_Step', 'Magento\Catalog\Model\Config\Source\Price\Step'], [ 'Mage_Adminhtml_Model_System_Config_Source_Product_Options_Price', - 'Magento\Catalog\Model\Config\Source\Product\Options\Price' + 'Magento\Catalog\Model\Config\Source\Product\Options\Price', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Product_Options_Type', - 'Magento\Catalog\Model\Config\Source\Product\Options\Type' + 'Magento\Catalog\Model\Config\Source\Product\Options\Type', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Product_Thumbnail', - 'Magento\Catalog\Model\Config\Source\Product\Thumbnail' + 'Magento\Catalog\Model\Config\Source\Product\Thumbnail', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Reports_Scope', - 'Magento\Config\Model\Config\Source\Reports\Scope' + 'Magento\Config\Model\Config\Source\Reports\Scope', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Shipping_Allmethods', - 'Magento\Shipping\Model\Config\Source\Allmethods' + 'Magento\Shipping\Model\Config\Source\Allmethods', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Shipping_Allspecificcountries', - 'Magento\Shipping\Model\Config\Source\Allspecificcountries' + 'Magento\Shipping\Model\Config\Source\Allspecificcountries', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Shipping_Flatrate', - 'Magento\OfflineShipping\Model\Config\Source\Flatrate' + 'Magento\OfflineShipping\Model\Config\Source\Flatrate', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Shipping_Tablerate', - 'Magento\OfflineShipping\Model\Config\Source\Tablerate' + 'Magento\OfflineShipping\Model\Config\Source\Tablerate', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Shipping_Taxclass', - 'Magento\Tax\Model\TaxClass\Source\Product' + 'Magento\Tax\Model\TaxClass\Source\Product', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Storage_Media_Database', - 'Magento\MediaStorage\Model\Config\Source\Storage\Media\Database' + 'Magento\MediaStorage\Model\Config\Source\Storage\Media\Database', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Storage_Media_Storage', - 'Magento\MediaStorage\Model\Config\Source\Storage\Media\Storage' + 'Magento\MediaStorage\Model\Config\Source\Storage\Media\Storage', ], ['Mage_Adminhtml_Model_System_Config_Source_Tax_Apply_On', 'Magento\Tax\Model\Config\Source\Apply\On'], ['Mage_Adminhtml_Model_System_Config_Source_Tax_Basedon', 'Magento\Tax\Model\Config\Source\Basedon'], ['Mage_Adminhtml_Model_System_Config_Source_Tax_Catalog', 'Magento\Tax\Model\Config\Source\Catalog'], [ 'Mage_Adminhtml_Model_System_Config_Source_Watermark_Position', - 'Magento\Catalog\Model\Config\Source\Watermark\Position' + 'Magento\Catalog\Model\Config\Source\Watermark\Position', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Web_Protocol', - 'Magento\Config\Model\Config\Source\Web\Protocol' + 'Magento\Config\Model\Config\Source\Web\Protocol', ], [ 'Mage_Adminhtml_Model_System_Config_Source_Web_Redirect', - 'Magento\Config\Model\Config\Source\Web\Redirect' + 'Magento\Config\Model\Config\Source\Web\Redirect', ], ['Mage_Adminhtml_Model_System_Config_Source_Allregion', 'Magento\Directory\Model\Config\Source\Allregion'], ['Mage_Adminhtml_Model_System_Config_Source_Category', 'Magento\Catalog\Model\Config\Source\Category'], @@ -576,7 +580,7 @@ ['Mage_Adminhtml_Model_System_Config_Source_Currency', 'Magento\Config\Model\Config\Source\Currency'], [ 'Mage_Adminhtml_Model_System_Config_Source_Enabledisable', - 'Magento\Config\Model\Config\Source\Enabledisable' + 'Magento\Config\Model\Config\Source\Enabledisable', ], ['Mage_Adminhtml_Model_System_Config_Source_Frequency', 'Magento\Sitemap\Model\Config\Source\Frequency'], ['Mage_Adminhtml_Model_System_Config_Source_Locale', 'Magento\Config\Model\Config\Source\Locale'], @@ -586,7 +590,7 @@ ['Mage_Adminhtml_Model_System_Config_Source_Yesno', 'Magento\Config\Model\Config\Source\Yesno'], [ 'Mage_Adminhtml_Model_System_Config_Source_Yesnocustom', - 'Magento\Config\Model\Config\Source\Yesnocustom' + 'Magento\Config\Model\Config\Source\Yesnocustom', ], ['Mage_Adminhtml_Model_System_Store', 'Magento\Store\Model\System\Store'], ['Mage_Adminhtml_Model_Url', 'Magento\Backend\Model\UrlInterface'], @@ -596,7 +600,7 @@ ['Mage_Adminhtml_System_ConfigController', 'Magento\Config\Controller\Adminhtml\System\Config'], [ 'Magento\Backend\Model\Config\Source\Currency\Service', - 'Magento\Directory\Model\Currency\Import\Source\Service' + 'Magento\Directory\Model\Currency\Import\Source\Service', ], ['Mage_Backend_Model_Menu_Config_Menu'], ['Mage_Backend_Model_Menu_Director_Dom'], @@ -621,71 +625,71 @@ ['Mage_Catalog_Model_Resource_Product_Attribute_Frontend_Tierprice'], [ 'Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Variations\Main', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Attribute\Edit\Tab\Variations\Main' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Attribute\Edit\Tab\Variations\Main', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Attribute\NewAttribute\Product\Created', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Attribute\NewAttribute\Product\Created' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Attribute\NewAttribute\Product\Created', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Configurable', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Composite\Fieldset\Configurable' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Composite\Fieldset\Configurable', ], ['Magento\Catalog\Block\Adminhtml\Product\Created'], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Filter\Inventory', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Filter\Inventory' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Filter\Inventory', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Checkbox', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Checkbox' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Checkbox', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Inventory', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Inventory' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Inventory', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute', ], [ '\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix', - '\Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix' + '\Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix', ], [ - 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Simple' + 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Simple', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config', ], [ '\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Settings', - '\Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Settings' + '\Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Settings', ], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs\Configurable', - 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tabs\Configurable' + 'Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tabs\Configurable', ], [ 'Magento\Catalog\Block\Product\Configurable\AssociatedSelector\Backend\Grid\ColumnSet', - 'Magento\ConfigurableProduct\Block\Product\Configurable\AssociatedSelector\Backend\Grid\ColumnSet' + 'Magento\ConfigurableProduct\Block\Product\Configurable\AssociatedSelector\Backend\Grid\ColumnSet', ], [ 'Magento\Catalog\Block\Product\Configurable\AssociatedSelector\Renderer\Id', - 'Magento\ConfigurableProduct\Block\Product\Configurable\AssociatedSelector\Renderer\Id' + 'Magento\ConfigurableProduct\Block\Product\Configurable\AssociatedSelector\Renderer\Id', ], [ 'Magento\Catalog\Block\Product\Configurable\AttributeSelector', - 'Magento\ConfigurableProduct\Block\Product\Configurable\AttributeSelector' + 'Magento\ConfigurableProduct\Block\Product\Configurable\AttributeSelector', ], [ 'Magento\Catalog\Block\Product\View\Type\Configurable', - 'Magento\ConfigurableProduct\Block\Product\View\Type\Configurable' + 'Magento\ConfigurableProduct\Block\Product\View\Type\Configurable', ], [ 'Magento\Catalog\Block\Layer\Filter\AbstractFilter', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], ['Magento\Catalog\Block\Layer\Filter\Attribute', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer'], ['Magento\Catalog\Block\Layer\Filter\Category', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer'], @@ -696,29 +700,29 @@ ['Magento\CatalogSearch\Block\Layer', 'Magento\LayeredNavigation\Block\Navigation'], [ 'Magento\CatalogSearch\Block\Layer\Filter\Attribute', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], ['Magento\CatalogSearch\Model\Layer', 'Magento\Catalog\Model\Layer'], ['Magento\Solr\Block\Catalog\Layer\View', 'Magento\LayeredNavigation\Block\Navigation'], [ 'Magento\Solr\Block\Catalog\Layer\Filter\Attribute', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], [ 'Magento\Solr\Block\Catalog\Layer\Filter\Category', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], [ 'Magento\Solr\Block\Catalog\Layer\Filter\Decimal', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], [ 'Magento\Solr\Block\Catalog\Layer\Filter\Price', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], [ 'Magento\Solr\Block\Catalogsearch\Layer\Filter\Attribute', - 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer', ], ['Magento\Solr\Block\Catalogsearch\Layer', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer'], ['Magento\Solr\Model\Catalog\Layer', 'Magento\Catalog\Model\Layer\Category'], @@ -730,44 +734,44 @@ ['Magento\Solr\Model\Search\Layer', 'Magento\Catalog\Model\Layer'], [ 'Magento\Catalog\Model\Product\Type\Configurable', - 'Magento\ConfigurableProduct\Model\Product\Type\Configurable' + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable', ], [ 'Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute', - 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute' + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute', ], [ 'Magento\Catalog\Model\Resource\Product\Type\Configurable\Product\Collection', - 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Product\Collection' + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Product\Collection', ], [ 'Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection', - 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection' + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection', ], [ 'Magento\Catalog\Model\Resource\Product\Type\Configurable', - 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable' + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable', ], [ 'Magento\Catalog\Model\Resource\Product\Indexer\Price\Configurable', - 'Magento\ConfigurableProduct\Model\Resource\Product\Indexer\Price\Configurable' + 'Magento\ConfigurableProduct\Model\Resource\Product\Indexer\Price\Configurable', ], [ 'Magento\Catalog\Model\Product\Type\Configurable\Price', - 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Price' + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Price', ], ['Magento\Catalog\Model\Product\AttributeSet\AlreadyExistsException'], ['Magento\Catalog\Model\Product\Option\Type\File\Exception'], [ 'Magento\Catalog\Model\Product\Option\Type\File\LargeSizeException', - 'Magento\Framework\Exception\File\LargeSizeException' + 'Magento\Framework\Exception\File\LargeSizeException', ], ['Magento\Catalog\Model\Product\Option\Type\File\NotImageException'], ['Magento\Catalog\Model\Product\Option\Type\File\OptionRequiredException'], ['Magento\Catalog\Model\Product\Option\Type\File\RunValidationException'], [ 'Magento\Checkout\Block\Cart\Item\Renderer\Configurable', - 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable' + 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable', ], ['Magento\Catalog\Model\Resource\Product\Flat\Indexer'], ['Magento\Catalog\Model\System\Config\Backend\Catalog\Product\Flat'], @@ -804,7 +808,7 @@ ['Magento\Core\Model\Resource\Db\Profiler', 'Magento\Framework\Model\Resource\Db\Profiler'], [ 'Magento\Core\Model\Resource\Entity\AbstractEntity', - 'Magento\Framework\Model\Resource\Entity\AbstractEntity' + 'Magento\Framework\Model\Resource\Entity\AbstractEntity', ], ['Magento\Core\Model\Resource\Entity\Table', 'Magento\Framework\Model\Resource\Entity\Table'], ['Magento\Core\Model\Resource\Flag', 'Magento\Framework\Flag\Resource'], @@ -815,7 +819,7 @@ ['Magento\Core\Model\Resource\Type\Db\Pdo\Mysql', 'Magento\Framework\Model\Resource\Type\Db\Pdo\Mysql'], [ 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', - 'Magento\Framework\Model\Resource\Db\Collection\AbstractCollection' + 'Magento\Framework\Model\Resource\Db\Collection\AbstractCollection', ], ['Magento\Email\Model\Info', 'Magento\Framework\Mail\MessageInterface'], ['Magento\Email\Model\Sender', 'Magento\Framework\Mail\Template\TransportBuilder'], @@ -849,7 +853,7 @@ ['Mage_Customer_Model_Convert_Parser_Customer'], [ 'Mage_Customer_Model_Resource_Address_Attribute_Backend_Street', - 'Mage_Eav_Model_Entity_Attribute_Backend_Default' + 'Mage_Eav_Model_Entity_Attribute_Backend_Default', ], ['Magento\Customer\Exception'], ['Mage_DesignEditor_Block_Page_Html_Head_Vde'], @@ -887,7 +891,7 @@ ['Mage_Reports_Model_Resource_Product_Ordered_Collection'], [ 'Mage_Reports_Model_Resource_Product_Viewed_Collection', - 'Magento\Reports\Model\Resource\Report\Product\Viewed\Collection' + 'Magento\Reports\Model\Resource\Report\Product\Viewed\Collection', ], ['Mage_Reports_Model_Resource_Refunded_Collection'], ['Mage_Reports_Model_Resource_Shipping_Collection'], @@ -897,27 +901,27 @@ ['Mage_Rss_Model_Session', 'Magento_Backend_Model_Auth and \Magento\Backend\Model\Auth\Session'], [ 'Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Tracking', - '\Magento\Shipping\Block\Adminhtml\Order\Tracking' + '\Magento\Shipping\Block\Adminhtml\Order\Tracking', ], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\Create\Tracking', - 'Magento\Shipping\Block\Adminhtml\Order\Tracking' + 'Magento\Shipping\Block\Adminhtml\Order\Tracking', ], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\Packaging', - '\Magento\Shipping\Block\Adminhtml\Order\Packaging' + '\Magento\Shipping\Block\Adminhtml\Order\Packaging', ], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\Packaging\Grid', - '\Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid' + '\Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid', ], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\Tracking\Info', - '\Magento\Shipping\Block\Adminhtml\Order\Tracking' + '\Magento\Shipping\Block\Adminhtml\Order\Tracking', ], [ 'Magento\Sales\Block\Adminhtml\Order\Shipment\View\Tracking', - 'Magento\Shipping\Block\Adminhtml\Order\Tracking\View' + 'Magento\Shipping\Block\Adminhtml\Order\Tracking\View', ], ['Mage_Sales_Block_Order_Details'], ['Mage_Sales_Block_Order_Tax'], @@ -1047,15 +1051,15 @@ ['Mage_Adminhtml_Block_Notification_Baseurl'], [ 'Mage_Adminhtml_Block_Notification_Grid_Renderer_Severity', - 'Magento\AdminNotification\Block\Grid\Renderer\Severity' + 'Magento\AdminNotification\Block\Grid\Renderer\Severity', ], [ 'Mage_Adminhtml_Block_Notification_Grid_Renderer_Notice', - 'Magento\AdminNotification\Block\Grid\Renderer\Notice' + 'Magento\AdminNotification\Block\Grid\Renderer\Notice', ], [ 'Mage_Adminhtml_Block_Notification_Grid_Renderer_Actions', - 'Magento\AdminNotification\Block\Grid\Renderer\Actions' + 'Magento\AdminNotification\Block\Grid\Renderer\Actions', ], ['Mage_Adminhtml_Block_Cache_Notifications'], ['Mage_AdminNotification_Block_Grid'], @@ -1069,7 +1073,7 @@ [ 'Magento\Catalog\Block\Product\View\Media', 'Decomposed into \Magento\Catalog\Block\Product\View\Gallery' . - ' and \Magento\Catalog\Block\Product\View\BaseImage classes' + ' and \Magento\Catalog\Block\Product\View\BaseImage classes', ], ['Magento\Wishlist\Block\Links', 'Magento\Wishlist\Block\Link'], ['Magento\Wishlist\Block\Render\Item\Price'], @@ -1282,7 +1286,7 @@ ['Magento\Eav\Model\Resource\Helper\Mysql4', 'Magento\Eav\Model\Resource\Helper'], [ 'Magento\Eav\Model\Entity\Attribute\Backend\Array', - 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend' + 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend', ], ['Magento\Sales\Model\Resource\Helper\HelperInterface', 'Magento\Sales\Model\Resource\HelperInterface'], ['Magento\Reports\Model\Resource\Helper\HelperInterface', 'Magento\Reports\Model\Resource\HelperInterface'], @@ -1407,11 +1411,11 @@ ['Magento\Core\Helper\Hint', 'Magento\Backend\Block\Store\Switcher'], [ 'Magento\Core\Model\Design\Fallback\Rule\ModularSwitch', - 'Magento\Framework\View\Design\Fallback\Rule\ModularSwitch' + 'Magento\Framework\View\Design\Fallback\Rule\ModularSwitch', ], [ 'Magento\Core\Model\Design\Fallback\Rule\RuleInterface', - 'Magento\Framework\View\Design\Fallback\Rule\RuleInterface' + 'Magento\Framework\View\Design\Fallback\Rule\RuleInterface', ], ['Magento\Core\Model\Design\Fallback\Rule\Simple', 'Magento\Framework\View\Design\Fallback\Rule\Simple'], ['Magento\Core\Model\Design\Fallback\Factory', 'Magento\Framework\View\Design\Fallback\RulePool'], @@ -1423,7 +1427,7 @@ ['Magento\Framework\View\Design\FileResolution\Strategy\Fallback\CachingProxy'], [ 'Magento\Core\Model\Design\FileResolution\Strategy\Fallback', - 'Magento\Framework\View\Design\FileResolution\Fallback\{File,ViewFile,LocaleFile,TemplateFile}' + 'Magento\Framework\View\Design\FileResolution\Fallback\{File,ViewFile,LocaleFile,TemplateFile}', ], ['Magento\Core\Model\Design\FileResolution\StrategyPool'], ['Magento\Framework\View\Design\FileResolution\StrategyPool'], @@ -1433,16 +1437,16 @@ ['Magento\Core\Model\Layout\File\ListFile', 'Magento\Framework\View\File\FileList'], [ 'Magento\Core\Model\Layout\File\Source\Aggregated', - 'Magento\Framework\View\Layout\File\Collector\Aggregated' + 'Magento\Framework\View\Layout\File\Collector\Aggregated', ], ['Magento\Core\Model\Layout\File\Source\Base', 'Magento\Framework\View\Layout\File\Source\Base'], [ 'Magento\Core\Model\Layout\File\Source\Decorator\ModuleDependency', - 'Magento\Framework\View\File\Collector\Decorator\ModuleDependency' + 'Magento\Framework\View\File\Collector\Decorator\ModuleDependency', ], [ 'Magento\Core\Model\Layout\File\Source\Decorator\ModuleOutput', - 'Magento\Framework\View\File\Collector\Decorator\ModuleOutput' + 'Magento\Framework\View\File\Collector\Decorator\ModuleOutput', ], ['Magento\Core\Model\Layout\File\Source\Override\Base', 'Magento\Framework\View\Layout\File\Override\Base'], ['Magento\Core\Model\Layout\File\Source\Override\Theme', 'Magento\Framework\View\Layout\File\Override\Theme'], @@ -1459,71 +1463,71 @@ ['Magento\Media\Helper\Data'], [ 'Magento\Adminhtml\Block\Promo\Catalog\Edit\Form', - 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Form' + 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Form', ], [ 'Magento\Adminhtml\Block\Promo\Catalog\Edit\Js', - 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Js' + 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Js', ], [ 'Magento\Adminhtml\Block\Promo\Catalog\Edit\Tab\Actions', - 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab\Actions' + 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab\Actions', ], [ 'Magento\Adminhtml\Block\Promo\Catalog\Edit\Tab\Conditions', - 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab\Conditions' + 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab\Conditions', ], [ 'Magento\Adminhtml\Block\Promo\Catalog\Edit\Tab\Main', - 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab\Main' + 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab\Main', ], [ 'Magento\Adminhtml\Block\Promo\Catalog\Edit\Tabs', - 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tabs' + 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tabs', ], ['Magento\Adminhtml\Block\Promo\Catalog\Edit', 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit'], ['Magento\Adminhtml\Block\Promo\Catalog', 'Magento\CatalogRule\Block\Adminhtml\Promo\Catalog'], [ 'Magento\Adminhtml\Block\Promo\Widget\Chooser\Sku', - 'Magento\CatalogRule\Block\Adminhtml\Widget\Chooser\Sku' + 'Magento\CatalogRule\Block\Adminhtml\Widget\Chooser\Sku', ], ['Magento\Adminhtml\Block\Promo\Widget\Chooser', 'Magento\CatalogRule\Block\Adminhtml\Widget\Chooser'], ['Magento\Adminhtml\Block\Promo\Quote\Edit\Form', 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Form'], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Actions', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Conditions', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Coupons\Form', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Form' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Form', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Coupons\Grid\Column\Renderer\Used', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid\Column\Renderer\Used' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid\Column\Renderer\Used', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Coupons\Grid', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Coupons', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Labels', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Main\Renderer\Checkbox', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Main\Renderer\Checkbox' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Main\Renderer\Checkbox', ], [ 'Magento\Adminhtml\Block\Promo\Quote\Edit\Tab\Main', - 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Main' + 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Main', ], ['Magento\Adminhtml\Block\Promo\Quote\Edit\Tabs', 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tabs'], ['Magento\Adminhtml\Block\Promo\Quote\Edit', 'Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit'], @@ -1536,11 +1540,11 @@ ['Magento\Adminhtml\Controller\System\Backup', 'Magento\Backend\Controller\Adminhtml\System\Backup'], [ 'Magento\Adminhtml\Controller\System\Config\System\Storage', - 'Magento\Config\Controller\Adminhtml\System\Config\System\Storage' + 'Magento\Config\Controller\Adminhtml\System\Config\System\Storage', ], [ 'Magento\MediaStorage\Controller\System\Config\System\Storage', - 'Magento\MediaStorage\Controller\Adminhtml\System\Config\System\Storage' + 'Magento\MediaStorage\Controller\Adminhtml\System\Config\System\Storage', ], ['Magento\Adminhtml\Controller\System\Design', 'Magento\Backend\Controller\Adminhtml\System\Design'], ['Magento\Adminhtml\Controller\System\Store', 'Magento\Backend\Controller\Adminhtml\System\Store'], @@ -1551,7 +1555,7 @@ ['Magento\Adminhtml\Block\System\Cache\Form', 'Magento\Backend\Block\System\Cache\Form'], [ 'Magento\Adminhtml\Block\System\Design\Edit\Tab\General', - 'Magento\Backend\Block\System\Design\Edit\Tab\General' + 'Magento\Backend\Block\System\Design\Edit\Tab\General', ], ['Magento\Adminhtml\Block\System\Design\Edit\Tabs', 'Magento\Backend\Block\System\Design\Edit\Tabs'], ['Magento\Adminhtml\Block\System\Design\Edit', 'Magento\Backend\Block\System\Design\Edit'], @@ -1563,32 +1567,32 @@ ['Magento\Adminhtml\Block\System\Store\Delete', 'Magento\Backend\Block\System\Store\Delete'], [ 'Magento\Adminhtml\Block\System\Store\Edit\AbstractForm', - 'Magento\Backend\Block\System\Store\Edit\AbstractForm' + 'Magento\Backend\Block\System\Store\Edit\AbstractForm', ], [ 'Magento\Adminhtml\Block\System\Store\Edit\Form\Group', - 'Magento\Backend\Block\System\Store\Edit\Form\Group' + 'Magento\Backend\Block\System\Store\Edit\Form\Group', ], [ 'Magento\Adminhtml\Block\System\Store\Edit\Form\Store', - 'Magento\Backend\Block\System\Store\Edit\Form\Store' + 'Magento\Backend\Block\System\Store\Edit\Form\Store', ], [ 'Magento\Adminhtml\Block\System\Store\Edit\Form\Website', - 'Magento\Backend\Block\System\Store\Edit\Form\Website' + 'Magento\Backend\Block\System\Store\Edit\Form\Website', ], ['Magento\Adminhtml\Block\System\Store\Edit', 'Magento\Backend\Block\System\Store\Edit'], [ 'Magento\Adminhtml\Block\System\Store\Grid\Render\Group', - 'Magento\Backend\Block\System\Store\Grid\Render\Group' + 'Magento\Backend\Block\System\Store\Grid\Render\Group', ], [ 'Magento\Adminhtml\Block\System\Store\Grid\Render\Store', - 'Magento\Backend\Block\System\Store\Grid\Render\Store' + 'Magento\Backend\Block\System\Store\Grid\Render\Store', ], [ 'Magento\Adminhtml\Block\System\Store\Grid\Render\Website', - 'Magento\Backend\Block\System\Store\Grid\Render\Website' + 'Magento\Backend\Block\System\Store\Grid\Render\Website', ], ['Magento\Adminhtml\Block\System\Store\Store', 'Magento\Backend\Block\System\Store\Store'], ['Magento\Adminhtml\Block\System\Variable\Edit\Form', 'Magento\Variable\Block\System\Variable\Edit\Form'], @@ -1598,15 +1602,15 @@ ['Magento\Adminhtml\Block\System\Variable', 'Magento\Variable\Block\System\Variable'], [ 'Magento\Adminhtml\Block\Checkout\Agreement\Edit\Form', - 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit\Form' + 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit\Form', ], [ 'Magento\Adminhtml\Block\Checkout\Agreement\Edit', - 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit' + 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit', ], [ 'Magento\Adminhtml\Block\Checkout\Agreement\Grid', - 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Grid' + 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Grid', ], ['Magento\Adminhtml\Block\Checkout\Agreement', 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement'], ['Magento\Adminhtml\Controller\Checkout\Agreement', 'Magento\Checkout\Controller\Adminhtml\Agreement'], @@ -1627,7 +1631,7 @@ ['Magento\Core\Model\EntryPoint\Cron', 'Magento\Framework\App\Cron'], [ 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped', - 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped' + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', ], ['Magento\Log\Model\EntryPoint\Shell', 'Magento\Log\App\Shell'], ['Magento\Core\Model\Config\Modules\Reader', 'Magento\Framework\Module\Dir\Reader'], @@ -1651,11 +1655,11 @@ ['Magento\Backend\Controller\Adminhtml\Action', 'Magento\Backend\App\Action'], [ 'Magento\Backend\Controller\Adminhtml\System\AbstractConfig', - 'Magento\Config\Controller\Adminhtml\System\AbstractConfig' + 'Magento\Config\Controller\Adminhtml\System\AbstractConfig', ], [ 'Magento\Backend\Controller\Adminhtml\System\ConfigSectionChecker', - 'Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker' + 'Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker', ], ['Magento\Backend\Block\System\Shipping\Ups', 'Magento\Ups\Block\Backend\System\CarrierConfig'], ['Magento\Core\Block\Text', 'Magento\Framework\View\Element\Text'], @@ -1695,44 +1699,44 @@ ['Magento\Core\Model\Url\ScopeResolver', 'Magento\Framework\Url\ScopeResolver'], [ 'Magento\Adminhtml\Block\Report\Config\Form\Field\MtdStart', - 'Magento\Reports\Block\Adminhtml\Config\Form\Field\MtdStart' + 'Magento\Reports\Block\Adminhtml\Config\Form\Field\MtdStart', ], [ 'Magento\Adminhtml\Block\Report\Config\Form\Field\YtdStart', - 'Magento\Reports\Block\Adminhtml\Config\Form\Field\YtdStart' + 'Magento\Reports\Block\Adminhtml\Config\Form\Field\YtdStart', ], ['Magento\Adminhtml\Block\Report\Filter\Form', 'Magento\Reports\Block\Adminhtml\Filter\Form'], ['Magento\Adminhtml\Block\Report\Grid\AbstractGrid', 'Magento\Reports\Block\Adminhtml\Grid\AbstractGrid'], [ 'Magento\Adminhtml\Block\Report\Grid\Column\Renderer\Blanknumber', - 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Blanknumber' + 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Blanknumber', ], [ 'Magento\Adminhtml\Block\Report\Grid\Column\Renderer\Currency', - 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency' + 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency', ], [ 'Magento\Adminhtml\Block\Report\Grid\Column\Renderer\Customer', - 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Customer' + 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Customer', ], [ 'Magento\Adminhtml\Block\Report\Grid\Column\Renderer\Product', - 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Product' + 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Product', ], ['Magento\Adminhtml\Block\Report\Grid\Shopcart', 'Magento\Reports\Block\Adminhtml\Grid\Shopcart'], [ 'Magento\Adminhtml\Block\Report\Product\Downloads\Grid', - 'Magento\Reports\Block\Adminhtml\Product\Downloads\Grid' + 'Magento\Reports\Block\Adminhtml\Product\Downloads\Grid', ], [ 'Magento\Adminhtml\Block\Report\Product\Downloads\Renderer\Purchases', - 'Magento\Reports\Block\Adminhtml\Product\Downloads\Renderer\Purchases' + 'Magento\Reports\Block\Adminhtml\Product\Downloads\Renderer\Purchases', ], ['Magento\Adminhtml\Block\Report\Product\Downloads', 'Magento\Reports\Block\Adminhtml\Product\Downloads'], ['Magento\Adminhtml\Block\Report\Product\Grid', 'Magento\Reports\Block\Adminhtml\Product\Grid'], [ 'Magento\Adminhtml\Block\Report\Product\Lowstock\Grid', - 'Magento\Reports\Block\Adminhtml\Product\Lowstock\Grid' + 'Magento\Reports\Block\Adminhtml\Product\Lowstock\Grid', ], ['Magento\Adminhtml\Block\Report\Product\Lowstock', 'Magento\Reports\Block\Adminhtml\Product\Lowstock'], ['Magento\Adminhtml\Block\Report\Product\Viewed\Grid', 'Magento\Reports\Block\Adminhtml\Product\Viewed\Grid'], @@ -1744,14 +1748,14 @@ ['Magento\Adminhtml\Block\Report\Review\Product', 'Magento\Reports\Block\Adminhtml\Review\Product'], [ 'Magento\Adminhtml\Block\Report\Sales\Bestsellers\Grid', - 'Magento\Reports\Block\Adminhtml\Sales\Bestsellers\Grid' + 'Magento\Reports\Block\Adminhtml\Sales\Bestsellers\Grid', ], ['Magento\Adminhtml\Block\Report\Sales\Bestsellers', 'Magento\Reports\Block\Adminhtml\Sales\Bestsellers'], ['Magento\Adminhtml\Block\Report\Sales\Coupons\Grid', 'Magento\Reports\Block\Adminhtml\Sales\Coupons\Grid'], ['Magento\Adminhtml\Block\Report\Sales\Coupons', 'Magento\Reports\Block\Adminhtml\Sales\Coupons'], [ 'Magento\Adminhtml\Block\Report\Sales\Grid\Column\Renderer\Date', - 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date' + 'Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date', ], ['Magento\Adminhtml\Block\Report\Sales\Invoiced\Grid', 'Magento\Reports\Block\Adminhtml\Sales\Invoiced\Grid'], ['Magento\Adminhtml\Block\Report\Sales\Invoiced', 'Magento\Reports\Block\Adminhtml\Sales\Invoiced'], @@ -1766,17 +1770,17 @@ ['Magento\Adminhtml\Block\Report\Search', 'Magento\Search\Block\Adminhtml\Reports\Search'], [ 'Magento\Adminhtml\Block\Report\Shopcart\Abandoned\Grid', - 'Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid' + 'Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid', ], ['Magento\Adminhtml\Block\Report\Shopcart\Abandoned', 'Magento\Reports\Block\Adminhtml\Shopcart\Abandoned'], [ 'Magento\Adminhtml\Block\Report\Shopcart\Customer\Grid', - 'Magento\Reports\Block\Adminhtml\Shopcart\Customer\Grid' + 'Magento\Reports\Block\Adminhtml\Shopcart\Customer\Grid', ], ['Magento\Adminhtml\Block\Report\Shopcart\Customer', 'Magento\Reports\Block\Adminhtml\Shopcart\Customer'], [ 'Magento\Adminhtml\Block\Report\Shopcart\Product\Grid', - 'Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid' + 'Magento\Reports\Block\Adminhtml\Shopcart\Product\Grid', ], ['Magento\Adminhtml\Block\Report\Shopcart\Product', 'Magento\Reports\Block\Adminhtml\Shopcart\Product'], ['Magento\Adminhtml\Block\Report\Wishlist\Grid', 'Magento\Reports\Block\Adminhtml\Wishlist\Grid'], @@ -1785,31 +1789,31 @@ ['Magento\Backend\Controller\Adminhtml\System\Variable', 'Magento\Variable\Controller\Adminhtml\System\Variable'], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\Delete', - 'Magento\Variable\Controller\Adminhtml\System\Variable\Delete' + 'Magento\Variable\Controller\Adminhtml\System\Variable\Delete', ], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\Edit', - 'Magento\Variable\Controller\Adminhtml\System\Variable\Edit' + 'Magento\Variable\Controller\Adminhtml\System\Variable\Edit', ], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\Index', - 'Magento\Variable\Controller\Adminhtml\System\Variable\Index' + 'Magento\Variable\Controller\Adminhtml\System\Variable\Index', ], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\NewAction', - 'Magento\Variable\Controller\Adminhtml\System\Variable\NewAction' + 'Magento\Variable\Controller\Adminhtml\System\Variable\NewAction', ], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\Save', - 'Magento\Variable\Controller\Adminhtml\System\Variable\Save' + 'Magento\Variable\Controller\Adminhtml\System\Variable\Save', ], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\Validate', - 'Magento\Variable\Controller\Adminhtml\System\Variable\Validate' + 'Magento\Variable\Controller\Adminhtml\System\Variable\Validate', ], [ 'Magento\Backend\Controller\Adminhtml\System\Variable\WysiwygPlugin', - 'Magento\Variable\Controller\Adminhtml\System\Variable\WysiwygPlugin' + 'Magento\Variable\Controller\Adminhtml\System\Variable\WysiwygPlugin', ], ['Magento\Core\Model\Cookie', 'Magento\Framework\Stdlib\Cookie'], ['Magento\Core\Model\Logger', 'Psr\Log\LoggerInterface'], @@ -1844,16 +1848,16 @@ ['Magento\Core\Model\Page\Asset\MergeService', 'Magento\Framework\View\Asset\MergeService'], [ 'Magento\Core\Model\Page\Asset\MergeStrategy\Checksum', - 'Magento\Framework\View\Asset\MergeStrategy\Checksum' + 'Magento\Framework\View\Asset\MergeStrategy\Checksum', ], ['Magento\Core\Model\Page\Asset\MergeStrategy\Direct', 'Magento\Framework\View\Asset\MergeStrategy\Direct'], [ 'Magento\Core\Model\Page\Asset\MergeStrategy\FileExists', - 'Magento\Framework\View\Asset\MergeStrategy\FileExists' + 'Magento\Framework\View\Asset\MergeStrategy\FileExists', ], [ 'Magento\Core\Model\Page\Asset\MergeStrategyInterface', - 'Magento\Framework\View\Asset\MergeStrategyInterface' + 'Magento\Framework\View\Asset\MergeStrategyInterface', ], ['Magento\Core\Model\Page\Asset\MergeableInterface', 'Magento\Framework\View\Asset\MergeableInterface'], ['Magento\Core\Model\Page\Asset\Merged', 'Magento\Framework\View\Asset\Merged'], @@ -1875,7 +1879,7 @@ ['Magento\Page\Block\Link', 'Magento\Framework\View\Element\Html\Link'], [ 'Magento\Core\Model\Layout\Argument\HandlerInterface', - 'Magento\Framework\View\Layout\Argument\HandlerInterface' + 'Magento\Framework\View\Layout\Argument\HandlerInterface', ], ['Magento\Core\Model\Layout\Argument\HandlerFactory', 'Magento\Framework\View\Layout\Argument\HandlerFactory'], ['Magento\Core\Model\Theme\Label', 'Magento\Framework\View\Design\Theme\Label'], @@ -1885,12 +1889,12 @@ ['Magento\Core\Model\Layout\PageType\Config', 'Magento\Framework\View\Layout\PageType\Config'], [ 'Magento\Core\Model\Layout\PageType\Config\Converter', - 'Magento\Framework\View\Layout\PageType\Config\Converter' + 'Magento\Framework\View\Layout\PageType\Config\Converter', ], ['Magento\Core\Model\Layout\PageType\Config\Reader', 'Magento\Framework\View\Layout\PageType\Config\Reader'], [ 'Magento\Core\Model\Layout\PageType\Config\SchemaLocator', - 'Magento\Framework\View\Layout\PageType\Config\SchemaLocator' + 'Magento\Framework\View\Layout\PageType\Config\SchemaLocator', ], ['Magento\Core\Model\Theme\CopyService', 'Magento\Theme\Model\CopyService'], ['Magento\Core\Model\Resource\Session', 'Magento\Framework\Session\SaveHandler\DbTable'], @@ -1904,73 +1908,73 @@ ['Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser'], [ 'Magento\Catalog\Model\Product\Type\Grouped\Backend', - 'Magento\GroupedProduct\Model\Product\Type\Grouped\Backend' + 'Magento\GroupedProduct\Model\Product\Type\Grouped\Backend', ], [ 'Magento\Catalog\Model\Product\Type\Grouped\Price', - 'Magento\GroupedProduct\Model\Product\Type\Grouped\Price' + 'Magento\GroupedProduct\Model\Product\Type\Grouped\Price', ], [ 'Magento\Catalog\Model\Resource\Product\Indexer\Price\Grouped', - 'Magento\GroupedProduct\Model\Resource\Product\Indexer\Price\Grouped' + 'Magento\GroupedProduct\Model\Resource\Product\Indexer\Price\Grouped', ], [ 'Magento\Catalog\Model\Resource\Product\Type\Grouped\AssociatedProductsCollection', - 'Magento\GroupedProduct\Model\Resource\Product\Type\Grouped\AssociatedProductsCollection' + 'Magento\GroupedProduct\Model\Resource\Product\Type\Grouped\AssociatedProductsCollection', ], ['Magento\Catalog\Model\Product\Type\Grouped', 'Magento\GroupedProduct\Model\Product\Type\Grouped'], [ 'Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Grouped', - 'Magento\GroupedProduct\Block\Adminhtml\Product\Composite\Fieldset\Grouped' + 'Magento\GroupedProduct\Block\Adminhtml\Product\Composite\Fieldset\Grouped', ], ['Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs\Grouped'], [ 'Magento\Catalog\Block\Product\Grouped\AssociatedProducts', - 'Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts' + 'Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts', ], [ 'Magento\Catalog\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts', - 'Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts' + 'Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts', ], ['Magento\Catalog\Block\Product\View\Type\Grouped', 'Magento\GroupedProduct\Block\Product\View\Type\Grouped'], [ 'Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped', - 'Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped' + 'Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped', ], [ 'Magento\Sales\Model\Order\Pdf\Items\Invoice\Grouped', - 'Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice\Grouped' + 'Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice\Grouped', ], [ 'Magento\Sales\Block\Order\Item\Renderer\Grouped', - 'Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped' + 'Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped', ], [ 'Magento\ImportExport\Model\Export\Entity\Product\Type\Grouped', - 'Magento\CatalogImportExport\Model\Export\Entity\Product\Type\Grouped' + 'Magento\CatalogImportExport\Model\Export\Entity\Product\Type\Grouped', ], [ 'Magento\ImportExport\Model\Import\Entity\Product\Type\Grouped', - 'Magento\CatalogImportExport\Model\Import\Entity\Product\Type\Grouped' + 'Magento\CatalogImportExport\Model\Import\Entity\Product\Type\Grouped', ], [ 'Magento\GroupedProduct\Model\Export\Entity\Product\Type\Grouped', - 'Magento\CatalogImportExport\Model\Export\Entity\Product\Type\Grouped' + 'Magento\CatalogImportExport\Model\Export\Entity\Product\Type\Grouped', ], [ 'Magento\GroupedProduct\Model\Import\Entity\Product\Type\Grouped', - 'Magento\CatalogImportExport\Model\Import\Entity\Product\Type\Grouped' + 'Magento\CatalogImportExport\Model\Import\Entity\Product\Type\Grouped', ], ['CollFactory', 'CollectionFactory'], // no need to shorten anymore [ 'Magento\Shipping\Model\Rate\Result\AbstractResult', - 'Magento\Quote\Model\Quote\Address\RateResult\AbstractResult' + 'Magento\Quote\Model\Quote\Address\RateResult\AbstractResult', ], ['Magento\Shipping\Model\Rate\Result\Error', 'Magento\Quote\Model\Quote\Address\RateResult\Error'], ['Magento\Shipping\Model\Rate\Result\Method', 'Magento\Quote\Model\Quote\Address\RateResult\Method'], [ 'Magento\Shipping\Model\Rate\AbstractRate', - 'Magento\Quote\Model\Quote\Address\Rate + Magento\Shipping\Model\CarrierFactory' + 'Magento\Quote\Model\Quote\Address\Rate + Magento\Shipping\Model\CarrierFactory', ], ['Magento\Shipping\Model\Rate\Request', 'Magento\Quote\Model\Quote\Address\RateRequest'], ['Magento\PageCache\Block\Adminhtml\Cache\Additional'], @@ -1987,48 +1991,48 @@ ['Magento\GoogleShopping\Helper\Price', 'Magento\Catalog\Model\Product\CatalogPrice'], [ 'Magento\Core\Model\Layout\Argument\Handler\ArrayHandler', - 'Magento\Framework\Data\Argument\Interpreter\ArrayType' + 'Magento\Framework\Data\Argument\Interpreter\ArrayType', ], ['Magento\Core\Model\Layout\Argument\Handler\String', 'Magento\Framework\Data\Argument\Interpreter\String'], ['Magento\Core\Model\Layout\Argument\Handler\Number', 'Magento\Framework\Data\Argument\Interpreter\Number'], ['Magento\Core\Model\Layout\Argument\Handler\Boolean', 'Magento\Framework\Data\Argument\Interpreter\Boolean'], [ 'Magento\Core\Model\Layout\Argument\Handler\Object', - 'Magento\Framework\View\Layout\Argument\Interpreter\Object' + 'Magento\Framework\View\Layout\Argument\Interpreter\Object', ], [ 'Magento\Core\Model\Layout\Argument\Handler\Options', - 'Magento\Framework\View\Layout\Argument\Interpreter\Options' + 'Magento\Framework\View\Layout\Argument\Interpreter\Options', ], ['Magento\Core\Model\Layout\Argument\Handler\Url', 'Magento\Framework\View\Layout\Argument\Interpreter\Url'], [ 'Magento\Core\Model\Layout\Argument\Handler\Helper', - 'Magento\Framework\View\Layout\Argument\Interpreter\HelperMethod' + 'Magento\Framework\View\Layout\Argument\Interpreter\HelperMethod', ], [ 'Magento\Core\Model\Layout\Argument\AbstractHandler', - 'Magento\Framework\View\Layout\Argument\Interpreter\Decorator\Updater' + 'Magento\Framework\View\Layout\Argument\Interpreter\Decorator\Updater', ], [ 'Magento\Core\Model\Layout\Argument\Processor', - 'Magento\Framework\View\Layout\Argument\Interpreter\Decorator\Updater' + 'Magento\Framework\View\Layout\Argument\Interpreter\Decorator\Updater', ], [ 'Magento\Core\Model\Layout\Argument\Updater', - 'Magento\Framework\View\Layout\Argument\Interpreter\Decorator\Updater' + 'Magento\Framework\View\Layout\Argument\Interpreter\Decorator\Updater', ], [ 'Magento\Core\Model\Layout\Argument\UpdaterInterface', - 'Magento\Framework\View\Layout\Argument\UpdaterInterface' + 'Magento\Framework\View\Layout\Argument\UpdaterInterface', ], ['Magento\Core\Model\Layout\Filter\Acl', 'Magento\Backend\Model\Layout\Filter\Acl'], [ 'Magento\Framework\View\Layout\Argument\HandlerInterface', - 'Magento\Framework\Data\Argument\InterpreterInterface' + 'Magento\Framework\Data\Argument\InterpreterInterface', ], [ 'Magento\Framework\View\Layout\Argument\HandlerFactory', - 'Magento\Framework\Data\Argument\Interpreter\Composite' + 'Magento\Framework\Data\Argument\Interpreter\Composite', ], ['Magento\Framework\Phrase\Renderer\Factory'], ['Magento\Catalog\Model\Category\Indexer\Product'], @@ -2038,32 +2042,32 @@ ['Magento\Catalog\Model\Resource\Product\Status'], [ 'Magento\CatalogInventory\Block\Stockqty\Type\Configurable', - 'Magento\ConfigurableProduct\Block\Stockqty\Type\Configurable' + 'Magento\ConfigurableProduct\Block\Stockqty\Type\Configurable', ], [ 'Magento\CatalogInventory\Model\Resource\Indexer\Stock\Configurable', - 'Magento\ConfigurableProduct\Model\Resource\Indexer\Stock\Configurable' + 'Magento\ConfigurableProduct\Model\Resource\Indexer\Stock\Configurable', ], [ 'Magento\ImportExport\Model\Export\Entity\Product\Type\Configurable', - 'Magento\CatalogImportExport\Model\Export\Product\Type\Configurable' + 'Magento\CatalogImportExport\Model\Export\Product\Type\Configurable', ], [ 'Magento\ConfigurableProduct\Model\Export\Entity\Product\Type\Configurable', - 'Magento\CatalogImportExport\Model\Export\Product\Type\Configurable' + 'Magento\CatalogImportExport\Model\Export\Product\Type\Configurable', ], [ 'Magento\ImportExport\Model\Import\Entity\Product\Type\Configurable', - 'Magento\CatalogImportExport\Model\Import\Product\Type\Configurable' + 'Magento\CatalogImportExport\Model\Import\Product\Type\Configurable', ], [ 'Magento\ConfigurableProduct\Model\Import\Entity\Product\Type\Configurable', - 'Magento\CatalogImportExport\Model\Import\Product\Type\Configurable' + 'Magento\CatalogImportExport\Model\Import\Product\Type\Configurable', ], ['Magento\Sales\Block\Adminhtml\Items\Renderer\Configurable'], [ 'Magento\Catalog\Model\Resource\Product\Collection\AssociatedProduct', - 'Magento\ConfigurableProduct\Model\Resource\Product\Collection\AssociatedProduct' + 'Magento\ConfigurableProduct\Model\Resource\Product\Collection\AssociatedProduct', ], ['Magento\Catalog\Model\Resource\Product\Collection\AssociatedProductUpdater'], ['Magento\Core\Model\Image\Adapter\Config', 'Magento\Framework\Image\Adapter\Config'], @@ -2085,12 +2089,12 @@ [ 'Magento\Core\Model\LocaleInterface', 'Magento\Framework\Locale\ResolverInterface, Magento\Framework\Locale\CurrencyInterface,' . - 'Magento\Framework\Locale\FormatInterface, Magento\Framework\Stdlib\DateTime\TimezoneInterface' + 'Magento\Framework\Locale\FormatInterface, Magento\Framework\Stdlib\DateTime\TimezoneInterface', ], [ 'Magento\Core\Model\Locale', 'Magento\Framework\Locale\Resolver, Magento\Framework\Locale\Currency, Magento\Framework\Locale\Format, ' . - 'Magento\Framework\Stdlib\DateTime\Timezone, Magento\Framework\Locale\Lists' + 'Magento\Framework\Stdlib\DateTime\Timezone, Magento\Framework\Locale\Lists', ], ['Magento\Framework\Locale\Hierarchy\Config\Converter', 'Magento\Framework\App\Language\Dictionary'], ['Magento\Framework\Locale\Hierarchy\Config\FileResolver', 'Magento\Framework\App\Language\Dictionary'], @@ -2106,35 +2110,35 @@ ['Magento\Usa\Model\Shipping\Carrier\Dhl\International', 'Magento\Dhl\Model\Carrier'], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\AbstractMethod', - 'Magento\Dhl\Model\Source\Method\AbstractMethod' + 'Magento\Dhl\Model\Source\Method\AbstractMethod', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Doc', - 'Magento\Dhl\Model\Source\Method\Doc' + 'Magento\Dhl\Model\Source\Method\Doc', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Freedoc', - 'Magento\Dhl\Model\Source\Method\Freedoc' + 'Magento\Dhl\Model\Source\Method\Freedoc', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Freenondoc', - 'Magento\Dhl\Model\Source\Method\Freenondoc' + 'Magento\Dhl\Model\Source\Method\Freenondoc', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Generic', - 'Magento\Dhl\Model\Source\Method\Generic' + 'Magento\Dhl\Model\Source\Method\Generic', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Nondoc', - 'Magento\Dhl\Model\Source\Method\Nondoc' + 'Magento\Dhl\Model\Source\Method\Nondoc', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Size', - 'Magento\Dhl\Model\Source\Method\Size' + 'Magento\Dhl\Model\Source\Method\Size', ], [ 'Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Unitofmeasure', - 'Magento\Dhl\Model\Source\Method\Unitofmeasure' + 'Magento\Dhl\Model\Source\Method\Unitofmeasure', ], ['Magento\Usa\Model\Shipping\Carrier\Dhl\AbstractDhl', 'Magento\Dhl\Model\AbstractDhl'], ['Magento\Usa\Model\Shipping\Carrier\Dhl'], @@ -2154,13 +2158,13 @@ ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Method', 'Magento\Ups\Model\Config\Source\Method'], [ 'Magento\Usa\Model\Shipping\Carrier\Ups\Source\OriginShipment', - 'Magento\Ups\Model\Config\Source\OriginShipment' + 'Magento\Ups\Model\Config\Source\OriginShipment', ], ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Pickup', 'Magento\Ups\Model\Config\Source\Pickup'], ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Type', 'Magento\Ups\Model\Config\Source\Type'], [ 'Magento\Usa\Model\Shipping\Carrier\Ups\Source\Unitofmeasure', - 'Magento\Ups\Model\Config\Source\Unitofmeasure' + 'Magento\Ups\Model\Config\Source\Unitofmeasure', ], ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Container', 'Magento\Usps\Model\Source\Container'], ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Freemethod', 'Magento\Usps\Model\Source\Freemethod'], @@ -2174,15 +2178,15 @@ ['Magento\Usa\Model\Simplexml\Element', 'Magento\Shipping\Model\Simplexml\Element'], [ 'Magento\Usa\Model\Shipping\Carrier\AbstractCarrier', - 'Magento\Shipping\Model\Carrier\AbstractCarrierOnline' + 'Magento\Shipping\Model\Carrier\AbstractCarrierOnline', ], [ 'Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Mode', - 'Magento\Shipping\Model\Config\Source\Online\Mode' + 'Magento\Shipping\Model\Config\Source\Online\Mode', ], [ 'Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Requesttype', - 'Magento\Shipping\Model\Config\Source\Online\Requesttype' + 'Magento\Shipping\Model\Config\Source\Online\Requesttype', ], ['Magento\Catalog\Helper\Product\Url', 'Magento\Framework\Filter\Translit'], ['Magento\Catalog\Model\Product\Indexer\Price'], @@ -2192,15 +2196,15 @@ ['Magento\Indexer\Model\Processor\CacheInvalidate', 'Magento\Indexer\Model\Processor\InvalidateCache'], [ 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Reviews', - 'Magento\Review\Block\Adminhtml\Product\Edit\Tab\Reviews' + 'Magento\Review\Block\Adminhtml\Product\Edit\Tab\Reviews', ], [ 'Magento\Catalog\Controller\Adminhtml\Product\Review', - 'Magento\Review\Controller\Adminhtml\Product' + 'Magento\Review\Controller\Adminhtml\Product', ], [ 'Magento\Review\Block\Helper', - 'Magento\Review\Block\Product\ReviewRenderer' + 'Magento\Review\Block\Product\ReviewRenderer', ], [ 'Magento\LauncherInterface', @@ -2230,35 +2234,35 @@ ['Magento\Backend\Helper\Media\Js'], [ 'Magento\Core\Model\Resource\Url\Rewrite\Collection', - 'Magento\UrlRewrite\Model\Resource\UrlRewriteCollection' + 'Magento\UrlRewrite\Model\Resource\UrlRewriteCollection', ], [ 'Magento\Core\Model\Resource\Url\Rewrite', - 'Magento\UrlRewrite\Model\Resource\UrlRewrite' + 'Magento\UrlRewrite\Model\Resource\UrlRewrite', ], [ 'Magento\Core\Model\Url\Rewrite', - 'Magento\UrlRewrite\Model\UrlRewrite' + 'Magento\UrlRewrite\Model\UrlRewrite', ], [ 'Magento\Core\Model\Source\Urlrewrite\Options', - 'Magento\UrlRewrite\Model\UrlRewrite\OptionProvider' + 'Magento\UrlRewrite\Model\UrlRewrite\OptionProvider', ], [ 'Magento\Core\Model\Source\Urlrewrite\Types', - 'Magento\UrlRewrite\Model\UrlRewrite\TypeProvider' + 'Magento\UrlRewrite\Model\UrlRewrite\TypeProvider', ], [ 'Magento\Core\Helper\Url\Rewrite', - 'Magento\UrlRewrite\Helper\UrlRewrite' + 'Magento\UrlRewrite\Helper\UrlRewrite', ], [ 'Magento\Core\App\FrontController\Plugin\UrlRewrite', - 'Magento\UrlRewrite\App\FrontController\Plugin\UrlRewrite' + 'Magento\UrlRewrite\App\FrontController\Plugin\UrlRewrite', ], [ 'Magento\Core\App\Request\RewriteService', - 'Magento\UrlRewrite\App\Request\RewriteService' + 'Magento\UrlRewrite\App\Request\RewriteService', ], ['Magento\Framework\App\ConfigInterface', 'Magento\Framework\App\Config\ScopeConfigInterface'], ['Magento\Core\Model\Store\ConfigInterface', 'Magento\Framework\App\Config\ScopeConfigInterface'], @@ -2267,11 +2271,11 @@ ['Magento\Core\App\Action\Plugin\StoreCheck', 'Magento\Store\App\Action\Plugin\StoreCheck'], [ 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler', - 'Magento\Framework\App\Bootstrap' + 'Magento\Framework\App\Bootstrap', ], [ 'Magento\Core\App\FrontController\Plugin\RequestPreprocessor', - 'Magento\Store\App\FrontController\Plugin\RequestPreprocessor' + 'Magento\Store\App\FrontController\Plugin\RequestPreprocessor', ], ['Magento\Core\App\Response\Redirect', 'Magento\Store\App\Response\Redirect'], ['Magento\Core\App\Router\Base', 'Magento\Framework\App\Router\Base'], @@ -2296,7 +2300,7 @@ ['Magento\Core\Model\Store', 'Magento\Store\Model\Store'], [ 'Magento\Store\Model\Exception', - 'Magento\Framework\Exception\LocalizedException, Magento\Framework\Exception\State\InitException' + 'Magento\Framework\Exception\LocalizedException, Magento\Framework\Exception\State\InitException', ], ['Magento\Core\Model\Store\Group', 'Magento\Store\Model\Group'], ['Magento\Core\Model\Store\Group\Factory', 'Magento\Store\Model\GroupFactory'], @@ -2337,11 +2341,11 @@ ['Magento\Rating\Model\Rating', 'Magento\Review\Model\Rating'], [ 'Magento\Rating\Model\Resource\Rating\Option\Vote\Collection', - 'Magento\Review\Model\Resource\Rating\Option\Vote\Collection' + 'Magento\Review\Model\Resource\Rating\Option\Vote\Collection', ], [ 'Magento\Rating\Model\Resource\Rating\Option\Collection', - 'Magento\Review\Model\Resource\Rating\Option\Collection' + 'Magento\Review\Model\Resource\Rating\Option\Collection', ], ['Magento\Rating\Model\Resource\Rating\Grid\Collection', 'Magento\Review\Model\Resource\Rating\Grid\Collection'], ['Magento\Rating\Model\Resource\Rating\Collection', 'Magento\Review\Model\Resource\Rating\Collection'], @@ -2365,7 +2369,7 @@ ['Magento\Checkout\Block\Adminhtml\Agreement\Edit', 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit'], [ 'Magento\Checkout\Block\Adminhtml\Agreement\Edit\Form', - 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit\Form' + 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit\Form', ], ['Magento\Checkout\Block\Adminhtml\Agreement\Grid', 'Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Grid'], ['Magento\Checkout\Block\Agreements', 'Magento\CheckoutAgreements\Block\Agreements'], @@ -2373,7 +2377,7 @@ ['Magento\Checkout\Model\Resource\Agreement', 'Magento\CheckoutAgreements\Model\Resource\Agreement'], [ 'Magento\Checkout\Model\Resource\Agreement\Collection', - 'Magento\CheckoutAgreements\Model\Resource\Agreement\Collection' + 'Magento\CheckoutAgreements\Model\Resource\Agreement\Collection', ], ['Magento\Sales\Block\Adminhtml\Invoice\Grid'], ['Magento\Sales\Block\Adminhtml\Shipment\Grid'], @@ -2383,7 +2387,7 @@ ['Magento\Catalog\Model\PriceCurrency'], [ 'Magento\Framework\App\FrontController\Plugin\Clickjacking', - 'X-Frame-Options HTTP header setting moved to server configuration' + 'X-Frame-Options HTTP header setting moved to server configuration', ], ['Magento\Backend\Model\Translate\Inline', 'Magento\Framework\Translate\Inline'], ['Magento\Backend\Model\Resource\Translate', 'Magento\Translation\Model\Resource\Translate'], @@ -2404,7 +2408,7 @@ ['Magento\Backup\Filesystem\Iterator\Filter', 'Magento\Framework\Backup\Filesystem\Iterator\Filter'], [ 'Magento\Backup\Filesystem\Rollback\AbstractRollback', - 'Magento\Framework\Backup\Filesystem\Rollback\AbstractRollback' + 'Magento\Framework\Backup\Filesystem\Rollback\AbstractRollback', ], ['Magento\Backup\Filesystem\Rollback\Fs', 'Magento\Framework\Backup\Filesystem\Rollback\Fs'], ['Magento\Backup\Filesystem\Rollback\Ftp', 'Magento\Framework\Backup\Filesystem\Rollback\Ftp'], @@ -2436,69 +2440,69 @@ ['Magento\Pear', 'Magento\Framework\Pear'], [ 'Magento\ImportExport\Model\Export\Product\Type\AbstractType', - 'Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType' + 'Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType', ], [ 'Magento\ImportExport\Model\Export\Product\Type\Factory', - 'Magento\CatalogImportExport\Model\Export\Product\Type\Factory' + 'Magento\CatalogImportExport\Model\Export\Product\Type\Factory', ], [ 'Magento\ImportExport\Model\Export\Product\Type\Simple', - 'Magento\CatalogImportExport\Model\Export\Product\Type\Simple' + 'Magento\CatalogImportExport\Model\Export\Product\Type\Simple', ], ['Magento\ImportExport\Model\Export\Product', 'Magento\CatalogImportExport\Model\Export\Product'], [ 'Magento\ImportExport\Model\Export\RowCustomizer\Composite', - 'Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite' + 'Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite', ], [ 'Magento\ImportExport\Model\Export\RowCustomizerInterface', - 'Magento\CatalogImportExport\Model\Export\RowCustomizerInterface' + 'Magento\CatalogImportExport\Model\Export\RowCustomizerInterface', ], [ 'Magento\ImportExport\Model\Import\Product\Type\AbstractType', - 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType' + 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType', ], [ 'Magento\ImportExport\Model\Import\Product\Type\Factory', - 'Magento\CatalogImportExport\Model\Import\Product\Type\Factory' + 'Magento\CatalogImportExport\Model\Import\Product\Type\Factory', ], [ 'Magento\ImportExport\Model\Import\Product\Type\Simple', - 'Magento\CatalogImportExport\Model\Import\Product\Type\Simple' + 'Magento\CatalogImportExport\Model\Import\Product\Type\Simple', ], [ 'Magento\ImportExport\Model\Import\Product\Option', - 'Magento\CatalogImportExport\Model\Import\Product\Option' + 'Magento\CatalogImportExport\Model\Import\Product\Option', ], ['Magento\ImportExport\Model\Import\Product', 'Magento\CatalogImportExport\Model\Import\Product'], [ 'Magento\ImportExport\Model\Import\Proxy\Product', - 'Magento\CatalogImportExport\Model\Import\Proxy\Product' + 'Magento\CatalogImportExport\Model\Import\Proxy\Product', ], [ 'Magento\ImportExport\Model\Import\Proxy\Product\Resource', - 'Magento\CatalogImportExport\Model\Import\Proxy\Product\Resource' + 'Magento\CatalogImportExport\Model\Import\Proxy\Product\Resource', ], [ 'Magento\ImportExport\Model\Import\Uploader', - 'Magento\CatalogImportExport\Model\Import\Uploader' + 'Magento\CatalogImportExport\Model\Import\Uploader', ], [ 'Magento\ImportExport\Model\Export\Entity\Customer\Finance', - 'Magento\CustomerFinance\Model\Export\Customer\Finance' + 'Magento\CustomerFinance\Model\Export\Customer\Finance', ], [ 'Magento\ImportExport\Model\Import\Entity\Eav\Customer\Finance', - 'Magento\CustomerFinance\Model\Import\Entity\Eav\Customer\Finance' + 'Magento\CustomerFinance\Model\Import\Entity\Eav\Customer\Finance', ], [ 'Magento\ImportExport\Model\Resource\Customer\Attribute\Finance\Collection', - 'Magento\CustomerFinance\Model\Resource\Customer\Attribute\Finance\Collection' + 'Magento\CustomerFinance\Model\Resource\Customer\Attribute\Finance\Collection', ], [ 'Magento\ImportExport\Model\Resource\Customer\Collection', - 'Magento\CustomerFinance\Model\Resource\Customer\Collection' + 'Magento\CustomerFinance\Model\Resource\Customer\Collection', ], ['Magento\Profiler', 'Magento\Framework\Profiler'], ['Magento\Shell', 'Magento\Framework\Shell'], @@ -2524,23 +2528,23 @@ ['Magento\Checkout\Helper\Url'], [ 'Magento\Customer\Service\V1\CustomerCurrentService', - 'Magento\Customer\Helper\Session\CurrentCustomer' + 'Magento\Customer\Helper\Session\CurrentCustomer', ], [ 'Magento\Customer\Service\V1\CustomerCurrentServiceInterface', - 'Magento\Customer\Helper\Session\CurrentCustomer' + 'Magento\Customer\Helper\Session\CurrentCustomer', ], [ 'Magento\Customer\Service\V1\CustomerAddressCurrentService', - 'Magento\Customer\Helper\Session\CurrentCustomerAddress' + 'Magento\Customer\Helper\Session\CurrentCustomerAddress', ], [ 'Magento\Customer\Service\V1\CustomerAddressCurrentServiceInterface', - 'Magento\Customer\Helper\Session\CurrentCustomerAddress' + 'Magento\Customer\Helper\Session\CurrentCustomerAddress', ], [ 'Magento\SalesArchive\Block\Adminhtml\Sales\Order\Grid\Button', - 'Magento\SalesArchive\Block\Adminhtml\Sales\Order\Grid' + 'Magento\SalesArchive\Block\Adminhtml\Sales\Order\Grid', ], ['Magento\OfflinePayments\Block\Form\Ccsave'], ['Magento\OfflinePayments\Block\Info\Ccsave'], @@ -2554,22 +2558,22 @@ ['Magento\Less\File\Source\Theme', 'Magento\Framework\View\File\Collector\ThemeModular'], [ 'Magento\Framework\View\Layout\File\FileList\CollateInterface', - 'Magento\Framework\View\File\FileList\CollateInterface' + 'Magento\Framework\View\File\FileList\CollateInterface', ], ['Magento\Framework\View\Layout\File\FileList\Collator', 'Magento\Framework\View\File\FileList\Collator'], ['Magento\Framework\View\Layout\File\FileList\Factory', 'Magento\Framework\View\File\FileList\Factory'], [ 'Magento\Framework\View\Layout\File\Source\Decorator\ModuleDependency', - 'Magento\Framework\View\File\Collector\Decorator\ModuleDependency' + 'Magento\Framework\View\File\Collector\Decorator\ModuleDependency', ], [ 'Magento\Framework\View\Layout\File\Source\Decorator\ModuleOutput', - 'Magento\Framework\View\File\Collector\Decorator\ModuleOutput' + 'Magento\Framework\View\File\Collector\Decorator\ModuleOutput', ], ['Magento\Framework\View\Layout\File\Source\Override\Base', 'Magento\Framework\View\File\Collector\Override\Base'], [ 'Magento\Framework\View\Layout\File\Source\Override\Theme', - 'Magento\Framework\View\File\Collector\Override\ThemeModular' + 'Magento\Framework\View\File\Collector\Override\ThemeModular', ], ['Magento\Framework\View\Layout\File\Source\Base', 'Magento\Framework\View\File\Collector\Base'], ['Magento\Framework\View\Layout\File\Source\Theme', 'Magento\Framework\View\File\Collector\ThemeModular'], @@ -2582,7 +2586,7 @@ ['Magento\Framework\View\Url\Resolver', 'Magento\Framework\View\Asset\Repository'], [ 'Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Css\Group', - 'Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Css' + 'Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Css', ], ['Magento\Framework\Filter\GridArray\Grid'], ['Magento\Css\PreProcessor\Composite'], @@ -2598,7 +2602,7 @@ ['Magento\Framework\View\Asset\PreProcessor\Composite'], [ 'Magento\Framework\View\Asset\PreProcessor\PreProcessorInterface', - 'Magento\Framework\View\Asset\PreProcessorInterface' + 'Magento\Framework\View\Asset\PreProcessorInterface', ], ['Magento\Framework\View\Publisher', '\Magento\Framework\App\View\Asset\Publisher'], ['Magento\Framework\View\Publisher\FileAbstract'], @@ -2619,43 +2623,43 @@ ['Magento\Framework\View\Design\FileResolution\Strategy\ViewInterface'], [ 'Magento\ImportExport\Model\Import\Entity\Product', - 'Magento\CatalogImportExport\Model\Import\Product' + 'Magento\CatalogImportExport\Model\Import\Product', ], [ 'Magento\ImportExport\Model\Import\Entity\Product\Option', - 'Magento\CatalogImportExport\Model\Import\Product\Option' + 'Magento\CatalogImportExport\Model\Import\Product\Option', ], [ 'Magento\ImportExport\Model\Import\Entity\Product\Type\AbstractType', - 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType' + 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType', ], [ 'Magento\ImportExport\Model\Import\Entity\Product\Type\Factory', - 'Magento\CatalogImportExport\Model\Import\Product\Type\Factory' + 'Magento\CatalogImportExport\Model\Import\Product\Type\Factory', ], [ 'Magento\ImportExport\Model\Import\Entity\Product\Type\Simple', - 'Magento\CatalogImportExport\Model\Import\Product\Type\Simple' + 'Magento\CatalogImportExport\Model\Import\Product\Type\Simple', ], [ 'Magento\ImportExport\Model\Export\Entity\Product', - 'Magento\CatalogImportExport\Model\Export\Product' + 'Magento\CatalogImportExport\Model\Export\Product', ], [ 'Magento\ImportExport\Model\Export\Entity\Product\Type\AbstractType', - 'Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType' + 'Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType', ], [ 'Magento\ImportExport\Model\Export\Entity\Product\Type\Factory', - 'Magento\CatalogImportExport\Model\Export\Product\Type\Factory' + 'Magento\CatalogImportExport\Model\Export\Product\Type\Factory', ], [ 'Magento\ImportExport\Model\Export\Entity\Product\Type\Simple', - 'Magento\CatalogImportExport\Model\Export\Product\Type\Simple' + 'Magento\CatalogImportExport\Model\Export\Product\Type\Simple', ], [ 'Magento\Bundle\Pricing\Price\BasePrice', - 'Magento\Catalog\Pricing\Price\BasePrice' + 'Magento\Catalog\Pricing\Price\BasePrice', ], ['Magento\Cataloginventory\Model\Resource\Indexer\Stock'], ['Magento\Catalog\Model\Product\Indexer\Eav'], @@ -2687,49 +2691,49 @@ ['Magento\AdminNotification\Model\System\MessageList', 'Magento\Framework\Notification\MessageList'], [ 'Magento\CatalogImportExport\Model\Import\Product\Type\Configurable', - 'Magento\ConfigurableImportExport\Model\Import\Product\Type\Configurable' + 'Magento\ConfigurableImportExport\Model\Import\Product\Type\Configurable', ], [ 'Magento\CatalogImportExport\Model\Export\Product\Type\Configurable', - 'Magento\ConfigurableImportExport\Model\Export\Product\Type\Configurable' + 'Magento\ConfigurableImportExport\Model\Export\Product\Type\Configurable', ], [ 'Magento\CatalogImportExport\Model\Export\RowCustomizer', - 'Magento\ConfigurableImportExport\Model\Export\RowCustomizer' + 'Magento\ConfigurableImportExport\Model\Export\RowCustomizer', ], [ 'Magento\CatalogImportExport\Model\Export\Product\Type\Grouped', - 'Magento\GroupedImportExport\Model\Export\Product\Type\Grouped' + 'Magento\GroupedImportExport\Model\Export\Product\Type\Grouped', ], [ 'Magento\CatalogImportExport\Model\Import\Product\Type\Grouped', - 'Magento\GroupedImportExport\Model\Import\Product\Type\Grouped' + 'Magento\GroupedImportExport\Model\Import\Product\Type\Grouped', ], ['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\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\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\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\TaxImportExport\Controller\Adminhtml\Rate\ImportExport', ], [ 'Magento\Tax\Controller\Adminhtml\Rate\ImportPost', - 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ImportPost' + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ImportPost', ], ['Magento\Tax\Model\Rate\CsvImportHandler', 'Magento\TaxImportExport\Model\Rate\CsvImportHandler'], ['\Magento\Theme\Helper\Layout'], @@ -2774,11 +2778,11 @@ ['\Magento\Framework\Api\AbstractObject', 'Magento\Framework\Api\AbstractSimpleObject'], [ '\Magento\Framework\Api\Eav\AbstractObjectBuilder', - 'Magento\Framework\Api\ExtensibleObjectBuilder' + 'Magento\Framework\Api\ExtensibleObjectBuilder', ], [ '\Magento\Framework\Api\AbstractObjectBuilder', - 'Magento\Framework\Api\AbstractSimpleObjectBuilder' + 'Magento\Framework\Api\AbstractSimpleObjectBuilder', ], ['Magento\Catalog\Block\Product'], ['\Magento\Sales\Model\Observer'], @@ -2850,7 +2854,7 @@ ['Magento\Tax\Service\V1\Data\TaxRateTitleBuilder', 'Magento\Tax\Api\Data\TaxRateTitleDataBuilder'], [ 'Magento\Tax\Service\V1\Data\TaxRateSearchResultsBuilder', - 'Magento\Tax\Api\Data\TaxRateSearchResultsDataBuilder' + 'Magento\Tax\Api\Data\TaxRateSearchResultsDataBuilder', ], ['Magento\Tax\Service\V1\Data\TaxRateSearchResults', 'Magento\Tax\Api\Data\TaxRateSearchResultsInterface'], ['Magento\Tax\Service\V1\Data\TaxRateBuilder', 'Magento\Tax\Api\Data\TaxRateDataBuilder'], @@ -2865,7 +2869,7 @@ ['Magento\Tax\Service\V1\Data\OrderTaxDetails', 'Magento\Tax\Api\Data\OrderTaxDetailsInterface'], [ 'Magento\Tax\Service\V1\Data\OrderTaxDetails\AppliedTax', - 'Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface' + 'Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface', ], ['Magento\Tax\Service\V1\Data\OrderTaxDetails\Item', 'Magento\Tax\Api\Data\OrderTaxDetailsItemInterface'], ['Magento\Tax\Service\V1\Data\QuoteDetails', 'Magento\Tax\Api\Data\QuoteDetailsInterface'], @@ -2895,23 +2899,23 @@ ['Magento\Bundle\Service\V1\Data\Product\Option', 'Magento\Bundle\Api\Data\OptionInterface'], [ 'Magento\Bundle\Service\V1\Product\Link\ReadServiceInterface', - 'Magento\Bundle\Api\ProductLinkManagementInterface' + 'Magento\Bundle\Api\ProductLinkManagementInterface', ], [ 'Magento\Bundle\Service\V1\Product\Link\WriteServiceInterface', - 'Magento\Bundle\Api\ProductLinkManagementInterface' + 'Magento\Bundle\Api\ProductLinkManagementInterface', ], [ 'Magento\Bundle\Service\V1\Product\Option\ReadServiceInterface', - 'Magento\Bundle\Api\ProductOptionRepositoryInterface' + 'Magento\Bundle\Api\ProductOptionRepositoryInterface', ], [ 'Magento\Bundle\Service\V1\Product\Option\WriteServiceInterface', - 'Magento\Bundle\Api\ProductOptionRepositoryInterface' + 'Magento\Bundle\Api\ProductOptionRepositoryInterface', ], [ 'Magento\Bundle\Service\V1\Product\Option\Type\ReadServiceInterface', - 'Magento\Bundle\Api\ProductOptionTypeListInterface' + 'Magento\Bundle\Api\ProductOptionTypeListInterface', ], ['Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader'], ['Magento\Sales\Model\Resource\AbstractResource', 'Magento\Framework\Model\Resource\Db\AbstractDb'], @@ -2925,11 +2929,11 @@ ['Magento\CatalogRule\Plugin\Indexer\Product\PriceIndexerTest'], [ 'Magento\Framework\Interception\ObjectManager\Compiled\Config', - 'Magento\Framework\Interception\ObjectManager\Config\Compiled' + 'Magento\Framework\Interception\ObjectManager\Config\Compiled', ], [ 'Magento\Framework\Interception\ObjectManager\Config', - 'Magento\Framework\Interception\ObjectManager\Config\Developer' + 'Magento\Framework\Interception\ObjectManager\Config\Developer', ], ['Magento\Core\Model\Design', 'Magento\Theme\Model\Design'], ['Magento\Core\Model\Resource\Design', 'Magento\Theme\Model\Resource\Design'], @@ -2940,7 +2944,7 @@ ['Magento\Core\Model\Resource\Theme', 'Magento\Theme\Model\Resource\Theme'], [ 'Magento\Core\Model\Resource\Theme\Customization\Update', - 'Magento\Theme\Model\Resource\Theme\Customization\Update' + 'Magento\Theme\Model\Resource\Theme\Customization\Update', ], ['Magento\Core\Model\Resource\Theme\Data\Collection', 'Magento\Theme\Model\Resource\Theme\Data\Collection'], ['Magento\Core\Model\Resource\Theme\File\Collection', 'Magento\Theme\Model\Resource\Theme\File\Collection'], @@ -2953,7 +2957,7 @@ ['Magento\Cms\Model\Resource\Page\Service'], [ 'Magento\Core\Model\TemplateEngine\Decorator\DebugHints', - 'Magento\Developer\Model\TemplateEngine\Decorator\DebugHints' + 'Magento\Developer\Model\TemplateEngine\Decorator\DebugHints', ], ['Magento\Directory\Helper\Url'], ['Magento\GiftMessage\Helper\Url'], @@ -2986,9 +2990,19 @@ ['Magento\Core\Model\Validator\Factory', 'Magento\Framework\Validator\Factory'], ['Magento\Sendfriend\Model\Observer'], ['Magento\Tools\Di\Compiler\Directory'], + ['Magento\Bundle\CustomerData\BundleItem'], + ['Magento\Catalog\Block\Product\Compare\AbstractCompare'], + ['Magento\Catalog\Block\Product\Compare\Link'], + ['Magento\Catalog\Block\Product\Compare\Sidebar'], + ['Magento\Checkout\Block\Cart\Sidebar\Totals'], + ['Magento\Checkout\Block\Cart\EmptyCart'], + ['Magento\Customer\Block\Account\Dashboard\Block'], + ['Magento\Customer\Block\Account\Dashboard\Newsletter'], + ['Magento\Customer\Block\Account\Dashboard\Sidebar'], + ['Magento\Tax\Block\Checkout\Cart\Sidebar\Totals'], [ 'Magento\Core\Model\TemplateEngine\Plugin\DebugHints', - 'Magento\Developer\Model\TemplateEngine\Plugin\DebugHints' + 'Magento\Developer\Model\TemplateEngine\Plugin\DebugHints', ], ['Magento\Backend\Model\Config\Backend\Cookie', 'Magento\Cookie\Model\Config\Backend\Cookie'], ['Magento\Backend\Model\Config\Backend\Cookie\Domain', 'Magento\Cookie\Model\Config\Backend\Domain'], @@ -3030,39 +3044,39 @@ ['Magento\Webapi\Model\Soap\Wsdl\Factory', 'Magento\Webapi\Model\Soap\WsdlFactory'], [ 'Magento\Webapi\Controller\Rest\Request\Deserializer\Json', - 'Magento\Framework\Webapi\Rest\Request\Deserializer\Json' + 'Magento\Framework\Webapi\Rest\Request\Deserializer\Json', ], [ 'Magento\Webapi\Controller\Rest\Request\Deserializer\Xml', - 'Magento\Framework\Webapi\Rest\Request\Deserializer\Xml' + 'Magento\Framework\Webapi\Rest\Request\Deserializer\Xml', ], [ 'Magento\Webapi\Controller\Rest\Request\Deserializer\Factory', - 'Magento\Framework\Webapi\Rest\Request\DeserializerFactory' + 'Magento\Framework\Webapi\Rest\Request\DeserializerFactory', ], [ 'Magento\Webapi\Controller\Rest\Request\DeserializerInterface', - 'Magento\Framework\Webapi\Rest\Request\DeserializerInterface' + 'Magento\Framework\Webapi\Rest\Request\DeserializerInterface', ], [ 'Magento\Webapi\Controller\Rest\Response\Renderer\Json', - 'Magento\Framework\Webapi\Rest\Response\Renderer\Json' + 'Magento\Framework\Webapi\Rest\Response\Renderer\Json', ], [ 'Magento\Webapi\Controller\Rest\Response\Renderer\Xml', - 'Magento\Framework\Webapi\Rest\Response\Renderer\Xml' + 'Magento\Framework\Webapi\Rest\Response\Renderer\Xml', ], [ 'Magento\Webapi\Controller\Rest\Response\PartialResponseProcessor', - 'Magento\Framework\Webapi\Rest\Response\FieldsFilter' + 'Magento\Framework\Webapi\Rest\Response\FieldsFilter', ], [ 'Magento\Webapi\Controller\Rest\Response\Renderer\Factory', - 'Magento\Framework\Webapi\Rest\Response\RendererFactory' + 'Magento\Framework\Webapi\Rest\Response\RendererFactory', ], [ 'Magento\Webapi\Controller\Rest\Response\RendererInterface', - 'Magento\Framework\Webapi\Rest\Response\RendererInterface' + 'Magento\Framework\Webapi\Rest\Response\RendererInterface', ], ['Magento\Webapi\Controller\Rest\Request', 'Magento\Framework\Webapi\Rest\Request'], ['Magento\Webapi\Controller\Rest\Response', 'Magento\Framework\Webapi\Rest\Response'], @@ -3076,7 +3090,7 @@ ['Magento\Webapi\Model\Config\Integration\Reader', 'Magento\Integration\Model\Config\Integration\Reader'], [ 'Magento\Webapi\Model\Config\Integration\SchemaLocator', - 'Magento\Integration\Model\Config\Integration\SchemaLocator' + 'Magento\Integration\Model\Config\Integration\SchemaLocator', ], ['Magento\Webapi\Model\IntegrationConfig', 'Magento\Integration\Model\IntegrationConfig'], ['Magento\Webapi\Model\Plugin\Service\V1\Integration', 'Magento\Integration\Model\Plugin\Service\V1\Integration'], @@ -3151,7 +3165,7 @@ ['Magento\CatalogRule\CatalogRuleException'], ['Magento\Payment\Exception'], ['Magento\UrlRewrite\Model\Storage\DuplicateEntryException'], - ['Magento\Setup\Mvc\Console\RouteListener'], + ['Magento\Framework\View\Element\UiComponent\Config\Manager'], ['Magento\Setup\Mvc\Console\RouteMatcher'], ['Magento\Setup\Mvc\Console\VerboseValidator'], ['Magento\Setup\Controller\ConsoleController'], @@ -3161,6 +3175,11 @@ ['Magento\Framework\Exception\File\ValidatorException'], ['Magento\Framework\Filesystem\FilesystemException', 'Magento\Framework\Exception\FileSystemException'], ['Magento\Shipping\Exception'], + ['Magento\Tax\Model\Resource\Sales\Order\Tax\Item\Collection'], + ['Magento\Tax\Model\Resource\Sales\Order\Tax\Item', 'Magento\Sales\Model\Resource\Order\Tax\Item'], + ['Magento\Tax\Model\Sales\Order\Tax\Item', 'Magento\Sales\Model\Order\Tax\Item'], + ['Magento\Reports\Block\Adminhtml\Product\Grid'], + ['Magento\Reports\Model\Totals'], ['Magento\Log\Model\Shell'], ['Magento\Log\App\Shell'], ['Magento\Framework\App\Cache\ManagerApp'], @@ -3172,18 +3191,18 @@ ['Magento\Tools\I18n\Dictionary\Generator', 'Magento\Setup\Module\I18n\Dictionary\Generator'], [ 'Magento\Tools\I18n\Dictionary\Loader\File\AbstractFile', - 'Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile' + 'Magento\Setup\Module\I18n\Dictionary\Loader\File\AbstractFile', ], ['Magento\Tools\I18n\Dictionary\Loader\File\Csv', 'Magento\Setup\Module\I18n\Dictionary\Loader\File\Csv'], ['Magento\Tools\I18n\Dictionary\Loader\FileInterface', 'Magento\Setup\Module\I18n\Dictionary\Loader\FileInterface'], ['Magento\Tools\I18n\Dictionary\Options\Resolver', 'Magento\Setup\Module\I18n\Dictionary\Options\Resolver'], [ 'Magento\Tools\I18n\Dictionary\Options\ResolverFactory', - 'Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory' + 'Magento\Setup\Module\I18n\Dictionary\Options\ResolverFactory', ], [ 'Magento\Tools\I18n\Dictionary\Options\ResolverInterface', - 'Magento\Setup\Module\I18n\Dictionary\Options\ResolverInterface' + 'Magento\Setup\Module\I18n\Dictionary\Options\ResolverInterface', ], ['Magento\Tools\I18n\Dictionary\Phrase', 'Magento\Setup\Module\I18n\Dictionary\Phrase'], ['Magento\Tools\I18n\Dictionary\Writer\Csv\Stdo', 'Magento\Setup\Module\I18n\Dictionary\Writer\Csv\Stdo'], @@ -3202,19 +3221,19 @@ ['Magento\Tools\I18n\Parser\Adapter\Js', 'Magento\Setup\Module\I18n\Parser\Adapter\Js'], [ 'Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector', - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector' + 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector', ], [ 'Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\Token', - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Token' + 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Token', ], [ 'Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\Translate', - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate' + 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate', ], [ 'Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector', - 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector' + 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector', ], ['Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer', 'Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer'], ['Magento\Tools\I18n\Parser\Adapter\Php', 'Magento\Setup\Module\I18n\Parser\Adapter\Php'], @@ -3227,24 +3246,24 @@ ['Magento\Tools\Di\App\Task\Manager', 'Magento\Setup\Module\Di\App\Task\Manager'], [ 'Magento\Tools\Di\App\Task\Operation\ApplicationCodeGenerator', - 'Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator' + 'Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator', ], ['Magento\Tools\Di\App\Task\Operation\Area', 'Magento\Setup\Module\Di\App\Task\Operation\Area'], ['Magento\Tools\Di\App\Task\Operation\Interception', 'Magento\Setup\Module\Di\App\Task\Operation\Interception'], [ 'Magento\Tools\Di\App\Task\Operation\InterceptionCache', - 'Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache' + 'Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache', ], [ 'Magento\Tools\Di\App\Task\Operation\RepositoryGenerator', - 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator' + 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator', ], ['Magento\Tools\Di\App\Task\OperationException', 'Magento\Setup\Module\Di\App\Task\OperationException'], ['Magento\Tools\Di\App\Task\OperationFactory', 'Magento\Setup\Module\Di\App\Task\OperationFactory'], ['Magento\Tools\Di\App\Task\OperationInterface', 'Magento\Setup\Module\Di\App\Task\OperationInterface'], [ 'Magento\Tools\Di\Code\Generator\InterceptionConfigurationBuilder', - 'Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder' + 'Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder', ], ['Magento\Tools\Di\Code\Generator\Interceptor', 'Magento\Setup\Module\Di\Code\Generator\Interceptor'], ['Magento\Tools\Di\Code\Generator\PluginList', 'Magento\Setup\Module\Di\Code\Generator\PluginList'], @@ -3253,14 +3272,14 @@ ['Magento\Tools\Di\Code\Reader\ClassesScanner', 'Magento\Setup\Module\Di\Code\Reader\ClassesScanner'], [ 'Magento\Tools\Di\Code\Reader\ClassesScannerInterface', - 'Magento\Setup\Module\Di\Code\Reader\ClassesScannerInterface' + 'Magento\Setup\Module\Di\Code\Reader\ClassesScannerInterface', ], ['Magento\Tools\Di\Code\Reader\ClassReaderDecorator', 'Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator'], ['Magento\Tools\Di\Code\Reader\Decorator\Area', 'Magento\Setup\Module\Di\Code\Reader\Decorator\Area'], ['Magento\Tools\Di\Code\Reader\Decorator\Directory', 'Magento\Setup\Module\Di\Code\Reader\Decorator\Directory'], [ 'Magento\Tools\Di\Code\Reader\Decorator\Interceptions', - 'Magento\Setup\Module\Di\Code\Reader\Decorator\Interceptions' + 'Magento\Setup\Module\Di\Code\Reader\Decorator\Interceptions', ], ['Magento\Tools\Di\Code\Reader\Type', 'Magento\Setup\Module\Di\Code\Reader\Type'], ['Magento\Tools\Di\Code\Scanner\ArrayScanner', 'Magento\Setup\Module\Di\Code\Scanner\ArrayScanner'], @@ -3268,11 +3287,11 @@ ['Magento\Tools\Di\Code\Scanner\DirectoryScanner', 'Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner'], [ 'Magento\Tools\Di\Code\Scanner\InheritanceInterceptorScanner', - 'Magento\Setup\Module\Di\Code\Scanner\InheritanceInterceptorScanner' + 'Magento\Setup\Module\Di\Code\Scanner\InheritanceInterceptorScanner', ], [ 'Magento\Tools\Di\Code\Scanner\InterceptedInstancesScanner', - 'Magento\Setup\Module\Di\Code\Scanner\InterceptedInstancesScanner' + 'Magento\Setup\Module\Di\Code\Scanner\InterceptedInstancesScanner', ], ['Magento\Tools\Di\Code\Scanner\PhpScanner', 'Magento\Setup\Module\Di\Code\Scanner\PhpScanner'], ['Magento\Tools\Di\Code\Scanner\PluginScanner', 'Magento\Setup\Module\Di\Code\Scanner\PluginScanner'], @@ -3280,34 +3299,34 @@ ['Magento\Tools\Di\Code\Scanner\ScannerInterface', 'Magento\Setup\Module\Di\Code\Scanner\ScannerInterface'], [ 'Magento\Tools\Di\Code\Scanner\XmlInterceptorScanner', - 'Magento\Setup\Module\Di\Code\Scanner\XmlInterceptorScanner' + 'Magento\Setup\Module\Di\Code\Scanner\XmlInterceptorScanner', ], ['Magento\Tools\Di\Code\Scanner\XmlScanner', 'Magento\Setup\Module\Di\Code\Scanner\XmlScanner'], ['Magento\Tools\Di\Compiler\ArgumentsResolver', 'Magento\Setup\Module\Di\Compiler\ArgumentsResolver'], ['Magento\Tools\Di\Compiler\ArgumentsResolverFactory', 'Magento\Setup\Module\Di\Compiler\ArgumentsResolverFactory'], [ 'Magento\Tools\Di\Compiler\Config\Chain\ArgumentsSerialization', - 'Magento\Setup\Module\Di\Compiler\Config\Chain\ArgumentsSerialization' + 'Magento\Setup\Module\Di\Compiler\Config\Chain\ArgumentsSerialization', ], [ 'Magento\Tools\Di\Compiler\Config\Chain\BackslashTrim', - 'Magento\Setup\Module\Di\Compiler\Config\Chain\BackslashTrim' + 'Magento\Setup\Module\Di\Compiler\Config\Chain\BackslashTrim', ], [ 'Magento\Tools\Di\Compiler\Config\Chain\InterceptorSubstitution', - 'Magento\Setup\Module\Di\Compiler\Config\Chain\InterceptorSubstitution' + 'Magento\Setup\Module\Di\Compiler\Config\Chain\InterceptorSubstitution', ], [ 'Magento\Tools\Di\Compiler\Config\Chain\PreferencesResolving', - 'Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving' + 'Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving', ], [ 'Magento\Tools\Di\Compiler\Config\ModificationChain', - 'Magento\Setup\Module\Di\Compiler\Config\ModificationChain' + 'Magento\Setup\Module\Di\Compiler\Config\ModificationChain', ], [ 'Magento\Tools\Di\Compiler\Config\ModificationInterface', - 'Magento\Setup\Module\Di\Compiler\Config\ModificationInterface' + 'Magento\Setup\Module\Di\Compiler\Config\ModificationInterface', ], ['Magento\Tools\Di\Compiler\Config\Reader', 'Magento\Setup\Module\Di\Compiler\Config\Reader'], ['Magento\Tools\Di\Compiler\Config\Writer\Filesystem', 'Magento\Setup\Module\Di\Compiler\Config\Writer\Filesystem'], @@ -3321,7 +3340,7 @@ ['Magento\Tools\Di\Definition\Serializer\Igbinary', 'Magento\Setup\Module\Di\Definition\Serializer\Igbinary'], [ 'Magento\Tools\Di\Definition\Serializer\SerializerInterface', - 'Magento\Setup\Module\Di\Definition\Serializer\SerializerInterface' + 'Magento\Setup\Module\Di\Definition\Serializer\SerializerInterface', ], ['Magento\Tools\Di\Definition\Serializer\Standard', 'Magento\Setup\Module\Di\Definition\Serializer\Standard'], ['Magento\Tools\Di\Compiler\Log\Writer\Quiet'], @@ -3334,4 +3353,294 @@ ['Magento\Log\Model\LogFactory\Clean'], ['Magento\Log\Model\Shell\CommandInterface'], ['Magento\Framework\App\Filesystem\DirectoryList\AbstractShell'], + [ + 'Magento\Integration\Service\V1\AdminTokenServiceInterface', + 'Magento\Integration\Api\AdminTokenServiceInterface', + ], + [ + 'Magento\Integration\Service\V1\AuthorizationServiceInterface', + 'Magento\Integration\Api\AuthorizationServiceInterface', + ], + [ + 'Magento\Integration\Service\V1\CustomerTokenServiceInterface', + 'Magento\Integration\Api\CustomerTokenServiceInterface', + ], + ['Magento\Integration\Service\V1\IntegrationInterface', 'Magento\Integration\Api\IntegrationServiceInterface'], + ['Magento\Integration\Service\V1\OauthInterface', 'Magento\Integration\Api\OauthServiceInterface'], + ['Magento\Integration\Service\V1\AdminTokenService', 'Magento\Integration\Model\AdminTokenService'], + ['Magento\Integration\Service\V1\AuthorizationService', 'Magento\Integration\Model\AuthorizationService'], + ['Magento\Integration\Service\V1\CustomerTokenService', 'Magento\Integration\Model\CustomerTokenService'], + ['Magento\Integration\Service\V1\Integration', 'Magento\Integration\Model\IntegrationService'], + ['Magento\Integration\Service\V1\Oauth', 'Magento\Integration\Model\OauthService'], + ['Magento\Integration\Model\Plugin\Service\V1\Integration', 'Magento\Integration\Model\Plugin\Integration'], + ['Magento\Search\Model\Resource\Helper'], + ['Magento\Tools\Layout\Reference'], + ['Magento\Tools\Layout\Formatter', 'Magento\Developer\Model\Tools\Formatter'], + ['Magento\Tools\Dependency\Circular', 'Magento\Setup\Module\Dependency\Circular'], + ['Magento\Tools\Dependency\Parser\Code', 'Magento\Setup\Module\Dependency\Parser\Code'], + ['Magento\Tools\Dependency\Parser\Composer\Json', 'Magento\Setup\Module\Dependency\Composer\Json'], + ['Magento\Tools\Dependency\Parser\Config\Xml', 'Magento\Setup\Module\Dependency\Config\Xml'], + ['Magento\Tools\Dependency\ParserInterface', 'Magento\Setup\Module\Dependency\ParserInterface'], + [ + 'Magento\Tools\Dependency\Report\Builder\AbstractBuilder', + 'Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder', + ], + ['Magento\Tools\Dependency\Report\BuilderInterface', 'Magento\Setup\Module\Dependency\Report\BuilderInterface'], + ['Magento\Tools\Dependency\Report\Circular\Builder', 'Magento\Setup\Module\Dependency\Report\Circular\Builder'], + [ + 'Magento\Tools\Dependency\Report\Circular\Data\Chain', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Chain', + ], + [ + 'Magento\Tools\Dependency\Report\Circular\Data\Config', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Config', + ], + [ + 'Magento\Tools\Dependency\Report\Circular\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', + ], + ['Magento\Tools\Dependency\Report\Circular\Writer', 'Magento\Setup\Module\Dependency\Report\Circular\Writer'], + [ + 'Magento\Tools\Dependency\Report\Data\Config\AbstractConfig', + 'Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig', + ], + [ + 'Magento\Tools\Dependency\Report\Data\ConfigInterface', + 'Magento\Setup\Module\Dependency\Report\Data\ConfigInterface', + ], + ['Magento\Tools\Dependency\Report\Dependency\Builder', 'Magento\Setup\Module\Dependency\Report\Dependency\Builder'], + [ + 'Magento\Tools\Dependency\Report\Dependency\Data\Config', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Config', + ], + [ + 'Magento\Tools\Dependency\Report\Dependency\Data\Dependency', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', + ], + [ + 'Magento\Tools\Dependency\Report\Dependency\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', + ], + ['Magento\Tools\Dependency\Report\Dependency\Writer', 'Magento\Setup\Module\Dependency\Report\Dependency\Writer'], + ['Magento\Tools\Dependency\Report\Framework\Builder', 'Magento\Setup\Module\Dependency\Report\Framework\Builder'], + [ + 'Magento\Tools\Dependency\Report\Framework\Data\Config', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Config', + ], + [ + 'Magento\Tools\Dependency\Report\Framework\Data\Dependency', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency', + ], + [ + 'Magento\Tools\Dependency\Report\Framework\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', + ], + ['Magento\Tools\Dependency\Report\Framework\Writer', 'Magento\Setup\Module\Dependency\Report\Framework\Writer'], + [ + 'Magento\Tools\Dependency\Report\Writer\Csv\AbstractWriter', + 'Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter', + ], + ['Magento\Tools\Dependency\Report\WriterInterface', 'Magento\Setup\Module\Dependency\Report\WriterInterface'], + ['Magento\Tools\Dependency\ServiceLocator', 'Magento\Setup\Module\Dependency\ServiceLocator'], + ['Magento\Tools\SampleData\Helper\Csv\Reader', 'Magento\SampleData\Helper\Csv\Reader'], + ['Magento\Tools\SampleData\Helper\Csv\ReaderFactory', 'Magento\SampleData\Helper\Csv\ReaderFactory'], + ['Magento\Tools\SampleData\Helper\Deploy', 'Magento\SampleData\Helper\Deploy'], + ['Magento\Tools\SampleData\Helper\Fixture', 'Magento\SampleData\Helper\Fixture'], + ['Magento\Tools\SampleData\Helper\PostInstaller', 'Magento\SampleData\Helper\PostInstaller'], + ['Magento\Tools\SampleData\Helper\StoreManager', 'Magento\SampleData\Helper\StoreManager'], + ['Magento\Tools\SampleData\Installer', 'Magento\SampleData\Model\Installer'], + ['Magento\Tools\SampleData\Logger', 'Magento\SampleData\Model\Logger'], + ['Magento\Tools\SampleData\ObserverManager', 'Magento\SampleData\Model\ObserverManager'], + ['Magento\Tools\SampleData\SetupFactory', 'Magento\SampleData\Model\SetupFactory'], + ['Magento\Tools\SampleData\SetupInterface', 'Magento\SampleData\Model\SetupInterface'], + [ + 'Magento\Tools\SampleData\Module\Bundle\Setup\Product\Converter', + 'Magento\SampleData\Module\Bundle\Setup\Product\Converter', + ], + ['Magento\Tools\SampleData\Module\Bundle\Setup\Product', 'Magento\SampleData\Module\Bundle\Setup\Product'], + ['Magento\Tools\SampleData\Module\Bundle\Setup', 'Magento\SampleData\Module\Bundle\Setup'], + ['Magento\Tools\SampleData\Module\Catalog\Setup\Attribute', 'Magento\SampleData\Module\Catalog\Setup\Attribute'], + ['Magento\Tools\SampleData\Module\Catalog\Setup\Category', 'Magento\SampleData\Module\Catalog\Setup\Category'], + [ + 'Magento\Tools\SampleData\Module\Catalog\Setup\Product\Converter', + 'Magento\SampleData\Module\Catalog\Setup\Product\Converter', + ], + [ + 'Magento\Tools\SampleData\Module\Catalog\Setup\Product\Gallery', + 'Magento\SampleData\Module\Catalog\Setup\Product\Gallery', + ], + ['Magento\Tools\SampleData\Module\Catalog\Setup\Product', 'Magento\SampleData\Module\Catalog\Setup\Product'], + [ + 'Magento\Tools\SampleData\Module\Catalog\Setup\ProductLink', + 'Magento\SampleData\Module\Catalog\Setup\ProductLink', + ], + ['Magento\Tools\SampleData\Module\Catalog\Setup', 'Magento\SampleData\Module\Catalog\Setup'], + ['Magento\Tools\SampleData\Module\CatalogRule\Setup\Rule', 'Magento\SampleData\Module\CatalogRule\Setup\Rule'], + ['Magento\Tools\SampleData\Module\CatalogRule\Setup', 'Magento\SampleData\Module\CatalogRule\Setup'], + [ + 'Magento\Tools\SampleData\Module\Cms\Setup\Block\Converter', + 'Magento\SampleData\Module\Cms\Setup\Block\Converter', + ], + ['Magento\Tools\SampleData\Module\Cms\Setup\Block', 'Magento\SampleData\Module\Cms\Setup\Block'], + ['Magento\Tools\SampleData\Module\Cms\Setup\Page', 'Magento\SampleData\Module\Cms\Setup\Page'], + ['Magento\Tools\SampleData\Module\Cms\Setup', 'Magento\SampleData\Module\Cms\Setup'], + [ + 'Magento\Tools\SampleData\Module\ConfigurableProduct\Setup\Product\Converter', + 'Magento\SampleData\Module\ConfigurableProduct\Setup\Product\Converter', + ], + [ + 'Magento\Tools\SampleData\Module\ConfigurableProduct\Setup\Product\Gallery', + 'Magento\SampleData\Module\ConfigurableProduct\Setup\Product\Gallery', + ], + [ + 'Magento\Tools\SampleData\Module\ConfigurableProduct\Setup\Product', + 'Magento\SampleData\Module\ConfigurableProduct\Setup\Product', + ], + [ + 'Magento\Tools\SampleData\Module\ConfigurableProduct\Setup', + 'Magento\SampleData\Module\ConfigurableProduct\Setup', + ], + ['Magento\Tools\SampleData\Module\Customer\Setup\Customer', 'Magento\SampleData\Module\Customer\Setup\Customer'], + ['Magento\Tools\SampleData\Module\Customer\Setup', 'Magento\SampleData\Module\Customer\Setup'], + ['Magento\Tools\SampleData\Module\CustomerBalance\Observer', 'Magento\SampleData\Module\CustomerBalance\Observer'], + [ + 'Magento\Tools\SampleData\Module\Downloadable\Setup\Product\Converter', + 'Magento\SampleData\Module\Downloadable\Setup\Product\Converter', + ], + [ + 'Magento\Tools\SampleData\Module\Downloadable\Setup\Product', + 'Magento\SampleData\Module\Downloadable\Setup\Product', + ], + ['Magento\Tools\SampleData\Module\Downloadable\Setup', 'Magento\SampleData\Module\Downloadable\Setup'], + [ + 'Magento\Tools\SampleData\Module\GiftCard\Setup\Product\Converter', + 'Magento\SampleData\Module\GiftCard\Setup\Product\Converter', + ], + ['Magento\Tools\SampleData\Module\GiftCard\Setup\Product', 'Magento\SampleData\Module\GiftCard\Setup\Product'], + ['Magento\Tools\SampleData\Module\GiftCard\Setup', 'Magento\SampleData\Module\GiftCard\Setup'], + [ + 'Magento\Tools\SampleData\Module\GiftRegistry\Setup\GiftRegistry', + 'Magento\SampleData\Module\GiftRegistry\Setup\GiftRegistry', + ], + ['Magento\Tools\SampleData\Module\GiftRegistry\Setup', 'Magento\SampleData\Module\GiftRegistry\Setup'], + [ + 'Magento\Tools\SampleData\Module\GroupedProduct\Setup\Product\Converter', + 'Magento\SampleData\Module\GroupedProduct\Setup\Product\Converter', + ], + [ + 'Magento\Tools\SampleData\Module\GroupedProduct\Setup\Product', + 'Magento\SampleData\Module\GroupedProduct\Setup\Product', + ], + ['Magento\Tools\SampleData\Module\GroupedProduct\Setup', 'Magento\SampleData\Module\GroupedProduct\Setup'], + [ + 'Magento\Tools\SampleData\Module\MultipleWishlist\Setup\Wishlist', + 'Magento\SampleData\Module\MultipleWishlist\Setup\Wishlist', + ], + ['Magento\Tools\SampleData\Module\MultipleWishlist\Setup', 'Magento\SampleData\Module\MultipleWishlist\Setup'], + [ + 'Magento\Tools\SampleData\Module\OfflineShipping\Setup\Tablerate', + 'Magento\SampleData\Module\OfflineShipping\Setup\Tablerate', + ], + ['Magento\Tools\SampleData\Module\OfflineShipping\Setup', 'Magento\SampleData\Module\OfflineShipping\Setup'], + ['Magento\Tools\SampleData\Module\Review\Setup\Review', 'Magento\SampleData\Module\Review\Setup\Review'], + ['Magento\Tools\SampleData\Module\Review\Setup', 'Magento\SampleData\Module\Review\Setup'], + [ + 'Magento\Tools\SampleData\Module\Sales\Setup\Order\Converter', + 'Magento\SampleData\Module\Sales\Setup\Order\Converter', + ], + [ + 'Magento\Tools\SampleData\Module\Sales\Setup\Order\Processor', + 'Magento\SampleData\Module\Sales\Setup\Order\Processor', + ], + ['Magento\Tools\SampleData\Module\Sales\Setup\Order', 'Magento\SampleData\Module\Sales\Setup\Order'], + ['Magento\Tools\SampleData\Module\Sales\Setup', 'Magento\SampleData\Module\Sales\Setup'], + ['Magento\Tools\SampleData\Module\SalesRule\Setup\Rule', 'Magento\SampleData\Module\SalesRule\Setup\Rule'], + ['Magento\Tools\SampleData\Module\SalesRule\Setup', 'Magento\SampleData\Module\SalesRule\Setup'], + ['Magento\Tools\SampleData\Module\TargetRule\Setup\Rule', 'Magento\SampleData\Module\TargetRule\Setup\Rule'], + ['Magento\Tools\SampleData\Module\TargetRule\Setup', 'Magento\SampleData\Module\TargetRule\Setup'], + ['Magento\Tools\SampleData\Module\Tax\Setup\Tax', 'Magento\SampleData\Module\Tax\Setup\Tax'], + ['Magento\Tools\SampleData\Module\Tax\Setup', 'Magento\SampleData\Module\Tax\Setup'], + ['Magento\Tools\SampleData\Module\Theme\Setup', 'Magento\SampleData\Module\Theme\Setup'], + ['Magento\Tools\SampleData\Module\Widget\Setup\CmsBlock', 'Magento\SampleData\Module\Widget\Setup\CmsBlock'], + ['Magento\Tools\SampleData\Module\Widget\Setup', 'Magento\SampleData\Module\Widget\Setup'], + [ + 'Magento\Tools\SampleData\Module\Wishlist\Setup\Wishlist\Helper', + 'Magento\SampleData\Module\Wishlist\Setup\Wishlist\Helper', + ], + ['Magento\Tools\SampleData\Module\Wishlist\Setup\Wishlist', 'Magento\SampleData\Module\Wishlist\Setup\Wishlist'], + ['Magento\Tools\SampleData\Module\Wishlist\Setup', 'Magento\SampleData\Module\Wishlist\Setup'], + ['Magento\Tools\SampleData\InstallerApp'], + [ + 'Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator', + 'Magento\Setup\Model\Complex\Generator', + ], + [ + 'Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern', + 'Magento\Setup\Model\Complex\Pattern', + ], + [ + 'Magento\ToolkitFramework\ImportExport\Fixture\Generator', + 'Magento\Setup\Model\Generator', + ], + ['Magento\ToolkitFramework\Helper\Cli'], + ['Magento\ToolkitFramework\Config'], + ['Magento\Framework\Locale\Validator', 'Magento\Framework\Validator\Locale'], + ['Magento\ToolkitFramework\Fixture', 'Magento\Setup\Fixtures\Fixture'], + ['Magento\ToolkitFramework\Application', 'Magento\Setup\Fixtures\FixtureModel'], + ['Magento\Framework\Locale\Lists', 'Magento\Framework\Locale\TranslatedLists'], + ['Magento\Setup\Model\Lists', 'Magento\Framework\Setup\Lists'], + ['Magento\Framework\View\Block\IdentityInterface'], + ['Magento\Framework\Config\ConfigOptionsList', 'Magento\Setup\Model\ConfigOptionsList'], + ['Magento\Customer\Controller\Address\BillingList'], + ['Magento\Checkout\Block\Onepage\Login'], + ['Magento\Checkout\Block\Onepage\Progress'], + ['Magento\Checkout\Block\Onepage\Review'], + ['Magento\Checkout\Controller\Onepage\Review'], + ['Magento\Checkout\Controller\Onepage\SaveBilling'], + ['Magento\Checkout\Controller\Onepage\SaveMethod'], + ['Magento\Checkout\Controller\Onepage\SavePayment'], + ['Magento\Checkout\Controller\Onepage\SaveShipping'], + ['Magento\Checkout\Controller\Onepage\SaveShippingMethod'], + ['Magento\Checkout\Controller\Onepage\ShippingMethod'], + ['Magento\Catalog\Model\Product\Gallery\ContentValidator', 'Magento\Framework\Api\ImageContentValidator'], + ['Magento\Centinel\Block\Adminhtml\Validation\Form'], + ['Magento\Centinel\Block\Adminhtml\Validation'], + ['Magento\Centinel\Block\Authentication\Complete'], + ['Magento\Centinel\Block\Authentication\Start'], + ['Magento\Centinel\Block\Authentication'], + ['Magento\Centinel\Block\Logo'], + ['Magento\Centinel\Controller\Adminhtml\Centinel\Index\AuthenticationComplete'], + ['Magento\Centinel\Controller\Adminhtml\Centinel\Index\AuthenticationStart'], + ['Magento\Centinel\Controller\Adminhtml\Centinel\Index\ValidatePaymentData'], + ['Magento\Centinel\Controller\Adminhtml\Centinel\Index'], + ['Magento\Centinel\Controller\Index\AuthenticationComplete'], + ['Magento\Centinel\Controller\Index\AuthenticationStart'], + ['Magento\Centinel\Controller\Index'], + ['Magento\Centinel\Helper\Data'], + ['Magento\Centinel\Model\State\Jcb'], + ['Magento\Centinel\Model\State\Mastercard'], + ['Magento\Centinel\Model\State\Visa'], + ['Magento\Centinel\Model\AbstractState'], + ['Magento\Centinel\Model\Api'], + ['Magento\Centinel\Model\Config'], + ['Magento\Centinel\Model\Observer'], + ['Magento\Centinel\Model\Service'], + ['Magento\Centinel\Model\StateFactory'], + ['Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure'], + ['CentinelClient'], + ['XMLParser'], + ['Magento\Centinel\Test\Block\Adminhtml\Order\View\Tab\Info'], + ['Magento\Centinel\Test\Block\Onepage\Review'], + ['Magento\Centinel\Test\Block\Authentication'], + ['Magento\Centinel\Test\Fixture\AbstractCreditCard'], + ['Magento\Centinel\Test\Fixture\GuestAuthorizenetInvalidCc'], + ['Magento\Centinel\Test\Fixture\GuestPayPalPayflowProInvalidCc'], + ['Magento\Centinel\Test\Fixture\GuestPayPalPayflowProValidCc'], + ['Magento\Centinel\Test\Fixture\GuestPayPalPaymentsProInvalidCc'], + ['Magento\Centinel\Test\Fixture\GuestPayPalPaymentsProValidCc'], + ['Magento\Centinel\Test\Fixture\RegisteredAuthorizenetValidCc'], + ['Magento\Centinel\Test\TestCase\AbstractCentinelPaymentsTest'], + ['Magento\Centinel\Test\TestCase\CentinelPaymentsInvalidCcTest'], + ['Magento\Centinel\Test\TestCase\CentinelPaymentsValidCcTest'], + ['Magento\Centinel\CreateOrderTest'], ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index b0e6f2627029a..04e4ebacf08ef 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -689,7 +689,7 @@ [ 'PARAM_BACKEND_FRONT_NAME', 'Magento\Backend\App\Area\FrontNameResolver', - 'Magento\Backend\Setup\ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME' + 'Magento\Backend\Setup\ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME', ], [ 'DEFAULT_ATTRIBUTE_SET_ID', @@ -702,26 +702,31 @@ 'Use \Magento\Eav\Model\Entity\Type::getDefaultAttributeSetId() method instead', ], ['CONFIG_PATH_WSDL_CACHE_ENABLED', 'Magento\Webapi\Model\Soap\Server'], + [ + 'SIDEBAR_ORDER_LIMIT', + 'Magento\Sales\Block\Reorder\Sidebar', + '\Magento\Sales\CustomerData\LastOrderedItems::SIDEBAR_ORDER_LIMIT', + ], ['ENTITY', 'Magento\Framework\App\Config\ValueInterface'], ['XML_PATH_ALLOW_CURRENCIES_INSTALLED', 'Magento\Framework\Locale\CurrencyInterface'], [ 'DEFAULT_CURRENCY', 'Magento\Framework\Locale\CurrencyInterface', - 'Magento\Framework\Locale\Currency::DEFAULT_CURRENCY' + 'Magento\Framework\Locale\Currency::DEFAULT_CURRENCY', ], [ 'DEFAULT_LOCALE', 'Magento\Framework\Locale\ResolverInterface', - 'Magento\Framework\Locale\Resolver::DEFAULT_LOCALE' + 'Magento\Framework\Locale\Resolver::DEFAULT_LOCALE', ], [ 'DEFAULT_GROUP', 'Magento\Framework\Message\ManagerInterface', - 'Magento\Framework\Message\Manager::DEFAULT_GROUP' + 'Magento\Framework\Message\Manager::DEFAULT_GROUP', ], [ 'SCOPE_DEFAULT', 'Magento\Framework\App\ScopeInterface', - 'Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT' - ] + 'Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT', + ], ]; 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 6a1f2846a85df..2ed697e91c893 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 @@ -48,13 +48,13 @@ [ '_checkCookieStore', 'Magento\Core\Model\Store\Storage\Db', - 'Magento\Store\Model\StorageFactory::_checkCookieStore' + 'Magento\Store\Model\StorageFactory::_checkCookieStore', ], ['_checkGetStore', 'Magento\Core\Model\App'], [ '_checkGetStore', 'Magento\Core\Model\Store\Storage\Db', - 'Magento\Store\Model\StorageFactory::_checkRequestStore' + 'Magento\Store\Model\StorageFactory::_checkRequestStore', ], ['_checkUrlSettings', 'Magento\Backend\Controller\Adminhtml\Action'], ['_collectOrigData', 'Magento\Catalog\Model\Resource\AbstractResource'], @@ -118,13 +118,13 @@ [ '_getStoreByGroup', 'Magento\Core\Model\Store\Storage\Db', - 'Magento\Store\Model\StorageFactory::_getStoreByGroup' + 'Magento\Store\Model\StorageFactory::_getStoreByGroup', ], ['_getStoreByWebsite', 'Magento\Core\Model\App'], [ '_getStoreByWebsite', 'Magento\Core\Model\Store\Storage\Db', - 'Magento\Store\Model\StorageFactory::_getStoreByWebsite' + 'Magento\Store\Model\StorageFactory::_getStoreByWebsite', ], ['_getStoreTaxRequest', 'Magento\Tax\Model\Sales\Total\Quote\Shipping'], ['_getUploadMaxFilesize', 'Magento\Catalog\Model\Product\Option\Type\File'], @@ -186,17 +186,17 @@ [ 'submitOrder', 'Magento\Quote\Model\Service\Quote', - 'Magento\Quote\Model\Service\Quote::submitOrderWithDataObject' + 'Magento\Quote\Model\Service\Quote::submitOrderWithDataObject', ], [ 'submitAll', 'Magento\Quote\Model\Service\Quote', - 'Magento\Quote\Model\Service\Quote::submitAllWithDataObject' + 'Magento\Quote\Model\Service\Quote::submitAllWithDataObject', ], [ 'exportCustomerAddress', 'Magento\Quote\Model\Quote\Address', - 'Magento\Quote\Model\Quote\Address::exportCustomerAddressData' + 'Magento\Quote\Model\Quote\Address::exportCustomerAddressData', ], ['_toHtml', 'Magento\Backend\Block\Widget\Container'], ['_unhookQueries', 'Magento\Core\Model\Resource\Setup'], @@ -247,23 +247,23 @@ [ 'addVisibleInCatalogFilterToCollection', '', - '$collection->setVisibility(\Magento\Catalog\Model\Product\Visibility->getVisibleInCatalogIds());' + '$collection->setVisibility(\Magento\Catalog\Model\Product\Visibility->getVisibleInCatalogIds());', ], [ 'addVisibleInSearchFilterToCollection', '', - '$collection->setVisibility(\Magento\Catalog\Model\Product\Visibility->getVisibleInSearchIds());' + '$collection->setVisibility(\Magento\Catalog\Model\Product\Visibility->getVisibleInSearchIds());', ], [ 'addVisibleInSiteFilterToCollection', '', - '$collection->setVisibility(\Magento\Catalog\Model\Product\Visibility->getVisibleInSiteIds());' + '$collection->setVisibility(\Magento\Catalog\Model\Product\Visibility->getVisibleInSiteIds());', ], ['addWishListSortOrder', 'Magento\Wishlist\Model\Resource\Item\Collection'], [ 'aggregateSalesReportShipmentData', '\Magento\Sales\Model\Observer', - '\Magento\Shipping\Model\Observer::aggregateSalesReportShipmentData' + '\Magento\Shipping\Model\Observer::aggregateSalesReportShipmentData', ], ['appendBundleSelectionData', 'Magento\Bundle\Model\Observer'], ['applyAllDataUpdates', 'Magento\Core\Model\Resource\Setup'], @@ -284,7 +284,7 @@ [ 'canTestHeaders', 'Magento\TestFramework\Bootstrap', - 'Magento_TestFramework_Helper_Bootstrap::canTestHeaders' + 'Magento_TestFramework_Helper_Bootstrap::canTestHeaders', ], ['catalogCategoryChangeProducts', 'Magento\Catalog\Model\Product\Flat\Observer'], ['catalog' . 'EventProductCollectionAfterLoad', 'Magento\GiftMessage\Model\Observer'], @@ -304,13 +304,13 @@ [ 'cleanMergedJsCss', 'Magento\Core\Model\Design\PackageInterface', - 'Magento\Framework\View\Asset\MergeService' + 'Magento\Framework\View\Asset\MergeService', ], ['cleanVarFolder', '', 'Magento\Framework\Filesystem\Io\File::rmdirRecursive()'], [ 'cleanVarSubFolders', '', - '\Magento\Framework\Filesystem::getDirectoryRead(\Magento\Framework\Filesystem::VAR_DIR)::search())' + '\Magento\Framework\Filesystem::getDirectoryRead(\Magento\Framework\Filesystem::VAR_DIR)::search())', ], ['collectRoutes', 'Magento\Backend\App\Router'], ['collectRoutes', 'Magento\Core\App\Router\Base'], @@ -341,7 +341,7 @@ [ 'getIsMessagesAvailable', 'Magento\GiftMessage\Helper\Message', - 'Magento\GiftMessage\Helper\Message::isMessagesAllowed' + 'Magento\GiftMessage\Helper\Message::isMessagesAllowed', ], ['drawOpenCategoryItem', 'Magento\Catalog\Block\Navigation'], ['renderCategoriesMenuHtml', 'Magento\Catalog\Block\Navigation'], @@ -359,28 +359,28 @@ [ 'getProductTypes', 'Magento\ImportExport\Model\Import\Config', - 'Magento\ImportExport\Model\Import\Config::getEntityTypes()' + 'Magento\ImportExport\Model\Import\Config::getEntityTypes()', ], [ 'getProductTypes', '\Magento\ImportExport\Model\Import\ConfigInterface', - '\Magento\ImportExport\Model\Import\ConfigInterface::getEntityTypes()' + '\Magento\ImportExport\Model\Import\ConfigInterface::getEntityTypes()', ], [ 'getProductTypes', 'Magento\ImportExport\Model\Export\Config', - 'Magento\ImportExport\Model\Export\Config::getEntityTypes()' + 'Magento\ImportExport\Model\Export\Config::getEntityTypes()', ], [ 'getProductTypes', '\Magento\ImportExport\Model\Export\ConfigInterface', - '\Magento\ImportExport\Model\Export\ConfigInterface::getEntityTypes()' + '\Magento\ImportExport\Model\Export\ConfigInterface::getEntityTypes()', ], ['forsedSave'], [ 'formatCurrency', 'Magento\Core\Helper\Data', - '\Magento\Framework\Pricing\PriceCurrencyInterface::convertAndFormat' + '\Magento\Framework\Pricing\PriceCurrencyInterface::convertAndFormat', ], ['formatPrice', 'Magento\Core\Helper\Data', '\Magento\Framework\Pricing\PriceCurrencyInterface::format'], ['generateBlocks', '', 'generateElements()'], @@ -432,7 +432,7 @@ [ 'getDbVendorName', 'Magento\TestFramework\Bootstrap', - 'Magento_TestFramework_Helper_Bootstrap::getDbVendorName' + 'Magento_TestFramework_Helper_Bootstrap::getDbVendorName', ], ['getDebug', 'Magento\Ogone\Model\Api'], ['getDebug', 'Magento\Paypal\Model\Api\AbstractApi'], @@ -465,13 +465,13 @@ [ 'getInitParams', 'Magento\TestFramework\Bootstrap', - 'Magento_TestFramework_Helper_Bootstrap::getAppInitParams' + 'Magento_TestFramework_Helper_Bootstrap::getAppInitParams', ], ['getInstallDate', 'Magento\Core\Model\Config'], [ 'getInstallDir', 'Magento\TestFramework\Bootstrap', - 'Magento_TestFramework_Helper_Bootstrap::getAppInstallDir' + 'Magento_TestFramework_Helper_Bootstrap::getAppInstallDir', ], ['getInstance', 'Magento\TestFramework\Bootstrap', 'Magento_TestFramework_Helper_Bootstrap::getInstance'], ['getIsActiveAanalytics', '', 'getOnsubmitJs'], @@ -504,7 +504,7 @@ [ 'getNumberDetail', 'Magento\Sales\Model\Order\Shipment\Track', - 'Magento\Shipping\Model\Order\Track::getNumberDetail()' + 'Magento\Shipping\Model\Order\Track::getNumberDetail()', ], ['getOneBalanceTotal'], ['getOptimalCssUrls', 'Magento\Core\Model\Design\Package\Proxy', 'Magento\Framework\View\Asset\Merged'], @@ -516,7 +516,7 @@ [ 'getOptions', 'Magento\Core\Model\Design\Source\Design', - 'Magento_Core_Model_Theme::getThemeCollectionOptionArray' + 'Magento_Core_Model_Theme::getThemeCollectionOptionArray', ], ['getOptionValues', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'], ['getOrderHtml', 'Magento\GoogleAnalytics\Block\Ga'], @@ -557,19 +557,19 @@ [ 'getResourceConfig', 'Magento\Framework\Config\Model\Config', - 'Magento_Config_Model_Config_Resource::getResourceConfig' + 'Magento_Config_Model_Config_Resource::getResourceConfig', ], ['getResourceConfig', 'Magento\Core\Model\Config'], [ 'getResourceConnectionConfig', 'Magento\Framework\Config\Model\Config', - 'Magento_Config_Model_Config_Resource::getResourceConnectionConfig' + 'Magento_Config_Model_Config_Resource::getResourceConnectionConfig', ], ['getResourceConnectionConfig', 'Magento\Core\Model\Config'], [ 'getResourceConnectionModel', 'Magento\Framework\Config\Model\Config', - 'Magento_Config_Model_Config_Resource::getResourceConnectionModel' + 'Magento_Config_Model_Config_Resource::getResourceConnectionModel', ], ['getResourceConnectionModel', 'Magento\Core\Model\Config'], ['getResourceModel', 'Magento\Core\Model\Config'], @@ -577,7 +577,7 @@ [ 'getResourceTypeConfig', 'Magento\Framework\Config\Model\Config', - 'Magento_Config_Model_Config_Resource::getResourceTypeConfig' + 'Magento_Config_Model_Config_Resource::getResourceTypeConfig', ], ['getResourceTypeConfig', 'Magento\Core\Model\Config'], ['getResTreeJson', 'Magento\User\Block\Role\Tab\Edit', 'getTree'], @@ -603,7 +603,7 @@ [ '_getDefaultControllerName', 'Magento\Framework\Url', - 'Magento\Framework\UrlInterface::DEFAULT_CONTROLLER_NAME' + 'Magento\Framework\UrlInterface::DEFAULT_CONTROLLER_NAME', ], ['_getDefaultUrlType', 'Magento\Framework\Url', 'Magento\Framework\UrlInterface::DEFAULT_URL_TYPE'], ['getSelectionFinalPrice', 'Magento\Bundle\Model\Product\Price'], @@ -631,7 +631,7 @@ [ 'getTagsByType', 'Magento\Framework\App\CacheInterface', - 'Magento_Cache_Frontend_Decorator_TagScope::getTag()' + 'Magento_Cache_Frontend_Decorator_TagScope::getTag()', ], ['getTaxAmount', 'Magento\Quote\Model\Quote\Item\AbstractItem'], ['getTaxRatesByProductClass', '', '_getAllRatesByProductClass'], @@ -640,7 +640,7 @@ [ 'getTemplateProcessor', 'Magento\Newsletter\Helper\Data', - 'Use directly model \Magento\Newsletter\Model\Template\Filter' + 'Use directly model \Magento\Newsletter\Model\Template\Filter', ], ['getTempVarDir', 'Magento\Core\Model\Config', 'Magento_Core_Model_Dir::getDir()'], ['getTestsDir', 'Magento\TestFramework\Bootstrap'], @@ -648,7 +648,7 @@ [ 'getThemeOptions', 'Magento\Core\Model\Design\Source\Design', - 'Magento_Core_Model_Theme::getThemeCollectionOptionArray' + 'Magento_Core_Model_Theme::getThemeCollectionOptionArray', ], ['getTotalModels', 'Magento\Quote\Model\Quote\Address'], ['importCustomerAddress', 'Magento\Quote\Model\Quote\Address'], @@ -693,7 +693,7 @@ [ 'initCurrentStore', 'Magento\Store\Model\Storage\Db', - 'Magento\Store\Model\StorageFactory::_reinitStores' + 'Magento\Store\Model\StorageFactory::_reinitStores', ], ['_checkGetStore', 'Magento\Store\Model\Storage\Db'], ['_checkCookieStore', 'Magento\Store\Model\Storage\Db'], @@ -746,19 +746,19 @@ [ 'map', 'Magento\Framework\ObjectManager\Config\Mapper\Dom', - 'Magento_ObjectManager_Config_Mapper_Dom::convert' + 'Magento_ObjectManager_Config_Mapper_Dom::convert', ], ['mergeFiles', 'Magento\Core\Helper\Data', 'Magento\Framework\View\Asset\MergeStrategyInterface'], ['mergeFiles', 'Magento\Core\Model\Design\Package', 'Magento\Framework\View\Asset\MergeStrategyInterface'], [ 'mergeFiles', 'Magento\Core\Model\Design\Package\Proxy', - 'Magento\Framework\View\Asset\MergeStrategyInterface' + 'Magento\Framework\View\Asset\MergeStrategyInterface', ], [ 'mergeFiles', 'Magento\Core\Model\Design\PackageInterface', - 'Magento\Framework\View\Asset\MergeStrategyInterface' + 'Magento\Framework\View\Asset\MergeStrategyInterface', ], ['order_success_page_view', 'Magento\GoogleAnalytics\Model\Observer'], ['orderedAction', 'Magento\Backend\Controller\Report\Product'], @@ -785,6 +785,7 @@ ['regenerateSessionId', 'Magento\Core\Model\Session\AbstractSession'], ['reinitialize', 'Magento\TestFramework\Bootstrap', 'Magento_TestFramework_Helper_Bootstrap::reinitialize'], ['removeAuthLink', 'Magento\Customer\Block\Account\Link'], + ['getCustomerName', 'Magento\Customer\Block\Account'], ['removeItem', 'Magento\Theme\Block\Html\Head'], ['removeCustomerFromSegments'], ['removeHandle', 'Magento\Core\Model\Layout\Update', 'Magento\Framework\View\Model\Layout\Merge'], @@ -868,11 +869,11 @@ ['_getOptionValuesCollection', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'], [ ' _prepareSystemAttributeOptionValues', - 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions' + 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions', ], [ '_prepareUserDefinedAttributeOptionValues', - 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions' + 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions', ], ['getLabelValues', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'], ['getStoreOptionValues', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'], @@ -880,32 +881,32 @@ [ 'substractQtyFromQuotes', 'Magento\Sales\Model\Observer', - 'Magento_Sales_Model_Observer_Backend_CatalogProductQuote::subtractQtyFromQuotes' + 'Magento_Sales_Model_Observer_Backend_CatalogProductQuote::subtractQtyFromQuotes', ], [ 'markQuotesRecollectOnCatalogRules', 'Magento\Sales\Model\Observer', - 'Magento_Sales_Model_Observer_Backend_CatalogPriceRule::dispatch' + 'Magento_Sales_Model_Observer_Backend_CatalogPriceRule::dispatch', ], [ 'catalogProductSaveAfter', 'Magento\Sales\Model\Observer', - 'Magento_Sales_Model_Observer_Backend_CatalogProductQuote::catalogProductSaveAfter' + 'Magento_Sales_Model_Observer_Backend_CatalogProductQuote::catalogProductSaveAfter', ], [ 'catalogProductStatusUpdate', 'Magento\Sales\Model\Observer', - 'Magento_Sales_Model_Observer_Backend_CatalogProductQuote::catalogProductStatusUpdate' + 'Magento_Sales_Model_Observer_Backend_CatalogProductQuote::catalogProductStatusUpdate', ], [ 'restrictAdminBillingAgreementUsage', 'Magento\Sales\Model\Observer', - 'Magento_Sales_Model_Observer_Backend_BillingAgreement::dispatch' + 'Magento_Sales_Model_Observer_Backend_BillingAgreement::dispatch', ], [ 'customerSaveAfter', 'Magento\Sales\Model\Observer', - 'Magento_Sales_Model_Observer_Backend_CustomerQuote::dispatch' + 'Magento_Sales_Model_Observer_Backend_CustomerQuote::dispatch', ], ['_getUsers', 'Magento\Backend\Block\Api\Role\Grid\User', 'getUsers'], ['_getGridHtml', 'Magento\Backend\Block\Api\Tab\Rolesusers', 'getGridHtml'], @@ -914,7 +915,7 @@ [ '_getImageUploadUrl', 'Magento\Backend\Block\Catalog\Product\Edit\Tab\Super\Config\Matrix', - 'getImageUploadUrl' + 'getImageUploadUrl', ], ['_getProduct', 'Magento\Backend\Block\Catalog\Product\Edit\Tab\Super\Config\Simple', 'getProduct'], ['_getProduct', 'Magento\Backend\Block\Catalog\Product\Edit\Tab\Super\Config', 'getProduct'], @@ -925,7 +926,7 @@ [ '_renderCellTemplate', 'Magento\Backend\Block\System\Config\Form\Field\Array\AbstractArray', - 'renderCellTemplate' + 'renderCellTemplate', ], ['_showSingle', 'Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option', 'showSingle'], ['_getDefaultValues', 'Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option', 'getDefaultValues'], @@ -933,7 +934,7 @@ [ '_getProduct', 'Magento\Catalog\Block\Product\Configurable\AssociatedSelector\Backend\Grid\ColumnSet', - 'getProduct' + 'getProduct', ], ['_getProduct', 'Magento\CatalogInventory\Block\Stockqty\AbstractStockqty', 'getProduct'], ['_getProduct', 'Magento\CatalogInventory\Block\Qtyincrements', 'getProduct'], @@ -969,7 +970,7 @@ [ 'getDefaultTemplatesAsOptionsArray', 'Magento\Email\Model\Template', - 'Magento_Adminhtml_Block_System_Email_Template_Edit::_getDefaultTemplatesAsOptionsArray' + 'Magento_Adminhtml_Block_System_Email_Template_Edit::_getDefaultTemplatesAsOptionsArray', ], ['getMetaTags', 'Magento\Theme\Block\Html\Head'], ['getMetaTagHtml', 'Magento\Theme\Block\Html\Head'], @@ -991,7 +992,7 @@ [ '_getResource', 'Magento\Weee\Model\Attribute\Backend\Weee\Tax', - 'Magento_Weee_Model_Attribute_Backend_Weee_Tax::$_attributeTax' + 'Magento_Weee_Model_Attribute_Backend_Weee_Tax::$_attributeTax', ], ['getCouponMassGenerator', 'Magento\SalesRule\Model\Rule', 'Magento\SalesRule\Model\Coupon\Massgenerator'], ['_getHelper', 'Magento\Captcha\Model\DefaultModel'], @@ -1012,7 +1013,7 @@ ['turnOnSerializableMode', 'Magento\Backup\Model\Resource\Db', 'prepareTransactionIsolationLevel'], ['turnOnMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\MaintenanceMode::set'], ['turnOffMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\MaintenanceMode::set'], - ['getMaintenanceFlagFilePath', 'Magento\Backup\Helper\Data',], + ['getMaintenanceFlagFilePath', 'Magento\Backup\Helper\Data'], ['_getResourceModel', '\Magento\Webapi\Model\Source\Acl\Role', '$this->_resource'], ['_getSession', '\Magento\GiftMessage\Model\Save', '$this->_session'], ['run', '\Magento\Framework\AppInterface'], @@ -1056,7 +1057,7 @@ [ 'getMerchantCountryCode', '\Magento\Core\Helper\Data', - '\Magento\Customer\Helper\Data::getMerchantCountryCode' + '\Magento\Customer\Helper\Data::getMerchantCountryCode', ], ['getMerchantVatNumber', '\Magento\Core\Helper\Data', '\Magento\Customer\Helper\Data::getMerchantVatNumber'], ['isCountryInEU', '\Magento\Core\Helper\Data', '\Magento\Customer\Helper\Data::isCountryInEU'], @@ -1069,7 +1070,7 @@ [ 'getProtectedFileExtensions', '\Magento\Core\Helper\Data', - '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::getProtectedFileExtensions' + '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::getProtectedFileExtensions', ], ['getStoreId', '\Magento\Core\Helper\Data'], ['getExactDivision', '\Magento\Core\Helper\Data', '\Magento\Framework\Math\Division::getExactDivision'], @@ -1087,39 +1088,39 @@ [ 'getHttpAuthCredentials', '\Magento\Core\Helper\Http', - '\Magento\Framework\HTTP\Authentication::getCredentials' + '\Magento\Framework\HTTP\Authentication::getCredentials', ], [ 'failHttpAuthentication', '\Magento\Core\Helper\Http', - '\Magento\Framework\HTTP\Authentication::setAuthenticationFailed' + '\Magento\Framework\HTTP\Authentication::setAuthenticationFailed', ], ['getRequestUri', '\Magento\Core\Helper\Http', '\Magento\Framework\HTTP\Header::getRequestUri'], [ 'getRequiredAgreementIds', '\Magento\Checkout\Helper\Data', - '\Magento\CheckoutAgreements\Model\AgreementsProvider::getRequiredAgreementIds' + '\Magento\CheckoutAgreements\Model\AgreementsProvider::getRequiredAgreementIds', ], ['validateIpAddr', '\Magento\Core\Helper\Http', '\Zend_Validate_Ip::isValid'], [ 'getRemoteAddr', '\Magento\Core\Helper\Http', - 'Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::getRemoteAddress' + 'Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::getRemoteAddress', ], [ 'getServerAddr', '\Magento\Core\Helper\Http', - 'Magento\Framework\HTTP\PhpEnvironment\ServerAddress::getServerAddress' + 'Magento\Framework\HTTP\PhpEnvironment\ServerAddress::getServerAddress', ], [ 'formatDate', 'Magento\Framework\Model\Resource\AbstractResource', - '\Magento\Framework\Stdlib\DateTime::formatDate' + '\Magento\Framework\Stdlib\DateTime::formatDate', ], [ 'mktime', 'Magento\Framework\Model\Resource\AbstractResource', - '\Magento\Framework\Stdlib\DateTime::toTimestamp' + '\Magento\Framework\Stdlib\DateTime::toTimestamp', ], ['getPlainTemplateMode', '\Magento\Email\Model\Template\Filter'], ['getMessage', '\Magento\Core\Model\Session\Context', 'getMessageFactory'], @@ -1132,7 +1133,7 @@ [ '_getConfigTimezone', '\Magento\Framework\Stdlib\DateTime\DateTime', - '\Magento\Core\Model\Locale::getConfigTimezone' + '\Magento\Core\Model\Locale::getConfigTimezone', ], ['_filterPostData', '\Magento\Checkout\Controller\Onepage'], ['_filterPostData', '\Magento\Customer\Controller\Account'], @@ -1144,12 +1145,12 @@ [ 'initLayoutMessages', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\View\Layout::initMessages' + '\Magento\Framework\View\Layout::initMessages', ], [ '_initLayoutMessages', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\View\Layout::initMessages' + '\Magento\Framework\View\Layout::initMessages', ], ['preDispatch', '\Magento\Core\Controller\Varien\Action'], ['postDispatch', '\Magento\Core\Controller\Varien\Action'], @@ -1157,44 +1158,44 @@ [ '_startSession', '\Magento\Core\Controller\Varien\Action', - '\Magento\Core\App\Action\Plugin\Session::aroundDispatch' + '\Magento\Core\App\Action\Plugin\Session::aroundDispatch', ], [ '_redirectSuccess', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\Response\RedirectInterface::success' + '\Magento\Framework\App\Response\RedirectInterface::success', ], [ '_redirectUrl', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\Response\RedirectInterface::redirect' + '\Magento\Framework\App\Response\RedirectInterface::redirect', ], [ '_redirectError', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\Response\RedirectInterface::error' + '\Magento\Framework\App\Response\RedirectInterface::error', ], ['_redirectReferer', '\Magento\Core\Controller\Varien\Action'], [ '_validateFormKey', '\Magento\Core\Controller\Varien\Action', - '\Magento\Core\App\Action\FormKeyValidator::validate' + '\Magento\Core\App\Action\FormKeyValidator::validate', ], [ '_getRefererUrl', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\Response\RedirectInterface::getRefererUrl' + '\Magento\Framework\App\Response\RedirectInterface::getRefererUrl', ], ['_isUrlInternal', '\Magento\Core\Controller\Varien\Action'], [ '_filterDateTime', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\Stdlib\DateTime\Filter\DateTime::filter' + '\Magento\Framework\Stdlib\DateTime\Filter\DateTime::filter', ], [ '_filterDates', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\Stdlib\DateTime\Filter\Date::filter' + '\Magento\Framework\Stdlib\DateTime\Filter\Date::filter', ], ['_initDesign', '\Magento\Core\Controller\Varien\Action', '\Magento\Core\Model\DesignLoader::load'], ['_firePreDispatchEvents', '\Magento\Core\Controller\Varien\Action'], @@ -1207,38 +1208,38 @@ [ 'addPageLayoutHandles', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::loadLayout' + '\Magento\Framework\App\ViewInterface::loadLayout', ], [ 'getDefaultLayoutHandle', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::getDefaultLayoutHandle' + '\Magento\Framework\App\ViewInterface::getDefaultLayoutHandle', ], [ 'generateLayoutXml', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::generateLayoutXml' + '\Magento\Framework\App\ViewInterface::generateLayoutXml', ], [ 'renderLayout', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::renderLayout' + '\Magento\Framework\App\ViewInterface::renderLayout', ], ['getLayout', '\Magento\Core\Controller\Varien\Action', '\Magento\Framework\App\ViewInterface::getLayout'], [ 'loadLayoutUpdates', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::loadLayoutUpdates' + '\Magento\Framework\App\ViewInterface::loadLayoutUpdates', ], [ 'generateLayoutBlocks', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::generateLayoutBlocks' + '\Magento\Framework\App\ViewInterface::generateLayoutBlocks', ], [ 'addActionLayoutHandles', '\Magento\Core\Controller\Varien\Action', - '\Magento\Framework\App\ViewInterface::addActionLayoutHandles' + '\Magento\Framework\App\ViewInterface::addActionLayoutHandles', ], ['getTranslator', '\Magento\Framework\App\Helper\Context'], ['getTranslator', '\Magento\Core\Helper\Data'], @@ -1249,28 +1250,28 @@ [ 'changeQuoteCustomerGroupId', '\Magento\Sales\Model\Observer', - '\Magento\Quote\Model\Observer\Frontend\Quote\Address\CollectTotals::dispatch' + '\Magento\Quote\Model\Observer\Frontend\Quote\Address\CollectTotals::dispatch', ], [ 'getEncryptedSessionId', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\AbstractSession::getSessionId' + '\Magento\Core\Model\Session\AbstractSession::getSessionId', ], [ 'getSessionIdQueryParam', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\SidResolver::getSessionIdQueryParam' + '\Magento\Core\Model\Session\SidResolver::getSessionIdQueryParam', ], ['getCookie', '\Magento\Core\Model\Session\AbstractSession'], [ 'unsetAll', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\AbstractSession::clearStorage' + '\Magento\Core\Model\Session\AbstractSession::clearStorage', ], [ 'clear', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\AbstractSession::clearStorage' + '\Magento\Core\Model\Session\AbstractSession::clearStorage', ], ['delete', '\Magento\Framework\Stdlib\Cookie', '\Magento\Framework\Stdlib\Cookie::set'], ['setSkipSessionIdFlag', '\Magento\Core\Model\Session\AbstractSession'], @@ -1360,49 +1361,49 @@ [ '_initProductSave', '\Magento\Catalog\Controller\Adminhtml\Product', - '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::initialize' + '\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::initialize', ], ['superGroupAction', '\Magento\Catalog\Controller\Adminhtml\Product'], [ 'superGroupPopupAction', '\Magento\Catalog\Controller\Adminhtml\Product', - '\Magento\GroupedProduct\Controller\Adminhtml\Edit::popupAction' + '\Magento\GroupedProduct\Controller\Adminhtml\Edit::popupAction', ], [ 'prepareProductSave', '\Magento\Bundle\Model\Observer', - '\Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle::afterInitialize' + '\Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle::afterInitialize', ], [ 'duplicateProduct', 'Magento\Bundle\Model\Observer', - 'Magento\Bundle\Model\Product\CopyConstructor\Bundle::build' + 'Magento\Bundle\Model\Product\CopyConstructor\Bundle::build', ], [ 'prepareProductSave', '\Magento\Downloadable\Model\Observer', - '\Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Downloadable::afterInitialize' + '\Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Downloadable::afterInitialize', ], [ 'duplicateProduct', '\Magento\Downloadable\Model\Observer', - '\Magento\Downloadable\Model\Product\CopyConstructor\Downloadable::build' + '\Magento\Downloadable\Model\Product\CopyConstructor\Downloadable::build', ], [ 'catalogProductPrepareSave', '\Magento\PricePermissions\Model\Observer', '\Magento\PricePermissions\Controller\Adminhtml\Product\Initialization\Helper\Plugin\PricePermissions::' . - 'afterInitialize' + 'afterInitialize', ], [ 'getGroupedOptions', '\Magento\Catalog\Helper\Product\Configuration', - '\Magento\GroupedProduct\Helper\Product\Configuration\Plugin\Grouped::aroundGetOptions' + '\Magento\GroupedProduct\Helper\Product\Configuration\Plugin\Grouped::aroundGetOptions', ], [ 'copyInventoryData', 'Magento\CatalogInventory\Model\Observer', - '\Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory::build' + '\Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory::build', ], ['getTrackingAjaxUrl', 'Magento\Shipping\Helper\Data'], ['isFreeMethod', 'Magento\Shipping\Helper\Data'], @@ -1427,34 +1428,34 @@ [ '_processArrayNode', 'Magento\Framework\ObjectManager\Config\Mapper\Dom', - 'Magento\Framework\Data\Argument\Interpreter\ArrayType' + 'Magento\Framework\Data\Argument\Interpreter\ArrayType', ], [ '_processValueNode', 'Magento\Framework\ObjectManager\Config\Mapper\Dom', - 'Magento\Framework\Data\Argument\Interpreter\Composite' + 'Magento\Framework\Data\Argument\Interpreter\Composite', ], ['canSkipFilePublication', 'Magento\Framework\View\Publisher'], ['_getExtension', 'Magento\Framework\View\Publisher'], [ '_buildPublishedFilePath', 'Magento\Framework\View\Publisher', - 'Magento\Framework\View\Publisher\FileInterface' + 'Magento\Framework\View\Publisher\FileInterface', ], [ '_buildPublicViewRedundantFilename', 'Magento\Framework\View\Publisher', - 'Magento\Framework\View\Publisher\File' + 'Magento\Framework\View\Publisher\File', ], [ '_buildPublicViewSufficientFilename', 'Magento\Framework\View\Publisher', - 'Magento\Framework\View\Publisher\File' + 'Magento\Framework\View\Publisher\File', ], [ '_buildPublicViewFilename', 'Magento\Framework\View\Publisher', - 'Magento\Framework\View\Publisher\FileInterface' + 'Magento\Framework\View\Publisher\FileInterface', ], ['cleanAction', 'Magento\PageCache\Controller\Adminhtml\PageCache'], ['_isAllowed', 'Magento\PageCache\Controller\Adminhtml\PageCache'], @@ -1462,7 +1463,7 @@ [ '_processDatabaseFile', 'Magento\Sales\Controller\Download', - '\Magento\Sales\Model\Download::_processDatabaseFile' + '\Magento\Sales\Model\Download::_processDatabaseFile', ], ['useDbCompatibleMode', 'Magento\Core\Helper\Data'], ['getFlag', 'Magento\Catalog\Helper\Product\Flat'], @@ -1475,38 +1476,38 @@ [ 'getProductStatus', 'Magento\Catalog\Model\Resource\Product\Status', - 'Magento\CatalogInventory\Model\Resource\Stock\Status' + 'Magento\CatalogInventory\Model\Resource\Stock\Status', ], ['updateProductStatus', 'Magento\Catalog\Model\Product\Status'], ['getProductStatus', 'Magento\Catalog\Model\Product\Status'], [ 'addValueSortToCollection', 'Magento\Catalog\Model\Product\Status', - 'Magento\CatalogInventory\Model\Resource\Stock\Status' + 'Magento\CatalogInventory\Model\Resource\Stock\Status', ], ['catalogProductStatusUpdate', 'Magento\Sales\Model\Observer\Backend\CatalogProductQuote'], ['applyPermissionsAfterReindex', 'Magento\CatalogPermissions\Model\Adminhtml\Observer'], [ 'transitionProductType', 'Magento\Catalog\Model\Observer', - 'Magento\Catalog\Model\Product\TypeTransitionManager::processProduct' + 'Magento\Catalog\Model\Product\TypeTransitionManager::processProduct', ], [ 'transitionProductType', 'Magento\Downloadable\Model\Observer', - 'Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin\Downloadable::aroundProcessProduct' + 'Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin\Downloadable::aroundProcessProduct', ], [ 'isUsedBySuperProducts', 'Magento\Catalog\Model\Resource\Attribute', - 'Magento\ConfigurableProduct\Model\Attribute\LockValidator::validate' + 'Magento\ConfigurableProduct\Model\Attribute\LockValidator::validate', ], ['_detectMimeType', 'Magento\Framework\File\Transfer\Adapter\Http', '\Magento\Framework\File\Mime::getMimeType()'], ['getPublishedFilePath', 'Magento\Framework\View\Publisher'], [ 'getPublicFilePath', 'Magento\Framework\View\PublicFilesManagerInterface', - 'Magento\Framework\View\AssetInterface' + 'Magento\Framework\View\AssetInterface', ], ['getPublicFilePath', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\AssetInterface'], ['getPublicViewFile', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\AssetInterface'], @@ -1535,7 +1536,7 @@ [ 'storeDate', 'Magento\Framework\Stdlib\DateTime\TimezoneInterface', - 'Magento\Framework\Stdlib\DateTime\TimezoneInterface::scopeDate' + 'Magento\Framework\Stdlib\DateTime\TimezoneInterface::scopeDate', ], ['utcDate', 'Magento\Core\Model\Locale'], ['storeTimeStamp', 'Magento\Core\Model\Locale', 'Magento\Framework\Stdlib\DateTime\Timezone::scopeTimeStamp'], @@ -1560,13 +1561,13 @@ [ 'convertMeasureDimension', 'Magento\Usa\Helper\Data', - 'Magento\Shipping\Helper\Carrier::convertMeasureDimension' + 'Magento\Shipping\Helper\Carrier::convertMeasureDimension', ], ['getMeasureWeightName', 'Magento\Usa\Helper\Data', 'Magento\Shipping\Helper\Carrier::getMeasureWeightName'], [ 'getMeasureDimensionName', 'Magento\Usa\Helper\Data', - 'Magento\Shipping\Helper\Carrier::getMeasureDimensionName' + 'Magento\Shipping\Helper\Carrier::getMeasureDimensionName', ], ['displayGirthValue', 'Magento\Usa\Helper\Data', 'Magento\Usps\Helper\Data::displayGirthValue'], ['reindexProductPrices', '\Magento\Catalog\Model\Observer'], @@ -1575,7 +1576,7 @@ [ 'getStoreConfig', 'Magento\Framework\View\Element\Context', - '\Magento\Framework\View\Element\Context::getScopeConfig' + '\Magento\Framework\View\Element\Context::getScopeConfig', ], ['setConfig', 'Magento\Store\Model\Store'], ['getConfig', 'Magento\Store\Model\Store'], @@ -1583,7 +1584,7 @@ [ '_toOptionHashOptimized', 'Magento\Framework\Data\Collection\Db', - 'Magento\Tax\Model\Resource\Calculation\Rate\Collection::toOptionHashOptimized' + 'Magento\Tax\Model\Resource\Calculation\Rate\Collection::toOptionHashOptimized', ], ['getSwitchCurrencyUrl', 'Magento\Directory\Block\Currency'], ['getPageVarName', 'Magento\Catalog\Block\Product\ProductList\Toolbar'], @@ -1606,7 +1607,7 @@ [ 'reviewsAction', 'Magento\Catalog\Controller\Adminhtml\Product', - 'Magento\Review\Controller\Adminhtml\Product\Reviews::gridAction' + 'Magento\Review\Controller\Adminhtml\Product\Reviews::gridAction', ], ['_insertInlineScriptsHtml', 'Magento\DesignEditor\Model\Translate\Inline', 'addInlineScript'], ['initializeTranslation', 'Magento\Backend\Model\Observer'], @@ -1632,11 +1633,11 @@ [ 'isReservedAttribute', 'Magento\Catalog\Model\Product', - 'Magento\Catalog\Model\Product\ReservedAttributeList::isReservedAttribute' + 'Magento\Catalog\Model\Product\ReservedAttributeList::isReservedAttribute', ], [ 'getRatingSummary', - 'Magento\Catalog\Model\Product' + 'Magento\Catalog\Model\Product', ], ['getCurrentStore', 'Magento\Store\Model\StoreManagerInterface'], ['getAnyStoreView', 'Magento\Store\Model\StoreManagerInterface'], @@ -1702,38 +1703,38 @@ [ 'convertModuleNotationToPath', 'Magento\Framework\View\Asset\PreProcessor\ModuleNotation', - 'Magento\Framework\View\Asset\ModuleNotation\Resolver::convertModuleNotationToPath' + 'Magento\Framework\View\Asset\ModuleNotation\Resolver::convertModuleNotationToPath', ], ['getViewFile', 'Magento\Framework\View\FileSystem', 'Magento\Framework\View\Asset\File::getSourceFile()'], [ '_unserializeValue', 'Magento\CatalogInventory\Helper\Minsaleqty', - 'Magento\CatalogInventory\Helper\Minsaleqty::unserializeValue' + 'Magento\CatalogInventory\Helper\Minsaleqty::unserializeValue', ], [ '_isEncodedArrayFieldValue', 'Magento\CatalogInventory\Helper\Minsaleqty', - 'Magento\CatalogInventory\Helper\Minsaleqty::isEncodedArrayFieldValue' + 'Magento\CatalogInventory\Helper\Minsaleqty::isEncodedArrayFieldValue', ], [ '_serializeValue', 'Magento\CatalogInventory\Helper\Minsaleqty', - 'Magento\CatalogInventory\Helper\Minsaleqty::serializeValue' + 'Magento\CatalogInventory\Helper\Minsaleqty::serializeValue', ], [ '_fixQty', 'Magento\CatalogInventory\Helper\Minsaleqty', - 'Magento\CatalogInventory\Helper\Minsaleqty::fixQty' + 'Magento\CatalogInventory\Helper\Minsaleqty::fixQty', ], [ '_encodeArrayFieldValue', 'Magento\CatalogInventory\Helper\Minsaleqty', - 'Magento\CatalogInventory\Helper\Minsaleqty::encodeArrayFieldValue' + 'Magento\CatalogInventory\Helper\Minsaleqty::encodeArrayFieldValue', ], [ '_decodeArrayFieldValue', 'Magento\CatalogInventory\Helper\Minsaleqty', - 'Magento\CatalogInventory\Helper\Minsaleqty::decodeArrayFieldValue' + 'Magento\CatalogInventory\Helper\Minsaleqty::decodeArrayFieldValue', ], ['updateOrderAction', 'Magento\Paypal\Controller\Express\AbstractExpress'], ['updateOrder', 'Magento\Paypal\Model\Express\Checkout'], @@ -1750,7 +1751,7 @@ [ 'getFlatColums', 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource', - 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::getFlatColumns' + 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::getFlatColumns', ], ['addProductAdvanced', '\Magento\Quote\Model\Quote'], ['translateArray', 'Magento\Framework\App\Helper\AbstractHelper'], @@ -1764,14 +1765,14 @@ [ 'getWebsites', 'Magento\CatalogInventory\Model\StockIndex', - 'Magento\CatalogInventory\Model\StockIndex:getWebsitesWithDefaultStores' + 'Magento\CatalogInventory\Model\StockIndex:getWebsitesWithDefaultStores', ], ['getProductType', 'Magento\CatalogInventory\Model\StockIndex'], ['getProductTypeInstance', 'Magento\CatalogInventory\Model\StockIndex'], [ 'getPriceHtml', '\Magento\Catalog\Block\Product\AbstractProduct', - '\Magento\Catalog\Block\Product\AbstractProduct::getProductPriceHtml' + '\Magento\Catalog\Block\Product\AbstractProduct::getProductPriceHtml', ], ['getDeleteUrl', '\Magento\Checkout\Block\Cart\Item\Renderer'], ['sendNewOrderEmail', 'Magento\Sales\Model\Order'], @@ -1792,72 +1793,72 @@ [ 'rebuildIndex', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::rebuildIndex' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::rebuildIndex', ], [ '_rebuildStoreIndex', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::rebuildStoreIndex' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::rebuildStoreIndex', ], [ '_getSearchableProducts', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getSearchableProducts' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getSearchableProducts', ], [ 'cleanIndex', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::cleanIndex' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::cleanIndex', ], [ 'getEavConfig', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getEavConfig' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getEavConfig', ], [ '_getSearchableAttributes', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getSearchableAttributes' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getSearchableAttributes', ], [ '_getSearchableAttribute', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getSearchableAttribute' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getSearchableAttribute', ], [ '_unifyField', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::unifyField' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::unifyField', ], [ '_getProductAttributes', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductAttributes' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductAttributes', ], [ '_getProductTypeInstance', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductTypeInstance' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductTypeInstance', ], [ '_getProductChildIds', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductChildIds' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductChildIds', ], [ '_getProductEmulator', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductEmulator' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getProductEmulator', ], [ '_prepareProductIndex', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::prepareProductIndex' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::prepareProductIndex', ], [ '_getAttributeValue', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getAttributeValue' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getAttributeValue', ], [ '_saveProductIndex', @@ -1866,12 +1867,12 @@ [ '_saveProductIndexes', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::saveProductIndexes' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::saveProductIndexes', ], [ '_getStoreDate', 'Magento\CatalogSearch\Model\Resource\Fulltext', - 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getStoreDate' + 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full::getStoreDate', ], [ 'updateCategoryIndex', @@ -1894,12 +1895,12 @@ [ 'loadPreviousPrices', 'Magento\Catalog\Model\Layer\Filter\Price', - 'Magento\CatalogSearch\Model\Price\Interval::loadPrevious' + 'Magento\CatalogSearch\Model\Price\Interval::loadPrevious', ], [ 'loadNextPrices', 'Magento\Catalog\Model\Layer\Filter\Price', - 'Magento\CatalogSearch\Model\Price\Interval::loadNext' + 'Magento\CatalogSearch\Model\Price\Interval::loadNext', ], ['getQuery', 'Magento\CatalogSearch\Helper\Data', 'Magento\Search\Model\QueryFactory::get'], ['getQueryText', 'Magento\CatalogSearch\Helper\Data', 'Magento\Search\Model\Query::getQueryText'], @@ -1984,7 +1985,7 @@ [ 'getRatesByCustomerAndProductTaxClassId', 'Magento\Tax\Service\V1\TaxRuleServiceInterface', - 'Magento\Tax\Api\TaxRateManagementInterface::getRatesByCustomerAndProductTaxClassId' + 'Magento\Tax\Api\TaxRateManagementInterface::getRatesByCustomerAndProductTaxClassId', ], ['getProduct', 'Magento\Catalog\Helper\Product'], ['getCategoryModel', 'Magento\Catalog\Model\Resource\Url'], @@ -2017,12 +2018,12 @@ [ 'isAutomaticCleaningAvailable', 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator', - 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::getCapabilities' + 'Magento\Framework\Cache\Backend\Decorator\AbstractDecorator::getCapabilities', ], [ 'getNoteNotify', 'Magento\Sales\Block\Adminhtml\Order\Create\Comment', - 'Magento\Sales\Block\Adminhtml\Order\Create\Totals' + 'Magento\Sales\Block\Adminhtml\Order\Create\Totals', ], ['getLinksConfig', 'Magento\Downloadable\Block\Catalog\Product\Links'], ['getAuthorizationAmounts', 'Magento\Paypal\Model\Config'], @@ -2079,44 +2080,44 @@ [ 'render', 'Magento\Framework\Webapi\ErrorProcessor', - 'Magento\Framework\Webapi\ErrorProcessor::renderErrorMessage' + 'Magento\Framework\Webapi\ErrorProcessor::renderErrorMessage', ], [ 'processServiceOutput', 'Magento\Webapi\Controller\Rest\Response\DataObjectConverter', - 'Magento\Framework\Webapi\ServiceOutputProcessor::process' + 'Magento\Framework\Webapi\ServiceOutputProcessor::process', ], [ 'getInputData', 'Magento\Webapi\Controller\ServiceArgsSerializer', - 'Magento\Framework\Webapi\ServiceInputProcessor::process' + 'Magento\Framework\Webapi\ServiceInputProcessor::process', ], [ 'getServiceName', 'Magento\Webapi\Helper\Data', - 'Magento\Webapi\Model\Soap\Config::getServiceName' + 'Magento\Webapi\Model\Soap\Config::getServiceName', ], [ 'getServiceNameParts', 'Magento\Webapi\Helper\Data', - 'Magento\Webapi\Model\Soap\Config::getServiceNameParts' + 'Magento\Webapi\Model\Soap\Config::getServiceNameParts', ], [ 'getSelectedResources', 'Magento\Webapi\Helper\Data', - 'Magento\Webapi\Model\Soap\Config::getSelectedResources' + 'Magento\Webapi\Model\Soap\Config::getSelectedResources', ], [ 'validateCredentials', 'Magento\Integration\Helper\Validator', - 'Magento\Integration\Model\CredentialsValidator::validate' + 'Magento\Integration\Model\CredentialsValidator::validate', ], ['getGlobalIcon', '\Magento\Backend\Block\Widget'], ['getSuccessRedirect', 'Magento\Customer\Controller\Account\CreatePost'], [ 'loginPostRedirect', 'Magento\Customer\Controller\Account\LoginPost', - 'Magento\Customer\Model\Account\Redirect::getRedirect' + 'Magento\Customer\Model\Account\Redirect::getRedirect', ], ['isReviewOwner', 'Magento\Review\Block\Customer\View'], ['getRegistration', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getRegistration'], @@ -2159,9 +2160,76 @@ ['addOrdersCount', 'Magento\Reports\Model\Resource\Customer\Collection'], ['addSumAvgTotals', 'Magento\Reports\Model\Resource\Customer\Collection'], ['orderByTotalAmount', 'Magento\Reports\Model\Resource\Customer\Collection'], - ['addOrdersCount', 'Magento\Reports\Model\Resource\Product\Collection'], ['addOrderedQty', 'Magento\Reports\Model\Resource\Product\Collection'], ['prepareForProductsInCarts', 'Magento\Reports\Model\Resource\Quote\Collection'], ['getOrdersSubSelect', 'Magento\Reports\Model\Resource\Quote\Collection'], ['isOrderIncrementIdUsed', 'Magento\Quote\Model\Resource\Quote'], + ['isStateProtected', 'Magento\Sales\Model\Order'], + ['_getBundleOptions', 'Magento\Bundle\Block\Checkout\Cart\Item\Renderer'], + ['_getSelectionFinalPrice', 'Magento\Bundle\Block\Checkout\Cart\Item\Renderer'], + ['_getSelectionQty', 'Magento\Bundle\Block\Checkout\Cart\Item\Renderer'], + ['getItemCount', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['getRecentItems', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['getSubtotal', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['getSummaryCount', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['isPossibleOnepageCheckout', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['getItems', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['getSummaryText', 'Magento\Checkout\Block\Cart\Sidebar', 'Moved to Magento\Checkout\CustomerData\Cart'], + ['getCacheKeyInfo', 'Magento\Checkout\Block\Cart\Sidebar'], + ['_serializeRenders', 'Magento\Checkout\Block\Cart\Sidebar'], + ['deserializeRenders', 'Magento\Checkout\Block\Cart\Sidebar'], + ['getIdentities', 'Magento\Checkout\Block\Cart\Sidebar'], + [ + 'validateMinimunAmount', + 'Magento\Checkout\Block\Cart\ValidationMessages', + 'Magento\Checkout\Block\Cart\ValidationMessages::validateMinimunAmount', + ], + ['getCustomerName', 'Magento\Customer\Block\Account\Customer', 'Moved to Magento\Customer\CustomerData'], + ['_prepareCollection', 'Magento\Wishlist\Block\Customer\Sidebar'], + ['_toHtml', 'Magento\Wishlist\Block\Customer\Sidebar'], + [ + 'getCanDisplayWishlist', + 'Magento\Wishlist\Block\Customer\Sidebar', + 'Moved to Magento\Wishlist\CustomerData\Wishlist', + ], + ['getWishlistItems', 'Magento\Wishlist\Block\Customer\Sidebar', 'Moved to Magento\Wishlist\CustomerData\Wishlist'], + ['getItemCount', 'Magento\Wishlist\Block\Customer\Sidebar', 'Moved to Magento\Wishlist\CustomerData\Wishlist'], + ['hasWishlistItems', 'Magento\Wishlist\Block\Customer\Sidebar', 'Moved to Magento\Wishlist\CustomerData\Wishlist'], + ['getIdentities', 'Magento\Wishlist\Block\Customer\Sidebar'], + [ + 'getAddAllToCartUrl', + 'Magento\Wishlist\Block\Customer\Sidebar', + 'Magento\Wishlist\Block\Customer\Sidebar::getAddAllToCartParams', + ], + [ + 'getItemAddToCartUrl', + 'Magento\Wishlist\Block\AbstractBlock', + 'Magento\Wishlist\Block\AbstractBlock::getItemAddToCartParams', + ], + ['getCounter', 'Magento\Wishlist\Block', 'Moved to Magento\Wishlist\CustomerData\Wishlist'], + ['_getItemCount', 'Magento\Wishlist\Block', 'Moved to Magento\Wishlist\CustomerData\Wishlist'], + ['_createCounter', 'Magento\Wishlist\Block', 'Moved to Magento\Wishlist\CustomerData\Wishlist'], + ['getTitle', 'Magento\Wishlist\Block'], + [ + 'initOrders', + 'Magento\Sales\Block\Reorder\Sidebar', + 'Moved to \Magento\Sales\CustomerData\LastOrderedItems', + ], + ['getItems', 'Magento\Sales\Block\Reorder\Sidebar', 'Moved to \Magento\Sales\CustomerData\LastOrderedItems'], + [ + 'isItemAvailableForReorder', + 'Magento\Sales\Block\Reorder\Sidebar', + 'Moved to \Magento\Sales\CustomerData\LastOrderedItems', + ], + [ + 'getLastOrder', + 'Magento\Sales\Block\Reorder\Sidebar', + 'Moved to \Magento\Sales\CustomerData\LastOrderedItems', + ], + ['getIdentities', 'Magento\Sales\Block\Reorder\Sidebar'], + ['assignData', 'Magento\OfflinePayments\Model\Checkmo'], + ['timeShift', 'Magento\Reports\Model\Resource\Report\Collection'], + ['Magento\Catalog\Model\Product\Attribute\Backend\Startdate', 'Magento\Catalog\Model\Attribute\Backend\Startdate'], + ['_getStoreTimezoneUtcOffset', 'Magento\Reports\Model\Resource\Report\AbstractReport'], + ['_dateToUtc', 'Magento\Reports\Model\Resource\Report\AbstractReport'], ]; 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 5014947fdb32a..b5f328e8bed28 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 @@ -398,9 +398,9 @@ ['_locale', 'Magento\Directory\Block\Currency', 'localeResolver'], ['_locale', 'Magento\GoogleAdwords\Model\Config\Source\Language'], ['_localeLists', 'Magento\Payment\Model\Config', 'localeResolver'], - ['zendLocale', 'Magento\Setup\Model\Lists', 'localeResolver'], + ['zendLocale', 'Magento\Framework\Setup\Lists', 'localeResolver'], ['_locale', 'Magento\Framework\Data\Form\Filter\Date', 'localeResolver'], - ['_locale', 'Magento\Framework\Locale\Lists', 'localeResolver'], + ['_locale', 'Magento\Framework\Locale\TranslatedLists', 'localeResolver'], ['_defaultLocale', 'Magento\Framework\Locale\Resolver', 'defaultLocale'], ['_scopeType', 'Magento\Framework\Locale\Resolver', 'scopeType'], ['_locale', 'Magento\Framework\Locale\Resolver', 'locale'], diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index 3b24b6214aa20..47b334a5237a5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -27,8 +27,6 @@ Magento/CatalogInventory/Model/Source Magento/CatalogSearch/Model/Resource/Helper Magento/CatalogSearch/Model/Resource/Advanced Magento/CatalogSearch/Model/Resource/Search -Magento/Centinel/Controller -Magento/Centinel/Model/State Magento/Checkout/Block/Multishipping Magento/Checkout/Model/Type Magento/Catalog/Model/Template @@ -166,3 +164,4 @@ Magento/Reports/Setup Magento/Sales/Setup Magento/SalesRule/Setup Magento/Eav/Setup +setup/src/Magento/Setup/Fixtures diff --git a/dev/tests/unit/framework/autoload.php b/dev/tests/unit/framework/autoload.php index 56021a2bb4acf..9f7aa040004fc 100644 --- a/dev/tests/unit/framework/autoload.php +++ b/dev/tests/unit/framework/autoload.php @@ -4,52 +4,10 @@ * See COPYING.txt for license details. */ -use Magento\Framework\Api\Code\Generator\DataBuilder; -use Magento\Framework\Api\Code\Generator\Mapper; -use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; -use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; -use Magento\Framework\Api\Code\Generator\SearchResults; -use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; -use Magento\Framework\Interception\Code\Generator\Interceptor; -use Magento\Framework\ObjectManager\Code\Generator\Converter; -use Magento\Framework\ObjectManager\Code\Generator\Factory; -use Magento\Framework\ObjectManager\Code\Generator\Persistor; -use Magento\Framework\ObjectManager\Code\Generator\Proxy; -use Magento\Framework\ObjectManager\Code\Generator\Repository; -use Magento\Tools\Di\Code\Scanner; -use Magento\Tools\Di\Compiler\Log\Writer; -use Magento\Tools\Di\Definition\Compressor; - -/** - * Enable code generation for the undeclared classes. - */ -$generationDir = TESTS_TEMP_DIR . '/var/generation'; -$generatorIo = new \Magento\Framework\Code\Generator\Io( - new \Magento\Framework\Filesystem\Driver\File(), - $generationDir +$autoloader = new \Magento\Framework\TestFramework\Unit\Autoloader\ExtensionGeneratorAutoloader( + new \Magento\Framework\Code\Generator\Io( + new \Magento\Framework\Filesystem\Driver\File(), + TESTS_TEMP_DIR . '/var/generation' + ) ); -$generator = new \Magento\Framework\Code\Generator( - $generatorIo, - [ - Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', - Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', - Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', - Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', - Persistor::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Persistor', - Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', - Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', - SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults', - ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', - ExtensionAttributesGenerator::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator' - ] -); -/** Initialize object manager for code generation based on configs */ -$magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); -$objectManager = $magentoObjectManagerFactory->create($_SERVER); -$generator->setObjectManager($objectManager); - -$autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); spl_autoload_register([$autoloader, 'load']); -$autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader(); -$autoloadWrapper->addPsr4('Magento\\', $generationDir . '/Magento/'); diff --git a/dev/tests/unit/phpunit.xml.dist b/dev/tests/unit/phpunit.xml.dist index 4c5587187da79..80c46fdb99225 100644 --- a/dev/tests/unit/phpunit.xml.dist +++ b/dev/tests/unit/phpunit.xml.dist @@ -21,6 +21,7 @@ + diff --git a/dev/tools/Magento/Tools/Dependency/generate/framework-dependencies.php b/dev/tools/Magento/Tools/Dependency/generate/framework-dependencies.php deleted file mode 100644 index ebdc4e125677e..0000000000000 --- a/dev/tools/Magento/Tools/Dependency/generate/framework-dependencies.php +++ /dev/null @@ -1,39 +0,0 @@ - 'Path to base directory for parsing']); - $console->parse(); - - $directory = $console->getOption('directory') ?: BP; - - Files::setInstance(new \Magento\Framework\App\Utility\Files($directory)); - $filesForParse = Files::init()->getFiles([Files::init()->getPathToSource() . '/app/code/Magento'], '*'); - $configFiles = Files::init()->getConfigFiles('module.xml', [], false); - - ServiceLocator::getFrameworkDependenciesReportBuilder()->build( - [ - 'parse' => [ - 'files_for_parse' => $filesForParse, - 'config_files' => $configFiles, - 'declared_namespaces' => Files::init()->getNamespaces(), - ], - 'write' => ['report_filename' => 'framework-dependencies.csv'], - ] - ); - - fwrite(STDOUT, PHP_EOL . 'Report successfully processed.' . PHP_EOL); -} catch (\Zend_Console_Getopt_Exception $e) { - fwrite(STDERR, $e->getUsageMessage() . PHP_EOL); - exit(1); -} catch (\Exception $e) { - fwrite(STDERR, 'Please, check passed path. Dependencies report generator failed: ' . $e->getMessage() . PHP_EOL); - exit(1); -} diff --git a/dev/tools/Magento/Tools/Dependency/generate/modules-circular-dependencies.php b/dev/tools/Magento/Tools/Dependency/generate/modules-circular-dependencies.php deleted file mode 100644 index ed5869bd2b0a3..0000000000000 --- a/dev/tools/Magento/Tools/Dependency/generate/modules-circular-dependencies.php +++ /dev/null @@ -1,34 +0,0 @@ - 'Path to base directory for parsing']); - $console->parse(); - - $directory = $console->getOption('directory') ?: BP; - - Files::setInstance(new \Magento\Framework\App\Utility\Files($directory)); - $filesForParse = Files::init()->getComposerFiles('code', false); - - ServiceLocator::getCircularDependenciesReportBuilder()->build( - [ - 'parse' => ['files_for_parse' => $filesForParse], - 'write' => ['report_filename' => 'modules-circular-dependencies.csv'], - ] - ); - - fwrite(STDOUT, PHP_EOL . 'Report successfully processed.' . PHP_EOL); -} catch (\Zend_Console_Getopt_Exception $e) { - fwrite(STDERR, $e->getUsageMessage() . PHP_EOL); - exit(1); -} catch (\Exception $e) { - fwrite(STDERR, 'Please, check passed path. Dependencies report generator failed: ' . $e->getMessage() . PHP_EOL); - exit(1); -} diff --git a/dev/tools/Magento/Tools/Dependency/generate/modules-dependencies.php b/dev/tools/Magento/Tools/Dependency/generate/modules-dependencies.php deleted file mode 100644 index b32dadf099e89..0000000000000 --- a/dev/tools/Magento/Tools/Dependency/generate/modules-dependencies.php +++ /dev/null @@ -1,35 +0,0 @@ - 'Path to base directory for parsing']); - $console->parse(); - - $directory = $console->getOption('directory') ?: BP; - - Files::setInstance(new \Magento\Framework\App\Utility\Files($directory)); - $filesForParse = Files::init()->getComposerFiles('code', false); - - ServiceLocator::getDependenciesReportBuilder()->build( - [ - 'parse' => ['files_for_parse' => $filesForParse], - 'write' => ['report_filename' => 'modules-dependencies.csv'], - ] - ); - - fwrite(STDOUT, PHP_EOL . 'Report successfully processed.' . PHP_EOL); -} catch (\Zend_Console_Getopt_Exception $e) { - fwrite(STDERR, $e->getUsageMessage() . PHP_EOL); - exit(1); -} catch (\Exception $e) { - fwrite(STDERR, 'Please, check passed path. Dependencies report generator failed: ' . $e->getMessage() . PHP_EOL); - exit(1); -} diff --git a/dev/tools/Magento/Tools/Layout/Reference/Processor.php b/dev/tools/Magento/Tools/Layout/Reference/Processor.php deleted file mode 100644 index 4ca794104d8ad..0000000000000 --- a/dev/tools/Magento/Tools/Layout/Reference/Processor.php +++ /dev/null @@ -1,195 +0,0 @@ - '//reference[@name]', - 'block' => '//block[@name]', - 'container' => '//container[@name]', - ]; - - /** - * @param Formatter $formatter - * @param string $referencesFile - */ - public function __construct(Formatter $formatter, $referencesFile) - { - $this->_formatter = $formatter; - $this->_referencesFile = $referencesFile; - $contents = ''; - if (file_exists($referencesFile)) { - $contents = file_get_contents($referencesFile); - } - $this->_referenceList = new \SimpleXMLElement($contents); - } - - /** - * Create list from array - * - * @param array $data - * @param string $type - * @return Processor - */ - protected function _addElements($data, $type) - { - array_walk_recursive( - $data, - function ($value) use ($type) { - if (!$this->_referenceList->xpath("//item[@type='{$type}' and @value='{$value}']")) { - $element = $this->_referenceList->addChild('item'); - $element->addAttribute('type', $type); - $element->addAttribute('value', $value); - } - } - ); - - return $this; - } - - /** - * Get layout file from Magento root directory - * - * @param string $path - * @return string[] - */ - public function getLayoutFiles($path) - { - $result = []; - $patterns = [ - '/app/design/*/*/*/layout/*.xml', - '/app/design/*/*/*/layout/*/*.xml', - '/app/design/*/*/*/layout/*/*/*/*.xml', - '/app/design/*/*/*/layout/*/*/*/*/*.xml', - '/app/design/*/*/*/layout/*/*/*/*/*/*.xml', - '/app/code/*/*/*/*/layout/*.xml', - '/app/code/*/*/*/*/layout/*/*.xml', - '/app/code/*/*/*/*/layout/*/*/*/*.xml', - '/app/code/*/*/*/*/layout/*/*/*/*/*.xml', - '/app/code/*/*/*/*/layout/*/*/*/*/*/*.xml', - ]; - - foreach ($patterns as $pattern) { - $result = array_merge($result, glob($path . $pattern)); - } - return $result; - } - - /** - * Retrieve references and referenced names from $layouts files and - * - * @param array $layouts - * @return Processor - * @throws \Exception - */ - public function getReferences($layouts) - { - if (empty($layouts)) { - throw new \Exception("No layouts found"); - } - $references = []; - foreach ($this->_referencePattern as $patternName => $xpath) { - $result = []; - foreach ($layouts as $layout) { - $xml = simplexml_load_file($layout); - $nodes = $xml->xpath($xpath); - foreach ($nodes as $node) { - $result[(string)$node['name']] = ''; - } - } - $resultPrint = array_keys($result); - sort($resultPrint); - $references[$patternName] = $resultPrint; - } - - $conflictReferences = $references['reference']; - foreach ($references as $key => $names) { - $this->_addElements($names, $key); - if ($key != 'reference') { - $conflictReferences = array_diff($conflictReferences, $names); - } - } - $this->_addElements($conflictReferences, 'conflictReferences'); - $this->_addElements(array_intersect($references['block'], $references['container']), 'conflictNames'); - return $this; - } - - /** - * Update layout files to new format of references using $processor - * - * @param array $layouts - * @param string $processor - * @param bool $overwrite - * @return void - */ - public function updateReferences($layouts, $processor = '', $overwrite = true) - { - if (empty($processor)) { - $processor = __DIR__ . '/../processors/layoutReferences.xsl'; - } - if (!file_exists($processor)) { - return; - } - $stylesheet = new \DOMDocument(); - $stylesheet->preserveWhiteSpace = true; - $stylesheet->load($processor); - - $xslt = new \XSLTProcessor(); - $xslt->registerPHPFunctions(); - $xslt->importStylesheet($stylesheet); - $xslt->setParameter('', 'referencesFile', str_replace('\\', '/', $this->_referencesFile)); - - foreach ($layouts as $layout) { - $doc = new \DOMDocument(); - $doc->preserveWhiteSpace = true; - $doc->load($layout); - - $transformedDoc = $xslt->transformToXml($doc); - $result = $this->_formatter->format($transformedDoc); - if ($overwrite) { - file_put_contents($layout, $result); - } else { - echo $result; - } - } - } - - /** - * Write reference list to the file - * - * @return Processor - */ - public function writeToFile() - { - $result = $this->_formatter->format($this->_referenceList->asXML()); - file_put_contents($this->_referencesFile, $result); - return $this; - } -} diff --git a/dev/tools/layout/processors/addItemRenderer.xsl b/dev/tools/Magento/Tools/Layout/processors/addItemRenderer.xsl similarity index 100% rename from dev/tools/layout/processors/addItemRenderer.xsl rename to dev/tools/Magento/Tools/Layout/processors/addItemRenderer.xsl diff --git a/dev/tools/layout/processors/headBlocks.xsl b/dev/tools/Magento/Tools/Layout/processors/headBlocks.xsl similarity index 100% rename from dev/tools/layout/processors/headBlocks.xsl rename to dev/tools/Magento/Tools/Layout/processors/headBlocks.xsl diff --git a/dev/tools/Magento/Tools/Layout/reference.php b/dev/tools/Magento/Tools/Layout/reference.php deleted file mode 100644 index 9c239f00993c3..0000000000000 --- a/dev/tools/Magento/Tools/Layout/reference.php +++ /dev/null @@ -1,67 +0,0 @@ - "Directory to process(optional, default {$rootDir})", - 'file|f=s' => 'File to process(optional)', - 'overwrite|o' => 'Overwrite file', - 'collect|c' => 'Collect names for a dictionary', - 'process|p' => 'Process references using dictionary', - 'dictionary|d=s' => 'Dictionary file (required)', - 'processor=s' => 'Processor file (optional)', - ] - ); - $opt->parse(); - - if ($opt->dir) { - $rootDir = realpath($opt->dir); - } - if (!file_exists($rootDir) || !is_dir($rootDir)) { - throw new \Exception("Directory to process ({$rootDir}) not found"); - } - if (empty($opt->dictionary)) { - throw new \Exception("Dictionary file is required"); - } - - if (!empty($opt->process) && empty($opt->file) && empty($opt->overwrite)) { - throw new \Exception("Overwrite option is required if you going to process multiple files"); - } - - if (!file_exists($opt->dictionary)) { - touch($opt->dictionary); - } - - $processor = new Processor(new Formatter(), realpath($opt->dictionary)); - - $layouts = []; - if (!empty($opt->file) && file_exists($opt->file)) { - $layouts = [realpath($opt->file)]; - } else { - $layouts = $processor->getLayoutFiles($rootDir); - } - - if ($opt->collect) { - $processor->getReferences($layouts)->writeToFile(); - } - - if ($opt->process) { - $processor->updateReferences($layouts, $opt->processor, $opt->overwrite); - } - - exit(0); -} catch (\Zend_Console_Getopt_Exception $e) { - echo $e->getUsageMessage(); - exit(255); -} catch (\Exception $e) { - echo $e, PHP_EOL; - exit(255); -} diff --git a/dev/tools/Magento/Tools/Layout/xmlUpdater.php b/dev/tools/Magento/Tools/Layout/xmlUpdater.php deleted file mode 100644 index 7233f568ef95b..0000000000000 --- a/dev/tools/Magento/Tools/Layout/xmlUpdater.php +++ /dev/null @@ -1,47 +0,0 @@ - 'File to process(required)', - 'processor|p=s' => 'Processor file (required)', - 'overwrite|o' => 'Overwrite file', - ] - ); - $opt->parse(); - - $doc = new \DOMDocument(); - $doc->preserveWhiteSpace = true; - $doc->load($opt->file); - - $stylesheet = new \DOMDocument(); - $stylesheet->preserveWhiteSpace = true; - $stylesheet->load($opt->processor); - - $formater = new \Magento\Tools\Layout\Formatter(); - - $xslt = new XSLTProcessor(); - $xslt->registerPHPFunctions(); - $xslt->importStylesheet($stylesheet); - $transformedDoc = $xslt->transformToXml($doc); - $result = $formater->format($transformedDoc); - if ($opt->overwrite) { - file_put_contents($opt->file, $result); - } else { - echo $result; - } - exit(0); -} catch (\Zend_Console_Getopt_Exception $e) { - echo $e->getUsageMessage(); - exit(255); -} catch (\Exception $e) { - echo $e, PHP_EOL; - exit(255); -} diff --git a/dev/tools/grunt/configs/banner.js b/dev/tools/grunt/configs/banner.js deleted file mode 100644 index df195f673c0bb..0000000000000 --- a/dev/tools/grunt/configs/banner.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -'use strict'; - -module.exports = { - firstLine: 'Copyright © <%= grunt.template.today("yyyy") %> Magento. All rights reserved.', - secondLine: 'See COPYING.txt for license details.', - - css: function () { - return '/**\n * ' + this.firstLine + '\n * ' + this.secondLine + '\n */\n'; - }, - - less: function () { - return '// /**\n// * ' + this.firstLine + '\n// * ' + this.secondLine + '\n// */\n'; - }, - - html: function () { - return '\n'; - } -}; diff --git a/dev/tools/grunt/configs/usebanner.js b/dev/tools/grunt/configs/usebanner.js index 699e33a66766d..fb952f050c2b9 100644 --- a/dev/tools/grunt/configs/usebanner.js +++ b/dev/tools/grunt/configs/usebanner.js @@ -5,7 +5,22 @@ 'use strict'; -var banner = require('./banner'); +var banner = { + firstLine: 'Copyright © 2015 Magento. All rights reserved.', + secondLine: 'See COPYING.txt for license details.', + + css: function () { + return '/**\n * ' + this.firstLine + '\n * ' + this.secondLine + '\n */\n'; + }, + + less: function () { + return '// /**\n// * ' + this.firstLine + '\n// * ' + this.secondLine + '\n// */\n'; + }, + + html: function () { + return '\n'; + } +}; module.exports = { options: { diff --git a/dev/tools/layout/xml-updater.php b/dev/tools/layout/xml-updater.php deleted file mode 100644 index 700f28d45fcc3..0000000000000 --- a/dev/tools/layout/xml-updater.php +++ /dev/null @@ -1,45 +0,0 @@ - 'File to process(required)', - 'processor|p=s' => 'Processor file (required)', - 'overwrite|o' => 'Overwrite file', - ]); - $opt->parse(); - - $doc = new DOMDocument(); - $doc->preserveWhiteSpace = true; - $doc->load($opt->file); - - $stylesheet = new DOMDocument(); - $stylesheet->preserveWhiteSpace = true; - $stylesheet->load($opt->processor); - - $formater = new \Magento\Tools\Layout\Formatter(); - - $xslt = new XSLTProcessor(); - $xslt->registerPHPFunctions(); - $xslt->importStylesheet($stylesheet); - $transformedDoc = $xslt->transformToXml($doc); - $result = $formater->format($transformedDoc); - if ($opt->overwrite) { - file_put_contents($opt->file, $result); - } else { - echo $result; - } - exit(0); -} catch (Zend_Console_Getopt_Exception $e) { - echo $e->getUsageMessage(); - exit(255); -} catch (Exception $e) { - echo $e, PHP_EOL; - exit(255); -} diff --git a/dev/tools/performance-toolkit/fixtures/orders.php b/dev/tools/performance-toolkit/fixtures/orders.php deleted file mode 100644 index 041fcea755125..0000000000000 --- a/dev/tools/performance-toolkit/fixtures/orders.php +++ /dev/null @@ -1,314 +0,0 @@ -getValue('orders', 0); - if ($ordersCount < 1) { - return; - } - $this->application->resetObjectManager(); - - $writeAdapter = $this->getConnection('write'); - - $quoteTableName = $this->getTableName( - 'quote', - 'Magento\Quote\Model\Resource\Quote' - ); - $quoteAddressTableName = $this->getTableName( - 'quote_address', - 'Magento\Quote\Model\Resource\Quote\Address' - ); - $quoteItemTableName = $this->getTableName( - 'quote_item', - 'Magento\Quote\Model\Resource\Quote\Item' - ); - $quoteItemOptionTableName = $this->getTableName( - 'quote_item_option', - 'Magento\Quote\Model\Resource\Quote\Item\Option' - ); - $quotePaymentTableName = $this->getTableName( - 'quote_payment', - 'Magento\Quote\Model\Resource\Quote\Payment' - ); - $quoteAddressRateTableName = $this->getTableName( - 'quote_shipping_rate', - 'Magento\Quote\Model\Resource\Quote\Address\Rate' - ); - $reportEventTableName = $this->getTableName( - 'report_event', - 'Magento\Reports\Model\Resource\Event' - ); - $salesOrderTableName = $this->getTableName( - 'sales_order', - 'Magento\Sales\Model\Resource\Order' - ); - $salesOrderAddressTableName = $this->getTableName( - 'sales_order_address', - 'Magento\Sales\Model\Resource\Order' - ); - $salesOrderGridTableName = $this->getTableName( - 'sales_order_grid', - 'Magento\Sales\Model\Resource\Order\Grid' - ); - $salesOrderItemTableName = $this->getTableName( - 'sales_order_item', - 'Magento\Sales\Model\Resource\Order\Item' - ); - $salesOrderPaymentTableName = $this->getTableName( - 'sales_order_payment', - 'Magento\Sales\Model\Resource\Order\Payment' - ); - $salesOrderStatusHistoryTableName = $this->getTableName( - 'sales_order_status_history', - 'Magento\Sales\Model\Resource\Order\Status\History' - ); - $eavEntityStoreTableName = $this->getTableName( - 'eav_entity_store', - '\Magento\Eav\Model\Resource\Entity\Store' - ); - /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); - /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); - /** @var $product \Magento\Catalog\Model\Product */ - $product = $this->application->getObjectManager()->get('Magento\Catalog\Model\Product'); - - $result = []; - $stores = $storeManager->getStores(); - foreach ($stores as $store) { - $storeId = $store->getStoreId(); - $websiteId = $store->getWebsite()->getId(); - $websiteName = $store->getWebsite()->getName(); - $groupName = $store->getGroup()->getName(); - $storeName = $store->getName(); - $storeRootCategory = $store->getRootCategoryId(); - $category->load($storeRootCategory); - $categoryResource = $category->getResource(); - //Get all categories - $resultsCategories = $categoryResource->getAllChildren($category); - foreach ($resultsCategories as $resultsCategory) { - $category->load($resultsCategory); - $structure = explode('/', $category->getPath()); - $pathSize = count($structure); - if ($pathSize > 1) { - $path = []; - for ($i = 1; $i < $pathSize; $i++) { - $path[] = $category->load($structure[$i])->getName(); - } - array_shift($path); - $resultsCategoryName = implode('/', $path); - } else { - $resultsCategoryName = $category->getName(); - } - //Not use root categories - if (trim($resultsCategoryName) != '') { - /** @var $productCategory \Magento\Catalog\Model\Category */ - $productCategory = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); - - /** @var $simpleProductCollection \Magento\Catalog\Model\Resource\Product\Collection */ - $simpleProductCollection = $this->application->getObjectManager()->create( - 'Magento\Catalog\Model\Resource\Product\Collection' - ); - - $simpleProductCollection->addStoreFilter($storeId); - $simpleProductCollection->addWebsiteFilter($websiteId); - $simpleProductCollection->addCategoryFilter($productCategory->load($resultsCategory)); - $simpleProductCollection->getSelect()->where(" type_id = 'simple' "); - $simpleIds = $simpleProductCollection->getAllIds(2); - $simpleProductsResult = []; - foreach ($simpleIds as $key => $simpleId) { - $simpleProduct = $product->load($simpleId); - $simpleProductsResult[$key]['simpleProductId'] = $simpleId; - $simpleProductsResult[$key]['simpleProductSku'] = $simpleProduct->getSku(); - $simpleProductsResult[$key]['simpleProductName'] = $simpleProduct->getName(); - } - - $result[] = [ - $storeId, - $websiteName. '\n'. $groupName . '\n' . $storeName, - $simpleProductsResult - ]; - } - } - } - - $productStoreId = function ($index) use ($result) { - return $result[$index % count($result)][0]; - }; - $productStoreName = function ($index) use ($result) { - return $result[$index % count($result)][1]; - }; - - $simpleProductId[0] = function ($index) use ($result) { - return $result[$index % count($result)][2][0]['simpleProductId']; - }; - $simpleProductId[1] = function ($index) use ($result) { - return $result[$index % count($result)][2][1]['simpleProductId']; - }; - $simpleProductSku[0] = function ($index) use ($result) { - return $result[$index % count($result)][2][0]['simpleProductSku']; - }; - $simpleProductSku[1] = function ($index) use ($result) { - return $result[$index % count($result)][2][1]['simpleProductSku']; - }; - $simpleProductName[0] = function ($index) use ($result) { - return $result[$index % count($result)][2][0]['simpleProductName']; - }; - $simpleProductName[1] = function ($index) use ($result) { - return $result[$index % count($result)][2][1]['simpleProductName']; - }; - - $entityId = 1; - while ($entityId <= $ordersCount) { - $queries = ""; - - $orderNumber = 100000000 * $productStoreId($entityId) + $entityId; - $email = 'order_' . $entityId . '@example.com'; - $firstName = 'First Name'; - $lastName = 'Last Name'; - $company = 'Company'; - $address = 'Address'; - $city = 'City'; - $state = 'Alabama'; - $country = 'US'; - $zip = '11111'; - $phone = '911'; - $time = date("Y-m-d h:i:s"); - - $simpleProductIdLen[0] = strlen($simpleProductId[0]($entityId)); - $simpleProductIdLen[1] = strlen($simpleProductId[1]($entityId)); - - $queries .= "INSERT INTO `{$eavEntityStoreTableName}` (`entity_store_id`, `entity_type_id`, `store_id`, `increment_prefix`, `increment_last_id`) VALUES ({$productStoreId($entityId)}, 5, {$productStoreId($entityId)}, '{$productStoreId($entityId)}', '{$orderNumber}') ON DUPLICATE KEY UPDATE `increment_last_id`='{$orderNumber}';"; - - $quoteId = $entityId; - $queries .= "INSERT INTO `{$quoteTableName}` (`entity_id`, `store_id`, `created_at`, `updated_at`, `converted_at`, `is_active`, `is_virtual`, `is_multi_shipping`, `items_count`, `items_qty`, `orig_order_id`, `store_to_base_rate`, `store_to_quote_rate`, `base_currency_code`, `store_currency_code`, `quote_currency_code`, `grand_total`, `base_grand_total`, `checkout_method`, `customer_id`, `customer_tax_class_id`, `customer_group_id`, `customer_email`, `customer_prefix`, `customer_firstname`, `customer_middlename`, `customer_lastname`, `customer_suffix`, `customer_dob`, `customer_note`, `customer_note_notify`, `customer_is_guest`, `remote_ip`, `applied_rule_ids`, `reserved_order_id`, `password_hash`, `coupon_code`, `global_currency_code`, `base_to_global_rate`, `base_to_quote_rate`, `customer_taxvat`, `customer_gender`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `is_changed`, `trigger_recollect`, `ext_shipping_info`, `is_persistent`, `gift_message_id`) VALUES ({$quoteId}, {$productStoreId($entityId)}, '{$time}', '1970-01-01 03:00:00', NULL, 0, 0, 0, 2, 2.0000, 0, 0.0000, 0.0000, 'USD', 'USD', 'USD', 25.3000, 25.3000, 'guest', NULL, 3, 0, '{$email}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, '127.0.0.1', '1', NULL, NULL, NULL, 'USD', 1.0000, 1.0000, NULL, NULL, 17.0000, 17.0000, 15.3000, 15.3000, 1, 0, NULL, 0, NULL);"; - - $quoteAddressId[0] = $entityId * 2 - 1; - $quoteAddressId[1] = $entityId * 2; - $queries .= "INSERT INTO `{$quoteAddressTableName}` (`address_id`, `quote_id`, `created_at`, `updated_at`, `customer_id`, `save_in_address_book`, `customer_address_id`, `address_type`, `email`, `prefix`, `firstname`, `middlename`, `lastname`, `suffix`, `company`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `fax`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `shipping_tax_amount`, `base_shipping_tax_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `customer_notes`, `applied_taxes`, `discount_description`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `base_subtotal_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `base_shipping_hidden_tax_amnt`, `shipping_incl_tax`, `base_shipping_incl_tax`, `free_shipping`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`, `gift_message_id`) VALUES ({$quoteAddressId[0]}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', NULL, 1, NULL, 'billing', '{$email}', NULL, '{$firstName}', NULL, '{$lastName}', NULL, '{$company}', '{$address}', '{$city}', '{$state}', 1, '{$zip}', '{$country}', '{$phone}', NULL, 0, 0, NULL, NULL, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, NULL, NULL, 0.0000, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, 0.0000, NULL, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);"; - $queries .= "INSERT INTO `{$quoteAddressTableName}` (`address_id`, `quote_id`, `created_at`, `updated_at`, `customer_id`, `save_in_address_book`, `customer_address_id`, `address_type`, `email`, `prefix`, `firstname`, `middlename`, `lastname`, `suffix`, `company`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `fax`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `shipping_tax_amount`, `base_shipping_tax_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `customer_notes`, `applied_taxes`, `discount_description`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `base_subtotal_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `base_shipping_hidden_tax_amnt`, `shipping_incl_tax`, `base_shipping_incl_tax`, `free_shipping`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`, `gift_message_id`) VALUES ({$quoteAddressId[1]}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', NULL, 0, NULL, 'shipping', '{$email}', NULL, '{$firstName}', NULL, '{$lastName}', NULL, '{$company}', '{$address}', '{$city}', '{$state}', 1, '{$zip}', '{$country}', '{$phone}', NULL, 1, 0, 'flatrate_flatrate', 'Flat Rate - Fixed', 2.0000, 17.0000, 17.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 10.0000, 0.0000, 0.0000, -1.7000, -1.7000, 25.3000, 25.3000, NULL, 'a:0:{}', NULL, 0.0000, 0.0000, 17.0000, NULL, 0.0000, 0.0000, 0.0000, NULL, 10.0000, 10.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL);"; - - $quoteItemId[0] = $entityId * 4 - 3; - $quoteItemId[1] = $entityId * 4 - 2; - $quoteItemId[2] = $entityId * 4 - 1; - $quoteItemId[3] = $entityId * 4; - $queries .= "INSERT INTO `{$quoteItemTableName}` (`item_id`, `quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `parent_item_id`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `custom_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `product_type`, `base_tax_before_discount`, `tax_before_discount`, `original_custom_price`, `redirect_url`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `free_shipping`, `gift_message_id`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$quoteItemId[0]}, {$quoteId}, '1970-01-01 03:00:00', '1970-01-01 03:00:00', {$simpleProductId[0]($entityId)}, {$productStoreId($entityId)}, NULL, 0, '{$simpleProductSku[0]($entityId)}', '{$simpleProductName[0]($entityId)}', NULL, '1', NULL, 0, 0, 1.0000, 1.0000, 8.5000, 8.5000, NULL, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 1.0000, 'simple', NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; - $queries .= "INSERT INTO `{$quoteItemTableName}` (`item_id`, `quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `parent_item_id`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `custom_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `product_type`, `base_tax_before_discount`, `tax_before_discount`, `original_custom_price`, `redirect_url`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `free_shipping`, `gift_message_id`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$quoteItemId[1]}, {$quoteId}, '1970-01-01 03:00:00', '1970-01-01 03:00:00', {$simpleProductId[1]($entityId)}, {$productStoreId($entityId)}, NULL, 0, '{$simpleProductSku[1]($entityId)}', '{$simpleProductName[1]($entityId)}', NULL, '1', NULL, 0, 0, 1.0000, 1.0000, 8.5000, 8.5000, NULL, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 1.0000, 'simple', NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; - - $quoteItemOptionId[0] = $entityId * 8 - 7; - $quoteItemOptionId[1] = $entityId * 8 - 6; - $quoteItemOptionId[2] = $entityId * 8 - 5; - $quoteItemOptionId[3] = $entityId * 8 - 4; - $quoteItemOptionId[4] = $entityId * 8 - 3; - $quoteItemOptionId[5] = $entityId * 8 - 2; - $quoteItemOptionId[6] = $entityId * 8 - 1; - $quoteItemOptionId[7] = $entityId * 8; - $queries .= "INSERT INTO `{$quoteItemOptionTableName}` (`option_id`, `item_id`, `product_id`, `code`, `value`) VALUES ({$quoteItemOptionId[0]}, {$quoteItemId[0]}, {$simpleProductId[0]($entityId)}, 'info_buyRequest', 'a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[0]}:\"{$simpleProductId[0]($entityId)}\";s:3:\"qty\";i:1;}');"; - $queries .= "INSERT INTO `{$quoteItemOptionTableName}` (`option_id`, `item_id`, `product_id`, `code`, `value`) VALUES ({$quoteItemOptionId[1]}, {$quoteItemId[1]}, {$simpleProductId[1]($entityId)}, 'info_buyRequest', 'a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[1]}:\"{$simpleProductId[1]($entityId)}\";s:3:\"qty\";i:1;}');"; - - $quotePaymentId = $quoteId; - $queries .= "INSERT INTO `{$quotePaymentTableName}` (`payment_id`, `quote_id`, `created_at`, `updated_at`, `method`, `cc_type`, `cc_number_enc`, `cc_last_4`, `cc_cid_enc`, `cc_owner`, `cc_exp_month`, `cc_exp_year`, `cc_ss_owner`, `cc_ss_start_month`, `cc_ss_start_year`, `po_number`, `additional_data`, `cc_ss_issue`, `additional_information`) VALUES ({$quotePaymentId}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', 'checkmo', NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL, NULL, NULL, NULL);"; - - $quoteShippingRateId = $quoteAddressId[1]; - $queries .= "INSERT INTO `{$quoteAddressRateTableName}` (`rate_id`, `address_id`, `created_at`, `updated_at`, `carrier`, `carrier_title`, `code`, `method`, `method_description`, `price`, `error_message`, `method_title`) VALUES ({$quoteShippingRateId}, {$quoteAddressId[1]}, '{$time}', '1970-01-01 03:00:00', 'flatrate', 'Flat Rate', 'flatrate_flatrate', 'flatrate', NULL, 10.0000, NULL, 'Fixed');"; - - $reportEventId[0] = $quoteItemId[0]; - $reportEventId[1] = $quoteItemId[1]; - $reportEventId[2] = $quoteItemId[2]; - $reportEventId[3] = $quoteItemId[3]; - $queries .= "INSERT INTO `{$reportEventTableName}` (`event_id`, `logged_at`, `event_type_id`, `object_id`, `subject_id`, `subtype`, `store_id`) VALUES ({$reportEventId[0]}, '{$time}', 4, {$simpleProductId[0]($entityId)}, 2, 1, {$productStoreId($entityId)});"; - $queries .= "INSERT INTO `{$reportEventTableName}` (`event_id`, `logged_at`, `event_type_id`, `object_id`, `subject_id`, `subtype`, `store_id`) VALUES ({$reportEventId[1]}, '{$time}', 4, {$simpleProductId[1]($entityId)}, 2, 1, {$productStoreId($entityId)});"; - - $salesOrderId = $quoteId; - $queries .= "INSERT INTO `{$salesOrderTableName}` (`entity_id`, `state`, `status`, `coupon_code`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`, `base_discount_canceled`, `base_discount_invoiced`, `base_discount_refunded`, `base_grand_total`, `base_shipping_amount`, `base_shipping_canceled`, `base_shipping_invoiced`, `base_shipping_refunded`, `base_shipping_tax_amount`, `base_shipping_tax_refunded`, `base_subtotal`, `base_subtotal_canceled`, `base_subtotal_invoiced`, `base_subtotal_refunded`, `base_tax_amount`, `base_tax_canceled`, `base_tax_invoiced`, `base_tax_refunded`, `base_to_global_rate`, `base_to_order_rate`, `base_total_canceled`, `base_total_invoiced`, `base_total_invoiced_cost`, `base_total_offline_refunded`, `base_total_online_refunded`, `base_total_paid`, `base_total_qty_ordered`, `base_total_refunded`, `discount_amount`, `discount_canceled`, `discount_invoiced`, `discount_refunded`, `grand_total`, `shipping_amount`, `shipping_canceled`, `shipping_invoiced`, `shipping_refunded`, `shipping_tax_amount`, `shipping_tax_refunded`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `subtotal_canceled`, `subtotal_invoiced`, `subtotal_refunded`, `tax_amount`, `tax_canceled`, `tax_invoiced`, `tax_refunded`, `total_canceled`, `total_invoiced`, `total_offline_refunded`, `total_online_refunded`, `total_paid`, `total_qty_ordered`, `total_refunded`, `can_ship_partially`, `can_ship_partially_item`, `customer_is_guest`, `customer_note_notify`, `billing_address_id`, `customer_group_id`, `edit_increment`, `email_sent`, `send_email`, `forced_shipment_with_invoice`, `payment_auth_expiration`, `quote_address_id`, `quote_id`, `shipping_address_id`, `adjustment_negative`, `adjustment_positive`, `base_adjustment_negative`, `base_adjustment_positive`, `base_shipping_discount_amount`, `base_subtotal_incl_tax`, `base_total_due`, `payment_authorization_amount`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `customer_dob`, `increment_id`, `applied_rule_ids`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `customer_middlename`, `customer_prefix`, `customer_suffix`, `customer_taxvat`, `discount_description`, `ext_customer_id`, `ext_order_id`, `global_currency_code`, `hold_before_state`, `hold_before_status`, `order_currency_code`, `original_increment_id`, `relation_child_id`, `relation_child_real_id`, `relation_parent_id`, `relation_parent_real_id`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `x_forwarded_for`, `customer_note`, `created_at`, `updated_at`, `total_item_count`, `customer_gender`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `base_shipping_hidden_tax_amnt`, `hidden_tax_invoiced`, `base_hidden_tax_invoiced`, `hidden_tax_refunded`, `base_hidden_tax_refunded`, `shipping_incl_tax`, `base_shipping_incl_tax`, `coupon_rule_name`, `gift_message_id`) VALUES ({$salesOrderId}, 'new', 'pending', NULL, '272ecb', 'Flat Rate - Fixed', 0, {$productStoreId($entityId)}, NULL, -1.7000, NULL, NULL, NULL, 25.3000, 10.0000, NULL, NULL, NULL, 0.0000, NULL, 17.0000, NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, 1.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1.7000, NULL, NULL, NULL, 25.3000, 10.0000, NULL, NULL, NULL, 0.0000, NULL, 0.0000, 0.0000, 17.0000, NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2.0000, NULL, NULL, NULL, 1, 1, 2, 0, NULL, 1, 1, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, 17.0000, 25.3000, NULL, NULL, 17.0000, 25.3000, 2.0000, NULL, {$orderNumber}, '1', 'USD', '{$email}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'USD', NULL, NULL, 'USD', NULL, NULL, NULL, NULL, NULL, '127.0.0.1', 'flatrate_flatrate', 'USD', '{$productStoreName($entityId)}', NULL, NULL, '{$time}', '{$time}', 2, NULL, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, 10.0000, 10.0000, NULL, NULL);"; - - $salesOrderAddressId[0] = $quoteAddressId[0]; - $salesOrderAddressId[1] = $quoteAddressId[1]; - $queries .= "INSERT INTO `{$salesOrderAddressTableName}` (`entity_id`, `parent_id`, `customer_address_id`, `quote_address_id`, `region_id`, `customer_id`, `fax`, `region`, `postcode`, `lastname`, `street`, `city`, `email`, `telephone`, `country_id`, `firstname`, `address_type`, `prefix`, `middlename`, `suffix`, `company`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`) VALUES ({$salesOrderAddressId[0]}, {$salesOrderId}, NULL, NULL, 1, NULL, NULL, '{$state}', '{$zip}', '{$lastName}', '{$address}', '{$city}', '{$email}', '{$phone}', '{$country}', '{$firstName}', 'shipping', NULL, NULL, NULL, '{$company}', NULL, NULL, NULL, NULL, NULL);"; - $queries .= "INSERT INTO `{$salesOrderAddressTableName}` (`entity_id`, `parent_id`, `customer_address_id`, `quote_address_id`, `region_id`, `customer_id`, `fax`, `region`, `postcode`, `lastname`, `street`, `city`, `email`, `telephone`, `country_id`, `firstname`, `address_type`, `prefix`, `middlename`, `suffix`, `company`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`) VALUES ({$salesOrderAddressId[1]}, {$salesOrderId}, NULL, NULL, 1, NULL, NULL, '{$state}', '{$zip}', '{$lastName}', '{$address}', '{$city}', '{$email}', '{$phone}', '{$country}', '{$firstName}', 'billing', NULL, NULL, NULL, '{$company}', NULL, NULL, NULL, NULL, NULL);"; - - $salesOrderGridId = $salesOrderId; - $queries .= "INSERT INTO `{$salesOrderGridTableName}` (`entity_id`, `status`, `store_id`, `store_name`, `customer_id`, `base_grand_total`, `base_total_paid`, `grand_total`, `total_paid`, `increment_id`, `base_currency_code`, `order_currency_code`, `shipping_name`, `billing_name`, `created_at`, `updated_at`) VALUES ({$salesOrderGridId}, 'pending', {$productStoreId($entityId)}, '{$productStoreName($entityId)}', NULL, 25.3000, NULL, 25.3000, NULL, {$orderNumber}, 'USD', 'USD', '', '', '{$time}', NULL);"; - - $salesOrderItemId[0] = $quoteItemId[0]; - $salesOrderItemId[1] = $quoteItemId[1]; - $salesOrderItemId[2] = $quoteItemId[2]; - $salesOrderItemId[3] = $quoteItemId[3]; - $queries .= "INSERT INTO `{$salesOrderItemTableName}` (`item_id`, `order_id`, `parent_item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `ext_order_item_id`, `locked_do_invoice`, `locked_do_ship`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `hidden_tax_invoiced`, `base_hidden_tax_invoiced`, `hidden_tax_refunded`, `base_hidden_tax_refunded`, `tax_canceled`, `hidden_tax_canceled`, `tax_refunded`, `base_tax_refunded`, `discount_refunded`, `base_discount_refunded`, `free_shipping`, `gift_message_id`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$salesOrderItemId[0]}, {$salesOrderId}, NULL, {$quoteItemId[0]}, {$productStoreId($entityId)}, '{$time}', '0000-00-00 00:00:00', {$simpleProductId[0]($entityId)}, 'simple', 'a:1:{s:15:\"info_buyRequest\";a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[0]}:\"{$simpleProductId[0]($entityId)}\";s:3:\"qty\";i:1;}}', 1.0000, 0, '{$simpleProductSku[0]($entityId)}', '{$simpleProductName[0]($entityId)}', NULL, '1', NULL, 0, 0, NULL, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, NULL, 8.5000, 8.5000, 10.0000, 10.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 0.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; - $queries .= "INSERT INTO `{$salesOrderItemTableName}` (`item_id`, `order_id`, `parent_item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `ext_order_item_id`, `locked_do_invoice`, `locked_do_ship`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `hidden_tax_invoiced`, `base_hidden_tax_invoiced`, `hidden_tax_refunded`, `base_hidden_tax_refunded`, `tax_canceled`, `hidden_tax_canceled`, `tax_refunded`, `base_tax_refunded`, `discount_refunded`, `base_discount_refunded`, `free_shipping`, `gift_message_id`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$salesOrderItemId[1]}, {$salesOrderId}, NULL, {$quoteItemId[1]}, {$productStoreId($entityId)}, '{$time}', '0000-00-00 00:00:00', {$simpleProductId[1]($entityId)}, 'simple', 'a:1:{s:15:\"info_buyRequest\";a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[1]}:\"{$simpleProductId[1]($entityId)}\";s:3:\"qty\";i:1;}}', 1.0000, 0, '{$simpleProductSku[1]($entityId)}', '{$simpleProductName[1]($entityId)}', NULL, '1', NULL, 0, 0, NULL, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, NULL, 8.5000, 8.5000, 10.0000, 10.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 0.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; - - $salesOrderPaymentId = $salesOrderId; - $queries .= "INSERT INTO `{$salesOrderPaymentTableName}` (`entity_id`, `parent_id`, `base_shipping_captured`, `shipping_captured`, `amount_refunded`, `base_amount_paid`, `amount_canceled`, `base_amount_authorized`, `base_amount_paid_online`, `base_amount_refunded_online`, `base_shipping_amount`, `shipping_amount`, `amount_paid`, `amount_authorized`, `base_amount_ordered`, `base_shipping_refunded`, `shipping_refunded`, `base_amount_refunded`, `amount_ordered`, `base_amount_canceled`, `quote_payment_id`, `additional_data`, `cc_exp_month`, `cc_ss_start_year`, `echeck_bank_name`, `method`, `cc_debug_request_body`, `cc_secure_verify`, `protection_eligibility`, `cc_approval`, `cc_last_4`, `cc_status_description`, `echeck_type`, `cc_debug_response_serialized`, `cc_ss_start_month`, `echeck_account_type`, `last_trans_id`, `cc_cid_status`, `cc_owner`, `cc_type`, `po_number`, `cc_exp_year`, `cc_status`, `echeck_routing_number`, `account_status`, `anet_trans_method`, `cc_debug_response_body`, `cc_ss_issue`, `echeck_account_name`, `cc_avs_status`, `cc_number_enc`, `cc_trans_id`, `address_status`, `additional_information`) VALUES ({$salesOrderPaymentId}, {$salesOrderId}, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10.0000, 10.0000, NULL, NULL, 25.3000, NULL, NULL, NULL, 25.3000, NULL, NULL, NULL, NULL, '0', NULL, 'checkmo', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'a:1:{s:53:\"a:1:{s:12:\"method_title\";s:19:\"Check / Money order\";}\";N;}');"; - - $salesOrderStatusHistoryId = $salesOrderId; - $queries .= "INSERT INTO `{$salesOrderStatusHistoryTableName}` (`entity_id`, `parent_id`, `is_customer_notified`, `is_visible_on_front`, `comment`, `status`, `created_at`, `entity_name`) VALUES ({$salesOrderStatusHistoryId}, {$salesOrderId}, 1, 0, NULL, 'pending', '{$time}', 'order');"; - - $writeAdapter->multiQuery($queries); - - $entityId++; - } - } - - /** - * {@inheritdoc} - */ - public function getActionTitle() - { - return 'Generating orders'; - } - - /** - * {@inheritdoc} - */ - public function introduceParamLabels() - { - return [ - 'orders' => 'Orders' - ]; - } - - /** - * Get real table name for db table, validated by db adapter - * - * @param string $tableName - * @param string $resourceName - * @return string - */ - public function getTableName($tableName, $resourceName) - { - $resource = $this->application->getObjectManager()->get($resourceName); - return $this->getConnection('write')->getTableName($resource->getTable($tableName)); - } - - /** - * Retrieve connection to resource specified by $resourceName - * - * @param string $resourceName - * @return \Magento\Framework\DB\Adapter\AdapterInterface|false - */ - public function getConnection($resourceName) - { - return $this->application->getObjectManager()->get( - 'Magento\Framework\App\Resource' - )->getConnection($resourceName); - } -} - -return new OrdersFixture($this); diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php deleted file mode 100644 index 9e6706a771344..0000000000000 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php +++ /dev/null @@ -1,215 +0,0 @@ -_applicationBaseDir = $applicationBaseDir; - $this->_shell = $shell; - $this->_initArguments = $initArguments; - } - - /** - * Update permissions for `var` directory - * - * @return void - */ - protected function _updateFilesystemPermissions() - { - /** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */ - $varDirectory = $this->getObjectManager()->get('Magento\Framework\Filesystem') - ->getDirectoryWrite(DirectoryList::VAR_DIR); - $varDirectory->changePermissions('', 0777); - } - - /** - * Bootstrap application, so it is possible to use its resources - * - * @return \Magento\ToolkitFramework\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(); - } - - /** - * Run reindex - * - * @return Application - */ - public function reindex() - { - $this->_shell->execute( - 'php -f ' . $this->_applicationBaseDir . '/bin/magento indexer:reindex --all' - ); - return $this; - } - - /** - * Load fixtures - * - * @return $this - * @throws \Exception - */ - public function loadFixtures() - { - if (!is_readable(__DIR__ . self::FIXTURES_DIR)) { - throw new \Exception( - 'Fixtures set directory `' . __DIR__ . self::FIXTURES_DIR . '` is not readable or does not exists.' - ); - } - $files = glob(__DIR__ . self::FIXTURES_DIR . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN); - foreach ($files as $file) { - /** @var \Magento\ToolkitFramework\Fixture $fixture */ - $fixture = require realpath($file); - $this->_fixtures[$fixture->getPriority()] = $fixture; - } - ksort($this->_fixtures); - foreach ($this->_fixtures as $fixture) { - $this->_paramLabels = array_merge($this->_paramLabels, $fixture->introduceParamLabels()); - } - return $this; - } - - /** - * Get param labels - * - * @return array - */ - public function getParamLabels() - { - return $this->_paramLabels; - } - - /** - * Get fixtures - * - * @return Fixture[] - */ - public function getFixtures() - { - return $this->_fixtures; - } - - /** - * Get object manager - * - * @return \Magento\Framework\ObjectManagerInterface - */ - public function getObjectManager() - { - if (!$this->_objectManager) { - $objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory( - BP, - $this->_initArguments - ); - $this->_objectManager = $objectManagerFactory->create($this->_initArguments); - $this->_objectManager->get('Magento\Framework\App\State')->setAreaCode(self::AREA_CODE); - } - return $this->_objectManager; - } - - /** - * Reset object manager - * - * @return \Magento\Framework\ObjectManagerInterface - */ - public function resetObjectManager() - { - $this->_objectManager = null; - $this->bootstrap(); - return $this; - } -} diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php deleted file mode 100644 index 0572b043a8c5a..0000000000000 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php +++ /dev/null @@ -1,60 +0,0 @@ -_config = (new \Magento\Framework\Xml\Parser())->load($filename)->xmlToArray(); - } - - /** - * Get profile configuration value - * - * @param string $key - * @param null|mixed $default - * - * @return mixed - */ - public function getValue($key, $default = null) - { - return isset($this->_config['config']['profile'][$key]) ? $this->_config['config']['profile'][$key] : $default; - } -} diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Helper/Cli.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Helper/Cli.php deleted file mode 100644 index 0ef33d75c1676..0000000000000 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Helper/Cli.php +++ /dev/null @@ -1,53 +0,0 @@ -getOption($key); - if ($value === null) { - return $default; - } - return $value; - } -} diff --git a/dev/tools/performance-toolkit/framework/bootstrap.php b/dev/tools/performance-toolkit/framework/bootstrap.php deleted file mode 100644 index 1fd4767308a76..0000000000000 --- a/dev/tools/performance-toolkit/framework/bootstrap.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - testsuite - - - - - - diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ConfigTest.php b/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ConfigTest.php deleted file mode 100644 index a474456aefb72..0000000000000 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ConfigTest.php +++ /dev/null @@ -1,18 +0,0 @@ -setExpectedException('Exception', 'Profile configuration file `))` is not readable or does not exists.'); - \Magento\ToolkitFramework\Config::getInstance()->loadConfig('))'); - } -} diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/Helper/CliTest.php b/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/Helper/CliTest.php deleted file mode 100644 index 4db21a63017a9..0000000000000 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/Helper/CliTest.php +++ /dev/null @@ -1,83 +0,0 @@ -_getOpt = $this->getMock( - 'Zend_Console_Getopt', - ['getOption'], - [[]] - ); - $this->_getOpt->expects($this->any())->method('getOption')->will( - $this->returnValueMap( - [ - [self::TEST_OPTION_NAME, self::TEST_OPTION_VALUE], - ['xxx', null], - ] - ) - ); - - \Magento\ToolkitFramework\Helper\Cli::setOpt($this->_getOpt); - } - - /** - * Tear down after test - * - * @return void - */ - public function tearDown() - { - $this->_getOpt = null; - $this->_object = null; - } - - /** - * Test CLI helper - * - * @return void - */ - public function testCli() - { - $this->assertEquals( - self::TEST_OPTION_VALUE, - \Magento\ToolkitFramework\Helper\Cli::getOption(self::TEST_OPTION_NAME) - ); - $this->assertEquals( - null, - \Magento\ToolkitFramework\Helper\Cli::getOption('xxx') - ); - $this->assertEquals( - 'default', - \Magento\ToolkitFramework\Helper\Cli::getOption('xxx', 'default') - ); - } -} diff --git a/dev/tools/performance-toolkit/generate.php b/dev/tools/performance-toolkit/generate.php deleted file mode 100644 index 3eae0197757f7..0000000000000 --- a/dev/tools/performance-toolkit/generate.php +++ /dev/null @@ -1,85 +0,0 @@ - 'Profile configuration file', - 'skip-reindex-i' => 'Skip reindex (Default - 0)', - ] - ); - - \Magento\ToolkitFramework\Helper\Cli::setOpt($shell); - - $args = $shell->getOptions(); - if (empty($args)) { - echo $shell->getUsageMessage(); - exit(0); - } - - $logWriter = new \Zend_Log_Writer_Stream('php://output'); - $logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL)); - $logger = new \Zend_Log($logWriter); - - $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer(), $logger); - - $application = new \Magento\ToolkitFramework\Application($applicationBaseDir, $shell, []); - $application->bootstrap(); - $application->loadFixtures(); - - $config = \Magento\ToolkitFramework\Config::getInstance(); - $config->loadConfig(\Magento\ToolkitFramework\Helper\Cli::getOption('profile')); - - echo 'Generating profile with following params:' . PHP_EOL; - foreach ($application->getParamLabels() as $configKey => $label) { - echo ' |- ' . $label . ': ' . $config->getValue($configKey) . PHP_EOL; - } - - /** @var $config \Magento\Indexer\Model\Config */ - $config = $application->getObjectManager()->get('Magento\Indexer\Model\Config'); - $indexerListIds = $config->getIndexers(); - /** @var $indexerRegistry \Magento\Indexer\Model\IndexerRegistry */ - $indexerRegistry = $application->getObjectManager()->create('Magento\Indexer\Model\IndexerRegistry'); - $application->indexerStates = []; - foreach ($indexerListIds as $key => $indexerId) { - $indexer = $indexerRegistry->get($indexerId['indexer_id']); - $application->indexersStates[$indexerId['indexer_id']] = $indexer->isScheduled(); - $indexer->setScheduled(true); - } - - foreach ($application->getFixtures() as $fixture) { - echo $fixture->getActionTitle() . '... '; - $startTime = microtime(true); - $fixture->execute(); - $endTime = microtime(true); - $resultTime = $endTime - $startTime; - echo ' done in ' . gmdate('H:i:s', $resultTime) . PHP_EOL; - } - - foreach ($indexerListIds as $indexerId) { - /** @var $indexer \Magento\Indexer\Model\Indexer */ - $indexer = $indexerRegistry->get($indexerId['indexer_id']); - $indexer->setScheduled($application->indexersStates[$indexerId['indexer_id']]); - } - - if (!\Magento\ToolkitFramework\Helper\Cli::getOption('skip-reindex')) { - $application->reindex(); - } - $totalEndTime = microtime(true); - $totalResultTime = $totalEndTime - $totalStartTime; - - echo 'Total execution time: ' . gmdate('H:i:s', $totalResultTime) . PHP_EOL; -} catch (\Zend_Console_Getopt_Exception $e) { - fwrite(STDERR, $e->getMessage() . "\n\n" . $e->getUsageMessage() . "\n"); - exit(1); -} catch (\Exception $e) { - fwrite(STDERR, $e->getMessage() . "\n"); - exit(1); -} diff --git a/lib/internal/CardinalCommerce/CentinelClient.php b/lib/internal/CardinalCommerce/CentinelClient.php deleted file mode 100644 index c2f19380cbe2e..0000000000000 --- a/lib/internal/CardinalCommerce/CentinelClient.php +++ /dev/null @@ -1,161 +0,0 @@ -request[$name] = $this->escapeXML($value); - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function getValue(name) - // - // Retrieve a specific value for the give name within the Centinel response collection. - ///////////////////////////////////////////////////////////////////////////////////////////// - - - function getValue($name) { - if (isset($this->response[$name])) { - return $this->response[$name]; - }else{ - return ""; - } - } - - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function getRequestXml(name) - // - // Serialize all elements of the request collection into a XML message, and format the required - // form payload according to the Centinel XML Message APIs. The form payload is returned from - // the function. - ///////////////////////////////////////////////////////////////////////////////////////////// - - - function getRequestXml(){ - $queryString = ""; - foreach ($this->request as $name => $value) { - $queryString = $queryString."<".($name).">".($value)."" ; - } - $queryString = $queryString.""; - return "cmpi_msg=".urlencode($queryString); - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function sendHttp(url, "", $timeout) - // - // HTTP POST the form payload to the url using cURL. - // form payload according to the Centinel XML Message APIs. The form payload is returned from - // the function. - ///////////////////////////////////////////////////////////////////////////////////////////// - - function sendHttp($url, $connectTimeout="", $timeout) { - - // verify that the URL uses a supported protocol. - - if( (strpos($url, "http://")=== 0) || (strpos($url, "https://")=== 0) ) { - - //Construct the payload to POST to the url. - - $data = $this->getRequestXml(); - // create a new cURL resource - - $ch = curl_init($url); - - // set URL and other appropriate options - curl_setopt($ch, CURLOPT_POST,1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - - // Execute the request. - - $result = curl_exec($ch); - $succeeded = curl_errno($ch) == 0 ? true : false; - - // close cURL resource, and free up system resources - - curl_close($ch); - - // If Communication was not successful set error result, otherwise - - if(!$succeeded) { - - $result = $this->setErrorResponse(CENTINEL_ERROR_CODE_8030, CENTINEL_ERROR_CODE_8030_DESC); - - } - - // Assert that we received an expected Centinel Message in reponse. - - if (strpos($result, "") === false) { - $result = $this->setErrorResponse(CENTINEL_ERROR_CODE_8010, CENTINEL_ERROR_CODE_8010_DESC); - } - - - } else { - $result = $this->setErrorResponse(CENTINEL_ERROR_CODE_8000, CENTINEL_ERROR_CODE_8000_DESC); - } - $parser = new XMLParser; - $parser->deserializeXml($result); - $this->response = $parser->deserializedResponse; - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function setErrorResponse(errorNo, errorDesc) - // - // Initialize an Error response to ensure that parsing will be handled properly. - ///////////////////////////////////////////////////////////////////////////////////////////// - - function setErrorResponse($errorNo, $errorDesc) { - - $resultText = ""; - $resultText = $resultText."".($errorNo)."" ; - $resultText = $resultText."".($errorDesc)."" ; - $resultText = $resultText.""; - - return $resultText; - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function escapeXML(value) - // - // Escaped string converting all '&' to '&' and all '<' to '<'. Return the escaped value. - ///////////////////////////////////////////////////////////////////////////////////////////// - - function escapeXML($elementValue){ - - $escapedValue = str_replace("&", "&", $elementValue); - $escapedValue = str_replace("<", "<", $escapedValue); - - return $escapedValue; - - } - - } diff --git a/lib/internal/CardinalCommerce/CentinelErrors.php b/lib/internal/CardinalCommerce/CentinelErrors.php deleted file mode 100644 index 2ac2eb1996262..0000000000000 --- a/lib/internal/CardinalCommerce/CentinelErrors.php +++ /dev/null @@ -1,24 +0,0 @@ -xml_parser = xml_parser_create(); - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function startElement(parser, name, attribute) - // - // Start Tag Element Handler - ///////////////////////////////////////////////////////////////////////////////////////////// - - function startElement($parser, $name, $attrs='') { - $this->elementName= $name; - - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function elementData(parser, data) - // - // Element Data Handler - ///////////////////////////////////////////////////////////////////////////////////////////// - - function elementData($parser, $data) { - $this->elementValue .= $data; - - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function endElement(name, value) - // - // End Tag Element Handler - ///////////////////////////////////////////////////////////////////////////////////////////// - - function endElement($parser, $name) { - - $this->deserializedResponse[$this->elementName]= $this->elementValue; - $this->elementName = ""; - $this->elementValue = ""; - } - - ///////////////////////////////////////////////////////////////////////////////////////////// - // Function deserialize(xmlString) - // - // Deserilize the XML reponse message and add each element to the deserializedResponse collection. - // Once complete, then each element reference will be available using the getValue function. - ///////////////////////////////////////////////////////////////////////////////////////////// - - function deserializeXml($responseString) { - - xml_set_object($this->xml_parser, $this); - xml_parser_set_option($this->xml_parser,XML_OPTION_CASE_FOLDING,FALSE); - xml_set_element_handler($this->xml_parser, "startElement", "endElement"); - xml_set_character_data_handler($this->xml_parser, "elementData"); - - if (!xml_parse($this->xml_parser, $responseString)) { - - $this->deserializedResponse["ErrorNo"]= CENTINEL_ERROR_CODE_8020; - $this->deserializedResponse["ErrorDesc"]= CENTINEL_ERROR_CODE_8020_DESC; - } - - xml_parser_free($this->xml_parser); - } - } diff --git a/lib/internal/Magento/Framework/Acl/CacheInterface.php b/lib/internal/Magento/Framework/Acl/CacheInterface.php index f96108cf07cef..9720865304495 100644 --- a/lib/internal/Magento/Framework/Acl/CacheInterface.php +++ b/lib/internal/Magento/Framework/Acl/CacheInterface.php @@ -1,12 +1,15 @@ _setDataValues($firstDataObject, $secondObjectArray, $interfaceName); return $this; } + + /** + * Filter attribute value objects for a provided data interface type from an array of custom attribute value objects + * + * @param AttributeValue[] $attributeValues Array of custom attribute + * @param string $type Data interface type + * @return AttributeValue[] + */ + public function getCustomAttributeValueByType(array $attributeValues, $type) + { + $attributeValueArray = []; + if (empty($attributeValues)) { + return $attributeValueArray; + } + foreach ($attributeValues as $attributeValue) { + if ($attributeValue->getValue() instanceof $type) { + $attributeValueArray[] = $attributeValue; + } + } + return $attributeValueArray; + } } diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php b/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php index 6dd8f258b4db7..7e29b6e6572da 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php +++ b/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php @@ -8,6 +8,8 @@ /** * Interface for entities which can be extended with extension attributes. + * + * @api */ interface ExtensibleDataInterface { diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php b/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php index aef1607c31dae..077929a40390f 100644 --- a/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php +++ b/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php @@ -8,6 +8,8 @@ /** * Marker interface for all extension attributes interfaces. + * + * @api */ interface ExtensionAttributesInterface { diff --git a/lib/internal/Magento/Framework/Api/ImageContent.php b/lib/internal/Magento/Framework/Api/ImageContent.php new file mode 100644 index 0000000000000..7bed13210d600 --- /dev/null +++ b/lib/internal/Magento/Framework/Api/ImageContent.php @@ -0,0 +1,80 @@ +_get(self::BASE64_ENCODED_DATA); + } + + /** + * {@inheritdoc} + * + * @return string + */ + public function getType() + { + return $this->_get(self::TYPE); + } + + /** + * {@inheritdoc} + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * {@inheritdoc} + * + * @param string $data + * @return $this + */ + public function setBase64EncodedData($data) + { + return $this->setData(self::BASE64_ENCODED_DATA, $data); + } + + /** + * {@inheritdoc} + * + * @param string $mimeType + * @return $this + */ + public function setType($mimeType) + { + return $this->setData(self::TYPE, $mimeType); + } + + /** + * {@inheritdoc} + * + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData(self::NAME, $name); + } +} diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php b/lib/internal/Magento/Framework/Api/ImageContentValidator.php similarity index 60% rename from app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php rename to lib/internal/Magento/Framework/Api/ImageContentValidator.php index c067da69a5b80..83cb8840b3c68 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php +++ b/lib/internal/Magento/Framework/Api/ImageContentValidator.php @@ -4,12 +4,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Catalog\Model\Product\Gallery; -use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface; +namespace Magento\Framework\Api; + +use Magento\Framework\Api\Data\ImageContentInterface; use Magento\Framework\Exception\InputException; +use Magento\Framework\Phrase; -class ContentValidator +/** + * Class for Image content validation + */ +class ImageContentValidator implements ImageContentValidatorInterface { /** * @var array @@ -38,26 +43,26 @@ public function __construct( /** * Check if gallery entry content is valid * - * @param ProductAttributeMediaGalleryEntryContentInterface $entryContent + * @param ImageContentInterface $imageContent * @return bool * @throws InputException */ - public function isValid(ProductAttributeMediaGalleryEntryContentInterface $entryContent) + public function isValid(ImageContentInterface $imageContent) { - $fileContent = @base64_decode($entryContent->getEntryData(), true); + $fileContent = @base64_decode($imageContent->getBase64EncodedData(), true); if (empty($fileContent)) { - throw new InputException(__('The image content must be valid base64 encoded data.')); + throw new InputException(new Phrase('The image content must be valid base64 encoded data.')); } $imageProperties = @getimagesizefromstring($fileContent); if (empty($imageProperties)) { - throw new InputException(__('The image content must be valid base64 encoded data.')); + throw new InputException(new Phrase('The image content must be valid base64 encoded data.')); } $sourceMimeType = $imageProperties['mime']; - if ($sourceMimeType != $entryContent->getMimeType() || !$this->isMimeTypeValid($sourceMimeType)) { - throw new InputException(__('The image MIME type is not valid or not supported.')); + if ($sourceMimeType != $imageContent->getType() || !$this->isMimeTypeValid($sourceMimeType)) { + throw new InputException(new Phrase('The image MIME type is not valid or not supported.')); } - if (!$this->isNameValid($entryContent->getName())) { - throw new InputException(__('Provided image name contains forbidden characters.')); + if (!$this->isNameValid($imageContent->getName())) { + throw new InputException(new Phrase('Provided image name contains forbidden characters.')); } return true; } diff --git a/lib/internal/Magento/Framework/Api/ImageContentValidatorInterface.php b/lib/internal/Magento/Framework/Api/ImageContentValidatorInterface.php new file mode 100644 index 0000000000000..1f2c9d0a3858f --- /dev/null +++ b/lib/internal/Magento/Framework/Api/ImageContentValidatorInterface.php @@ -0,0 +1,27 @@ + 'jpg', + 'image/jpeg' => 'jpg', + 'image/gif' => 'gif', + 'image/png' => 'png', + ]; + + /** + * @var Filesystem + */ + private $filesystem; + + /** + * @var Filesystem + */ + private $contentValidator; + + /** + * @var DataObjectHelper + */ + private $dataObjectHelper; + + /** + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + + /** + * @var Uploader + */ + private $uploader; + + /** + * @var \Magento\Framework\Filesystem\Directory\WriteInterface + */ + private $mediaDirectory; + + /** + * @param Filesystem $fileSystem + * @param ImageContentValidatorInterface $contentValidator + * @param DataObjectHelper $dataObjectHelper + * @param \Psr\Log\LoggerInterface $logger + * @param Uploader $uploader + */ + public function __construct( + Filesystem $fileSystem, + ImageContentValidatorInterface $contentValidator, + DataObjectHelper $dataObjectHelper, + \Psr\Log\LoggerInterface $logger, + Uploader $uploader + ) { + $this->filesystem = $fileSystem; + $this->contentValidator = $contentValidator; + $this->dataObjectHelper = $dataObjectHelper; + $this->logger = $logger; + $this->uploader = $uploader; + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); + } + + /** + * {@inheritdoc} + */ + public function save( + CustomAttributesDataInterface $dataObjectWithCustomAttributes, + $entityType, + CustomAttributesDataInterface $previousCustomerData = null + ) { + //Get all Image related custom attributes + $imageDataObjects = $this->dataObjectHelper->getCustomAttributeValueByType( + $dataObjectWithCustomAttributes->getCustomAttributes(), + '\Magento\Framework\Api\Data\ImageContentInterface' + ); + + // Return if no images to process + if (empty($imageDataObjects)) { + return $dataObjectWithCustomAttributes; + } + + // For every image, save it and replace it with corresponding Eav data object + /** @var $imageDataObject \Magento\Framework\Api\AttributeValue */ + foreach ($imageDataObjects as $imageDataObject) { + + /** @var $imageContent \Magento\Framework\Api\Data\ImageContentInterface */ + $imageContent = $imageDataObject->getValue(); + + $filename = $this->processImageContent($entityType, $imageContent); + + //Set filename from static media location into data object + $dataObjectWithCustomAttributes->setCustomAttribute( + $imageDataObject->getAttributeCode(), + $filename + ); + + //Delete previously saved image if it exists + if ($previousCustomerData) { + $previousImageAttribute = $previousCustomerData->getCustomAttribute( + $imageDataObject->getAttributeCode() + ); + if ($previousImageAttribute) { + $previousImagePath = $previousImageAttribute->getValue(); + if (!empty($previousImagePath)) { + @unlink($this->mediaDirectory->getAbsolutePath() . $entityType . $previousImagePath); + } + } + } + } + + return $dataObjectWithCustomAttributes; + } + + /** + * {@inheritdoc} + */ + public function processImageContent($entityType, $imageContent) + { + if (!$this->contentValidator->isValid($imageContent)) { + throw new InputException(new Phrase('The image content is not valid.')); + } + + $fileContent = @base64_decode($imageContent->getBase64EncodedData(), true); + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); + $fileName = substr(md5(rand()), 0, 7) . '.' . $imageContent->getName(); + $tmpDirectory->writeFile($fileName, $fileContent); + + $fileAttributes = [ + 'tmp_name' => $tmpDirectory->getAbsolutePath() . $fileName, + 'name' => $imageContent->getName() + ]; + + try { + $this->uploader->processFileAttributes($fileAttributes); + $this->uploader->setFilesDispersion(true); + $this->uploader->setFilenamesCaseSensitivity(false); + $this->uploader->setAllowRenameFiles(true); + $destinationFolder = $entityType; + $this->uploader->save($this->mediaDirectory->getAbsolutePath($destinationFolder), $imageContent->getName()); + } catch (\Exception $e) { + $this->logger->critical($e); + } + return $this->uploader->getUploadedFileName(); + } + + /** + * @param string $mimeType + * @return string + */ + protected function getMimeTypeExtension($mimeType) + { + if (isset($this->mimeTypeExtensionMap[$mimeType])) { + return $this->mimeTypeExtensionMap[$mimeType]; + } else { + return ""; + } + } +} diff --git a/lib/internal/Magento/Framework/Api/ImageProcessorInterface.php b/lib/internal/Magento/Framework/Api/ImageProcessorInterface.php new file mode 100644 index 0000000000000..42a7b29e6a4e1 --- /dev/null +++ b/lib/internal/Magento/Framework/Api/ImageProcessorInterface.php @@ -0,0 +1,44 @@ +objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->imageContentValidator = $this->objectManager->getObject('Magento\Framework\Api\ImageContentValidator'); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage The image content must be valid base64 encoded data. + */ + public function testIsValidEmptyContent() + { + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn(''); + + $this->imageContentValidator->isValid($imageContent); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage The image content must be valid base64 encoded data. + */ + public function testIsValidEmptyProperties() + { + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn('testImageData'); + + $this->imageContentValidator->isValid($imageContent); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage The image MIME type is not valid or not supported. + */ + public function testIsValidInvalidMIMEType() + { + $pathToImageFile = BP . '/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/_files/image.jpg'; + $encodedData = @base64_encode(file_get_contents($pathToImageFile)); + + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn($encodedData); + $imageContent->expects($this->any()) + ->method('getType') + ->willReturn('invalidType'); + + $this->imageContentValidator->isValid($imageContent); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Provided image name contains forbidden characters. + */ + public function testIsValidInvalidName() + { + $pathToImageFile = BP . '/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/_files/image.jpg'; + $encodedData = @base64_encode(file_get_contents($pathToImageFile)); + + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn($encodedData); + $imageContent->expects($this->any()) + ->method('getName') + ->willReturn('invalid:Name'); + $imageContent->expects($this->any()) + ->method('getType') + ->willReturn('image/jpeg'); + + $this->imageContentValidator->isValid($imageContent); + } + + public function testIsValid() + { + $pathToImageFile = BP . '/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/_files/image.jpg'; + $encodedData = @base64_encode(file_get_contents($pathToImageFile)); + + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn($encodedData); + $imageContent->expects($this->any()) + ->method('getName') + ->willReturn('validName'); + $imageContent->expects($this->any()) + ->method('getType') + ->willReturn('image/jpeg'); + + $this->assertTrue($this->imageContentValidator->isValid($imageContent)); + } +} diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php new file mode 100644 index 0000000000000..feb8f0fac55f4 --- /dev/null +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Api/ImageProcessorTest.php @@ -0,0 +1,241 @@ +objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->directoryWriteMock = $this->getMockForAbstractClass( + 'Magento\Framework\Filesystem\Directory\WriteInterface' + ); + $this->fileSystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + ->disableOriginalConstructor() + ->getMock(); + $this->fileSystemMock->expects($this->any()) + ->method('getDirectoryWrite') + ->willReturn($this->directoryWriteMock); + $this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') + ->disableOriginalConstructor() + ->getMock(); + $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->uploaderMock = $this->getMockBuilder('Magento\Framework\Api\Uploader') + ->setMethods( + [ + 'processFileAttributes', + 'setFilesDispersion', + 'setFilenamesCaseSensitivity', + 'setAllowRenameFiles', + 'save', + 'getUploadedFileName' + ] + ) + ->disableOriginalConstructor() + ->getMock(); + + $this->imageProcessor = $this->objectManager->getObject( + 'Magento\Framework\Api\ImageProcessor', + [ + 'fileSystem' => $this->fileSystemMock, + 'contentValidator' => $this->contentValidatorMock, + 'dataObjectHelper' => $this->dataObjectHelperMock, + 'logger' => $this->loggerMock, + 'uploader' => $this->uploaderMock + ] + ); + } + + public function testSaveWithNoImageData() + { + $imageDataMock = $this->getMockBuilder('Magento\Framework\Api\CustomAttributesDataInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageDataMock->expects($this->once()) + ->method('getCustomAttributes') + ->willReturn([]); + + $this->dataObjectHelperMock->expects($this->once()) + ->method('getCustomAttributeValueByType') + ->willReturn([]); + + $this->assertEquals($imageDataMock, $this->imageProcessor->save($imageDataMock, 'testEntityType')); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage The image content is not valid. + */ + public function testSaveInputException() + { + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + ->disableOriginalConstructor() + ->getMock(); + $imageDataObject->expects($this->once()) + ->method('getValue') + ->willReturn($imageContent); + + $imageDataMock = $this->getMockBuilder('Magento\Framework\Api\CustomAttributesDataInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageDataMock->expects($this->once()) + ->method('getCustomAttributes') + ->willReturn([]); + + $this->dataObjectHelperMock->expects($this->once()) + ->method('getCustomAttributeValueByType') + ->willReturn([$imageDataObject]); + + $this->contentValidatorMock->expects($this->once()) + ->method('isValid') + ->willReturn(false); + + $this->imageProcessor->save($imageDataMock, 'testEntityType'); + } + + public function testSaveWithNoPreviousData() + { + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn('testImageData'); + $imageContent->expects($this->any()) + ->method('getName') + ->willReturn('testFileName'); + + $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + ->disableOriginalConstructor() + ->getMock(); + $imageDataObject->expects($this->once()) + ->method('getValue') + ->willReturn($imageContent); + + $imageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $imageData->expects($this->once()) + ->method('getCustomAttributes') + ->willReturn([]); + + $this->dataObjectHelperMock->expects($this->once()) + ->method('getCustomAttributeValueByType') + ->willReturn([$imageDataObject]); + + $this->contentValidatorMock->expects($this->once()) + ->method('isValid') + ->willReturn(true); + + $this->directoryWriteMock->expects($this->any()) + ->method('getAbsolutePath') + ->willReturn('testPath'); + + $this->assertEquals($imageData, $this->imageProcessor->save($imageData, 'testEntityType')); + } + + public function testSaveWithPreviousData() + { + $imageContent = $this->getMockBuilder('Magento\Framework\Api\Data\ImageContentInterface') + ->disableOriginalConstructor() + ->getMock(); + $imageContent->expects($this->any()) + ->method('getBase64EncodedData') + ->willReturn('testImageData'); + $imageContent->expects($this->any()) + ->method('getName') + ->willReturn('testFileName'); + + $imageDataObject = $this->getMockBuilder('Magento\Framework\Api\AttributeValue') + ->disableOriginalConstructor() + ->getMock(); + $imageDataObject->expects($this->once()) + ->method('getValue') + ->willReturn($imageContent); + + $imageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $imageData->expects($this->once()) + ->method('getCustomAttributes') + ->willReturn([]); + + $this->dataObjectHelperMock->expects($this->once()) + ->method('getCustomAttributeValueByType') + ->willReturn([$imageDataObject]); + + $this->contentValidatorMock->expects($this->once()) + ->method('isValid') + ->willReturn(true); + + $this->directoryWriteMock->expects($this->any()) + ->method('getAbsolutePath') + ->willReturn('testPath'); + + $prevImageAttribute = $this->getMockForAbstractClass('Magento\Framework\Api\AttributeInterface'); + $prevImageAttribute->expects($this->once()) + ->method('getValue') + ->willReturn('testImagePath'); + + $prevImageData = $this->getMockForAbstractClass('Magento\Framework\Api\CustomAttributesDataInterface'); + $prevImageData->expects($this->once()) + ->method('getCustomAttribute') + ->willReturn($prevImageAttribute); + + $this->assertEquals($imageData, $this->imageProcessor->save($imageData, 'testEntityType', $prevImageData)); + } +} diff --git a/lib/internal/Magento/Framework/Api/Uploader.php b/lib/internal/Magento/Framework/Api/Uploader.php new file mode 100644 index 0000000000000..3c36bd226951d --- /dev/null +++ b/lib/internal/Magento/Framework/Api/Uploader.php @@ -0,0 +1,40 @@ +_file = $fileAttributes; + if (!file_exists($this->_file['tmp_name'])) { + $code = empty($this->_file['tmp_name']) ? self::TMP_NAME_EMPTY : 0; + throw new \Exception('File was not processed correctly.', $code); + } else { + $this->_fileExists = true; + } + } +} diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php index aaf238eadacaa..05fd99ceaa7d2 100644 --- a/lib/internal/Magento/Framework/App/Bootstrap.php +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -12,6 +12,7 @@ use Magento\Framework\Autoload\Populator; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Profiler; +use Magento\Framework\Config\File\ConfigFilePool; /** * A bootstrap of Magento application @@ -147,7 +148,8 @@ public static function createObjectManagerFactory($rootDir, array $initParams) { $dirList = self::createFilesystemDirectoryList($rootDir, $initParams); $driverPool = self::createFilesystemDriverPool($initParams); - return new ObjectManagerFactory($dirList, $driverPool); + $configFilePool = self::createConfigFilePool(); + return new ObjectManagerFactory($dirList, $driverPool, $configFilePool); } /** @@ -181,6 +183,16 @@ public static function createFilesystemDriverPool(array $initParams) return new DriverPool($extraDrivers); } + /** + * Creates instance of configuration files pool + * + * @return DriverPool + */ + public static function createConfigFilePool() + { + return new ConfigFilePool(); + } + /** * Constructor * diff --git a/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php b/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php index 0a21d0ac00ac7..c2f16266e8749 100644 --- a/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php +++ b/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php @@ -7,7 +7,6 @@ use Magento\Framework\App\Cache\Type\FrontendPool; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\Config\ConfigOptionsList; /** * In-memory readonly pool of all cache front-end instances known to the system diff --git a/lib/internal/Magento/Framework/App/Cache/State.php b/lib/internal/Magento/Framework/App/Cache/State.php index d7de86d9ba359..20d55a3f001fc 100644 --- a/lib/internal/Magento/Framework/App/Cache/State.php +++ b/lib/internal/Magento/Framework/App/Cache/State.php @@ -98,7 +98,7 @@ public function setEnabled($cacheType, $isEnabled) public function persist() { $this->load(); - $this->writer->saveConfig([ConfigFilePool::APP_CONFIG => [self::CACHE_KEY => $this->statuses]]); + $this->writer->saveConfig([ConfigFilePool::APP_ENV => [self::CACHE_KEY => $this->statuses]]); } /** diff --git a/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php b/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php index eeb0776c8dc02..05ee315579b95 100644 --- a/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php +++ b/lib/internal/Magento/Framework/App/Cache/Type/FrontendPool.php @@ -7,7 +7,6 @@ use Magento\Framework\App\Cache\Frontend\Pool; use Magento\Framework\App\DeploymentConfig; -use Magento\Framework\Config\ConfigOptionsList; /** * In-memory readonly pool of cache front-ends with enforced access control, specific to cache types diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php index de210b4287105..5ccb6c347c6fd 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php @@ -7,6 +7,7 @@ namespace Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Config\File\ConfigFilePool; /** * Deployment configuration reader @@ -14,69 +15,87 @@ class Reader { /** - * Default configuration file name + * @var DirectoryList */ - const DEFAULT_FILE = 'config.php'; + private $dirList; /** - * Directory list object - * - * @var DirectoryList + * @var ConfigFilePool */ - private $dirList; + private $configFilePool; /** - * Custom file name + * Configuration file names * - * @var string + * @var array */ - private $file; + private $files; /** * Constructor * * @param DirectoryList $dirList + * @param ConfigFilePool $configFilePool * @param null|string $file * @throws \InvalidArgumentException */ - public function __construct(DirectoryList $dirList, $file = null) + public function __construct(DirectoryList $dirList, ConfigFilePool $configFilePool, $file = null) { $this->dirList = $dirList; + $this->configFilePool = $configFilePool; if (null !== $file) { if (!preg_match('/^[a-z\d\.\-]+\.php$/i', $file)) { throw new \InvalidArgumentException("Invalid file name: {$file}"); } - $this->file = $file; + $this->files = [$file]; } else { - $this->file = self::DEFAULT_FILE; + $this->files = $this->configFilePool->getPaths(); } } /** * Gets the file name * - * @return string + * @return array */ - public function getFile() + public function getFiles() { - return $this->file; + return $this->files; } /** * Loads the configuration file * - * @param string $configFile + * @param string $fileKey * @return array + * @throws \Exception */ - public function load($configFile = null) + public function load($fileKey = null) { - if ($configFile) { - $file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $configFile; + $path = $this->dirList->getPath(DirectoryList::CONFIG); + if ($fileKey) { + $result = @include $path . '/' . $this->configFilePool->getPath($fileKey); } else { - $file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $this->file; + $configFiles = $this->configFilePool->getPaths(); + $result = []; + foreach (array_keys($configFiles) as $fileKey) { + $configFile = $path . '/' . $this->configFilePool->getPath($fileKey); + $fileData = @include $configFile; + if (!empty($fileData)) { + $intersection = array_intersect_key($result, $fileData); + if (!empty($intersection)) { + $displayList = ''; + foreach (array_keys($intersection) as $key) { + $displayList .= $key . PHP_EOL; + } + throw new \Exception( + "Key collision! The following keys occur in multiple config files:" . PHP_EOL . $displayList + ); + } + $result = array_merge($result, $fileData); + } + } } - - $result = @include $file; return $result ?: []; } } diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php index 644af48555deb..8fd58e29391f2 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php @@ -78,10 +78,12 @@ public function __construct( public function checkIfWritable() { $configDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG); - if ($configDirectory->isWritable($this->reader->getFile())) { - return true; + foreach ($this->reader->getFiles() as $file) { + if (!$configDirectory->isWritable($file)) { + return false; + } } - return false; + return true; } /** @@ -99,7 +101,7 @@ public function saveConfig(array $data, $override = false) if (isset($paths[$fileKey])) { if ($this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->isExist($paths[$fileKey])) { - $currentData = $this->reader->load($paths[$fileKey]); + $currentData = $this->reader->load($fileKey); if ($override) { $config = array_merge($currentData, $config); } else { @@ -109,6 +111,11 @@ public function saveConfig(array $data, $override = false) $contents = $this->formatter->format($config); $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile($paths[$fileKey], $contents); + if (function_exists('opcache_invalidate')) { + opcache_invalidate( + $this->filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath($paths[$fileKey]) + ); + } } } $this->deploymentConfig->resetData(); diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index c712e82a26470..98f338759f77a 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -12,8 +12,7 @@ use Magento\Framework\Interception\ObjectManager\ConfigInterface; use Magento\Framework\ObjectManager\Definition\Compiled\Serialized; use Magento\Framework\App\ObjectManager\Environment; -use Magento\Framework\App\EnvironmentFactory; -use Magento\Framework\App\EnvironmentInterface; +use Magento\Framework\Config\File\ConfigFilePool; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -71,6 +70,13 @@ class ObjectManagerFactory */ protected $driverPool; + /** + * Configuration file pool + * + * @var ConfigFilePool + */ + protected $configFilePool; + /** * Factory * @@ -83,11 +89,13 @@ class ObjectManagerFactory * * @param DirectoryList $directoryList * @param DriverPool $driverPool + * @param ConfigFilePool $configFilePool */ - public function __construct(DirectoryList $directoryList, DriverPool $driverPool) + public function __construct(DirectoryList $directoryList, DriverPool $driverPool, ConfigFilePool $configFilePool) { $this->directoryList = $directoryList; $this->driverPool = $driverPool; + $this->configFilePool = $configFilePool; } /** @@ -100,7 +108,7 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool */ public function create(array $arguments) { - $deploymentConfig = $this->createDeploymentConfig($this->directoryList, $arguments); + $deploymentConfig = $this->createDeploymentConfig($this->directoryList, $this->configFilePool, $arguments); $arguments = array_merge($deploymentConfig->get(), $arguments); $definitionFactory = new \Magento\Framework\ObjectManager\DefinitionFactory( $this->driverPool->getDriver(DriverPool::FILE), @@ -179,18 +187,22 @@ public function create(array $arguments) * Creates deployment configuration object * * @param DirectoryList $directoryList + * @param ConfigFilePool $configFilePool * @param array $arguments * @return DeploymentConfig */ - protected function createDeploymentConfig(DirectoryList $directoryList, array $arguments) - { + protected function createDeploymentConfig( + DirectoryList $directoryList, + ConfigFilePool $configFilePool, + array $arguments + ) { $customFile = isset($arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG_FILE]) ? $arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG_FILE] : null; $customData = isset($arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG]) ? $arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG] : []; - $reader = new DeploymentConfig\Reader($directoryList, $customFile); + $reader = new DeploymentConfig\Reader($directoryList, $configFilePool, $customFile); return new DeploymentConfig($reader, $customData); } diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php index e6e502cf38171..18502821429cf 100644 --- a/lib/internal/Magento/Framework/App/Request/Http.php +++ b/lib/internal/Magento/Framework/App/Request/Http.php @@ -345,6 +345,25 @@ public static function getDistroBaseUrlPath($server) return $result; } + /** + * Return url with no script name + * + * @param string $url + * @return string + */ + public static function getUrlNoScript($url) + { + if (!isset($_SERVER['SCRIPT_NAME'])) { + return $url; + } + + if (($pos = strripos($url, basename($_SERVER['SCRIPT_NAME']))) !== false) { + $url = substr($url, 0, $pos); + } + + return $url; + } + /** * Retrieve full action name * diff --git a/lib/internal/Magento/Framework/App/Resource.php b/lib/internal/Magento/Framework/App/Resource.php index b498ec9d349fe..d76a3a68bdcaf 100644 --- a/lib/internal/Magento/Framework/App/Resource.php +++ b/lib/internal/Magento/Framework/App/Resource.php @@ -10,7 +10,7 @@ use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\Resource\ConfigInterface as ResourceConfigInterface; use Magento\Framework\Model\Resource\Type\Db\ConnectionFactoryInterface; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; class Resource { @@ -104,11 +104,10 @@ public function getConnectionByName($connectionName) return $this->_connections[$connectionName]; } - $dbInfo = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - if (null === $dbInfo) { - return false; - } - $connectionConfig = $dbInfo['connection'][$connectionName]; + $connectionConfig = $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/' . $connectionName + ); + if ($connectionConfig) { $connection = $this->_connectionFactory->create($connectionConfig); } @@ -233,7 +232,7 @@ private function getTablePrefix() { if (null === $this->_tablePrefix) { $this->_tablePrefix = (string)$this->deploymentConfig->get( - ConfigOptionsList::CONFIG_PATH_DB_PREFIX + ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX ); } return $this->_tablePrefix; diff --git a/lib/internal/Magento/Framework/App/Resource/Config.php b/lib/internal/Magento/Framework/App/Resource/Config.php index d6f57e82fd5f4..444b43b13f53f 100644 --- a/lib/internal/Magento/Framework/App/Resource/Config.php +++ b/lib/internal/Magento/Framework/App/Resource/Config.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\App\Resource; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; class Config extends \Magento\Framework\Config\Data\Scoped implements ConfigInterface { @@ -37,7 +37,8 @@ public function __construct( ) { parent::__construct($reader, $configScope, $cache, $cacheId); - foreach ($deploymentConfig->getConfigData(ConfigOptionsList::KEY_RESOURCE) as $resourceName => $resourceData) { + $resource = $deploymentConfig->getConfigData(ConfigOptionsListConstants::KEY_RESOURCE); + foreach ($resource as $resourceName => $resourceData) { if (!isset($resourceData['connection'])) { throw new \InvalidArgumentException('Invalid initial resource configuration'); } diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index 6b510679daadc..55cda163252ab 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -52,19 +52,7 @@ public function __construct( } /** - * Send the response, including all headers, rendering exceptions if so - * requested. - * - * @return void - */ - public function sendResponse() - { - $this->sendVary(); - parent::sendResponse(); - } - - /** - * Send Vary coookie + * Send Vary cookie * * @return void */ @@ -74,12 +62,10 @@ public function sendVary() if (!empty($data)) { ksort($data); $cookieValue = sha1(serialize($data)); - $sensitiveCookMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata() - ->setPath('/'); + $sensitiveCookMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata()->setPath('/'); $this->cookieManager->setSensitiveCookie(self::COOKIE_VARY_STRING, $cookieValue, $sensitiveCookMetadata); } else { - $cookieMetadata = $this->cookieMetadataFactory->createCookieMetadata() - ->setPath('/'); + $cookieMetadata = $this->cookieMetadataFactory->createCookieMetadata()->setPath('/'); $this->cookieManager->deleteCookie(self::COOKIE_VARY_STRING, $cookieMetadata); } } diff --git a/lib/internal/Magento/Framework/App/Rss/UrlBuilder.php b/lib/internal/Magento/Framework/App/Rss/UrlBuilder.php index e70f242262452..b421b8f608db7 100644 --- a/lib/internal/Magento/Framework/App/Rss/UrlBuilder.php +++ b/lib/internal/Magento/Framework/App/Rss/UrlBuilder.php @@ -7,13 +7,12 @@ /** * Class UrlBuilder - * @package Magento\Rss\Model */ class UrlBuilder implements UrlBuilderInterface { /** - * @param array $queryParams - * @return string + * {@inheritdoc} + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getUrl(array $queryParams = []) { diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php index 6418ba19f9dd7..d3d5771042d89 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php @@ -7,7 +7,6 @@ use Magento\Framework\App\Cache\Frontend\Pool; use Magento\Framework\App\Cache\Type\FrontendPool; -use Magento\Framework\Config\ConfigOptionsList; class PoolTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php index c5767244b54ee..8278d0fdfe45b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/StateTest.php @@ -93,7 +93,7 @@ public function testPersist() { $model = new State($this->config, $this->writer); $this->config->expects($this->once())->method('getConfigData')->willReturn(['test_cache_type' => true]); - $configValue = [ConfigFilePool::APP_CONFIG => ['cache_types' => ['test_cache_type' => true]]]; + $configValue = [ConfigFilePool::APP_ENV => ['cache_types' => ['test_cache_type' => true]]]; $this->writer->expects($this->once())->method('saveConfig')->with($configValue); $model->persist(); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php index 9b0adbe03e123..5f6af37c48b86 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Type/FrontendPoolTest.php @@ -6,7 +6,6 @@ namespace Magento\Framework\App\Test\Unit\Cache\Type; use \Magento\Framework\App\Cache\Type\FrontendPool; -use Magento\Framework\Config\ConfigOptionsList; class FrontendPoolTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php index a1bce3da6da24..04437a742a5f0 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php @@ -6,8 +6,7 @@ namespace Magento\Framework\App\Test\Unit\DeploymentConfig; -use \Magento\Framework\App\DeploymentConfig\Reader; - +use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\Filesystem\DirectoryList; class ReaderTest extends \PHPUnit_Framework_TestCase @@ -17,17 +16,33 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ private $dirList; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $configFilePool; + protected function setUp() { $this->dirList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $this->dirList->expects($this->any()) + ->method('getPath') + ->with(DirectoryList::CONFIG) + ->willReturn(__DIR__ . '/_files'); + $this->configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $this->configFilePool + ->expects($this->any()) + ->method('getPaths') + ->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'env.php']); } public function testGetFile() { - $object = new Reader($this->dirList); - $this->assertEquals(Reader::DEFAULT_FILE, $object->getFile()); - $object = new Reader($this->dirList, 'custom.php'); - $this->assertEquals('custom.php', $object->getFile()); + $object = new Reader($this->dirList, $this->configFilePool); + $files = $object->getFiles(); + $this->assertArrayHasKey('configKeyOne', $files); + $this->assertArrayHasKey('configKeyTwo', $files); + $object = new Reader($this->dirList, $this->configFilePool, 'customOne.php'); + $this->assertEquals(['customOne.php'], $object->getFiles()); } /** @@ -36,34 +51,82 @@ public function testGetFile() */ public function testWrongFile() { - new Reader($this->dirList, 'invalid_name'); + new Reader($this->dirList, $this->configFilePool, 'invalid_name'); + } + + public function testLoad() + { + $files = [['configKeyOne', 'config.php'], ['configKeyTwo','env.php']]; + $this->configFilePool + ->expects($this->any()) + ->method('getPath') + ->will($this->returnValueMap($files)); + $object = new Reader($this->dirList, $this->configFilePool); + $this->assertSame(['fooKey' =>'foo', 'barKey' => 'bar', 'envKey' => 'env'], $object->load()); } /** * @param string $file * @param array $expected - * @dataProvider loadDataProvider + * @dataProvider loadCustomDataProvider */ - public function testLoad($file, $expected) + public function testCustomLoad($file, $expected) { - $this->dirList->expects($this->once()) - ->method('getPath') - ->with(DirectoryList::CONFIG) - ->willReturn(__DIR__ . '/_files'); - $object = new Reader($this->dirList, $file); - $this->assertSame($expected, $object->load()); + $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $configFilePool->expects($this->any())->method('getPaths')->willReturn([$file]); + $configFilePool->expects($this->any())->method('getPath')->willReturn($file); + $object = new Reader($this->dirList, $configFilePool, $file); + $this->assertSame($expected, $object->load($file)); } /** * @return array */ - public function loadDataProvider() + public function loadCustomDataProvider() { return [ - [null, ['foo', 'bar']], - ['config.php', ['foo', 'bar']], - ['custom.php', ['baz']], - ['nonexistent.php', []] + ['custom.php', ['bazKey' => 'baz']], + ['nonexistent.php', []], ]; } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Key collision + */ + public function testMerging() + { + $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $files = [['configKeyOne', 'mergeOne.php'], ['configKeyTwo','mergeTwo.php']]; + $configFilePool + ->expects($this->any()) + ->method('getPath') + ->will($this->returnValueMap($files)); + $configFilePool + ->expects($this->any()) + ->method('getPaths') + ->willReturn(['configKeyOne' => 'mergeOne.php', 'configKeyTwo' => 'mergeTwo.php']); + $object = new Reader($this->dirList, $configFilePool); + $object->load(); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Key collision + */ + public function testMergingWithDuplicateEndValues() + { + $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); + $files = [['configKeyOne', 'config.php'], ['configKeyTwo','duplicateConfig.php']]; + $configFilePool + ->expects($this->any()) + ->method('getPath') + ->will($this->returnValueMap($files)); + $configFilePool + ->expects($this->any()) + ->method('getPaths') + ->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'duplicateConfig.php']); + $object = new Reader($this->dirList, $configFilePool); + $object->load(); + } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php index e1ab784199fa3..f780a3a7cde72 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/WriterTest.php @@ -28,6 +28,11 @@ class WriterTest extends \PHPUnit_Framework_TestCase */ private $dirWrite; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $dirRead; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -59,12 +64,19 @@ protected function setUp() $this->deploymentConfig, $this->formatter ); - $this->reader->expects($this->any())->method('getFile')->willReturn('test.php'); + $this->reader->expects($this->any())->method('getFiles')->willReturn('test.php'); $this->dirWrite = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $this->dirRead = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); + $this->dirRead->expects($this->any()) + ->method('getAbsolutePath'); $filesystem->expects($this->any()) ->method('getDirectoryWrite') ->with(DirectoryList::CONFIG) ->willReturn($this->dirWrite); + $filesystem->expects($this->any()) + ->method('getDirectoryRead') + ->with(DirectoryList::CONFIG) + ->willReturn($this->dirRead); } public function testSaveConfig() diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php index e5519913e59aa..569b3df839882 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/config.php @@ -4,4 +4,4 @@ * See COPYING.txt for license details. */ -return ['foo', 'bar']; +return ['fooKey' => 'foo', 'barKey' => 'bar']; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php index 22cd13edb6746..4e57bcc515846 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/custom.php @@ -4,4 +4,4 @@ * See COPYING.txt for license details. */ -return ['baz']; +return ['bazKey' => 'baz']; diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/_files/application_test/fixture2.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/duplicateConfig.php similarity index 74% rename from dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/_files/application_test/fixture2.php rename to lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/duplicateConfig.php index bc915c0a49063..18337a49daf24 100644 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/_files/application_test/fixture2.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/duplicateConfig.php @@ -4,4 +4,4 @@ * See COPYING.txt for license details. */ -$this->applied[] = 'fixture2'; +return ['barKey' => 'someOtherBar']; diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/_files/application_test/fixture1.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/env.php similarity index 77% rename from dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/_files/application_test/fixture1.php rename to lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/env.php index 5d49951b6782a..660088939bca8 100644 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/_files/application_test/fixture1.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/env.php @@ -4,4 +4,4 @@ * See COPYING.txt for license details. */ -$this->applied[] = 'fixture1'; +return ['envKey' => 'env']; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/mergeOne.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/mergeOne.php new file mode 100644 index 0000000000000..84d2e3494ba6f --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/mergeOne.php @@ -0,0 +1,9 @@ + ['otherFooValueOne' => ['yetAnotherFooKey' => 'yetAnotherFooValue']] +]; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/mergeTwo.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/mergeTwo.php new file mode 100644 index 0000000000000..eb199f652a756 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/_files/mergeTwo.php @@ -0,0 +1,9 @@ + ['otherFooValueTwo' => ['yetAnotherFooKeyTwo' => 'yetAnotherFooValueTwo']] +]; diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php index 5a1cfec68056a..a92a9eb73432d 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceTest.php @@ -9,7 +9,7 @@ namespace Magento\Framework\App\Test\Unit; use \Magento\Framework\App\Resource; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; class ResourceTest extends \PHPUnit_Framework_TestCase { @@ -59,21 +59,18 @@ public function setUp() $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->deploymentConfig->expects($this->any()) - ->method('getConfigData') - ->with(ConfigOptionsList::KEY_DB) + ->method('get') ->will($this->returnValue( [ - 'connection' => [ - 'default' => [ - 'host' => 'localhost', - 'dbname' => 'magento', - 'username' => 'username', - ], - self::CONNECTION_NAME => [ - 'host' => 'localhost', - 'dbname' => 'magento', - 'username' => 'username', - ], + 'default' => [ + 'host' => 'localhost', + 'dbname' => 'magento', + 'username' => 'username', + ], + self::CONNECTION_NAME => [ + 'host' => 'localhost', + 'dbname' => 'magento', + 'username' => 'username', ], ] ) diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index 57fe340acda36..275a2bfdf0f4c 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -134,8 +134,7 @@ public function getPhpFiles($appCode = true, $otherCode = true, $templates = tru $files, glob($this->_path . '/*.php', GLOB_NOSORT), glob($this->_path . '/pub/*.php', GLOB_NOSORT), - $this->getFilesSubset(["{$this->_path}/lib/internal/Magento"], '*.php', $this->libTestDirs), - self::getFiles(["{$this->_path}/dev/tools/Magento/Tools/SampleData"], '*.php') + $this->getFilesSubset(["{$this->_path}/lib/internal/Magento"], '*.php', $this->libTestDirs) ); } if ($tests) { @@ -946,7 +945,6 @@ public function classFileExists($class, &$path = '') '/app/code/', '/lib/internal/', '/dev/tools/', - '/dev/tools/performance-toolkit/framework/', '/dev/tests/api-functional/framework/', '/dev/tests/integration/framework/', '/dev/tests/integration/framework/tests/unit/testsuite/', diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index 87e57f5f7e97c..4cce39b13ab9a 100644 --- a/lib/internal/Magento/Framework/AppInterface.php +++ b/lib/internal/Magento/Framework/AppInterface.php @@ -17,7 +17,7 @@ interface AppInterface /** * Magento version */ - const VERSION = '0.74.0-beta9'; + const VERSION = '0.74.0-beta11'; /** * Launch application diff --git a/lib/internal/Magento/Framework/Authorization/PolicyInterface.php b/lib/internal/Magento/Framework/Authorization/PolicyInterface.php index dc14adda4a4bf..57245b95dfcdb 100644 --- a/lib/internal/Magento/Framework/Authorization/PolicyInterface.php +++ b/lib/internal/Magento/Framework/Authorization/PolicyInterface.php @@ -1,12 +1,15 @@ logger = $logger; + } + + /** + * {@inheritdoc} + */ + public function remove($identifier) + { + $result = parent::remove($identifier); + $this->log(compact('identifier')); + return $result; + } + + /** + * {@inheritdoc} + */ + public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = []) + { + $result = parent::clean($mode, $tags, $mode); + $this->log(compact('tags', 'mode')); + return $result; + } + + /** + * @param mixed $args + * @return void + */ + public function log($args) + { + $this->logger->execute($args); + } +} diff --git a/lib/internal/Magento/Framework/Cache/InvalidateLogger.php b/lib/internal/Magento/Framework/Cache/InvalidateLogger.php new file mode 100644 index 0000000000000..41c26d5370e04 --- /dev/null +++ b/lib/internal/Magento/Framework/Cache/InvalidateLogger.php @@ -0,0 +1,56 @@ +request = $request; + $this->logger = $logger; + } + + /** + * Logger invalidate cache + * @param mixed $invalidateInfo + * @return void + */ + public function execute($invalidateInfo) + { + $this->logger->debug('cache_invalidate: ', $this->makeParams($invalidateInfo)); + } + + /** + * Make extra data to logger message + * @param mixed $invalidateInfo + * @return array + */ + private function makeParams($invalidateInfo) + { + $method = $this->request->getMethod(); + $url = $this->request->getUriString(); + return compact('method', 'url', 'invalidateInfo'); + } +} diff --git a/lib/internal/Magento/Framework/Config/CacheInterface.php b/lib/internal/Magento/Framework/Config/CacheInterface.php index 9d4a2ca161054..6e3167b85f1d7 100644 --- a/lib/internal/Magento/Framework/Config/CacheInterface.php +++ b/lib/internal/Magento/Framework/Config/CacheInterface.php @@ -7,6 +7,11 @@ */ namespace Magento\Framework\Config; +/** + * Config cache interface. + * + * @api + */ interface CacheInterface extends \Magento\Framework\Cache\FrontendInterface { } diff --git a/lib/internal/Magento/Framework/Config/ConfigGenerator.php b/lib/internal/Magento/Framework/Config/ConfigGenerator.php deleted file mode 100644 index 0b53e4f8aac30..0000000000000 --- a/lib/internal/Magento/Framework/Config/ConfigGenerator.php +++ /dev/null @@ -1,201 +0,0 @@ - ConfigOptionsList::KEY_HOST, - ConfigOptionsList::INPUT_KEY_DB_NAME => ConfigOptionsList::KEY_NAME, - ConfigOptionsList::INPUT_KEY_DB_USER => ConfigOptionsList::KEY_USER, - ConfigOptionsList::INPUT_KEY_DB_PASSWORD => ConfigOptionsList::KEY_PASS, - ConfigOptionsList::INPUT_KEY_DB_PREFIX => ConfigOptionsList::KEY_PREFIX, - ConfigOptionsList::INPUT_KEY_DB_MODEL => ConfigOptionsList::KEY_MODEL, - ConfigOptionsList::INPUT_KEY_DB_ENGINE => ConfigOptionsList::KEY_ENGINE, - ConfigOptionsList::INPUT_KEY_DB_INIT_STATEMENTS => ConfigOptionsList::KEY_INIT_STATEMENTS, - ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY => ConfigOptionsList::KEY_ENCRYPTION_KEY, - ConfigOptionsList::INPUT_KEY_SESSION_SAVE => ConfigOptionsList::KEY_SAVE, - ConfigOptionsList::INPUT_KEY_RESOURCE => ConfigOptionsList::KEY_RESOURCE, - ]; - - /** - * @var Random - */ - protected $random; - - /** - * @var DeploymentConfig - */ - protected $deploymentConfig; - - /** - * Constructor - * - * @param Random $random - * @param DeploymentConfig $deploymentConfig - */ - public function __construct(Random $random, DeploymentConfig $deploymentConfig) - { - $this->random = $random; - $this->deploymentConfig = $deploymentConfig; - } - - /** - * Creates install segment config data - * - * @return ConfigData - */ - public function createInstallConfig() - { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); - - if ($this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE) === null) { - $configData->set(ConfigOptionsList::CONFIG_PATH_INSTALL_DATE, date('r')); - } - return $configData; - } - - /** - * Creates encryption key config data - * @param array $data - * @return ConfigData - */ - public function createCryptConfig(array $data) - { - $currentKey = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_CRYPT_KEY); - - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); - if (isset($data[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY])) { - if ($currentKey !== null) { - $key = $currentKey . "\n" . $data[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY]; - } else { - $key = $data[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY]; - } - - $configData->set(ConfigOptionsList::CONFIG_PATH_CRYPT_KEY, $key); - } else { - if ($currentKey === null) { - $configData->set(ConfigOptionsList::CONFIG_PATH_CRYPT_KEY, md5($this->random->getRandomString(10))); - } - } - - return $configData; - } - - /** - * Creates session config data - * - * @param array $data - * @return ConfigData - */ - public function createSessionConfig(array $data) - { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); - - if (isset($data[ConfigOptionsList::INPUT_KEY_SESSION_SAVE])) { - $configData->set( - ConfigOptionsList::CONFIG_PATH_SESSION_SAVE, - $data[ConfigOptionsList::INPUT_KEY_SESSION_SAVE] - ); - } - - return $configData; - } - - /** - * Creates definitions config data - * - * @param array $data - * @return ConfigData - */ - public function createDefinitionsConfig(array $data) - { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); - - if (!empty($data[ConfigOptionsList::INPUT_KEY_DEFINITION_FORMAT])) { - $configData->set( - ConfigOptionsList::CONFIG_PATH_DEFINITION_FORMAT, - $data[ConfigOptionsList::INPUT_KEY_DEFINITION_FORMAT] - ); - } - - return $configData; - } - - /** - * Creates db config data - * - * @param array $data - * @return ConfigData - */ - public function createDbConfig(array $data) - { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); - - $optional = [ - ConfigOptionsList::INPUT_KEY_DB_HOST, - ConfigOptionsList::INPUT_KEY_DB_NAME, - ConfigOptionsList::INPUT_KEY_DB_USER, - ConfigOptionsList::INPUT_KEY_DB_PASSWORD, - ConfigOptionsList::INPUT_KEY_DB_MODEL, - ConfigOptionsList::INPUT_KEY_DB_ENGINE, - ConfigOptionsList::INPUT_KEY_DB_INIT_STATEMENTS, - ]; - - if (isset($data[ConfigOptionsList::INPUT_KEY_DB_PREFIX])) { - $configData->set(ConfigOptionsList::CONFIG_PATH_DB_PREFIX, $data[ConfigOptionsList::INPUT_KEY_DB_PREFIX]); - } - - foreach ($optional as $key) { - if (isset($data[$key])) { - $configData->set( - ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::$paramMap[$key], - $data[$key] - ); - } - } - - $currentStatus = $this->deploymentConfig->get( - ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT . ConfigOptionsList::KEY_ACTIVE - ); - - if ($currentStatus === null) { - $configData->set(ConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT . ConfigOptionsList::KEY_ACTIVE, '1'); - } - - return $configData; - } - - /** - * Creates resource config data - * - * @return ConfigData - */ - public function createResourceConfig() - { - $configData = new ConfigData(ConfigFilePool::APP_CONFIG); - - if ($this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP) === null) { - $configData->set(ConfigOptionsList::CONFIG_PATH_RESOURCE_DEFAULT_SETUP, 'default'); - } - - return $configData; - } -} diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsList.php b/lib/internal/Magento/Framework/Config/ConfigOptionsList.php deleted file mode 100644 index 5ed04b1bc6023..0000000000000 --- a/lib/internal/Magento/Framework/Config/ConfigOptionsList.php +++ /dev/null @@ -1,237 +0,0 @@ -configGenerator = $configGenerator; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return [ - new TextConfigOption( - self::INPUT_KEY_ENCRYPTION_KEY, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_CRYPT_KEY, - 'Encryption key' - ), - new SelectConfigOption( - self::INPUT_KEY_SESSION_SAVE, - SelectConfigOption::FRONTEND_WIZARD_SELECT, - [self::SESSION_SAVE_FILES, self::SESSION_SAVE_DB], - self::CONFIG_PATH_SESSION_SAVE, - 'Session save location', - self::SESSION_SAVE_FILES - ), - new SelectConfigOption( - self::INPUT_KEY_DEFINITION_FORMAT, - SelectConfigOption::FRONTEND_WIZARD_SELECT, - DefinitionFactory::getSupportedFormats(), - self::CONFIG_PATH_DEFINITION_FORMAT, - 'Type of definitions used by Object Manager' - ), - new TextConfigOption( - self::INPUT_KEY_DB_HOST, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_HOST, - 'Database server host', - 'localhost' - ), - new TextConfigOption( - self::INPUT_KEY_DB_NAME, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_NAME, - 'Database name', - 'magento2' - ), - new TextConfigOption( - self::INPUT_KEY_DB_USER, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_USER, - 'Database server username', - 'root' - ), - new TextConfigOption( - self::INPUT_KEY_DB_ENGINE, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_ENGINE, - 'Database server engine', - 'innodb' - ), - new TextConfigOption( - self::INPUT_KEY_DB_PASSWORD, - TextConfigOption::FRONTEND_WIZARD_PASSWORD, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_PASS, - 'Database server password', - '' - ), - new TextConfigOption( - self::INPUT_KEY_DB_PREFIX, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_PREFIX, - 'Database table prefix', - '' - ), - new TextConfigOption( - self::INPUT_KEY_DB_MODEL, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_MODEL, - 'Database type', - 'mysql4' - ), - new TextConfigOption( - self::INPUT_KEY_DB_INIT_STATEMENTS, - TextConfigOption::FRONTEND_WIZARD_TEXT, - self::CONFIG_PATH_DB_CONNECTION_DEFAULT . self::KEY_INIT_STATEMENTS, - 'Database initial set of commands', - 'SET NAMES utf8;' - ), - ]; - } - - /** - * {@inheritdoc} - */ - public function createConfig(array $data, DeploymentConfig $deploymentConfig) - { - $configData = []; - $configData[] = $this->configGenerator->createInstallConfig($deploymentConfig); - $configData[] = $this->configGenerator->createCryptConfig($data, $deploymentConfig); - $configData[] = $this->configGenerator->createSessionConfig($data); - $definitionConfig = $this->configGenerator->createDefinitionsConfig($data); - if (isset($definitionConfig)) { - $configData[] = $definitionConfig; - } - $configData[] = $this->configGenerator->createDbConfig($data); - $configData[] = $this->configGenerator->createResourceConfig(); - return $configData; - } - - /** - * {@inheritdoc} - */ - public function validate(array $options) - { - $errors = []; - - if (isset($options[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY]) - && !$options[ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY]) { - $errors[] = 'Invalid encryption key.'; - } - - if (isset($options[ConfigOptionsList::INPUT_KEY_SESSION_SAVE])) { - if ($options[ConfigOptionsList::INPUT_KEY_SESSION_SAVE] != ConfigOptionsList::SESSION_SAVE_FILES && - $options[ConfigOptionsList::INPUT_KEY_SESSION_SAVE] != ConfigOptionsList::SESSION_SAVE_DB - ) { - $errors[] = 'Invalid session save location.'; - } - } - - return $errors; - } -} diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php new file mode 100644 index 0000000000000..f6de3f89043da --- /dev/null +++ b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php @@ -0,0 +1,90 @@ + 'config.php' + self::APP_CONFIG => 'config.php', + self::APP_ENV => 'env.php', ]; /** diff --git a/lib/internal/Magento/Framework/Config/FileResolverInterface.php b/lib/internal/Magento/Framework/Config/FileResolverInterface.php index b4a238472cb66..21735d9f7ba00 100644 --- a/lib/internal/Magento/Framework/Config/FileResolverInterface.php +++ b/lib/internal/Magento/Framework/Config/FileResolverInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Config; +/** + * File resolver interface. + * + * @api + */ interface FileResolverInterface { /** diff --git a/lib/internal/Magento/Framework/Config/ReaderInterface.php b/lib/internal/Magento/Framework/Config/ReaderInterface.php index 6372451bb723e..54db23bf016bd 100644 --- a/lib/internal/Magento/Framework/Config/ReaderInterface.php +++ b/lib/internal/Magento/Framework/Config/ReaderInterface.php @@ -7,6 +7,11 @@ */ namespace Magento\Framework\Config; +/** + * Config reader interface. + * + * @api + */ interface ReaderInterface { /** diff --git a/lib/internal/Magento/Framework/Config/SchemaLocatorInterface.php b/lib/internal/Magento/Framework/Config/SchemaLocatorInterface.php index 6df006849c577..56ca06cff90bf 100644 --- a/lib/internal/Magento/Framework/Config/SchemaLocatorInterface.php +++ b/lib/internal/Magento/Framework/Config/SchemaLocatorInterface.php @@ -7,6 +7,11 @@ */ namespace Magento\Framework\Config; +/** + * Config schema locator interface. + * + * @api + */ interface SchemaLocatorInterface { /** diff --git a/lib/internal/Magento/Framework/Config/ScopeInterface.php b/lib/internal/Magento/Framework/Config/ScopeInterface.php index 3b7994da97d87..438e3e1df8255 100644 --- a/lib/internal/Magento/Framework/Config/ScopeInterface.php +++ b/lib/internal/Magento/Framework/Config/ScopeInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Config; +/** + * Config scope interface. + * + * @api + */ interface ScopeInterface { /** diff --git a/lib/internal/Magento/Framework/Config/ScopeListInterface.php b/lib/internal/Magento/Framework/Config/ScopeListInterface.php index b0be13b89cea6..bb681e36d74d2 100644 --- a/lib/internal/Magento/Framework/Config/ScopeListInterface.php +++ b/lib/internal/Magento/Framework/Config/ScopeListInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Config; +/** + * Config scope list interface. + * + * @api + */ interface ScopeListInterface { /** diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php index 52bc10dc59b89..24452acb4336f 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/File/ConfigFilePoolTest.php @@ -27,6 +27,7 @@ public function testGetPaths() { $expected['new_key'] = 'new_config.php'; $expected[ConfigFilePool::APP_CONFIG] = 'config.php'; + $expected[ConfigFilePool::APP_ENV] = 'env.php'; $this->assertEquals($expected, $this->configFilePool->getPaths()); } diff --git a/lib/internal/Magento/Framework/Config/ValidationStateInterface.php b/lib/internal/Magento/Framework/Config/ValidationStateInterface.php index 1f3000f6fb5fc..61f39fb67cc76 100644 --- a/lib/internal/Magento/Framework/Config/ValidationStateInterface.php +++ b/lib/internal/Magento/Framework/Config/ValidationStateInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Config; +/** + * Config validation state interface. + * + * @api + */ interface ValidationStateInterface { /** diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index 9d74f61e2495a..2e62b25d371ee 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -17,6 +17,11 @@ */ class Cli extends SymfonyApplication { + /** + * Name of input option + */ + const INPUT_KEY_BOOTSTRAP = 'bootstrap'; + /** * {@inheritdoc} */ @@ -41,7 +46,7 @@ protected function getApplicationCommands() $toolsCommands = []; $modulesCommands = []; - $bootstrapParam = new ComplexParameter('bootstrap'); + $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP); $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER); $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; $bootstrap = Bootstrap::create(BP, $params); diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Oyejorge.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Oyejorge.php index e490aa616ba34..c91e1721686ac 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Oyejorge.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Oyejorge.php @@ -12,16 +12,25 @@ */ class Oyejorge implements \Magento\Framework\Css\PreProcessor\AdapterInterface { + /** + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + /** * @var \Magento\Framework\App\State */ protected $appState; /** - * @param \Magento\Framework\App\State $appState + * @param \Psr\Log\LoggerInterface $logger + * @param State $appState */ - public function __construct(State $appState) - { + public function __construct( + \Psr\Log\LoggerInterface $logger, + State $appState + ) { + $this->logger = $logger; $this->appState = $appState; } @@ -32,8 +41,14 @@ public function __construct(State $appState) public function process($sourceFilePath) { $options = ['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]; - $parser = new \Less_Parser($options); - $parser->parseFile($sourceFilePath, ''); - return $parser->getCss(); + try { + $parser = new \Less_Parser($options); + $parser->parseFile($sourceFilePath, ''); + return $parser->getCss(); + } catch (\Exception $e) { + $messagePrefix = 'CSS compilation from LESS '; + $this->logger->critical($messagePrefix . $e->getMessage()); + return $messagePrefix . $e->getMessage(); + } } } diff --git a/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php b/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php index 938cfe6a31ec2..96eb992ade3f5 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php +++ b/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php @@ -508,14 +508,6 @@ public function delete($table, $where = ''); */ public function query($sql, $bind = []); - /** - * Executes a SQL statement(s) - * - * @param string $sql - * @return \Magento\Framework\DB\Adapter\AdapterInterface - */ - public function multiQuery($sql); - /** * Fetches all SQL result rows as a sequential array. * Uses the current fetchMode for the adapter. diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index 932d824cdeec7..74d74986e0e68 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -19,6 +19,7 @@ use Magento\Framework\DB\Select; use Magento\Framework\DB\Statement\Parameter; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Phrase; use Magento\Framework\Stdlib\DateTime; use Magento\Framework\Stdlib\String; @@ -402,6 +403,7 @@ protected function _checkDdlTransaction($sql) } } + /** * Special handling for PDO query(). * All bind parameter names must begin with ':'. @@ -410,9 +412,10 @@ protected function _checkDdlTransaction($sql) * @param mixed $bind An array of data or data itself to bind to the placeholders. * @return \Zend_Db_Statement_Pdo|void * @throws \Zend_Db_Adapter_Exception To re-throw \PDOException. + * @throws LocalizedException In case multiple queries are attempted at once, to protect from SQL injection * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function query($sql, $bind = []) + protected function _query($sql, $bind = []) { $connectionErrors = [ 2006, // SQLSTATE[HY000]: General error: 2006 MySQL server has gone away @@ -463,6 +466,45 @@ public function query($sql, $bind = []) } while ($retry); } + + /** + * Special handling for PDO query(). + * All bind parameter names must begin with ':'. + * + * @param string|\Zend_Db_Select $sql The SQL statement with placeholders. + * @param mixed $bind An array of data or data itself to bind to the placeholders. + * @return \Zend_Db_Statement_Pdo|void + * @throws \Zend_Db_Adapter_Exception To re-throw \PDOException. + * @throws LocalizedException In case multiple queries are attempted at once, to protect from SQL injection + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + public function query($sql, $bind = []) + { + if (strpos(rtrim($sql, " \t\n\r\0;"), ';') !== false && count($this->_splitMultiQuery($sql)) > 1) { + throw new \Magento\Framework\Exception\LocalizedException(new Phrase('Cannot execute multiple queries')); + } + return $this->_query($sql, $bind); + } + + /** + * Allows multiple queries -- to safeguard against SQL injection, USE CAUTION and verify that input + * cannot be tampered with. + * + * Special handling for PDO query(). + * All bind parameter names must begin with ':'. + * + * @param string|\Zend_Db_Select $sql The SQL statement with placeholders. + * @param mixed $bind An array of data or data itself to bind to the placeholders. + * @return \Zend_Db_Statement_Pdo|void + * @throws \Zend_Db_Adapter_Exception To re-throw \PDOException. + * @throws LocalizedException In case multiple queries are attempted at once, to protect from SQL injection + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + public function multiQuery($sql, $bind = []) + { + return $this->_query($sql, $bind); + } + /** * Prepares SQL query by moving to bind all special parameters that can be confused with bind placeholders * (e.g. "foo:bar"). And also changes named bind to positional one, because underlying library has problems @@ -616,47 +658,6 @@ public function setQueryHook($hook) return $prev; } - /** - * Executes a SQL statement(s) - * - * @param string $sql - * @throws \Zend_Db_Exception - * @return array - */ - public function multiQuery($sql) - { - return $this->multiMagentoQuery($sql); - } - - /** - * Run Multi Query - * - * @param string $sql - * @return array - * @throws \Exception - */ - public function multiMagentoQuery($sql) - { - ##$result = $this->rawQuery($sql); - - #$this->beginTransaction(); - try { - $stmts = $this->_splitMultiQuery($sql); - $result = []; - foreach ($stmts as $stmt) { - $result[] = $this->rawQuery($stmt); - } - #$this->commit(); - } catch (\Exception $e) { - #$this->rollback(); - throw $e; - } - - $this->resetDdlCache(); - - return $result; - } - /** * Split multi statement query * @@ -3736,7 +3737,7 @@ public function createTrigger(\Magento\Framework\DB\Ddl\Trigger $trigger) $statements ); - return $this->query($sql); + return $this->multiQuery($sql); } /** diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php index 9297ffad51e38..b7c080064bc96 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php @@ -177,6 +177,18 @@ public function testCheckDdlTransaction($ddlQuery) $this->_mockAdapter->query($ddlQuery); } + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Cannot execute multiple queries + */ + public function testMultipleQueryException() + { + $sql = "SELECT COUNT(*) AS _num FROM test; "; + $sql.= "INSERT INTO test(id) VALUES (1); "; + $sql.= "SELECT COUNT(*) AS _num FROM test; "; + $this->_mockAdapter->query($sql); + } + /** * Data Provider for testCheckDdlTransaction */ diff --git a/lib/internal/Magento/Framework/DomDocument/DomDocumentFactory.php b/lib/internal/Magento/Framework/DomDocument/DomDocumentFactory.php new file mode 100644 index 0000000000000..8ad10682c5e96 --- /dev/null +++ b/lib/internal/Magento/Framework/DomDocument/DomDocumentFactory.php @@ -0,0 +1,22 @@ +_objectManager = $objectManager; - } - - /** - * Create empty DOM document instance. - * - * @return \DOMDocument - */ - public function createDomDocument() - { - return $this->_objectManager->create('DOMDocument', []); - } -} diff --git a/lib/internal/Magento/Framework/Filesystem/Driver/File.php b/lib/internal/Magento/Framework/Filesystem/Driver/File.php index 67320447f5470..167027a7d8589 100644 --- a/lib/internal/Magento/Framework/Filesystem/Driver/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Driver/File.php @@ -7,8 +7,8 @@ */ namespace Magento\Framework\Filesystem\Driver; -use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Filesystem\DriverInterface; class File implements DriverInterface { @@ -299,7 +299,7 @@ public function copy($source, $destination, DriverInterface $targetDriver = null [ $source, $destination, - $this->getWarningMessage() + $this->getWarningMessage(), ] ) ); @@ -329,7 +329,7 @@ public function symlink($source, $destination, DriverInterface $targetDriver = n [ $source, $destination, - $this->getWarningMessage() + $this->getWarningMessage(), ] ) ); @@ -644,6 +644,16 @@ public function fileWrite($resource, $data) */ public function filePutCsv($resource, array $data, $delimiter = ',', $enclosure = '"') { + /** + * Security enhancement for CSV data processing by Excel-like applications. + * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1054702 + */ + foreach ($data as $key => $value) { + if (isset($value[0]) && $value[0] === '=') { + $data[$key] = ' ' . $value; + } + } + $result = @fputcsv($resource, $data, $delimiter, $enclosure); if (!$result) { throw new FileSystemException( diff --git a/lib/internal/Magento/Framework/Filesystem/Io/File.php b/lib/internal/Magento/Framework/Filesystem/Io/File.php index 09e4b21ed521a..352cdb3b5643f 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/File.php @@ -177,6 +177,15 @@ public function streamWriteCsv(array $row, $delimiter = ',', $enclosure = '"') if (!$this->_streamHandler) { return false; } + /** + * Security enhancement for CSV data processing by Excel-like applications. + * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1054702 + */ + foreach ($row as $key => $value) { + if (isset($value[0]) && $value[0] === '=') { + $row[$key] = ' ' . $value; + } + } return @fputcsv($this->_streamHandler, $row, $delimiter, $enclosure); } diff --git a/lib/internal/Magento/Framework/HTTP/ClientInterface.php b/lib/internal/Magento/Framework/HTTP/ClientInterface.php index c47fba7125401..17cd1c3bef2ab 100644 --- a/lib/internal/Magento/Framework/HTTP/ClientInterface.php +++ b/lib/internal/Magento/Framework/HTTP/ClientInterface.php @@ -4,71 +4,78 @@ * See COPYING.txt for license details. */ +namespace Magento\Framework\HTTP; + /** - * Interface for different HTTP clients + * Interface for HTTP clients * - * @author Magento Core Team + * @api */ -namespace Magento\Framework\HTTP; - interface ClientInterface { /** * Set request timeout - * @param int $value + * + * @param int $value value in seconds * @return void */ public function setTimeout($value); /** * Set request headers from hash - * @param array $headers + * + * @param array $headers an array of header names as keys and header values as values * @return void */ public function setHeaders($headers); /** * Add header to request - * @param string $name - * @param string $value + * + * @param string $name name of the HTTP header + * @param string $value value of the HTTP header * @return void */ public function addHeader($name, $value); /** * Remove header from request - * @param string $name + * + * @param string $name name of the HTTP header * @return void */ public function removeHeader($name); /** - * Set login credentials - * for basic auth. - * @param string $login - * @param string $pass + * Set login credentials for basic authentication. + * + * @param string $login user identity/name + * @param string $pass user password * @return void */ public function setCredentials($login, $pass); /** * Add cookie to request - * @param string $name - * @param string $value + * + * @param string $name name of the cookie + * @param string $value value of the cookie * @return void */ public function addCookie($name, $value); /** * Remove cookie from request - * @param string $name + * + * @param string $name name of the cookie * @return void */ public function removeCookie($name); /** * Set request cookies from hash - * @param array $cookies + * + * @param array $cookies an array of cookies with cookie names as keys and cookie values as value * @return void */ public function setCookies($cookies); @@ -82,13 +89,15 @@ public function removeCookies(); /** * Make GET request - * @param string full uri + * + * @param string $uri full uri * @return array */ public function get($uri); /** * Make POST request + * * @param string $uri full uri * @param array $params POST fields array * @return void @@ -97,30 +106,35 @@ public function post($uri, $params); /** * Get response headers + * * @return array */ public function getHeaders(); /** * Get response body + * * @return string */ public function getBody(); /** * Get response status code + * * @return int */ public function getStatus(); /** * Get response cookies (k=>v) + * * @return array */ public function getCookies(); /** * Set additional option + * * @param string $key * @param string $value * @return void @@ -129,6 +143,7 @@ public function setOption($key, $value); /** * Set additional options + * * @param array $arr * @return void */ diff --git a/lib/internal/Magento/Framework/Interception/Interceptor.php b/lib/internal/Magento/Framework/Interception/Interceptor.php index 3f0eb54fccd4f..f7718efc13ce8 100644 --- a/lib/internal/Magento/Framework/Interception/Interceptor.php +++ b/lib/internal/Magento/Framework/Interception/Interceptor.php @@ -60,6 +60,9 @@ public function __sleep() public function __wakeup() { + if (method_exists(get_parent_class($this), '__wakeup')) { + parent::__wakeup(); + } $this->___init(); } diff --git a/lib/internal/Magento/Framework/Json/DecoderInterface.php b/lib/internal/Magento/Framework/Json/DecoderInterface.php index 9c80d21030313..444008b5d5f2a 100644 --- a/lib/internal/Magento/Framework/Json/DecoderInterface.php +++ b/lib/internal/Magento/Framework/Json/DecoderInterface.php @@ -6,13 +6,14 @@ namespace Magento\Framework\Json; /** - * Json decoder + * JSON decoder * + * @api */ interface DecoderInterface { /** - * Decodes the given $data string which is encoded in the JSON format. + * Decodes the given $data string which is encoded in the JSON format into a PHP type (array, string literal, etc.) * * @param string $data * @return mixed diff --git a/lib/internal/Magento/Framework/Json/EncoderInterface.php b/lib/internal/Magento/Framework/Json/EncoderInterface.php index 79283d119f408..a2b72a22ff2f8 100644 --- a/lib/internal/Magento/Framework/Json/EncoderInterface.php +++ b/lib/internal/Magento/Framework/Json/EncoderInterface.php @@ -6,8 +6,9 @@ namespace Magento\Framework\Json; /** - * Json encoder + * JSON encoder * + * @api */ interface EncoderInterface { diff --git a/lib/internal/Magento/Framework/Locale/Bundle/DataBundle.php b/lib/internal/Magento/Framework/Locale/Bundle/DataBundle.php index 35d70f78512ad..d5ddb742c70bd 100644 --- a/lib/internal/Magento/Framework/Locale/Bundle/DataBundle.php +++ b/lib/internal/Magento/Framework/Locale/Bundle/DataBundle.php @@ -28,10 +28,16 @@ public function get($locale) $locale = $this->cleanLocale($locale); $class = get_class($this); if (!isset(static::$bundles[$class][$locale])) { - $bundle = new \ResourceBundle($locale, $this->path); - if (!$bundle && $this->path != 'ICUDATA') { - $bundle = new \ResourceBundle($locale, 'ICUDATA'); + try { + $bundle = new \ResourceBundle($locale, $this->path); + if (!$bundle && $this->path != 'ICUDATA') { + $bundle = new \ResourceBundle($locale, 'ICUDATA'); + } + } catch (\Exception $e) { + // HHVM compatibility: constructor throws on invalid resource + $bundle = null; } + static::$bundles[$class][$locale] = $bundle; } return static::$bundles[$class][$locale]; diff --git a/lib/internal/Magento/Framework/Locale/Format.php b/lib/internal/Magento/Framework/Locale/Format.php index 7cec1393dbba4..66a47518a2080 100644 --- a/lib/internal/Magento/Framework/Locale/Format.php +++ b/lib/internal/Magento/Framework/Locale/Format.php @@ -19,16 +19,24 @@ class Format implements \Magento\Framework\Locale\FormatInterface */ protected $_localeResolver; + /** + * @var \Magento\Directory\Model\CurrencyFactory + */ + protected $currencyFactory; + /** * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param ResolverInterface $localeResolver + * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory */ public function __construct( \Magento\Framework\App\ScopeResolverInterface $scopeResolver, - \Magento\Framework\Locale\ResolverInterface $localeResolver + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Directory\Model\CurrencyFactory $currencyFactory ) { $this->_scopeResolver = $scopeResolver; $this->_localeResolver = $localeResolver; + $this->currencyFactory = $currencyFactory; } /** @@ -81,12 +89,21 @@ public function getNumber($value) /** * Functions returns array with price formatting info * + * @param string $localeCode Locale code. + * @param string $currencyCode Currency code. * @return array * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function getPriceFormat() + public function getPriceFormat($localeCode = null, $currencyCode = null) { - $localeData = (new DataBundle())->get($this->_localeResolver->getLocale()); + $localeCode = $localeCode ?: $this->_localeResolver->getLocale(); + if ($currencyCode) { + $currency = $this->currencyFactory->create()->load($currencyCode); + } else { + $currency = $this->_scopeResolver->getScope()->getCurrentCurrency(); + } + $localeData = (new DataBundle())->get($localeCode); $format = $localeData['NumberElements']['latn']['patterns']['currencyFormat'] ?: explode(';', $localeData['NumberPatterns'][1])[0]; $decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal'] @@ -122,7 +139,7 @@ public function getPriceFormat() $result = [ //TODO: change interface - 'pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), + 'pattern' => $currency->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $decimalSymbol, diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/ListsTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php similarity index 96% rename from lib/internal/Magento/Framework/Locale/Test/Unit/ListsTest.php rename to lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php index 5d36dd09ef17f..b2ccd64f10dac 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/ListsTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php @@ -6,10 +6,10 @@ namespace Magento\Framework\Locale\Test\Unit; -class ListsTest extends \PHPUnit_Framework_TestCase +class TranslatedListsTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Locale\Lists + * @var \Magento\Framework\Locale\TranslatedLists */ protected $listsModel; @@ -35,7 +35,7 @@ protected function setUp() ->method('getLocale') ->will($this->returnValue('en_US')); - $this->listsModel = new \Magento\Framework\Locale\Lists( + $this->listsModel = new \Magento\Framework\Locale\TranslatedLists( $this->mockConfig, $this->mockLocaleResolver ); diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/ValidatorTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/ValidatorTest.php deleted file mode 100644 index b786006cd46c7..0000000000000 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/ValidatorTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getMock('Magento\Framework\Locale\ConfigInterface'); - $localeConfigMock->expects( - $this->any() - )->method( - 'getAllowedLocales' - )->will( - $this->returnValue(['en_US', 'de_DE', 'es_ES']) - ); - - $this->_validatorModel = new \Magento\Framework\Locale\Validator($localeConfigMock); - } - - /** - * @return array - */ - public function testIsValidDataProvider() - { - return [ - 'case1' => ['locale' => 'en_US', 'valid' => true], - 'case2' => ['locale' => 'pp_PP', 'valid' => false] - ]; - } - - /** - * @dataProvider testIsValidDataProvider - * @param string $locale - * @param boolean $valid - * @covers \Magento\Framework\Locale\Validator::isValid - */ - public function testIsValid($locale, $valid) - { - $this->assertEquals($valid, $this->_validatorModel->isValid($locale)); - } -} diff --git a/lib/internal/Magento/Framework/Locale/Lists.php b/lib/internal/Magento/Framework/Locale/TranslatedLists.php similarity index 92% rename from lib/internal/Magento/Framework/Locale/Lists.php rename to lib/internal/Magento/Framework/Locale/TranslatedLists.php index 1eccb05ea03ef..f67c73cd0dd95 100644 --- a/lib/internal/Magento/Framework/Locale/Lists.php +++ b/lib/internal/Magento/Framework/Locale/TranslatedLists.php @@ -13,7 +13,7 @@ use Magento\Framework\Locale\Bundle\LanguageBundle; use Magento\Framework\Locale\Bundle\RegionBundle; -class Lists implements ListsInterface +class TranslatedLists implements ListsInterface { /** * @var \Magento\Framework\Locale\ConfigInterface @@ -67,7 +67,7 @@ public function getTranslatedOptionLocales() protected function _getOptionLocales($translatedName = false) { $currentLocale = $this->localeResolver->getLocale(); - $locales = \ResourceBundle::getLocales(null); + $locales = \ResourceBundle::getLocales('') ?: []; $languages = (new LanguageBundle())->get($currentLocale)['Languages']; $countries = (new RegionBundle())->get($currentLocale)['Countries']; @@ -103,7 +103,7 @@ public function getOptionTimezones() { $options = []; $locale = $this->localeResolver->getLocale(); - $zones = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL); + $zones = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL) ?: []; foreach ($zones as $code) { $options[] = [ 'label' => \IntlTimeZone::createTimeZone($code)->getDisplayName( @@ -111,9 +111,9 @@ public function getOptionTimezones() \IntlTimeZone::DISPLAY_LONG, $locale ) . ' (' . $code . ')', - 'value' => $code + 'value' => $code, ]; - } + } return $this->_sortOptionArray($options); } @@ -123,9 +123,8 @@ public function getOptionTimezones() public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false) { $options = []; - $days = (new DataBundle())->get( - $this->localeResolver->getLocale() - )['calendar']['gregorian']['dayNames']['format']['wide']; + $days = (new DataBundle()) + ->get($this->localeResolver->getLocale())['calendar']['gregorian']['dayNames']['format']['wide'] ?: []; $englishDays = (new DataBundle())->get('en_US')['calendar']['gregorian']['dayNames']['format']['abbreviated']; foreach ($days as $code => $name) { $code = $preserveCodes ? $englishDays[$code] : $code; @@ -140,7 +139,7 @@ public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false) public function getOptionCountries() { $options = []; - $countries = (new RegionBundle())->get($this->localeResolver->getLocale())['Countries']; + $countries = (new RegionBundle())->get($this->localeResolver->getLocale())['Countries'] ?: []; foreach ($countries as $code => $name) { $options[] = ['label' => $name, 'value' => $code]; } @@ -152,7 +151,7 @@ public function getOptionCountries() */ public function getOptionCurrencies() { - $currencies = (new CurrencyBundle())->get($this->localeResolver->getLocale())['Currencies']; + $currencies = (new CurrencyBundle())->get($this->localeResolver->getLocale())['Currencies'] ?: []; $options = []; $allowed = $this->_config->getAllowedCurrencies(); foreach ($currencies as $code => $data) { @@ -169,7 +168,7 @@ public function getOptionCurrencies() */ public function getOptionAllCurrencies() { - $currencies = (new CurrencyBundle())->get($this->localeResolver->getLocale())['Currencies']; + $currencies = (new CurrencyBundle())->get($this->localeResolver->getLocale())['Currencies'] ?: []; $options = []; foreach ($currencies as $code => $data) { $options[] = ['label' => $data[1], 'value' => $code]; diff --git a/lib/internal/Magento/Framework/Mail/MessageInterface.php b/lib/internal/Magento/Framework/Mail/MessageInterface.php index ddc4368c9ceb2..5e23aa980d448 100644 --- a/lib/internal/Magento/Framework/Mail/MessageInterface.php +++ b/lib/internal/Magento/Framework/Mail/MessageInterface.php @@ -1,12 +1,15 @@ configData && ($this->config->isAvailable())) { - $this->configData = $this->config->getConfigData(ConfigOptionsList::KEY_MODULES); + $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); } } } diff --git a/lib/internal/Magento/Framework/Module/Setup.php b/lib/internal/Magento/Framework/Module/Setup.php index 396c24baf5d02..6cd25275253c0 100644 --- a/lib/internal/Magento/Framework/Module/Setup.php +++ b/lib/internal/Magento/Framework/Module/Setup.php @@ -129,7 +129,7 @@ public function tableExists($table) */ public function run($sql) { - $this->getConnection()->multiQuery($sql); + $this->getConnection()->query($sql); return $this; } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php index 92870f4790c50..d4f1af7fa8a07 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php @@ -101,7 +101,7 @@ public function testIsModuleInfoAvailable() public function testIsModuleInfoAvailableNoConfig() { $this->config->expects($this->once())->method('isAvailable')->willReturn(true); - $this->config->expects($this->once())->method('getConfigData')->willReturn(null); + $this->config->expects($this->once())->method('get')->willReturn(null); $this->assertFalse($this->model->isModuleInfoAvailable()); } @@ -114,9 +114,9 @@ public function testIsModuleInfoAvailableNoConfig() private function setLoadConfigExpectation($isExpected = true) { if ($isExpected) { - $this->config->expects($this->once())->method('getConfigData')->willReturn(self::$enabledFixture); + $this->config->expects($this->once())->method('get')->willReturn(self::$enabledFixture); } else { - $this->config->expects($this->never())->method('getConfigData'); + $this->config->expects($this->never())->method('get'); } } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php index 913a1f7c77c8e..c2be490444b4f 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/SetupTest.php @@ -85,7 +85,7 @@ public function testRun() { $q = 'SELECT something'; $this->connection->expects($this->once()) - ->method('multiQuery') + ->method('query') ->with($q); $this->object->run($q); } diff --git a/lib/internal/Magento/Framework/Mview/ActionInterface.php b/lib/internal/Magento/Framework/Mview/ActionInterface.php index ed488cc76fc7d..77c320edcc65e 100644 --- a/lib/internal/Magento/Framework/Mview/ActionInterface.php +++ b/lib/internal/Magento/Framework/Mview/ActionInterface.php @@ -12,6 +12,7 @@ interface ActionInterface * * @param int[] $ids * @return void + * @api */ public function execute($ids); } diff --git a/lib/internal/Magento/Framework/Oauth/ConsumerInterface.php b/lib/internal/Magento/Framework/Oauth/ConsumerInterface.php index a6bab9c9dff4a..ce80249347677 100644 --- a/lib/internal/Magento/Framework/Oauth/ConsumerInterface.php +++ b/lib/internal/Magento/Framework/Oauth/ConsumerInterface.php @@ -6,17 +6,16 @@ namespace Magento\Framework\Oauth; /** - * Interface ConsumerInterface - * - * This interface exposes minimal consumer functionality needed by the Oauth library. + * Oauth consumer interface. * + * @api */ interface ConsumerInterface { /** * Validate consumer data (e.g. Key and Secret length). * - * @return bool - True if the consumer data is valid. + * @return bool True if the consumer data is valid. * @throws \Exception */ public function validate(); diff --git a/lib/internal/Magento/Framework/Oauth/NonceGeneratorInterface.php b/lib/internal/Magento/Framework/Oauth/NonceGeneratorInterface.php index d83c6e6e0e810..b014e6c02a40f 100644 --- a/lib/internal/Magento/Framework/Oauth/NonceGeneratorInterface.php +++ b/lib/internal/Magento/Framework/Oauth/NonceGeneratorInterface.php @@ -6,12 +6,11 @@ namespace Magento\Framework\Oauth; /** - * Interface NonceGeneratorInterface - * - * This interface provides methods for generating a nonce for a consumer and validating a nonce to ensure that it - * is not already used by an existing consumer. Validation will persist the nonce if validation succeeds. A method - * for generating a current timestamp is also provided by this interface. + * NonceGeneratorInterface provides methods for generating a nonce for a consumer and validating a nonce to ensure + * that it is not already used by an existing consumer. Validation will persist the nonce if validation succeeds. + * A method for generating a current timestamp is also provided by this interface. * + * @api */ interface NonceGeneratorInterface { @@ -19,14 +18,14 @@ interface NonceGeneratorInterface * Generate a new nonce for the consumer (if consumer is specified). * * @param ConsumerInterface $consumer - * @return string - The generated nonce value. + * @return string The generated nonce value. */ public function generateNonce(ConsumerInterface $consumer = null); /** * Generate a current timestamp. * - * @return int + * @return int The time as an int */ public function generateTimestamp(); @@ -36,10 +35,10 @@ public function generateTimestamp(); * by the specified consumer. * * @param ConsumerInterface $consumer - * @param string $nonce - The nonce value. - * @param int $timestamp - The 'oauth_timestamp' value. + * @param string $nonce The nonce value. + * @param int $timestamp The 'oauth_timestamp' value. * @return void - * @throws \Magento\Framework\Oauth\Exception - Exceptions are thrown for validation errors. + * @throws \Magento\Framework\Oauth\Exception Exceptions are thrown for validation errors. */ public function validateNonce(ConsumerInterface $consumer, $nonce, $timestamp); } diff --git a/lib/internal/Magento/Framework/Oauth/OauthInterface.php b/lib/internal/Magento/Framework/Oauth/OauthInterface.php index 771ed1751b128..64831aa805d85 100644 --- a/lib/internal/Magento/Framework/Oauth/OauthInterface.php +++ b/lib/internal/Magento/Framework/Oauth/OauthInterface.php @@ -6,12 +6,11 @@ namespace Magento\Framework\Oauth; /** - * Interface OauthInterface - * - * This interface provides methods consistent with implementing a 2-legged OAuth authentication mechanism. Methods + * OauthInterface provides methods consistent with implementing a 2-legged OAuth authentication mechanism. Methods * include creating a request token, getting an access token, and performing certain validations on tokens and * token requests. A method is also included for generating an OAuth header that can be used in an HTTP request. * + * @api */ interface OauthInterface { diff --git a/lib/internal/Magento/Framework/Oauth/TokenProviderInterface.php b/lib/internal/Magento/Framework/Oauth/TokenProviderInterface.php index 9b2c69a35d382..fae40664c5773 100644 --- a/lib/internal/Magento/Framework/Oauth/TokenProviderInterface.php +++ b/lib/internal/Magento/Framework/Oauth/TokenProviderInterface.php @@ -6,21 +6,20 @@ namespace Magento\Framework\Oauth; /** - * Interface TokenProviderInterface - * - * This interface provides token manipulation, such as creating a request token and getting an access token as well - * as methods for performing certain validations on tokens and token requests. Consumer methods are also provided to - * help clients manipulating tokens validate and acquire the associated token consumer. + * TokenProviderInterface provides token manipulation, such as creating a request token and getting an access token + * as well as methods for performing certain validations on tokens and token requests. Consumer methods are also + * provided to help clients manipulating tokens validate and acquire the associated token consumer. * + * @api */ interface TokenProviderInterface { /** * Validate the consumer. * - * @param ConsumerInterface $consumer - The consumer. - * @return bool - True if the consumer is valid. - * @throws \Magento\Framework\Oauth\Exception - Validation errors. + * @param ConsumerInterface $consumer The consumer. + * @return bool True if the consumer is valid. + * @throws \Magento\Framework\Oauth\Exception Validation errors. */ public function validateConsumer($consumer); @@ -35,19 +34,19 @@ public function validateConsumer($consumer); * * * @param ConsumerInterface $consumer - * @return array - The request token and secret. - * @throws \Magento\Framework\Oauth\Exception - Validation errors. + * @return array The request token and secret. + * @throws \Magento\Framework\Oauth\Exception Validation errors. */ public function createRequestToken($consumer); /** * Validates the request token and verifier. Verifies the request token is associated with the consumer. * - * @param string $requestToken - The 'oauth_token' request token value. - * @param ConsumerInterface $consumer - The consumer given the 'oauth_consumer_key'. - * @param string $oauthVerifier - The 'oauth_verifier' value. - * @return string - The request token secret (i.e. 'oauth_token_secret'). - * @throws \Magento\Framework\Oauth\Exception - Validation errors. + * @param string $requestToken The 'oauth_token' request token value. + * @param ConsumerInterface $consumer The consumer given the 'oauth_consumer_key'. + * @param string $oauthVerifier The 'oauth_verifier' value. + * @return string The request token secret (i.e. 'oauth_token_secret'). + * @throws \Magento\Framework\Oauth\Exception Validation errors. */ public function validateRequestToken($requestToken, $consumer, $oauthVerifier); @@ -61,43 +60,43 @@ public function validateRequestToken($requestToken, $consumer, $oauthVerifier); * ) * * - * @param ConsumerInterface $consumer - The consumer given the 'oauth_consumer_key'. - * @return array - The access token and secret. - * @throws \Magento\Framework\Oauth\Exception - Validation errors. + * @param ConsumerInterface $consumer The consumer given the 'oauth_consumer_key'. + * @return array The access token and secret. + * @throws \Magento\Framework\Oauth\Exception Validation errors. */ public function getAccessToken($consumer); /** * Validates the Oauth token type and verifies that it's associated with the consumer. * - * @param string $accessToken - The 'oauth_token' access token value. - * @param ConsumerInterface $consumer - The consumer given the 'oauth_consumer_key'. - * @return string - The access token secret. - * @throws \Magento\Framework\Oauth\Exception - Validation errors. + * @param string $accessToken The 'oauth_token' access token value. + * @param ConsumerInterface $consumer The consumer given the 'oauth_consumer_key'. + * @return string The access token secret. + * @throws \Magento\Framework\Oauth\Exception Validation errors. */ public function validateAccessTokenRequest($accessToken, $consumer); /** * Validate an access token string. * - * @param string $accessToken - The 'oauth_token' access token string. - * @return int - Consumer ID if the access token is valid. - * @throws \Magento\Framework\Oauth\Exception - Validation errors. + * @param string $accessToken The 'oauth_token' access token string. + * @return int Consumer ID if the access token is valid. + * @throws \Magento\Framework\Oauth\Exception Validation errors. */ public function validateAccessToken($accessToken); /** * Perform basic validation of an Oauth token, of any type (e.g. request, access, etc.). * - * @param string $oauthToken - The token string. - * @return bool - True if the Oauth token passes basic validation. + * @param string $oauthToken The token string. + * @return bool True if the Oauth token passes basic validation. */ public function validateOauthToken($oauthToken); /** * Retrieve a consumer given the consumer's key. * - * @param string $consumerKey - The 'oauth_consumer_key' value. + * @param string $consumerKey The 'oauth_consumer_key' value. * @return ConsumerInterface * @throws \Magento\Framework\Oauth\Exception */ diff --git a/lib/internal/Magento/Framework/Object/IdentityInterface.php b/lib/internal/Magento/Framework/Object/IdentityInterface.php index 938978cc9135c..2a3714d574fb1 100644 --- a/lib/internal/Magento/Framework/Object/IdentityInterface.php +++ b/lib/internal/Magento/Framework/Object/IdentityInterface.php @@ -6,7 +6,9 @@ namespace Magento\Framework\Object; /** - * Interface IdentityInterface + * Interface for + * 1. models which require cache refresh when it is created/updated/deleted + * 2. blocks which render this information to front-end */ interface IdentityInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php b/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php index 4b2a750e81c75..b988ac0019d00 100644 --- a/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Adjustment/AdjustmentInterface.php @@ -10,6 +10,8 @@ /** * Interface AdjustmentInterface + * + * @api */ interface AdjustmentInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php b/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php index bbba05cf461bd..d9f95da235f07 100644 --- a/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Adjustment/CalculatorInterface.php @@ -10,6 +10,8 @@ /** * Calculator interface + * + * @api */ interface CalculatorInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Amount/AmountInterface.php b/lib/internal/Magento/Framework/Pricing/Amount/AmountInterface.php index 9ba0484af2ca6..b8f64677d4983 100644 --- a/lib/internal/Magento/Framework/Pricing/Amount/AmountInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Amount/AmountInterface.php @@ -8,6 +8,8 @@ /** * Amount interface, the amount values are in display currency + * + * @api */ interface AmountInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Object/SaleableInterface.php b/lib/internal/Magento/Framework/Pricing/Object/SaleableInterface.php index 253c2ce99cc96..214ac4140f18e 100644 --- a/lib/internal/Magento/Framework/Pricing/Object/SaleableInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Object/SaleableInterface.php @@ -8,6 +8,8 @@ /** * Interface SaleableInterface + * + * @api */ interface SaleableInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Price/BasePriceProviderInterface.php b/lib/internal/Magento/Framework/Pricing/Price/BasePriceProviderInterface.php index 1ed9fb2266149..d2627b74408ac 100644 --- a/lib/internal/Magento/Framework/Pricing/Price/BasePriceProviderInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Price/BasePriceProviderInterface.php @@ -8,6 +8,8 @@ /** * Interface BasePriceProviderInterface + * + * @api */ interface BasePriceProviderInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php b/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php index 24a1f97d9e225..d14ee84eee167 100644 --- a/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Price/PriceInterface.php @@ -10,6 +10,8 @@ /** * Catalog price interface + * + * @api */ interface PriceInterface { diff --git a/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php b/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php index 980a8ff079c9b..6566654752413 100644 --- a/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php +++ b/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php @@ -8,6 +8,8 @@ /** * Interface PriceCurrencyInterface + * + * @api */ interface PriceCurrencyInterface { diff --git a/lib/internal/Magento/Framework/Pricing/PriceInfoInterface.php b/lib/internal/Magento/Framework/Pricing/PriceInfoInterface.php index 8dc113a490fe7..8e24243453dd7 100644 --- a/lib/internal/Magento/Framework/Pricing/PriceInfoInterface.php +++ b/lib/internal/Magento/Framework/Pricing/PriceInfoInterface.php @@ -11,6 +11,8 @@ /** * Price info model interface + * + * @api */ interface PriceInfoInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Render/AdjustmentRenderInterface.php b/lib/internal/Magento/Framework/Pricing/Render/AdjustmentRenderInterface.php index d87b00d465fb8..6efeb6b64f9c8 100644 --- a/lib/internal/Magento/Framework/Pricing/Render/AdjustmentRenderInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Render/AdjustmentRenderInterface.php @@ -11,6 +11,8 @@ /** * Adjustment render interface + * + * @api */ interface AdjustmentRenderInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Render/AmountRenderInterface.php b/lib/internal/Magento/Framework/Pricing/Render/AmountRenderInterface.php index 3779c69dd31ca..0df0962300bbc 100644 --- a/lib/internal/Magento/Framework/Pricing/Render/AmountRenderInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Render/AmountRenderInterface.php @@ -12,6 +12,8 @@ /** * Price amount renderer interface + * + * @api */ interface AmountRenderInterface { diff --git a/lib/internal/Magento/Framework/Pricing/Render/PriceBoxRenderInterface.php b/lib/internal/Magento/Framework/Pricing/Render/PriceBoxRenderInterface.php index 044144d4b0622..f97286f2a1590 100644 --- a/lib/internal/Magento/Framework/Pricing/Render/PriceBoxRenderInterface.php +++ b/lib/internal/Magento/Framework/Pricing/Render/PriceBoxRenderInterface.php @@ -12,6 +12,8 @@ /** * Price box render interface + * + * @api */ interface PriceBoxRenderInterface { diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php index b2e1940f123b1..4f6b76f302e93 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php @@ -203,4 +203,14 @@ public function testFindSetterMethodNameInvalidAttribute() $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); $this->_typeProcessor->findSetterMethodName($class, 'InvalidAttribute'); } + + /** + * @expectedException \Exception + * @expectedExceptionMessageRegExp /Property :"InvalidAttribute" does not exist in the provided class: \w+/ + */ + public function testFindSetterMethodNameWrongCamelCasedAttribute() + { + $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $this->_typeProcessor->findSetterMethodName($class, 'ActivE'); + } } diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php index 580be037ad206..2653248cec8dd 100644 --- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php @@ -501,20 +501,7 @@ public function findGetterMethodName(ClassReflection $class, $camelCaseProperty) { $getterName = 'get' . $camelCaseProperty; $boolGetterName = 'is' . $camelCaseProperty; - if ($class->hasMethod($getterName)) { - $methodName = $getterName; - } elseif ($class->hasMethod($boolGetterName)) { - $methodName = $boolGetterName; - } else { - throw new \Exception( - sprintf( - 'Property :"%s" does not exist in the provided class: "%s".', - $camelCaseProperty, - $class->getName() - ) - ); - } - return $methodName; + return $this->findAccessorMethodName($class, $camelCaseProperty, $getterName, $boolGetterName); } /** @@ -547,10 +534,31 @@ public function findSetterMethodName(ClassReflection $class, $camelCaseProperty) { $setterName = 'set' . $camelCaseProperty; $boolSetterName = 'setIs' . $camelCaseProperty; - if ($class->hasMethod($setterName)) { - $methodName = $setterName; - } elseif ($class->hasMethod($boolSetterName)) { - $methodName = $boolSetterName; + return $this->findAccessorMethodName($class, $camelCaseProperty, $setterName, $boolSetterName); + } + + /** + * Find the accessor method name for a property from the given class + * + * @param ClassReflection $class + * @param string $camelCaseProperty + * @param string $accessorName + * @param bool $boolAccessorName + * @return string processed method name + * @throws \Exception If $camelCaseProperty has no corresponding setter method + */ + protected function findAccessorMethodName( + ClassReflection $class, + $camelCaseProperty, + $accessorName, + $boolAccessorName + ) { + if ($this->classHasMethod($class, $accessorName)) { + $methodName = $accessorName; + return $methodName; + } elseif ($this->classHasMethod($class, $boolAccessorName)) { + $methodName = $boolAccessorName; + return $methodName; } else { throw new \Exception( sprintf( @@ -560,6 +568,19 @@ public function findSetterMethodName(ClassReflection $class, $camelCaseProperty) ) ); } - return $methodName; + } + + /** + * Checks if method is defined + * + * Case sensitivity of the method is taken into account. + * + * @param ClassReflection $class + * @param string $methodName + * @return bool + */ + protected function classHasMethod(ClassReflection $class, $methodName) + { + return $class->hasMethod($methodName) && ($class->getMethod($methodName)->getName() == $methodName); } } diff --git a/lib/internal/Magento/Framework/Setup/ConfigOptionsListInterface.php b/lib/internal/Magento/Framework/Setup/ConfigOptionsListInterface.php index 1a693cc22931c..40251a31bb616 100644 --- a/lib/internal/Magento/Framework/Setup/ConfigOptionsListInterface.php +++ b/lib/internal/Magento/Framework/Setup/ConfigOptionsListInterface.php @@ -34,7 +34,8 @@ public function createConfig(array $options, DeploymentConfig $deploymentConfig) * Validates user input option values and returns error messages * * @param array $options + * @param DeploymentConfig $deploymentConfig * @return string[] */ - public function validate(array $options); + public function validate(array $options, DeploymentConfig $deploymentConfig); } diff --git a/setup/src/Magento/Setup/Model/Lists.php b/lib/internal/Magento/Framework/Setup/Lists.php similarity index 91% rename from setup/src/Magento/Setup/Model/Lists.php rename to lib/internal/Magento/Framework/Setup/Lists.php index e52e921594cae..9e3941c15b5bf 100644 --- a/setup/src/Magento/Setup/Model/Lists.php +++ b/lib/internal/Magento/Framework/Setup/Lists.php @@ -4,14 +4,13 @@ * See COPYING.txt for license details. */ -namespace Magento\Setup\Model; +namespace Magento\Framework\Setup; use Magento\Framework\Locale\Bundle\CurrencyBundle; use Magento\Framework\Locale\Bundle\LanguageBundle; use Magento\Framework\Locale\Bundle\RegionBundle; use Magento\Framework\Locale\ConfigInterface; use Magento\Framework\Locale\Resolver; -use Magento\Framework\Locale\ResolverInterface; class Lists { @@ -33,9 +32,10 @@ public function __construct(ConfigInterface $localeConfig) /** * Retrieve list of timezones * + * @param bool $doSort * @return array */ - public function getTimezoneList() + public function getTimezoneList($doSort = true) { $zones = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL); $list = []; @@ -46,7 +46,11 @@ public function getTimezoneList() Resolver::DEFAULT_LOCALE ) . ' (' . $code . ')'; } - asort($list); + + if ($doSort) { + asort($list); + } + return $list; } @@ -75,8 +79,7 @@ public function getLocaleList() { $languages = (new LanguageBundle())->get(Resolver::DEFAULT_LOCALE)['Languages']; $countries = (new RegionBundle())->get(Resolver::DEFAULT_LOCALE)['Countries']; - $locales = \ResourceBundle::getLocales(null); - + $locales = \ResourceBundle::getLocales('') ?: []; $list = []; foreach ($locales as $locale) { if (!in_array($locale, $this->allowedLocales)) { diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ListsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php similarity index 93% rename from setup/src/Magento/Setup/Test/Unit/Model/ListsTest.php rename to lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php index ab782aa71e2e2..12636a427d73c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ListsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php @@ -4,11 +4,9 @@ * See COPYING.txt for license details. */ -namespace Magento\Setup\Test\Unit\Model; +namespace Magento\Framework\Setup\Test\Unit; -use \Magento\Setup\Model\Lists; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\Setup\Lists; class ListsTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index 7dc6f2538b27f..0879ea7d32023 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -146,7 +146,7 @@ public function date($date = null, $locale = null, $useTimezone = true) $locale = $locale ?: $this->_localeResolver->getLocale(); $timezone = $useTimezone ? $this->_scopeConfig->getValue($this->getDefaultTimezonePath(), $this->_scopeType) - : 'UTC'; + : date_default_timezone_get(); if (empty($date)) { return new \DateTime('now', new \DateTimeZone($timezone)); diff --git a/lib/internal/Magento/Framework/System/Ftp.php b/lib/internal/Magento/Framework/System/Ftp.php index d02ceec99093e..b36bd07f8f5d2 100644 --- a/lib/internal/Magento/Framework/System/Ftp.php +++ b/lib/internal/Magento/Framework/System/Ftp.php @@ -4,11 +4,11 @@ * See COPYING.txt for license details. */ +namespace Magento\Framework\System; + /** * Class to work with remote FTP server */ -namespace Magento\Framework\System; - class Ftp { /** diff --git a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php index 69e2260002ce0..baa556bb19f78 100644 --- a/lib/internal/Magento/Framework/Test/Unit/UrlTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/UrlTest.php @@ -114,20 +114,16 @@ protected function getUrlModel($arguments = []) } /** - * @param $port mixed + * @param $httpHost string * @param $url string * @dataProvider getCurrentUrlProvider */ - public function testGetCurrentUrl($port, $url) + public function testGetCurrentUrl($httpHost, $url) { $requestMock = $this->getRequestMock(); - $requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT') - ->will($this->returnValue($port)); - $requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI') - ->will($this->returnValue('/fancy_uri')); + $requestMock->expects($this->once())->method('getServer')->with('REQUEST_URI')->willReturn('/fancy_uri'); $requestMock->expects($this->once())->method('getScheme')->will($this->returnValue('http')); - $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('example.com')); - + $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue($httpHost)); $model = $this->getUrlModel(['request' => $requestMock]); $this->assertEquals($url, $model->getCurrentUrl()); } @@ -135,9 +131,9 @@ public function testGetCurrentUrl($port, $url) public function getCurrentUrlProvider() { return [ - 'without_port' => ['', 'http://example.com/fancy_uri'], - 'default_port' => [80, 'http://example.com/fancy_uri'], - 'custom_port' => [8080, 'http://example.com:8080/fancy_uri'] + 'without_port' => ['example.com', 'http://example.com/fancy_uri'], + 'default_port' => ['example.com:80', 'http://example.com/fancy_uri'], + 'custom_port' => ['example.com:8080', 'http://example.com:8080/fancy_uri'] ]; } diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Autoloader/ExtensionGeneratorAutoloader.php b/lib/internal/Magento/Framework/TestFramework/Unit/Autoloader/ExtensionGeneratorAutoloader.php new file mode 100644 index 0000000000000..9f14464d01c87 --- /dev/null +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Autoloader/ExtensionGeneratorAutoloader.php @@ -0,0 +1,97 @@ +generatorIo = $generatorIo; + } + + /** + * Load an *Extension or *ExtensionInterface class. If it does not exist, create a stub file and load it. + * + * @param string $className + * @return void + */ + public function load($className) + { + if (!class_exists($className)) { + if (!$this->isExtension($className) && !$this->isExtensionInterface($className)) { + return false; + } + + $resultFileName = $this->generatorIo->getResultFileName($className); + + if (!$this->generatorIo->fileExists($resultFileName)) { + $this->generatorIo->makeResultFileDirectory($className); + + $classNameParts = explode('\\', $className); + + /* Split the type name and namespace for the file's contents. */ + $justTypeName = $classNameParts[count($classNameParts) - 1]; + + unset($classNameParts[count($classNameParts) - 1]); + $namespace = implode('\\', $classNameParts); + + if ($this->isExtension($className)) { + $content = "namespace $namespace;\n\nclass $justTypeName implements " + . "{$justTypeName}Interface\n{\n\n}"; + } else if ($this->isExtensionInterface($className)) { + $content = "namespace $namespace;\n\ninterface $justTypeName extends " + . "\\Magento\\Framework\\Api\\ExtensionAttributesInterface \n{\n\n}"; + } + + $this->generatorIo->writeResultFile($resultFileName, $content); + } + + include $resultFileName; + } + + return false; + } + + /** + * Determines if the passed in class name is an ExtensionInterface type. + * + * @param string $className + * @return bool + */ + private function isExtensionInterface($className) + { + $suffix = "ExtensionInterface"; + return substr($className, -strlen($suffix), strlen($suffix)) === $suffix; + } + + /** + * Determines if the passed in class name is an Extension type. + * + * @param string $className + * @return bool + */ + private function isExtension($className) + { + $suffix = "Extension"; + return substr($className, -strlen($suffix), strlen($suffix)) === $suffix; + } +} diff --git a/lib/internal/Magento/Framework/Translate/AdapterInterface.php b/lib/internal/Magento/Framework/Translate/AdapterInterface.php index 19a4bbdc7f908..c8948465a1774 100644 --- a/lib/internal/Magento/Framework/Translate/AdapterInterface.php +++ b/lib/internal/Magento/Framework/Translate/AdapterInterface.php @@ -6,11 +6,13 @@ // @codingStandardsIgnoreFile +namespace Magento\Framework\Translate; + /** * Magento translate adapter interface + * + * @api */ -namespace Magento\Framework\Translate; - interface AdapterInterface { /** diff --git a/lib/internal/Magento/Framework/Translate/Inline/ConfigInterface.php b/lib/internal/Magento/Framework/Translate/Inline/ConfigInterface.php index 12a3a0d9b44ad..b9540c27f51a2 100644 --- a/lib/internal/Magento/Framework/Translate/Inline/ConfigInterface.php +++ b/lib/internal/Magento/Framework/Translate/Inline/ConfigInterface.php @@ -1,12 +1,15 @@ _request->getServer('SERVER_PORT'); - if ($port) { + $httpHostWithPort = $this->_request->getHttpHost(false); + $httpHostWithPort = explode(':', $httpHostWithPort); + $httpHost = isset($httpHostWithPort[0]) ? $httpHostWithPort[0] : ''; + $port = ''; + if (isset($httpHostWithPort[1])) { $defaultPorts = [ \Magento\Framework\App\Request\Http::DEFAULT_HTTP_PORT, \Magento\Framework\App\Request\Http::DEFAULT_HTTPS_PORT, ]; - $port = in_array($port, $defaultPorts) ? '' : ':' . $port; + if (!in_array($httpHostWithPort[1], $defaultPorts)) { + /** Custom port */ + $port = ':' . $httpHostWithPort[1]; + } } - $requestUri = $this->_request->getServer('REQUEST_URI'); - $url = $this->_request->getScheme() . '://' . $this->_request->getHttpHost() . $port . $requestUri; - return $url; + return $this->_request->getScheme() . '://' . $httpHost . $port . $this->_request->getServer('REQUEST_URI'); } /** diff --git a/lib/internal/Magento/Framework/Url/DecoderInterface.php b/lib/internal/Magento/Framework/Url/DecoderInterface.php index 1ff0ea158a7ca..33fbc322fc7df 100644 --- a/lib/internal/Magento/Framework/Url/DecoderInterface.php +++ b/lib/internal/Magento/Framework/Url/DecoderInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Url; +/** + * Base64 decoder for URLs + * + * @api + */ interface DecoderInterface { /** diff --git a/lib/internal/Magento/Framework/Url/EncoderInterface.php b/lib/internal/Magento/Framework/Url/EncoderInterface.php index bae05119b776e..9091cdb9d49ff 100644 --- a/lib/internal/Magento/Framework/Url/EncoderInterface.php +++ b/lib/internal/Magento/Framework/Url/EncoderInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Url; +/** + * Base64 encoder for URLs + * + * @api + */ interface EncoderInterface { /** diff --git a/lib/internal/Magento/Framework/Url/QueryParamsResolverInterface.php b/lib/internal/Magento/Framework/Url/QueryParamsResolverInterface.php index 163ab2f8b00fe..c1cd7b513480a 100644 --- a/lib/internal/Magento/Framework/Url/QueryParamsResolverInterface.php +++ b/lib/internal/Magento/Framework/Url/QueryParamsResolverInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Url; +/** + * Resolves query parameters in a URL. + * + * @api + */ interface QueryParamsResolverInterface { /** diff --git a/lib/internal/Magento/Framework/Url/RouteParamsResolverInterface.php b/lib/internal/Magento/Framework/Url/RouteParamsResolverInterface.php index 234300ff8b21d..a3d0da5f23a9f 100644 --- a/lib/internal/Magento/Framework/Url/RouteParamsResolverInterface.php +++ b/lib/internal/Magento/Framework/Url/RouteParamsResolverInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Url; +/** + * Route parameters resolver. + * + * @api + */ interface RouteParamsResolverInterface { /** diff --git a/lib/internal/Magento/Framework/Url/ScopeInterface.php b/lib/internal/Magento/Framework/Url/ScopeInterface.php index 17913211a7d72..3a5c06e4e5d72 100644 --- a/lib/internal/Magento/Framework/Url/ScopeInterface.php +++ b/lib/internal/Magento/Framework/Url/ScopeInterface.php @@ -5,6 +5,12 @@ */ namespace Magento\Framework\Url; +/** + * This ScopeInterface adds URL methods to the scope interface to help + * determine scope based on URLs. + * + * @api + */ interface ScopeInterface extends \Magento\Framework\App\ScopeInterface { /** diff --git a/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php b/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php index a31ae25c76ea4..3c868a7d54dca 100644 --- a/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php +++ b/lib/internal/Magento/Framework/Url/ScopeResolverInterface.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\Url; +/** + * This ScopeResolverInterface adds the ability to get the Magento area the code is executing in. + * + * @api + */ interface ScopeResolverInterface extends \Magento\Framework\App\ScopeResolverInterface { /** diff --git a/lib/internal/Magento/Framework/Url/SecurityInfo.php b/lib/internal/Magento/Framework/Url/SecurityInfo.php index e868f45f5741d..c29d83c4c484c 100644 --- a/lib/internal/Magento/Framework/Url/SecurityInfo.php +++ b/lib/internal/Magento/Framework/Url/SecurityInfo.php @@ -16,6 +16,11 @@ class SecurityInfo implements \Magento\Framework\Url\SecurityInfoInterface */ protected $secureUrlsList = []; + /** + * List of patterns excluded form secure url list + */ + protected $excludedUrlsList = []; + /** * List of already checked urls * @@ -25,10 +30,12 @@ class SecurityInfo implements \Magento\Framework\Url\SecurityInfoInterface /** * @param string[] $secureUrlList + * @param string[] $excludedUrlList */ - public function __construct($secureUrlList = []) + public function __construct($secureUrlList = [], $excludedUrlList = []) { $this->secureUrlsList = $secureUrlList; + $this->excludedUrlsList = $excludedUrlList; } /** @@ -41,6 +48,11 @@ public function isSecure($url) { if (!isset($this->secureUrlsCache[$url])) { $this->secureUrlsCache[$url] = false; + foreach ($this->excludedUrlsList as $match) { + if (strpos($url, (string)$match) === 0) { + return $this->secureUrlsCache[$url]; + } + } foreach ($this->secureUrlsList as $match) { if (strpos($url, (string)$match) === 0) { $this->secureUrlsCache[$url] = true; diff --git a/lib/internal/Magento/Framework/Url/SecurityInfoInterface.php b/lib/internal/Magento/Framework/Url/SecurityInfoInterface.php index abc8132d70157..649c925b328fd 100644 --- a/lib/internal/Magento/Framework/Url/SecurityInfoInterface.php +++ b/lib/internal/Magento/Framework/Url/SecurityInfoInterface.php @@ -1,12 +1,15 @@ _model = new \Magento\Framework\Url\SecurityInfo(['/account', '/cart']); + $this->_model = new \Magento\Framework\Url\SecurityInfo(['/account', '/cart'], ['/cart/remove', 'customer']); } /** @@ -39,7 +39,9 @@ public function secureUrlDataProvider() ['/product', false], ['/product/12312', false], ['/cart', true], - ['/cart/add', true] + ['/cart/add', true], + ['/cart/remove', false], + ['/customer', false] ]; } } diff --git a/lib/internal/Magento/Framework/Validator/Currency.php b/lib/internal/Magento/Framework/Validator/Currency.php new file mode 100644 index 0000000000000..7f08b17170bdc --- /dev/null +++ b/lib/internal/Magento/Framework/Validator/Currency.php @@ -0,0 +1,48 @@ +lists = $lists; + } + + /** + * Validate currency code + * + * @param string $currencyCode + * @return bool + */ + public function isValid($currencyCode) + { + $isValid = true; + $allowedCurrencyCodes = array_keys($this->lists->getCurrencyList()); + + if (!$currencyCode || !in_array($currencyCode, $allowedCurrencyCodes)) { + $isValid = false; + } + + return $isValid; + } +} diff --git a/lib/internal/Magento/Framework/Locale/Validator.php b/lib/internal/Magento/Framework/Validator/Locale.php similarity index 55% rename from lib/internal/Magento/Framework/Locale/Validator.php rename to lib/internal/Magento/Framework/Validator/Locale.php index 0cdf265af01b3..aeaf129280368 100644 --- a/lib/internal/Magento/Framework/Locale/Validator.php +++ b/lib/internal/Magento/Framework/Validator/Locale.php @@ -4,28 +4,28 @@ * See COPYING.txt for license details. */ +namespace Magento\Framework\Validator; + +use Magento\Framework\Setup\Lists; + /** * Locale validator model - * - * @author Magento Core Team */ -namespace Magento\Framework\Locale; - -class Validator +class Locale { /** - * @var \Magento\Framework\Locale\ConfigInterface + * @var Lists */ - protected $_localeConfig; + protected $lists; /** * Constructor * - * @param \Magento\Framework\Locale\ConfigInterface $localeConfig + * @param Lists $lists */ - public function __construct(\Magento\Framework\Locale\ConfigInterface $localeConfig) + public function __construct(Lists $lists) { - $this->_localeConfig = $localeConfig; + $this->lists = $lists; } /** @@ -39,7 +39,7 @@ public function __construct(\Magento\Framework\Locale\ConfigInterface $localeCon public function isValid($localeCode) { $isValid = true; - $allowedLocaleCodes = $this->_localeConfig->getAllowedLocales(); + $allowedLocaleCodes = array_keys($this->lists->getLocaleList()); if (!$localeCode || !in_array($localeCode, $allowedLocaleCodes)) { $isValid = false; diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php new file mode 100644 index 0000000000000..e76b854e553cd --- /dev/null +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/CurrencyTest.php @@ -0,0 +1,28 @@ +getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $lists->expects($this->any())->method('getCurrencyList')->will($this->returnValue($this->expectedCurrencies)); + $currency = new \Magento\Framework\Validator\Currency($lists); + $this->assertEquals(true, $currency->isValid('EUR')); + } +} diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php new file mode 100644 index 0000000000000..27ca99f1c4fd2 --- /dev/null +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/LocaleTest.php @@ -0,0 +1,28 @@ +getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $lists->expects($this->any())->method('getLocaleList')->will($this->returnValue($this->expectedLocales)); + $locale = new \Magento\Framework\Validator\Locale($lists); + $this->assertEquals(true, $locale->isValid('en_US')); + } +} diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php new file mode 100644 index 0000000000000..a86989ca609f3 --- /dev/null +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/TimezoneTest.php @@ -0,0 +1,28 @@ +getMock('Magento\Framework\Setup\Lists', [], [], '', false); + $lists->expects($this->any())->method('getTimezoneList')->will($this->returnValue($this->expectedTimezones)); + $timezone = new \Magento\Framework\Validator\Timezone($lists); + $this->assertEquals(true, $timezone->isValid('America/Los_Angeles')); + } +} diff --git a/lib/internal/Magento/Framework/Validator/Timezone.php b/lib/internal/Magento/Framework/Validator/Timezone.php new file mode 100644 index 0000000000000..33094ab747bdb --- /dev/null +++ b/lib/internal/Magento/Framework/Validator/Timezone.php @@ -0,0 +1,48 @@ +lists = $lists; + } + + /** + * Validate timezone code + * + * @param string $timezoneCode + * @return bool + */ + public function isValid($timezoneCode) + { + $isValid = true; + $allowedTimezoneCodes = array_keys($this->lists->getTimezoneList()); + + if (!$timezoneCode || !in_array($timezoneCode, $allowedTimezoneCodes)) { + $isValid = false; + } + + return $isValid; + } +} diff --git a/lib/internal/Magento/Framework/View/Asset/Source.php b/lib/internal/Magento/Framework/View/Asset/Source.php index 29d7d4a6af02c..c4eb693b2a973 100644 --- a/lib/internal/Magento/Framework/View/Asset/Source.php +++ b/lib/internal/Magento/Framework/View/Asset/Source.php @@ -138,11 +138,14 @@ private function preProcess(LocalInterface $asset) return unserialize($cached); } + $origContent = $path ? $this->rootDir->readFile($path) : ''; + $origContentType = $this->getContentType($path) ?: $asset->getContentType(); + $chain = $this->chainFactory->create( [ 'asset' => $asset, - 'origContent' => $this->rootDir->readFile($path), - 'origContentType' => $this->getContentType($path), + 'origContent' => $origContent, + 'origContentType' => $origContentType, 'origAssetPath' => $path ] ); diff --git a/lib/internal/Magento/Framework/View/Block/IdentityInterface.php b/lib/internal/Magento/Framework/View/Block/IdentityInterface.php deleted file mode 100644 index 412f84472f2dd..0000000000000 --- a/lib/internal/Magento/Framework/View/Block/IdentityInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -_layout = $context->getLayout(); $this->_eventManager = $context->getEventManager(); $this->_urlBuilder = $context->getUrlBuilder(); - $this->_translator = $context->getTranslator(); $this->_cache = $context->getCache(); $this->_design = $context->getDesignPackage(); $this->_session = $context->getSession(); @@ -186,10 +185,24 @@ public function __construct(\Magento\Framework\View\Element\Context $context, ar $this->filterManager = $context->getFilterManager(); $this->_localeDate = $context->getLocaleDate(); $this->inlineTranslation = $context->getInlineTranslation(); + if (isset($data['jsLayout'])) { + $this->jsLayout = $data['jsLayout']; + unset($data['jsLayout']); + } parent::__construct($data); $this->_construct(); } + /** + * Retrieve serialized JS layout configuration ready to use in template + * + * @return string + */ + public function getJsLayout() + { + return json_encode($this->jsLayout); + } + /** * Get request * diff --git a/lib/internal/Magento/Framework/View/Element/Context.php b/lib/internal/Magento/Framework/View/Element/Context.php index 9a11458aa3c4a..c640198f91bcc 100644 --- a/lib/internal/Magento/Framework/View/Element/Context.php +++ b/lib/internal/Magento/Framework/View/Element/Context.php @@ -44,13 +44,6 @@ class Context implements \Magento\Framework\ObjectManager\ContextInterface */ protected $_urlBuilder; - /** - * Translator - * - * @var \Magento\Framework\TranslateInterface - */ - protected $_translator; - /** * Cache * @@ -163,7 +156,6 @@ public function __construct( \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\TranslateInterface $translator, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Session\SessionManagerInterface $session, @@ -182,7 +174,6 @@ public function __construct( $this->_layout = $layout; $this->_eventManager = $eventManager; $this->_urlBuilder = $urlBuilder; - $this->_translator = $translator; $this->_cache = $cache; $this->_design = $design; $this->_session = $session; @@ -278,16 +269,6 @@ public function getScopeConfig() return $this->_scopeConfig; } - /** - * Get translator - * - * @return \Magento\Framework\TranslateInterface - */ - public function getTranslator() - { - return $this->_translator; - } - /** * Get inline translation status object * diff --git a/lib/internal/Magento/Framework/View/Element/Messages.php b/lib/internal/Magento/Framework/View/Element/Messages.php index feedc28c86499..790a614c6a818 100644 --- a/lib/internal/Magento/Framework/View/Element/Messages.php +++ b/lib/internal/Magento/Framework/View/Element/Messages.php @@ -99,23 +99,9 @@ public function __construct( $this->messageFactory = $messageFactory; $this->collectionFactory = $collectionFactory; $this->messageManager = $messageManager; - $this->_isScopePrivate = true; parent::__construct($context, $data); } - /** - * Preparing global layout - * - * @return $this - */ - protected function _prepareLayout() - { - $this->addStorageType($this->messageManager->getDefaultGroup()); - $this->addMessages($this->messageManager->getMessages(true)); - parent::_prepareLayout(); - return $this; - } - /** * Set messages collection * diff --git a/lib/internal/Magento/Framework/View/Element/Template/Context.php b/lib/internal/Magento/Framework/View/Element/Template/Context.php index fab3a911e20a9..6fddcb6728016 100644 --- a/lib/internal/Magento/Framework/View/Element/Template/Context.php +++ b/lib/internal/Magento/Framework/View/Element/Template/Context.php @@ -66,7 +66,6 @@ class Context extends \Magento\Framework\View\Element\Context * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Framework\TranslateInterface $translator * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Session\SessionManagerInterface $session @@ -94,7 +93,6 @@ public function __construct( \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\TranslateInterface $translator, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Session\SessionManagerInterface $session, @@ -120,7 +118,6 @@ public function __construct( $layout, $eventManager, $urlBuilder, - $translator, $cache, $design, $session, diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ContentType/Json.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ContentType/Json.php index 3185bc6cb2ac0..6af04342a3a6c 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/ContentType/Json.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ContentType/Json.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\View\Element\UiComponent\ContentType; +use Magento\Framework\Json\Encoder; use Magento\Framework\View\FileSystem; use Magento\Framework\View\TemplateEnginePool; use Magento\Framework\View\Element\UiComponentInterface; @@ -14,17 +15,25 @@ */ class Json extends AbstractContentType { + /** + * @var Encoder + */ + private $encoder; + /** * Constructor * * @param FileSystem $filesystem * @param TemplateEnginePool $templateEnginePool + * @param Encoder $encoder */ public function __construct( FileSystem $filesystem, - TemplateEnginePool $templateEnginePool + TemplateEnginePool $templateEnginePool, + Encoder $encoder ) { parent::__construct($filesystem, $templateEnginePool); + $this->encoder = $encoder; } /** @@ -34,12 +43,13 @@ public function __construct( * @param string $template * @return string * @throws \Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function render(UiComponentInterface $component, $template = '') { - $data = $component->getDataSourceData(); + $data = $component->getContext()->getDataSourceData($component); $data = reset($data); - return json_encode($data['config']['data']); + return $this->encoder->encode($data['config']['data']); } } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php index 2e9e35bce7ef1..c4b3167ac45ca 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php @@ -19,6 +19,8 @@ /** * Class Context + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Context implements ContextInterface { @@ -198,6 +200,49 @@ public function getDataProvider() return $this->dataProvider; } + /** + * @param UiComponentInterface $component + * @return array + */ + public function getDataSourceData(UiComponentInterface $component) + { + $dataSource = []; + $id = $this->getRequestParam($this->getDataProvider()->getRequestFieldName()); + if ($id) { // case form + $this->getDataProvider()->addFilter($this->getDataProvider()->getPrimaryFieldName(), $id); + $data = $this->getDataProvider()->getData(); + if (isset($data[$id])) { + $dataSource = [ + 'data' => $data[$id] + ]; + } + } else { // case listing + $dataSource = [ + 'data' => $this->getDataProvider()->getData(), + 'totalCount' => $this->getDataProvider()->count() + ]; + } + + $this->prepareDataSource($dataSource, $component); + + $dataProviderConfig = $this->getDataProvider()->getConfigData(); + return [ + $this->getDataProvider()->getName() => [ + 'type' => 'dataSource', + 'name' => $this->getDataProvider()->getName(), + 'dataScope' => $this->getNamespace(), + 'config' => array_replace_recursive( + array_merge($dataSource, $dataProviderConfig), + [ + 'params' => [ + 'namespace' => $this->getNamespace() + ], + ] + ) + ] + ]; + } + /** * Get page layout * @@ -299,4 +344,22 @@ public function getUrl($route = '', $params = []) { return $this->urlBuilder->getUrl($route, $params); } + + /** + * Call `prepareData` method of all the components + * + * @param array $data + * @param UiComponentInterface $component + * @return void + */ + protected function prepareDataSource(array & $data, UiComponentInterface $component) + { + $childComponents = $component->getChildComponents(); + if (!empty($childComponents)) { + foreach ($childComponents as $child) { + $this->prepareDataSource($data, $child); + } + } + $component->prepareDataSource($data); + } } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php index 321f2cc5b2e06..02d0398204d95 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php @@ -60,6 +60,14 @@ public function setDataProvider(DataProviderInterface $dataProvider); */ public function getDataProvider(); + /** + * Get Data Source array + * + * @param UiComponentInterface $component + * @return array + */ + public function getDataSourceData(UiComponentInterface $component); + /** * Getting all request data * diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php index 034e0fa56c6c4..e0390785dfa66 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php @@ -10,6 +10,13 @@ */ interface DataProviderInterface { + /** + * Get Data Provider name + * + * @return string + */ + public function getName(); + /** * Get config data * @@ -37,6 +44,14 @@ public function getMeta(); */ public function getFieldMetaInfo($fieldSetName, $fieldName); + /** + * Get field Set meta info + * + * @param string $fieldSetName + * @return array + */ + public function getFieldSetMetaInfo($fieldSetName); + /** * @param string $fieldSetName * @return array diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/JsConfigInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/JsConfigInterface.php index 0826398d68404..257a198b026d1 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/JsConfigInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/JsConfigInterface.php @@ -13,9 +13,10 @@ interface JsConfigInterface extends UiComponentInterface { /** - * Get JS config + * Get configuration of related JavaScript Component * - * @return array|string + * @param UiComponentInterface $component + * @return array */ - public function getJsConfig(); + public function getJsConfig(UiComponentInterface $component); } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php index a1b37315a3a1c..4908a9cddb684 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php @@ -11,6 +11,7 @@ use Magento\Framework\Data\Argument\InterpreterInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\Config\ManagerInterface; +use Magento\Framework\View\Element\UiComponent\ContextFactory; /** * Class UiComponentFactory @@ -38,23 +39,31 @@ class UiComponentFactory extends Object */ protected $argumentInterpreter; + /** + * @var ContextFactory + */ + protected $contextFactory; + /** * Constructor * * @param ObjectManagerInterface $objectManager * @param ManagerInterface $componentManager * @param InterpreterInterface $argumentInterpreter + * @param ContextFactory $contextFactory * @param array $data */ public function __construct( ObjectManagerInterface $objectManager, ManagerInterface $componentManager, InterpreterInterface $argumentInterpreter, + ContextFactory $contextFactory, array $data = [] ) { $this->objectManager = $objectManager; $this->componentManager = $componentManager; $this->argumentInterpreter = $argumentInterpreter; + $this->contextFactory = $contextFactory; parent::__construct($data); } @@ -105,10 +114,7 @@ protected function argumentsResolver($identifier, array $componentData) $attributes = $componentData[ManagerInterface::COMPONENT_ATTRIBUTES_KEY]; $className = $attributes['class']; unset($attributes['class']); - $arguments = []; - foreach ($componentData[ManagerInterface::COMPONENT_ARGUMENTS_KEY] as $name => $argument) { - $arguments[$name] = $this->argumentInterpreter->evaluate($argument); - } + $arguments = $componentData[ManagerInterface::COMPONENT_ARGUMENTS_KEY]; if (!isset($arguments['data'])) { $arguments['data'] = []; @@ -140,7 +146,9 @@ public function create($identifier, $name = null, array $arguments = []) ); $componentArguments = array_merge($componentArguments, $arguments); if (!isset($componentArguments['context'])) { - throw new LocalizedException(new \Magento\Framework\Phrase('Context, is required argument.')); + $componentArguments['context'] = $this->contextFactory->create([ + 'namespace' => $identifier + ]); } $componentContext = $componentArguments['context']; $components = []; @@ -160,7 +168,7 @@ public function create($identifier, $name = null, array $arguments = []) return $component; } else { - $defaultData = $this->componentManager->createRawComponentData($name); + $defaultData = $this->componentManager->createRawComponentData($name, true); list($className, $componentArguments) = $this->argumentsResolver($identifier, $defaultData); /** @var \Magento\Framework\View\Element\UiComponentInterface $component */ $component = $this->objectManager->create($className, array_merge($componentArguments, $arguments)); diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponentInterface.php index a38823e7f0b14..0735eff2a4c4d 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponentInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentInterface.php @@ -26,6 +26,13 @@ public function getName(); */ public function getComponentName(); + /** + * Get component configuration + * + * @return array + */ + public function getConfiguration(); + /** * Render component * @@ -96,14 +103,17 @@ public function setData($key, $value = null); public function getData($key = '', $index = null); /** - * @return array + * Prepare component configuration + * + * @return void */ - public function getDataSourceData(); + public function prepare(); /** - * Prepare component configuration + * Prepare Data Source * + * @param array $dataSource * @return void */ - public function prepare(); + public function prepareDataSource(array & $dataSource); } diff --git a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php index e232546d6ac1e..31d5be5b7247a 100644 --- a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php @@ -182,7 +182,10 @@ protected function convertCustomAttributeValue($customAttributesValueArray, $dat $camelCaseAttributeCodeKey = lcfirst( SimpleDataObjectConverter::snakeCaseToUpperCamelCase(AttributeValue::ATTRIBUTE_CODE) ); - foreach ($customAttributesValueArray as $customAttribute) { + foreach ($customAttributesValueArray as $key => $customAttribute) { + if (!is_array($customAttribute)) { + $customAttribute = [AttributeValue::ATTRIBUTE_CODE => $key, AttributeValue::VALUE => $customAttribute]; + } if (isset($customAttribute[AttributeValue::ATTRIBUTE_CODE])) { $customAttributeCode = $customAttribute[AttributeValue::ATTRIBUTE_CODE]; } elseif (isset($customAttribute[$camelCaseAttributeCodeKey])) { @@ -242,6 +245,7 @@ protected function _createDataObjectForTypeAndArrayValue($type, $customAttribute * @param mixed $value * @param string $type Convert given value to the this type * @return mixed + * @throws WebapiException * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _convertValue($value, $type) diff --git a/lib/internal/Magento/Framework/XsltProcessor/XsltProcessorFactory.php b/lib/internal/Magento/Framework/XsltProcessor/XsltProcessorFactory.php new file mode 100644 index 0000000000000..7d56b227176d4 --- /dev/null +++ b/lib/internal/Magento/Framework/XsltProcessor/XsltProcessorFactory.php @@ -0,0 +1,22 @@ +o)throw Error("Minimum 2 arguments must be given");if(e.isArray(u)){i={};for(var f in u){r=u[f];try{i[r]=JSON.parse(s.getItem(r))}catch(c){i[r]=s.getItem(r)}}return i}if(2!=o){try{i=JSON.parse(s.getItem(u))}catch(c){throw new ReferenceError(u+" is not defined in this storage")}for(var f=2;o-1>f;f++)if(i=i[a[f]],void 0===i)throw new ReferenceError([].slice.call(a,1,f+1).join(".")+" is not defined in this storage");if(e.isArray(a[f])){n=i,i={};for(var m in a[f])i[a[f][m]]=n[a[f][m]];return i}return i[a[f]]}try{return JSON.parse(s.getItem(u))}catch(c){return s.getItem(u)}}function r(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1],u=s[2],f={};if(2>n||!e.isPlainObject(a)&&3>n)throw Error("Minimum 3 arguments must be given or second parameter must be an object");if(e.isPlainObject(a)){for(var c in a)r=a[c],e.isPlainObject(r)?o.setItem(c,JSON.stringify(r)):o.setItem(c,r);return a}if(3==n)return"object"==typeof u?o.setItem(a,JSON.stringify(u)):o.setItem(a,u),u;try{i=o.getItem(a),null!=i&&(f=JSON.parse(i))}catch(m){}i=f;for(var c=2;n-2>c;c++)r=s[c],i[r]&&e.isPlainObject(i[r])||(i[r]={}),i=i[r];return i[s[c]]=s[c+1],o.setItem(a,JSON.stringify(f)),f}function i(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1];if(2>n)throw Error("Minimum 2 arguments must be given");if(e.isArray(a)){for(var u in a)o.removeItem(a[u]);return!0}if(2==n)return o.removeItem(a),!0;try{r=i=JSON.parse(o.getItem(a))}catch(f){throw new ReferenceError(a+" is not defined in this storage")}for(var u=2;n-1>u;u++)if(i=i[s[u]],void 0===i)throw new ReferenceError([].slice.call(s,1,u).join(".")+" is not defined in this storage");if(e.isArray(s[u]))for(var c in s[u])delete i[s[u][c]];else delete i[s[u]];return o.setItem(a,JSON.stringify(r)),!0}function n(t,r){var n=a(t);for(var o in n)i(t,n[o]);if(r)for(var o in e.namespaceStorages)u(o)}function o(r){var i=arguments.length,n=arguments,s=(window[r],n[1]);if(1==i)return 0==a(r).length;if(e.isArray(s)){for(var u=0;ui)throw Error("Minimum 2 arguments must be given");if(e.isArray(o)){for(var a=0;a1?t.apply(this,o):n,a._cookie)for(var u in e.cookie())""!=u&&s.push(u.replace(a._prefix,""));else for(var f in a)s.push(f);return s}function u(t){if(!t||"string"!=typeof t)throw Error("First parameter must be a string");g?(window.localStorage.getItem(t)||window.localStorage.setItem(t,"{}"),window.sessionStorage.getItem(t)||window.sessionStorage.setItem(t,"{}")):(window.localCookieStorage.getItem(t)||window.localCookieStorage.setItem(t,"{}"),window.sessionCookieStorage.getItem(t)||window.sessionCookieStorage.setItem(t,"{}"));var r={localStorage:e.extend({},e.localStorage,{_ns:t}),sessionStorage:e.extend({},e.sessionStorage,{_ns:t})};return e.cookie&&(window.cookieStorage.getItem(t)||window.cookieStorage.setItem(t,"{}"),r.cookieStorage=e.extend({},e.cookieStorage,{_ns:t})),e.namespaceStorages[t]=r,r}function f(e){if(!window[e])return!1;var t="jsapi";try{return window[e].setItem(t,t),window[e].removeItem(t),!0}catch(r){return!1}}var c="ls_",m="ss_",g=f("localStorage"),h={_type:"",_ns:"",_callMethod:function(e,t){var r=[this._type],t=Array.prototype.slice.call(t),i=t[0];return this._ns&&r.push(this._ns),"string"==typeof i&&-1!==i.indexOf(".")&&(t.shift(),[].unshift.apply(t,i.split("."))),[].push.apply(r,t),e.apply(this,r)},get:function(){return this._callMethod(t,arguments)},set:function(){var t=arguments.length,i=arguments,n=i[0];if(1>t||!e.isPlainObject(n)&&2>t)throw Error("Minimum 2 arguments must be given or first parameter must be an object");if(e.isPlainObject(n)&&this._ns){for(var o in n)r(this._type,this._ns,o,n[o]);return n}var s=this._callMethod(r,i);return this._ns?s[n.split(".")[0]]:s},remove:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(i,arguments)},removeAll:function(e){return this._ns?(r(this._type,this._ns,{}),!0):n(this._type,e)},isEmpty:function(){return this._callMethod(o,arguments)},isSet:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(s,arguments)},keys:function(){return this._callMethod(a,arguments)}};if(e.cookie){window.name||(window.name=Math.floor(1e8*Math.random()));var l={_cookie:!0,_prefix:"",_expires:null,_path:null,_domain:null,setItem:function(t,r){e.cookie(this._prefix+t,r,{expires:this._expires,path:this._path,domain:this._domain})},getItem:function(t){return e.cookie(this._prefix+t)},removeItem:function(t){return e.removeCookie(this._prefix+t)},clear:function(){for(var t in e.cookie())""!=t&&(!this._prefix&&-1===t.indexOf(c)&&-1===t.indexOf(m)||this._prefix&&0===t.indexOf(this._prefix))&&e.removeCookie(t)},setExpires:function(e){return this._expires=e,this},setPath:function(e){return this._path=e,this},setDomain:function(e){return this._domain=e,this},setConf:function(e){return e.path&&(this._path=e.path),e.domain&&(this._domain=e.domain),e.expires&&(this._expires=e.expires),this},setDefaultConf:function(){this._path=this._domain=this._expires=null}};g||(window.localCookieStorage=e.extend({},l,{_prefix:c,_expires:3650}),window.sessionCookieStorage=e.extend({},l,{_prefix:m+window.name+"_"})),window.cookieStorage=e.extend({},l),e.cookieStorage=e.extend({},h,{_type:"cookieStorage",setExpires:function(e){return window.cookieStorage.setExpires(e),this},setPath:function(e){return window.cookieStorage.setPath(e),this},setDomain:function(e){return window.cookieStorage.setDomain(e),this},setConf:function(e){return window.cookieStorage.setConf(e),this},setDefaultConf:function(){return window.cookieStorage.setDefaultConf(),this}})}e.initNamespaceStorage=function(e){return u(e)},g?(e.localStorage=e.extend({},h,{_type:"localStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionStorage"})):(e.localStorage=e.extend({},h,{_type:"localCookieStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionCookieStorage"})),e.namespaceStorages={},e.removeAllStorages=function(t){e.localStorage.removeAll(t),e.sessionStorage.removeAll(t),e.cookieStorage&&e.cookieStorage.removeAll(t),t||(e.namespaceStorages={})}}); \ No newline at end of file diff --git a/lib/web/mage/adminhtml/grid.js b/lib/web/mage/adminhtml/grid.js index 62ede73c5c2fc..684f8358df001 100644 --- a/lib/web/mage/adminhtml/grid.js +++ b/lib/web/mage/adminhtml/grid.js @@ -63,7 +63,7 @@ varienGrid.prototype = { } } if (this.sortVar && this.dirVar) { - var columns = $$('#' + this.containerId + this.tableSufix + ' thead a'); + var columns = $$('#' + this.containerId + this.tableSufix + ' thead [data-sort]'); for (var col = 0; col < columns.length; col++) { Event.observe(columns[col], 'click', this.thLinkOnClick); @@ -107,10 +107,10 @@ varienGrid.prototype = { Element.addClassName(element, 'on-mouse'); - if (!Element.hasClassName('pointer') + if (!Element.hasClassName('_clickable') && (this.rowClickCallback !== openGridRow || element.title)) { if (element.title) { - Element.addClassName(element, 'pointer'); + Element.addClassName(element, '_clickable'); } } }, @@ -135,11 +135,11 @@ varienGrid.prototype = { }, doSort:function (event) { - var element = Event.findElement(event, 'a'); + var element = Event.findElement(event, 'th'); - if (element.name && element.title) { - this.addVarToUrl(this.sortVar, element.name); - this.addVarToUrl(this.dirVar, element.title); + if (element.readAttribute('data-sort') && element.readAttribute('data-direction')) { + this.addVarToUrl(this.sortVar, element.readAttribute('data-sort')); + this.addVarToUrl(this.dirVar, element.readAttribute('data-direction')); this.reload(this.url); } Event.stop(event); @@ -267,7 +267,7 @@ varienGrid.prototype = { } }, bindFilterFields : function(){ - var filters = $$('#'+this.containerId+' .filter input', '#'+this.containerId+' .filter select'); + var filters = $$('#'+this.containerId+' [data-role="filter-form"] input', '#'+this.containerId+' [data-role="filter-form"] select'); for (var i=0; i', this.options.placeholderAttrs)).prev(); this._offsetTop = this._placeholder.offset().top; - this._height = this.element.outerHeight(true); + this._height = this.element + .parents(this.options.pageMainActions) + .outerHeight(); }, /** @@ -65,8 +69,19 @@ define([ */ _handlePageScroll: function() { var isActive = ($(window).scrollTop() > this._offsetTop); - this.element - [isActive ? 'addClass': 'removeClass'](this.options.fixedClass); + + if (isActive) { + this.element + .addClass(this.options.fixedClass) + .parents(this.options.pageMainActions) + .addClass(this.options.hiddenClass); + } else { + this.element + .removeClass(this.options.fixedClass) + .parents(this.options.pageMainActions) + .removeClass(this.options.hiddenClass); + } + this._placeholder.height(isActive ? this._height: ''); }, diff --git a/lib/web/mage/layout.js b/lib/web/mage/layout.js new file mode 100644 index 0000000000000..8f79b006715c5 --- /dev/null +++ b/lib/web/mage/layout.js @@ -0,0 +1,18 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true */ +/*global console:true*/ +define(['underscore'], function($) { + return { + build: function(config) { + var types = _.map(_.flatten(config), function(item) { + return item.type; + }); + require(types, function () { + + }); + } + }; +}); diff --git a/lib/web/mage/storage.js b/lib/web/mage/storage.js new file mode 100644 index 0000000000000..ea0b6b432ba9d --- /dev/null +++ b/lib/web/mage/storage.js @@ -0,0 +1,37 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define(['jquery', 'mage/url'], function ($, urlBuilder) { + "use strict"; + return { + get: function (url, contentType) { + contentType = contentType || 'application/json'; + return $.ajax({ + url: urlBuilder.build(url), + type: 'GET', + async: false, + contentType: contentType + }); + }, + post: function(url, data, contentType) { + contentType = contentType || 'application/json'; + return $.ajax({ + url: urlBuilder.build(url), + type: 'POST', + data: data, + contentType: contentType + }); + }, + put: function(url, data, contentType) { + contentType = contentType || 'application/json'; + return $.ajax({ + url: urlBuilder.build(url), + type: 'PUT', + data: data, + contentType: contentType + }); + } + }; +}); diff --git a/lib/web/mage/url.js b/lib/web/mage/url.js new file mode 100644 index 0000000000000..9b342a64be94b --- /dev/null +++ b/lib/web/mage/url.js @@ -0,0 +1,19 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint regexdash:true eqnull:true browser:true jquery:true*/ +define([], function () { + var baseUrl = ''; + return { + setBaseUrl: function (url) { + baseUrl = url; + }, + build: function(path) { + if (path.indexOf(baseUrl) != -1) { + return path; + } + return baseUrl + path; + } + } +}); diff --git a/lib/web/mage/utils/compare.js b/lib/web/mage/utils/compare.js index f71e1bf892227..69634f893c49f 100644 --- a/lib/web/mage/utils/compare.js +++ b/lib/web/mage/utils/compare.js @@ -3,12 +3,16 @@ * See COPYING.txt for license details. */ define([ - 'underscore', - 'mage/utils/objects' -], function (_, utils) { + 'underscore' +], function (_) { 'use strict'; - var primitives = [ + var objType = '[object Object]', + objString = Object.prototype.toString, + result = [], + primitives; + + primitives = [ 'undefined', 'boolean', 'number', @@ -21,45 +25,21 @@ define([ return oldIsPrimitive ? a !== b : true; } - function fullPath(prefix, part) { - return prefix ? prefix + '.' + part : part; + function isObject(data) { + return typeof data == 'object' ? + objString.call(data) === objType : + false; } - function format(name, newValue, oldValue, type) { - return { - name: name, - type: type, - value: newValue, - oldValue: oldValue - }; - } - - function flatten(obj, ns, result) { - result = result || {}; - ns = ns || ''; - - if (!utils.isObject(obj)) { - obj = {}; - } - - _.each(obj, function (value, key) { - key = fullPath(ns, key); - - if (utils.isObject(value)) { - flatten(value, key, result); - } - - result[key] = value; - }); - - return result; + function getPath(prefix, part) { + return prefix ? prefix + '.' + part : part; } function getConatiners(changes) { - var indexed, - result = {}; + var result = {}, + indexed; - indexed = _.indexBy(changes, 'name'); + indexed = _.indexBy(changes, 'path'); _.each(indexed, function (change, name) { var path; @@ -67,9 +47,9 @@ define([ name = name.split('.'); name.forEach(function (part) { - path = fullPath(path, part); + path = getPath(path, part); - if (!_.has(indexed, path)) { + if (!(path in indexed)) { result[path] = result[path] || []; result[path].push(change); } @@ -79,54 +59,81 @@ define([ return result; } - function getModified(oldValues, current, key) { - var previous, - someIsObject; - - if (_.has(oldValues, key)) { - previous = oldValues[key]; - someIsObject = !utils.isObject(previous) || !utils.isObject(current); + function addChange(path, name, type, newValue, oldValue) { + var data = { + path: path, + name: name, + type: type + }; - if (someIsObject && isDifferent(previous, current)) { - return format(key, current, previous, 'update'); - } + if (type !== 'remove') { + data.value = newValue; + data.oldValue = oldValue; } else { - return format(key, current, undefined, 'add'); + data.oldValue = newValue; } + + result.push(data); } - function getRemoved(newValues, previous, key) { - if (!_.has(newValues, key)) { - return format(key, undefined, previous, 'remove'); + function setAll(ns, name, type, iterator, placeholder) { + var key; + + if (arguments.length > 4) { + type === 'add' ? + addChange(ns, name, 'update', iterator, placeholder) : + addChange(ns, name, 'update', placeholder, iterator); + } else { + addChange(ns, name, type, iterator); } - } - function compare(oldObj, newObj, ns) { - var removed, - modfied; + if (!isObject(iterator)) { + return; + } - oldObj = flatten(oldObj, ns); - newObj = flatten(newObj, ns); + for (key in iterator) { + setAll(getPath(ns, key), key, type, iterator[key]); + } + } + + function compare(old, current, ns, name) { + var key, + oldIsObj = isObject(old), + newIsObj = isObject(current); - removed = _.map(oldObj, getRemoved.bind(null, newObj)), - modfied = _.map(newObj, getModified.bind(null, oldObj)); + if (oldIsObj && newIsObj) { + for (key in old) { + if (!(key in current)) { + setAll(getPath(ns, key), key, 'remove', old[key]); + } + } - return _.compact(Array.prototype.concat(removed, modfied)); + for (key in current) { + key in old ? + compare(old[key], current[key], getPath(ns, key), key) : + setAll(getPath(ns, key), key, 'add', current[key]); + } + } else if (oldIsObj) { + setAll(ns, name, 'remove', old, current); + } else if (newIsObj) { + setAll(ns, name, 'add', current, old); + } else if (isDifferent(old, current)) { + addChange(ns, name, 'update', current, old); + } } return { - compare: function (oldValue, newValue, ns) { - var changes = []; + compare: function () { + var changes; - if (utils.isObject(oldValue) || utils.isObject(newValue)) { - changes = compare.apply(null, arguments); - } else if (isDifferent(oldValue, newValue)) { - changes.push(format(ns, newValue, oldValue, 'update')); - } + compare.apply(null, arguments); + + changes = result.splice(0, result.length); return { containers: getConatiners(changes), - changes: changes + changes: changes, + equal: !changes.length }; } }; diff --git a/lib/web/mage/utils/objects.js b/lib/web/mage/utils/objects.js index c2d88f8386227..7cd4924e492a3 100644 --- a/lib/web/mage/utils/objects.js +++ b/lib/web/mage/utils/objects.js @@ -3,9 +3,10 @@ * See COPYING.txt for license details. */ define([ + 'ko', 'jquery', 'underscore' -], function ($, _) { +], function (ko, $, _) { 'use strict'; /** @@ -18,17 +19,24 @@ define([ * returns {*} New value for the property. */ function setNested(parent, path, value) { - var last = path.pop(); + var last = path.pop(), + len = path.length, + pi = 0, + part = path[pi]; - path.forEach(function (part) { - if (_.isUndefined(parent[part])) { + for (; pi < len; part = path[++pi]) { + if (typeof parent[part] === 'undefined') { parent[part] = {}; } parent = parent[part]; - }); + } - parent[last] = value; + if (typeof parent[last] === 'function') { + parent[last](value); + } else { + parent[last] = value; + } return value; } @@ -42,15 +50,23 @@ define([ * @returns {*} Value of the property. */ function getNested(parent, path) { - var exists; + var exists = true, + len = path.length, + pi = 0; - exists = path.every(function (part) { - parent = parent[part]; + for (; pi < len && exists; pi++) { + parent = parent[path[pi]]; - return !_.isUndefined(parent); - }); + if (typeof parent === 'undefined') { + exists = false; + } + } if (exists) { + if (ko.isObservable(parent)) { + parent = parent(); + } + return parent; } } @@ -192,29 +208,15 @@ define([ }, extend: function (target) { - var extenders = _.toArray(arguments).splice(1), - clone, - src; - - extenders.forEach(function (node) { - _.each(node, function (value, key) { - src = target[key]; - - if (this.isObject(value) || Array.isArray(value)) { - if (Array.isArray(value)) { - clone = src && Array.isArray(src) ? src : []; - } else { - clone = src && this.isObject(src) ? src : {}; - } - - target[key] = this.extend(clone, value); - } else if (!_.isUndefined(value)) { - target[key] = value; - } - }, this); - }, this); + var args = _.toArray(arguments); + + args.unshift(true); + + return $.extend.apply($, args); + }, - return target; + copy: function (data) { + return this.extend({}, data); }, isObject: function (data) { diff --git a/lib/web/mage/utils/template.js b/lib/web/mage/utils/template.js index 86c53247dcf97..a2b8cd462f666 100644 --- a/lib/web/mage/utils/template.js +++ b/lib/web/mage/utils/template.js @@ -8,19 +8,83 @@ define([ ], function (_, utils) { 'use strict'; - var opener = '<%'; + var tmplSettings = _.templateSettings, + interpolate = /\$\{([\s\S]+?)\}/g, + opener = '${', + template, + hasStringTmpls; + + /** + * Identifies whether ES6 templates are supported. + */ + hasStringTmpls = (function () { + var testString = 'var foo = "bar"; return `${ foo }` === foo'; + + try { + return Function(testString)(); + } catch (e) { + return false; + } + })(); + + if (hasStringTmpls) { + /** + * Evaluates template string using ES6 templates. + * + * @param {String} tmpl - Template string. + * @param {Object} $ - Data object used in a template. + * @returns {String} Compiled template. + */ + template = function (tmpl, $) { + return eval('`' + tmpl + '`'); + }; + } else { + /** + * Fallback function used when ES6 templates are not supported. + * Uses underscore templates renderer. + * + * @param {String} tmpl - Template string. + * @param {Object} data - Data object used in a template. + * @returns {String} Compiled template. + */ + template = function (tmpl, data) { + var cached = tmplSettings.interpolate; + tmplSettings.interpolate = interpolate; + + tmpl = _.template(tmpl, {variable: '$'})(data); + + tmplSettings.interpolate = cached; + + return tmpl; + }; + } + + /** + * Checks if provided value contains template syntax. + * + * @param {*} value - Value to be check. + * @returns {Boolean} + */ function isTemplate(value) { - return _.isString(value) && ~value.indexOf(opener); + return typeof value === 'string' && ~value.indexOf(opener); } + /** + * Iteratively processes provided string + * until no templates syntax will be found. + * + * @param {String} tmpl - Template string. + * @param {Object} data - Data object used in a template. + * @returns {String} Compiled template. + */ function render(tmpl, data) { var last = tmpl; data = Object.create(data); while (~tmpl.indexOf(opener)) { - tmpl = _.template(tmpl)(data); + tmpl = template(tmpl, data); if (tmpl === last) { break; @@ -36,26 +100,38 @@ define([ /** * Applies provided data to the template. * - * @param {Object} tmpl - * @param {Object} [$data] - Data object to match with template. - * @returns {Object} + * @param {Object|String} tmpl + * @param {Object} [data] - Data object to match with template. + * @returns {Object|String} * * @example Template defined as a string. * var source = { foo: 'Random Stuff', bar: 'Some' }; * - * utils.template('{bar} {foo}', source); + * utils.template('${ $.bar } ${ $.foo }', source); * => 'Some Random Stuff'; * - * @example Example of template defined as object. - * var tpl = { key: { '{bar}_Baz': '{foo}' } }; + * @example Template defined as an object. + * var tmpl = { + * key: {'${ $.$data.bar }': '${ $.$data.foo }'}, + * foo: 'bar', + * baz: 'Upper ${ $.foo.toUpperCase() }' + * }; * - * utils.template(tpl, source); - * => { key: { 'Some_Baz': 'Random Stuff' } }; + * utils.template(tmpl, source); + * => { + * key: {'Some': 'Random Stuff'}, + * foo: 'bar', + * baz: 'Upper BAR' + * }; */ - template: function (tmpl, $data) { + template: function (tmpl, data) { + if (typeof tmpl === 'string') { + return render(tmpl, data); + } + tmpl = utils.extend({}, tmpl); - tmpl.$data = $data || {}; + tmpl.$data = data || {}; _.each(tmpl, function iterate(value, key, list) { if (key === '$data') { diff --git a/lib/web/mage/view/composite.js b/lib/web/mage/view/composite.js new file mode 100644 index 0000000000000..217d1855a4ac3 --- /dev/null +++ b/lib/web/mage/view/composite.js @@ -0,0 +1,26 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define(['jquery'], function($) { + return function (wrapperTag) { + wrapperTag = wrapperTag || 'div'; + var renderedChildren = {}; + var children = {}; + return { + addChild: function (child, key) { + children[key] = child; + }, + + render: function (root) { + $.each(children, function (key, child) { + var childRoot = $('
      '); + renderedChildren[key] = child.render(childRoot); + root.append(childRoot); + }); + } + } + } +}); diff --git a/package.json b/package.json index 69657eb7702c6..55e65759502a1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "Magento2", "author": "Magento, an eBay Inc. company", "description": "Magento2 node modules dependencies for local development", - "version": "0.42.0-beta1", + "version": "0.74.0-beta7", "repository": { "type": "git", "url": "https://github.com/magento/magento2.git" @@ -11,7 +11,7 @@ "devDependencies": { "grunt": "^0.4.5", "grunt-autoprefixer": "^2.0.0", - "grunt-banner": "^0.3.1", + "grunt-banner": "^0.4.0", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-connect": "^0.9.0", "grunt-contrib-cssmin": "^0.10.0", diff --git a/pub/cron.php b/pub/cron.php index 8e70c3cb0e927..3f7793e674cba 100755 --- a/pub/cron.php +++ b/pub/cron.php @@ -14,27 +14,16 @@ if ($_GET){ $opt = $_GET; } else { - $usage = 'Usage: php -f pub/cron.php -- [--group=]' . PHP_EOL; - $longOpts = [ - 'help', - 'group::', - 'standaloneProcessStarted::' - ]; - $opt = getopt('', $longOpts); - if (isset($opt['help'])) { - echo $usage; - exit(0); - } -} -if (empty($opt['group'])) { - $opt['group'] = 'default'; -} -// It is tracked for internal communication between processes, no user input is needed for this -if (empty($opt['standaloneProcessStarted'])) { - $opt['standaloneProcessStarted'] = '0'; + echo "You cannot run this from the command line." . PHP_EOL . + "Run \"php bin/magento cron:run\" instead." . PHP_EOL; + exit(1); } try { + if (empty($opt['group'])) { + $opt['group'] = 'default'; + } + $opt['standaloneProcessStarted'] = '0'; $params = $_SERVER; $params[StoreManager::PARAM_RUN_CODE] = 'admin'; $params[Store::CUSTOM_ENTRY_POINT_PARAM] = true; diff --git a/dev/tools/performance-toolkit/README.txt b/setup/performance-toolkit/README.txt similarity index 95% rename from dev/tools/performance-toolkit/README.txt rename to setup/performance-toolkit/README.txt index 7f09be4ad422a..59ea7a69df706 100644 --- a/dev/tools/performance-toolkit/README.txt +++ b/setup/performance-toolkit/README.txt @@ -15,7 +15,7 @@ Plugins (only if you want to use additional reports (like graphs)): Usage ----------- -Before running the jMeter tests for the first time, you will need to first use generate.php to generate the test data. +Before running the jMeter tests for the first time, you will need to first use bin/magento setup:performance:generate-fixtures command to generate the test data. 1. Run via console Scenario can accept parameters that are described bellow in format : @@ -32,8 +32,8 @@ Scenario can accept parameters that are described bellow in format Percentage of users that will reach the (logged-in) customer checkout stage. Default is '4'. Number of loops to run. Default is '1'. Admin backend path. Default is 'admin'. - Admin backend user. Default is 'admin'. - Admin backend password. Default is '123123q'. + Admin backend user. Default is 'admin'. + Admin backend password. Default is '123123q'. Deviation (ms) for "think time" emulation. Default is '1000'. Constant delay offset (ms) for "think time" emulation. Default is '2000'. diff --git a/dev/tools/performance-toolkit/benchmark.jmx b/setup/performance-toolkit/benchmark.jmx similarity index 85% rename from dev/tools/performance-toolkit/benchmark.jmx rename to setup/performance-toolkit/benchmark.jmx index dba0ec039cd9c..21a247514cb10 100644 --- a/dev/tools/performance-toolkit/benchmark.jmx +++ b/setup/performance-toolkit/benchmark.jmx @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + @@ -83,14 +83,14 @@ ${__P(admin_path,admin)} = - - admin_user - ${__P(admin_user,admin)} + + admin-user + ${__P(admin-user,admin)} = - - admin_password - ${__P(admin_password,123123q)} + + admin-password + ${__P(admin-password,123123q)} = @@ -724,14 +724,14 @@ productList.add(productMap); true - ${admin_password} + ${admin-password} = true login[password] true - ${admin_user} + ${admin-user} = true login[username] @@ -2349,6 +2349,15 @@ vars.put("category_name", props.get("category_name"));6 + + false + cart_id + "quoteData":{"entity_id":"([^'"]+)", + $1$ + + 1 + + false form_key @@ -2358,7 +2367,7 @@ vars.put("category_name", props.get("category_name"));1 - + ^.+$ @@ -2366,73 +2375,18 @@ vars.put("category_name", props.get("category_name"));false 1 variable - form_key + cart_id - - - ${think_time_delay_offset} - ${think_time_deviation} - - - - - - - true - method - guest - = - true - - - true - 1 - = - true - isAjax - - - true - 1 - = - true - ajax - - - - - - - - http - UTF-8 - ${base_path}checkout/onepage/saveMethod/ - POST - true - false - true - false - false - - - - - - - Referer - http://mage2.com/checkout/onepage/ - - - - - + - [] + ^.+$ Assertion.response_data false - 8 + 1 + variable + form_key @@ -2441,148 +2395,20 @@ vars.put("category_name", props.get("category_name"));${think_time_deviation} - - + + true + - - true - billing[address_id] - - = - true - - - true - billing[city] - Culver City - = - true - - - true - billing[company] - - = - true - - - true - billing[confirm_password] - - = - true - - - true - billing[country_id] - US - = - true - - - true - billing[customer_password] - - = - true - - - true - billing[email] - test@example.com - = - true - - - true - billing[fax] - - = - true - - - true - billing[firstname] - Name - = - true - - - true - billing[lastname] - Lastname - = - true - - - true - billing[postcode] - 90232 - = - true - - - true - billing[region] - - = - true - - - true - billing[region_id] - 12 - = - true - - - true - 1 - = - true - billing[save_in_address_book] - - - true - billing[street][] - 10441 Jefferson Blvd, ste 200 - = - true - - - true - billing[street][] - - = - true - - - true - billing[telephone] - 1-310-945-0345 - = - true - - - true - billing[use_for_shipping] - 1 - = - true - - - true - 1 - = - true - ajax - - - true - 1 + + false + {"shippingAddress":{"company":"","fax":"","city":"Culver City","firstname":"Name","lastname":"Lastname" +,"street":{"0":"10441 Jefferson Blvd, ste 200","1":""},"telephone":"1-310-945-0345","postcode":"90232" +,"region_id":"12","country_id":"US","region":"","save_in_address_book":"1","email":"test@example.com" +,"same_as_billing":1},"billingAddress":{"company":"","fax":"","city":"Culver City","firstname":"Name" +,"lastname":"Lastname","street":{"0":"10441 Jefferson Blvd, ste 200","1":""},"telephone":"1-310-945-0345" +,"postcode":"90232","region_id":"12","country_id":"US","region":"","save_in_address_book":"1","email" +:"test@example.com","same_as_billing":1},"additionalData":{"extensionAttributes":{}}} = - true - isAjax @@ -2592,7 +2418,7 @@ vars.put("category_name", props.get("category_name")); http UTF-8 - ${base_path}checkout/onepage/saveBilling/ + ${base_path}rest/default/V1/guest-carts/${cart_id}/addresses POST true false @@ -2608,12 +2434,24 @@ vars.put("category_name", props.get("category_name"));Referer http://mage2.com/checkout/onepage/ + + Content-Type + application/json; charset=UTF-8 + + + X-Requested-With + XMLHttpRequest + + + Accept + application/json + - "goto_section":"shipping_method" + {"shipping_methods": Assertion.response_data false @@ -2626,29 +2464,16 @@ vars.put("category_name", props.get("category_name"));${think_time_deviation} - - + + true + - - true - shipping_method - flatrate_flatrate - = - true - - - true - 1 - = - true - ajax - - - true - 1 + + false + {"cartId":"${cart_id}","paymentMethod":{"method":"checkmo","po_number":null,"cc_owner" +:null,"cc_number":null,"cc_type":null,"cc_exp_year":null,"cc_exp_month":null,"additional_data":null} +,"shippingCarrierCode":"flatrate","shippingMethodCode":"flatrate"} = - true - isAjax @@ -2658,8 +2483,8 @@ vars.put("category_name", props.get("category_name")); http UTF-8 - ${base_path}checkout/onepage/saveShippingMethod/ - POST + ${base_path}rest/default/V1/guest-carts/${cart_id}/collect-totals + PUT true false true @@ -2674,12 +2499,24 @@ vars.put("category_name", props.get("category_name"));Referer http://mage2.com/checkout/onepage/ + + Content-Type + application/json; charset=UTF-8 + + + Accept + application/json + + + X-Requested-With + XMLHttpRequest + - "goto_section":"payment" + {"grand_total": Assertion.response_data false @@ -2692,36 +2529,14 @@ vars.put("category_name", props.get("category_name"));${think_time_deviation} - - + + true + - - true - payment[method] - checkmo - = - true - - - true - ${form_key} - = - true - form_key - - - true - 1 - = - true - ajax - - - true - 1 + + false + = - true - isAjax @@ -2731,8 +2546,8 @@ vars.put("category_name", props.get("category_name")); http UTF-8 - ${base_path}checkout/onepage/savePayment/ - POST + ${base_path}rest/default/V1/guest-carts/${cart_id}/order + PUT true false true @@ -2741,78 +2556,34 @@ vars.put("category_name", props.get("category_name")); - - - "goto_section":"review" - - Assertion.response_data - false - 2 - - - - - ${think_time_delay_offset} - ${think_time_deviation} - - - - - - - true - payment[method] - checkmo - = - true + + + + Referer + http://mage2.com/checkout/onepage/ - - true - ${form_key} - = - true - form_key - false + + Content-Type + application/json; charset=UTF-8 - - true - 1 - = - true - ajax + + Accept + application/json - - true - 1 - = - true - isAjax + + X-Requested-With + XMLHttpRequest - - - - - - http - UTF-8 - ${base_path}checkout/onepage/saveOrder/ - POST - true - false - true - false - false - - - + + - {"success":true,"error":false} + ^"\d+"$ Assertion.response_data false - 2 + 1 @@ -3453,6 +3224,15 @@ if (emailsCount < 1) { 6 + + false + cart_id + "quoteData":{"entity_id":"([^'"]+)", + $1$ + + 1 + + false form_key @@ -3462,6 +3242,17 @@ if (emailsCount < 1) { 1 + + + ^.+$ + + Assertion.response_data + false + 1 + variable + cart_id + + ^.+$ @@ -3527,145 +3318,26 @@ if (emailsCount < 1) { false - - - false - //div[span='1'][h2='Billing Information'] - false - false - true - false - true - true - - - + ${think_time_delay_offset} ${think_time_deviation} - - + + true + - - true - 37 - = - true - billing[address_id] - - - true - Fayetteville - = - true - billing[city] - - - true - - = - true - billing[company] - - - true - US - = - true - billing[country_id] - - - true - - = - true - billing[fax] - - - true - Anthony - = - true - billing[firstname] - - - true - Nealy - = - true - billing[lastname] - - - true - 123123 - = - true - billing[postcode] - - - true - Arkansas - = - true - billing[region] - - - true - 5 - = - true - billing[region_id] - - - true - 123 Freedom Blvd. #123 - = - true - billing[street][] - - - true - - = - true - billing[street][] - - - true - 022-333-4455 - = - true - billing[telephone] - - - true - 1 - = - true - billing[use_for_shipping] - - - true - 1 - = - true - billing[save_in_address_book] - - - true - 1 - = - true - ajax - - - true - 1 + + false + {"shippingAddress":{"company":"","fax":"","city":"Culver City","firstname":"Name","lastname":"Lastname" +,"street":{"0":"10441 Jefferson Blvd, ste 200","1":""},"telephone":"1-310-945-0345","postcode":"90232" +,"region_id":"12","country_id":"US","region":"","save_in_address_book":"1","email":"test@example.com" +,"same_as_billing":1},"billingAddress":{"company":"","fax":"","city":"Culver City","firstname":"Name" +,"lastname":"Lastname","street":{"0":"10441 Jefferson Blvd, ste 200","1":""},"telephone":"1-310-945-0345" +,"postcode":"90232","region_id":"12","country_id":"US","region":"","save_in_address_book":"1","email" +:"test@example.com","same_as_billing":1},"additionalData":{"extensionAttributes":{}}} = - true - isAjax @@ -3675,7 +3347,7 @@ if (emailsCount < 1) { http UTF-8 - ${base_path}checkout/onepage/saveBilling/ + ${base_path}rest/default/V1/carts/mine/addresses POST true false @@ -3685,9 +3357,30 @@ if (emailsCount < 1) { + + + + Referer + http://mage2.com/checkout/onepage/ + + + Content-Type + application/json; charset=UTF-8 + + + X-Requested-With + XMLHttpRequest + + + Accept + application/json + + + + - "goto_section":"shipping + {"shipping_methods": Assertion.response_data false @@ -3700,43 +3393,16 @@ if (emailsCount < 1) { ${think_time_deviation} - - + + true + - - true - quote_item - = - true - giftoptions[1496][type] - - - true - quote - = - true - giftoptions[451][type] - - - true - shipping_method - flatrate_flatrate - = - true - - - true - 1 - = - true - ajax - - - true - 1 + + false + {"cartId":"${cart_id}","paymentMethod":{"method":"checkmo","po_number":null,"cc_owner" +:null,"cc_number":null,"cc_type":null,"cc_exp_year":null,"cc_exp_month":null,"additional_data":null} +,"shippingCarrierCode":"flatrate","shippingMethodCode":"flatrate"} = - true - isAjax @@ -3746,8 +3412,8 @@ if (emailsCount < 1) { http UTF-8 - ${base_path}checkout/onepage/saveShippingMethod/ - POST + ${base_path}rest/default/V1/carts/mine/collect-totals + PUT true false true @@ -3756,73 +3422,30 @@ if (emailsCount < 1) { - - - "goto_section":"payment" - - Assertion.response_data - false - 2 - - - - - ${think_time_delay_offset} - ${think_time_deviation} - - - - - - - true - payment[method] - checkmo - = - true + + + + Referer + http://mage2.com/checkout/onepage/ - - true - ${form_key} - = - true - form_key + + Content-Type + application/json; charset=UTF-8 - - true - 1 - = - true - ajax + + Accept + application/json - - true - 1 - = - true - isAjax + + X-Requested-With + XMLHttpRequest - - - - - - http - UTF-8 - ${base_path}checkout/onepage/savePayment/ - POST - true - false - true - false - false - - - + + - "goto_section":"review" + {"grand_total": Assertion.response_data false @@ -3836,36 +3459,13 @@ if (emailsCount < 1) { - + true + - - true - payment[method] - checkmo - = - true - - - true - ${form_key} - = - true - form_key - false - - - true - 1 - = - true - ajax - - - true - 1 + + false + = - true - isAjax @@ -3875,8 +3475,8 @@ if (emailsCount < 1) { http UTF-8 - ${base_path}checkout/onepage/saveOrder/ - POST + ${base_path}rest/default/V1/carts/mine/order + PUT true false true @@ -3885,13 +3485,34 @@ if (emailsCount < 1) { + + + + Referer + http://mage2.com/checkout/onepage/ + + + Content-Type + application/json; charset=UTF-8 + + + Accept + application/json + + + X-Requested-With + XMLHttpRequest + + + + - {"success":true,"error":false} + ^"\d+"$ Assertion.response_data false - 2 + 1 diff --git a/dev/tools/performance-toolkit/profiles/ce/extra_large.xml b/setup/performance-toolkit/profiles/ce/extra_large.xml similarity index 100% rename from dev/tools/performance-toolkit/profiles/ce/extra_large.xml rename to setup/performance-toolkit/profiles/ce/extra_large.xml diff --git a/dev/tools/performance-toolkit/profiles/ce/large.xml b/setup/performance-toolkit/profiles/ce/large.xml similarity index 100% rename from dev/tools/performance-toolkit/profiles/ce/large.xml rename to setup/performance-toolkit/profiles/ce/large.xml diff --git a/dev/tools/performance-toolkit/profiles/ce/medium.xml b/setup/performance-toolkit/profiles/ce/medium.xml similarity index 100% rename from dev/tools/performance-toolkit/profiles/ce/medium.xml rename to setup/performance-toolkit/profiles/ce/medium.xml diff --git a/dev/tools/performance-toolkit/profiles/ce/small.xml b/setup/performance-toolkit/profiles/ce/small.xml similarity index 100% rename from dev/tools/performance-toolkit/profiles/ce/small.xml rename to setup/performance-toolkit/profiles/ce/small.xml diff --git a/setup/pub/magento/setup/customize-your-store.js b/setup/pub/magento/setup/customize-your-store.js index 476e4914d4953..2d33921503fa5 100644 --- a/setup/pub/magento/setup/customize-your-store.js +++ b/setup/pub/magento/setup/customize-your-store.js @@ -7,7 +7,7 @@ angular.module('customize-your-store', ['ngStorage', 'ngSanitize']) .controller('customizeYourStoreController', ['$scope', '$localStorage' , '$state', '$http', '$sce', function ($scope, $localStorage, $state, $http, $sce) { $scope.store = { - timezone: 'America/Los_Angeles', + timezone: 'UTC', currency: 'USD', language: 'en_US', useSampleData: false, @@ -28,6 +28,16 @@ angular.module('customize-your-store', ['ngStorage', 'ngSanitize']) $scope.loading = false; + if (!$localStorage.store) { + $http.get('index.php/customize-your-store/default-time-zone',{'responseType' : 'json'}) + .success(function (data) { + $scope.store.timezone = data.defaultTimeZone; + }) + .error(function (data) { + $scope.store.timezone = 'UTC'; + }); + } + if ($localStorage.store) { $scope.store = $localStorage.store; } diff --git a/setup/pub/magento/setup/success.js b/setup/pub/magento/setup/success.js index 134b3a6b5c459..a7581e40de242 100644 --- a/setup/pub/magento/setup/success.js +++ b/setup/pub/magento/setup/success.js @@ -6,9 +6,23 @@ 'use strict'; angular.module('success', ['ngStorage']) .controller('successController', ['$scope', '$localStorage', function ($scope, $localStorage) { + $scope.url = { + front: '', + admin: '' + }; $scope.db = $localStorage.db; $scope.admin = $localStorage.admin; $scope.config = $localStorage.config; + if ($scope.config.https.front) { + $scope.url.front = $scope.config.https.text; + } else { + $scope.url.front = $scope.config.address.actual_base_url; + } + if ($scope.config.https.admin) { + $scope.url.admin = $scope.config.https.text + $scope.config.address.admin + '/'; + } else { + $scope.url.admin = $scope.config.address.actual_base_url + $scope.config.address.admin + '/'; + } $scope.messages = $localStorage.messages; $localStorage.$reset(); }]); diff --git a/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php new file mode 100644 index 0000000000000..5a604c2e8eb9a --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/AbstractDependenciesCommand.php @@ -0,0 +1,86 @@ +setDefinition( + [ + new InputOption( + self::INPUT_KEY_DIRECTORY, + 'd', + InputOption::VALUE_REQUIRED, + 'Path to base directory for parsing', + BP + ), + new InputOption( + self::INPUT_KEY_OUTPUT, + 'o', + InputOption::VALUE_REQUIRED, + 'Report filename', + $this->getDefaultOutputFilename() + ) + ] + ); + parent::configure(); + } + + /** + * Build dependencies report + * + * @param string $outputPath + * @return void + */ + abstract protected function buildReport($outputPath); + + /** + * Get the default output report filename + * + * @return string + */ + abstract protected function getDefaultOutputFilename(); + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + Files::setInstance(new Files($input->getOption(self::INPUT_KEY_DIRECTORY))); + $this->buildReport($input->getOption(self::INPUT_KEY_OUTPUT)); + $output->writeln('Report successfully processed.'); + } catch (\Exception $e) { + $output->writeln( + 'Please check the path you provided. Dependencies report generator failed with error: ' . + $e->getMessage() . '' + ); + } + } +} diff --git a/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php index fab2e492b31e8..ebb36b354cbe7 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractMaintenanceCommand.php @@ -6,6 +6,7 @@ namespace Magento\Setup\Console\Command; use Magento\Framework\App\MaintenanceMode; +use Magento\Setup\Validator\IpValidator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -18,18 +19,25 @@ abstract class AbstractMaintenanceCommand extends AbstractSetupCommand const INPUT_KEY_IP = 'ip'; /** - * @var MaintenanceMode $maintenanceMode + * @var MaintenanceMode */ protected $maintenanceMode; + /** + * @var IpValidator + */ + protected $ipValidator; + /** * Constructor * * @param MaintenanceMode $maintenanceMode + * @param IpValidator $ipValidator */ - public function __construct(MaintenanceMode $maintenanceMode) + public function __construct(MaintenanceMode $maintenanceMode, IpValidator $ipValidator) { $this->maintenanceMode = $maintenanceMode; + $this->ipValidator = $ipValidator; parent::__construct(); } @@ -72,6 +80,12 @@ abstract protected function getDisplayString(); protected function execute(InputInterface $input, OutputInterface $output) { $addresses = $input->getOption(self::INPUT_KEY_IP); + $messages = $this->validate($addresses); + if (!empty($messages)) { + $output->writeln('' . implode('' . PHP_EOL . '', $messages)); + return; + } + $this->maintenanceMode->set($this->isEnable()); $output->writeln($this->getDisplayString()); @@ -85,4 +99,15 @@ protected function execute(InputInterface $input, OutputInterface $output) ); } } + + /** + * Validates IP addresses and return error messages + * + * @param string[] $addresses + * @return string[] + */ + protected function validate(array $addresses) + { + return $this->ipValidator->validateIps($addresses, true); + } } diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php index 9777b23379061..b33d9582e3782 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php @@ -88,16 +88,21 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $modules = $input->getArgument(self::INPUT_KEY_MODULES); } - if (empty($modules)) { - throw new \InvalidArgumentException( - 'No modules specified. Specify a space-separated list of modules or use the --all option' - ); + $messages = $this->validate($modules); + if (!empty($messages)) { + $output->writeln(implode(PHP_EOL, $messages)); + return; } /** * @var \Magento\Framework\Module\Status $status */ $status = $this->objectManagerProvider->get()->get('Magento\Framework\Module\Status'); - $modulesToChange = $status->getModulesToChange($isEnable, $modules); + try { + $modulesToChange = $status->getModulesToChange($isEnable, $modules); + } catch (\LogicException $e) { + $output->writeln('' . $e->getMessage() . ''); + return; + } if (!empty($modulesToChange)) { $force = $input->getOption(self::INPUT_KEY_FORCE); if (!$force) { @@ -136,6 +141,22 @@ protected function execute(InputInterface $input, OutputInterface $output) } } + /** + * Validate list of modules and return error messages + * + * @param string[] $modules + * @return string[] + */ + protected function validate(array $modules) + { + $messages = []; + if (empty($modules)) { + $messages[] = 'No modules specified. Specify a space-separated list of modules' . + ' or use the --all option'; + } + return $messages; + } + /** * Is it "enable" or "disable" command * @@ -156,19 +177,19 @@ private function cleanup(InputInterface $input, OutputInterface $output) /** @var \Magento\Framework\App\Cache $cache */ $cache = $objectManager->get('Magento\Framework\App\Cache'); $cache->clean(); - $output->writeln('Cache cleared successfully.'); + $output->writeln('Cache cleared successfully.'); /** @var \Magento\Framework\App\State\CleanupFiles $cleanupFiles */ $cleanupFiles = $objectManager->get('Magento\Framework\App\State\CleanupFiles'); $cleanupFiles->clearCodeGeneratedClasses(); - $output->writeln('Generated classes cleared successfully.'); + $output->writeln('Generated classes cleared successfully.'); if ($input->getOption(self::INPUT_KEY_CLEAR_STATIC_CONTENT)) { $cleanupFiles->clearMaterializedViewFiles(); - $output->writeln('Generated static view files cleared successfully.'); + $output->writeln('Generated static view files cleared successfully.'); } else { $output->writeln( 'Alert: Generated static view files were not cleared.' . ' You can clear them using the --' . self::INPUT_KEY_CLEAR_STATIC_CONTENT . ' option.' - . ' Failure to clear static view files might cause display issues in the Admin and storefront.' + . ' Failure to clear static view files might cause display issues in the Admin and storefront.' ); } } diff --git a/setup/src/Magento/Setup/Console/Command/AbstractSetupCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractSetupCommand.php index 3b8975c02de35..7803cacfed564 100644 --- a/setup/src/Magento/Setup/Console/Command/AbstractSetupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AbstractSetupCommand.php @@ -11,7 +11,7 @@ /** * An abstract class for all Magento Setup command. - * It adds InitParamListener's magento_init_params option to all setup command. + * It adds InitParamListener's magento-init-params option to all setup command. */ abstract class AbstractSetupCommand extends Command { diff --git a/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php b/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php index 3dd27d09e0c5f..411969ae2d84f 100644 --- a/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php +++ b/setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php @@ -9,6 +9,7 @@ use Magento\Setup\Model\AdminAccount; use Magento\Setup\Model\ConsoleLogger; use Magento\Setup\Model\InstallerFactory; +use Magento\User\Model\UserValidationRules; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,12 +21,19 @@ class AdminUserCreateCommand extends AbstractSetupCommand */ private $installerFactory; + /** + * @var UserValidationRules + */ + private $validationRules; + /** * @param InstallerFactory $installerFactory + * @param UserValidationRules $validationRules */ - public function __construct(InstallerFactory $installerFactory) + public function __construct(InstallerFactory $installerFactory, UserValidationRules $validationRules) { $this->installerFactory = $installerFactory; + $this->validationRules = $validationRules; parent::__construct(); } @@ -49,7 +57,8 @@ protected function execute(InputInterface $input, OutputInterface $output) { $errors = $this->validate($input); if ($errors) { - throw new \InvalidArgumentException(implode("\n", $errors)); + $output->writeln('' . implode('' . PHP_EOL . '', $errors) . ''); + return; } $installer = $this->installerFactory->create(new ConsoleLogger($output)); $installer->installAdminUser($input->getOptions()); @@ -65,7 +74,7 @@ public function getOptionsList() { return [ new InputOption(AdminAccount::KEY_USER, null, InputOption::VALUE_REQUIRED, 'Admin user'), - new InputOption(AdminAccount::KEY_PASSWORD, null, InputOption::VALUE_REQUIRED, 'Admin password'), + new InputOption(AdminAccount::KEY_PASSWORD, null, InputOption::VALUE_REQUIRED, 'Admin password', ''), new InputOption(AdminAccount::KEY_EMAIL, null, InputOption::VALUE_REQUIRED, 'Admin email'), new InputOption(AdminAccount::KEY_FIRST_NAME, null, InputOption::VALUE_REQUIRED, 'Admin first name'), new InputOption(AdminAccount::KEY_LAST_NAME, null, InputOption::VALUE_REQUIRED, 'Admin last name'), @@ -81,18 +90,21 @@ public function getOptionsList() public function validate(InputInterface $input) { $errors = []; - $required = [ - AdminAccount::KEY_USER, - AdminAccount::KEY_PASSWORD, - AdminAccount::KEY_EMAIL, - AdminAccount::KEY_FIRST_NAME, - AdminAccount::KEY_LAST_NAME, - ]; - foreach ($required as $key) { - if (!$input->getOption($key)) { - $errors[] = 'Missing option ' . $key; - } + $user = new \Magento\Framework\Object(); + $user->setFirstname($input->getOption(AdminAccount::KEY_FIRST_NAME)) + ->setLastname($input->getOption(AdminAccount::KEY_LAST_NAME)) + ->setUsername($input->getOption(AdminAccount::KEY_USER)) + ->setEmail($input->getOption(AdminAccount::KEY_EMAIL)) + ->setPassword($input->getOption(AdminAccount::KEY_PASSWORD)); + + $validator = new \Magento\Framework\Validator\Object; + $this->validationRules->addUserInfoRules($validator); + $this->validationRules->addPasswordRules($validator); + + if (!$validator->isValid($user)) { + $errors = array_merge($errors, $validator->getMessages()); } + return $errors; } } diff --git a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php index 6a86ee2ce9a8a..eaca97c02042a 100644 --- a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php @@ -7,6 +7,7 @@ namespace Magento\Setup\Console\Command; use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Config\ConfigOptionsListConstants; use Magento\Framework\Module\ModuleList; use Magento\Setup\Model\ConfigModel; use Symfony\Component\Console\Input\InputInterface; @@ -104,9 +105,15 @@ function ($value) { ); $optionsToChange = array_intersect(array_keys($inputOptions), array_keys($commandOptions)); + $optionsToChange = array_diff($optionsToChange, [ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION]); $this->configModel->process($inputOptions); + $optionsWithDefaultValues = array_diff( + $optionsWithDefaultValues, + [ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION] + ); + if (count($optionsWithDefaultValues) > 0) { $defaultValuesMessage = implode(', ', $optionsWithDefaultValues); $output->writeln( @@ -134,7 +141,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) foreach ($errors as $error) { $output->writeln("$error"); } - throw new \InvalidArgumentException('Parameters validation is failed'); + throw new \InvalidArgumentException('Parameter validation failed'); } } } diff --git a/setup/src/Magento/Setup/Console/Command/DependenciesShowFrameworkCommand.php b/setup/src/Magento/Setup/Console/Command/DependenciesShowFrameworkCommand.php new file mode 100644 index 0000000000000..c665ff7f3edcc --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/DependenciesShowFrameworkCommand.php @@ -0,0 +1,81 @@ +directoryList = $directoryList; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setDescription('Shows number of dependencies on Magento framework') + ->setName('info:dependencies:show-framework'); + parent::configure(); + } + + /** + * Return default output filename for framework dependencies report + * + * @return string + */ + protected function getDefaultOutputFilename() + { + return 'framework-dependencies.csv'; + } + + /** + * Build Framework dependencies report + * + * @param string $outputPath + * @return void + */ + protected function buildReport($outputPath) + { + $root = $this->directoryList->getRoot(); + $filePath = str_replace( + $root, + Files::init()->getPathToSource(), + $this->directoryList->getPath(DirectoryList::MODULES) . '/Magento' + ); + $filesForParse = Files::init()->getFiles([$filePath], '*'); + $configFiles = Files::init()->getConfigFiles('module.xml', [], false); + + ServiceLocator::getFrameworkDependenciesReportBuilder()->build( + [ + 'parse' => [ + 'files_for_parse' => $filesForParse, + 'config_files' => $configFiles, + 'declared_namespaces' => Files::init()->getNamespaces(), + ], + 'write' => ['report_filename' => $outputPath], + ] + ); + } +} diff --git a/setup/src/Magento/Setup/Console/Command/DependenciesShowModulesCircularCommand.php b/setup/src/Magento/Setup/Console/Command/DependenciesShowModulesCircularCommand.php new file mode 100644 index 0000000000000..01b2208f57f13 --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/DependenciesShowModulesCircularCommand.php @@ -0,0 +1,53 @@ +setDescription('Shows number of circular dependencies between modules') + ->setName('info:dependencies:show-modules-circular'); + parent::configure(); + } + + /** + * Return default output filename for modules circular dependencies report + * + * @return string + */ + protected function getDefaultOutputFilename() + { + return 'modules-circular-dependencies.csv'; + } + + /** + * Build circular dependencies between modules report + * + * @param string $outputPath + * @return void + */ + protected function buildReport($outputPath) + { + $filesForParse = Files::init()->getComposerFiles('code', false); + + ServiceLocator::getCircularDependenciesReportBuilder()->build( + [ + 'parse' => ['files_for_parse' => $filesForParse], + 'write' => ['report_filename' => $outputPath], + ] + ); + } +} diff --git a/setup/src/Magento/Setup/Console/Command/DependenciesShowModulesCommand.php b/setup/src/Magento/Setup/Console/Command/DependenciesShowModulesCommand.php new file mode 100644 index 0000000000000..429d36c89d00f --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/DependenciesShowModulesCommand.php @@ -0,0 +1,53 @@ +setDescription('Shows number of dependencies between modules') + ->setName('info:dependencies:show-modules'); + parent::configure(); + } + + /** + * Return default output filename for modules dependencies report + * + * @return string + */ + protected function getDefaultOutputFilename() + { + return 'modules-dependencies.csv'; + } + + /** + * Build circular dependencies between modules report + * + * @param string $outputPath + * @return void + */ + protected function buildReport($outputPath) + { + $filesForParse = Files::init()->getComposerFiles('code', false); + + ServiceLocator::getDependenciesReportBuilder()->build( + [ + 'parse' => ['files_for_parse' => $filesForParse], + 'write' => ['report_filename' => $outputPath], + ] + ); + } +} diff --git a/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php b/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php index 5cde08cd967e9..715e919ce1290 100644 --- a/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php @@ -13,6 +13,7 @@ use Magento\Framework\App\DeploymentConfig; use Symfony\Component\Console\Input\InputArgument; use Magento\Setup\Model\ObjectManagerProvider; +use Magento\Framework\Validator\Locale; /** * Command for deploy static content @@ -43,16 +44,26 @@ class DeployStaticContentCommand extends Command */ private $deploymentConfig; + /** + * @var Locale + */ + private $validator; + /** * Inject dependencies * * @param ObjectManagerProvider $objectManagerProvider * @param DeploymentConfig $deploymentConfig + * @param Locale $validator */ - public function __construct(ObjectManagerProvider $objectManagerProvider, DeploymentConfig $deploymentConfig) - { + public function __construct( + ObjectManagerProvider $objectManagerProvider, + DeploymentConfig $deploymentConfig, + Locale $validator + ) { $this->objectManagerProvider = $objectManagerProvider; $this->deploymentConfig = $deploymentConfig; + $this->validator = $validator; parent::__construct(); } @@ -94,9 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $languages = $input->getArgument(self::LANGUAGE_OPTION); foreach ($languages as $lang) { - if (!preg_match('/^[a-z]{2}_[A-Z]{2}$/', $lang)) { + + if (!$this->validator->isValid($lang)) { throw new \InvalidArgumentException( - $lang . ' argument has invalid value format' + $lang . ' argument has invalid value, please run info:language:list for list of available locales' ); } } diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 8236627a40caf..9c75faf07f034 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -101,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output) 'application' => '#^' . $appCodePath . '/[\\w]+/[\\w]+/Test#', 'framework' => '#^' . $libraryPath . '/[\\w]+/[\\w]+/([\\w]+/)?Test#' ]; + $dataAttributesIncludePattern = [ + 'service_data_attributes' => '/\/etc\/([a-zA-Z_]*\/service_data_attributes|service_data_attributes)\.xml$/' + ]; $this->configureObjectManager($output); $operations = [ @@ -108,6 +111,10 @@ protected function execute(InputInterface $input, OutputInterface $output) 'path' => $compiledPathsList['application'], 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'] ], + OperationFactory::DATA_ATTRIBUTES_GENERATOR => [ + 'path' => $compiledPathsList['application'], + 'filePatterns' => $dataAttributesIncludePattern + ], OperationFactory::APPLICATION_CODE_GENERATOR => [ $compiledPathsList['application'], $compiledPathsList['library'], diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php index 6f37a57c9c00c..941d21c21a712 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php @@ -5,7 +5,6 @@ */ namespace Magento\Setup\Console\Command; -use Magento\Store\Model\StoreManager; use Magento\Setup\Model\ObjectManagerProvider; use Magento\Framework\App\ObjectManager; use Symfony\Component\Console\Input\InputInterface; @@ -48,6 +47,13 @@ class DiCompileMultiTenantCommand extends AbstractSetupCommand const INPUT_KEY_EXCLUDE_PATTERN= 'exclude-pattern'; /**#@- */ + /**#@+ + * Possible values for serializer + */ + const SERIALIZER_VALUE_SERIALIZE = 'serialize'; + const SERIALIZER_VALUE_IGBINARY = 'igbinary'; + /**#@- */ + /** * Object Manager * @@ -109,7 +115,8 @@ protected function configure() self::INPUT_KEY_SERIALIZER, null, InputOption::VALUE_REQUIRED, - 'Serializer function that should be used (serialize|igbinary) default: serialize' + 'Serializer function that should be used (' . self::SERIALIZER_VALUE_SERIALIZE . '|' + . self::SERIALIZER_VALUE_IGBINARY . ') default: ' . self::SERIALIZER_VALUE_SERIALIZE ), new InputOption( self::INPUT_KEY_EXTRA_CLASSES_FILE, @@ -150,6 +157,12 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $errors = $this->validate($input); + if ($errors) { + $output->writeln($errors); + return; + } + $generationDir = $input->getOption(self::INPUT_KEY_GENERATION) ? $input->getOption(self::INPUT_KEY_GENERATION) : $this->directoryList->getPath(DirectoryList::GENERATION); $testExcludePatterns = [ @@ -359,4 +372,77 @@ private function compileCode($generationDir, $fileExcludePatterns, $input) } file_put_contents($pluginDefFile, $outputContent); } + + /** + * Check if all option values provided by the user are valid + * + * @param InputInterface $input + * @return string[] + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + private function validate(InputInterface $input) + { + $errors = []; + $options = $input->getOptions(); + foreach ($options as $key => $value) { + if (!$value) { + continue; + } + switch ($key) { + case self::INPUT_KEY_SERIALIZER: + if (($value !== self::SERIALIZER_VALUE_SERIALIZE) && ($value !== self::SERIALIZER_VALUE_IGBINARY)) { + $errors[] = 'Invalid value for command option \'' . self::INPUT_KEY_SERIALIZER + . '\'. Possible values (' . self::SERIALIZER_VALUE_SERIALIZE . '|' + . self::SERIALIZER_VALUE_IGBINARY . ').'; + } + break; + case self::INPUT_KEY_EXTRA_CLASSES_FILE: + if (!file_exists($value)) { + $errors[] = 'Path does not exist for the value of command option \'' + . self::INPUT_KEY_EXTRA_CLASSES_FILE . '\'.'; + } + break; + case self::INPUT_KEY_GENERATION: + $errorMsg = $this->validateOutputPath($value, self::INPUT_KEY_GENERATION); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case self::INPUT_KEY_DI: + $errorMsg = $this->validateOutputPath($value, self::INPUT_KEY_DI); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case self::INPUT_KEY_EXCLUDE_PATTERN: + if (@preg_match($value, null) === false) { + $errors[] = 'Invalid pattern for command option \'' . self::INPUT_KEY_EXCLUDE_PATTERN + . '\'.'; + } + break; + } + } + return $errors; + } + + /** + * Validate output path based on type + * + * @param string $value + * @param string $type + * @return string + */ + private function validateOutputPath($value, $type) + { + $errorMsg = ''; + if (!file_exists($value)) { + $errorMsg = 'Path does not exist for the value of command option \'' . $type . '\'.'; + } + if (file_exists($value) && !is_writeable($value)) { + $errorMsg .= 'Non-writable directory is provided by the value of command option \'' + . $type . '\'.'; + + } + return $errorMsg; + } } diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php new file mode 100644 index 0000000000000..e61ca8a3c7df0 --- /dev/null +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -0,0 +1,123 @@ +fixtureModel = $fixtureModel; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('setup:performance:generate-fixtures') + ->setDescription('Generates fixtures') + ->setDefinition([ + new InputArgument( + self::PROFILE_ARGUMENT, + InputArgument::REQUIRED, + 'Path to profile configuration file' + ), + new InputOption( + self::SKIP_REINDEX_OPTION, + 's', + InputOption::VALUE_NONE, + 'Skip reindex' + ) + ]); + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + $totalStartTime = microtime(true); + + $fixtureModel = $this->fixtureModel; + $fixtureModel->initObjectManager(); + $fixtureModel->loadFixtures(); + $fixtureModel->loadConfig($input->getArgument(self::PROFILE_ARGUMENT)); + + $output->writeln('Generating profile with following params:'); + + foreach ($fixtureModel->getParamLabels() as $configKey => $label) { + $output->writeln(' |- ' . $label . ': ' . $fixtureModel->getValue($configKey) . ''); + } + + /** @var $config \Magento\Indexer\Model\Config */ + $config = $fixtureModel->getObjectManager()->get('Magento\Indexer\Model\Config'); + $indexerListIds = $config->getIndexers(); + /** @var $indexerRegistry \Magento\Indexer\Model\IndexerRegistry */ + $indexerRegistry = $fixtureModel->getObjectManager()->create('Magento\Indexer\Model\IndexerRegistry'); + $indexersState = []; + foreach ($indexerListIds as $indexerId) { + $indexer = $indexerRegistry->get($indexerId['indexer_id']); + $indexersState[$indexerId['indexer_id']] = $indexer->isScheduled(); + $indexer->setScheduled(true); + } + + foreach ($fixtureModel->getFixtures() as $fixture) { + $output->write($fixture->getActionTitle() . '... '); + $startTime = microtime(true); + $fixture->execute(); + $endTime = microtime(true); + $resultTime = $endTime - $startTime; + $output->writeln(' done in ' . gmdate('H:i:s', $resultTime)); + } + + foreach ($indexerListIds as $indexerId) { + /** @var $indexer \Magento\Indexer\Model\Indexer */ + $indexer = $indexerRegistry->get($indexerId['indexer_id']); + $indexer->setScheduled($indexersState[$indexerId['indexer_id']]); + } + + if (!$input->getOption(self::SKIP_REINDEX_OPTION)) { + $fixtureModel->reindex($output); + } + + $totalEndTime = microtime(true); + $totalResultTime = $totalEndTime - $totalStartTime; + + $output->writeln('Total execution time: ' . gmdate('H:i:s', $totalResultTime) . ''); + } catch (\Exception $e) { + $output->writeln('' . $e->getMessage() . ''); + } + } +} diff --git a/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php index 4e2aba2b3ab85..e39d0292876f6 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoCurrencyListCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; -use Magento\Setup\Model\Lists; +use Magento\Framework\Setup\Lists; /** * Command prints list of available currencies @@ -48,8 +48,13 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $table = $this->getHelperSet()->get('table'); + $table->setHeaders(['Currency', 'Code']); + foreach ($this->lists->getCurrencyList() as $key => $currency) { - $output->writeln($key . ' => ' . $currency); + $table->addRow([$currency, $key]); } + + $table->render($output); } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php index 6066baeadda4f..648a3490f71a7 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoLanguageListCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; -use Magento\Setup\Model\Lists; +use Magento\Framework\Setup\Lists; /** * Command prints list of available language locales @@ -48,8 +48,14 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $table = $this->getHelperSet()->get('table'); + $table->setHeaders(['Language', 'Code']); + foreach ($this->lists->getLocaleList() as $key => $locale) { - $output->writeln($key . ' => ' . $locale); + $table->addRow([$locale, $key]); } + + $table->render($output); + } } diff --git a/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php b/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php index 4cb013b4dfa07..fd79c63770508 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; -use Magento\Setup\Model\Lists; +use Magento\Framework\Setup\Lists; /** * Command prints list of available timezones @@ -48,8 +48,13 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $table = $this->getHelperSet()->get('table'); + $table->setHeaders(['Timezone', 'Code']); + foreach ($this->lists->getTimezoneList() as $key => $timezone) { - $output->writeln($key . ' => ' . $timezone); + $table->addRow([$timezone, $key]); } + + $table->render($output); } } diff --git a/setup/src/Magento/Setup/Console/Command/InstallCommand.php b/setup/src/Magento/Setup/Console/Command/InstallCommand.php index 2601e45b7aa1e..3bc8622022592 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallCommand.php @@ -14,23 +14,29 @@ /** * Command to install Magento application + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InstallCommand extends AbstractSetupCommand { /** * Parameter indicating command whether to cleanup database in the install routine */ - const INPUT_KEY_CLEANUP_DB = 'cleanup_database'; + const INPUT_KEY_CLEANUP_DB = 'cleanup-database'; /** * Parameter to specify an order_increment_prefix */ - const INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX = 'sales_order_increment_prefix'; + const INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX = 'sales-order-increment-prefix'; /** * Parameter indicating command whether to install Sample Data */ - const INPUT_KEY_USE_SAMPLE_DATA = 'use_sample_data'; + const INPUT_KEY_USE_SAMPLE_DATA = 'use-sample-data'; + + /** + * Regex for sales_order_increment_prefix validation. + */ + const SALES_ORDER_INCREMENT_PREFIX_RULE = '/^.{0,20}$/'; /** * Installer service factory @@ -134,11 +140,34 @@ protected function initialize(InputInterface $input, OutputInterface $output) } $errors = $this->configModel->validate($configOptionsToValidate); $errors = array_merge($errors, $this->adminUser->validate($input)); + $errors = array_merge($errors, $this->validate($input)); + $errors = array_merge($errors, $this->userConfig->validate($input)); + if (!empty($errors)) { foreach ($errors as $error) { $output->writeln("$error"); } - throw new \InvalidArgumentException('Parameters validation is failed'); + throw new \InvalidArgumentException('Parameter validation failed'); + } + } + + /** + * Validate sales_order_increment_prefix value + * + * It will save the value which discarding characters after 20th to the database so it should be + * validated in advance. + * + * @param InputInterface $input + * @return string[] Array of error messages + */ + public function validate(InputInterface $input) + { + $errors = []; + $value = $input->getOption(self::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX); + if (preg_match(self::SALES_ORDER_INCREMENT_PREFIX_RULE, $value) != 1) { + $errors[] = 'Validation failed, ' . self::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX + . ' must be 20 characters or less'; } + return $errors; } } diff --git a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php index ae4eb99fa86c4..d1641d960e9fa 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php @@ -13,6 +13,14 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Magento\Setup\Model\StoreConfigurationDataMapper; +use Magento\Setup\Model\ObjectManagerProvider; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Store\Model\Store; +use Magento\Framework\Validator\Locale; +use Magento\Framework\Validator\Timezone; +use Magento\Framework\Validator\Currency; +use Magento\Framework\Url\Validator; class InstallStoreConfigurationCommand extends AbstractSetupCommand { @@ -28,18 +36,28 @@ class InstallStoreConfigurationCommand extends AbstractSetupCommand */ private $deploymentConfig; + /** + * Object Manager + * + * @var ObjectManagerInterface + */ + private $objectManager; + /** * Inject dependencies * * @param InstallerFactory $installerFactory * @param DeploymentConfig $deploymentConfig + * @param ObjectManagerProvider $objectManagerProvider */ public function __construct( InstallerFactory $installerFactory, - DeploymentConfig $deploymentConfig + DeploymentConfig $deploymentConfig, + ObjectManagerProvider $objectManagerProvider ) { $this->installerFactory = $installerFactory; $this->deploymentConfig = $deploymentConfig; + $this->objectManager = $objectManagerProvider->get(); parent::__construct(); } @@ -65,6 +83,11 @@ protected function execute(InputInterface $input, OutputInterface $output) ); return; } + $errors = $this->validate($input); + if ($errors) { + $output->writeln($errors); + return; + } $installer = $this->installerFactory->create(new ConsoleLogger($output)); $installer->installUserConfig($input->getOptions()); } @@ -133,4 +156,140 @@ public function getOptionsList() ), ]; } + + /** + * Check if option values provided by the user are valid + * + * @param InputInterface $input + * @return string[] + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + public function validate(InputInterface $input) + { + $errors = []; + $options = $input->getOptions(); + foreach ($options as $key => $value) { + if (!$value) { + continue; + } + switch ($key) { + case StoreConfigurationDataMapper::KEY_BASE_URL: + /** @var Validator $url */ + $url = $this->objectManager->get('Magento\Framework\Url\Validator'); + if (!$url->isValid($value)) { + $errorMsgs = $url->getMessages(); + $errors[] = '' . 'Command option \'' . StoreConfigurationDataMapper::KEY_BASE_URL + . '\': ' . $errorMsgs[Validator::INVALID_URL] .''; + } + break; + case StoreConfigurationDataMapper::KEY_LANGUAGE: + /** @var Locale $lists */ + $lists = $this->objectManager->get('Magento\Framework\Validator\Locale'); + $errorMsg = $this->validateCodes($lists, $value, StoreConfigurationDataMapper::KEY_LANGUAGE); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case StoreConfigurationDataMapper::KEY_TIMEZONE: + /** @var Timezone $lists */ + $lists = $this->objectManager->get('Magento\Framework\Validator\Timezone'); + $errorMsg = $this->validateCodes($lists, $value, StoreConfigurationDataMapper::KEY_TIMEZONE); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case StoreConfigurationDataMapper::KEY_CURRENCY: + /** @var Currency $lists */ + $lists = $this->objectManager->get('Magento\Framework\Validator\Currency'); + $errorMsg = $this->validateCodes($lists, $value, StoreConfigurationDataMapper::KEY_CURRENCY); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case StoreConfigurationDataMapper::KEY_USE_SEF_URL: + $errorMsg = $this->validateBinaryValue($value, StoreConfigurationDataMapper::KEY_USE_SEF_URL); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case StoreConfigurationDataMapper::KEY_IS_SECURE: + $errorMsg = $this->validateBinaryValue($value, StoreConfigurationDataMapper::KEY_IS_SECURE); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case StoreConfigurationDataMapper::KEY_BASE_URL_SECURE: + try { + /** @var Validator $url */ + $url = $this->objectManager->get('Magento\Framework\Url\Validator'); + $errorMsgs = ''; + if (!$url->isValid($value)) { + $errorMsgs = $url->getMessages(); + if (!empty($errorMsgs)) { + $errors[] = '' . 'Command option \'' + . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE + . '\': ' . $errorMsgs[Validator::INVALID_URL] .''; + } + } + if (empty($errorMsgs) && strpos($value, 'https:') === false) { + throw new LocalizedException(new \Magento\Framework\Phrase("Invalid secure URL.")); + } + } catch (LocalizedException $e) { + $errors[] = '' . 'Command option \'' . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE + . '\': ' . $e->getLogMessage() .''; + } + break; + case StoreConfigurationDataMapper::KEY_IS_SECURE_ADMIN: + $errorMsg = $this->validateBinaryValue($value, StoreConfigurationDataMapper::KEY_IS_SECURE_ADMIN); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + case StoreConfigurationDataMapper::KEY_ADMIN_USE_SECURITY_KEY: + $errorMsg = $this->validateBinaryValue( + $value, + StoreConfigurationDataMapper::KEY_ADMIN_USE_SECURITY_KEY + ); + if ($errorMsg !== '') { + $errors[] = $errorMsg; + } + break; + } + } + return $errors; + } + + /** + * Validate binary value for a specified key + * + * @param string $value + * @param string $key + * @return string + */ + private function validateBinaryValue($value, $key) + { + $errorMsg = ''; + if ($value !== '0' && $value !== '1') { + $errorMsg = '' . 'Command option \'' . $key . '\': Invalid value. Possible values (0|1).'; + } + return $errorMsg; + } + + /** + * Validate codes for languages, currencies or timezones + * + * @param Locale|Timezone|Currency $lists + * @param string $code + * @param string $type + * @return string + */ + private function validateCodes($lists, $code, $type) + { + $errorMsg = ''; + if (!$lists->isValid($code)) { + $errorMsg = '' . 'Command option \'' . $type . '\': Invalid value. To see possible values, ' + . "run command 'bin/magento info:" . $type . ':list\'.'; + } + return $errorMsg; + } } diff --git a/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php b/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php index 3aad4d09d1603..121c1cf4852e2 100644 --- a/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php +++ b/setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php @@ -8,6 +8,7 @@ use Magento\Framework\App\MaintenanceMode; use Magento\Framework\Module\ModuleList; +use Magento\Setup\Validator\IpValidator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -25,18 +26,25 @@ class MaintenanceAllowIpsCommand extends AbstractSetupCommand const INPUT_KEY_NONE = 'none'; /** - * @var MaintenanceMode $maintenanceMode + * @var MaintenanceMode */ private $maintenanceMode; + /** + * @var IpValidator + */ + private $ipValidator; + /** * Constructor * * @param MaintenanceMode $maintenanceMode + * @param IpValidator $ipValidator */ - public function __construct(MaintenanceMode $maintenanceMode) + public function __construct(MaintenanceMode $maintenanceMode, IpValidator $ipValidator) { $this->maintenanceMode = $maintenanceMode; + $this->ipValidator = $ipValidator; parent::__construct(); } @@ -75,6 +83,12 @@ protected function execute(InputInterface $input, OutputInterface $output) { if (!$input->getOption(self::INPUT_KEY_NONE)) { $addresses = $input->getArgument(self::INPUT_KEY_IP); + $messages = $this->validate($addresses); + if (!empty($messages)) { + $output->writeln('' . implode('' . PHP_EOL . '', $messages)); + return; + } + if (!empty($addresses)) { $this->maintenanceMode->setAddresses(implode(',', $addresses)); $output->writeln( @@ -87,4 +101,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Set exempt IP-addresses: none'); } } + + /** + * Validates IP addresses and return error messages + * + * @param string[] $addresses + * @return string[] + */ + protected function validate(array $addresses) + { + return $this->ipValidator->validateIps($addresses, false); + } } diff --git a/setup/src/Magento/Setup/Console/CommandList.php b/setup/src/Magento/Setup/Console/CommandList.php index 0cb36548c556e..da9f1a45ff92d 100644 --- a/setup/src/Magento/Setup/Console/CommandList.php +++ b/setup/src/Magento/Setup/Console/CommandList.php @@ -43,9 +43,13 @@ protected function getCommandsClasses() 'Magento\Setup\Console\Command\DbDataUpgradeCommand', 'Magento\Setup\Console\Command\DbSchemaUpgradeCommand', 'Magento\Setup\Console\Command\DbStatusCommand', + 'Magento\Setup\Console\Command\DependenciesShowFrameworkCommand', + 'Magento\Setup\Console\Command\DependenciesShowModulesCircularCommand', + 'Magento\Setup\Console\Command\DependenciesShowModulesCommand', 'Magento\Setup\Console\Command\DeployStaticContentCommand', 'Magento\Setup\Console\Command\DiCompileCommand', 'Magento\Setup\Console\Command\DiCompileMultiTenantCommand', + 'Magento\Setup\Console\Command\GenerateFixturesCommand', 'Magento\Setup\Console\Command\I18nCollectPhrasesCommand', 'Magento\Setup\Console\Command\I18nPackCommand', 'Magento\Setup\Console\Command\InfoCurrencyListCommand', diff --git a/setup/src/Magento/Setup/Controller/CustomizeYourStore.php b/setup/src/Magento/Setup/Controller/CustomizeYourStore.php index 8598b2465d205..11e2a4b490064 100644 --- a/setup/src/Magento/Setup/Controller/CustomizeYourStore.php +++ b/setup/src/Magento/Setup/Controller/CustomizeYourStore.php @@ -5,10 +5,11 @@ */ namespace Magento\Setup\Controller; -use Magento\Setup\Model\Lists; +use Magento\Framework\Setup\Lists; use Magento\Setup\Model\SampleData; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; +use Zend\View\Model\JsonModel; class CustomizeYourStore extends AbstractActionController { @@ -46,4 +47,19 @@ public function indexAction() $view->setTerminal(true); return $view; } + + /** + * Getting default time zone from server settings + * + * @return JsonModel + */ + public function defaultTimeZoneAction() + { + $defaultTimeZone = trim(@date_default_timezone_get()); + if (empty($defaultTimeZone)) { + return new JsonModel(['defaultTimeZone' => 'UTC']); + } else { + return new JsonModel(['defaultTimeZone' => $defaultTimeZone]); + } + } } diff --git a/setup/src/Magento/Setup/Controller/DatabaseCheck.php b/setup/src/Magento/Setup/Controller/DatabaseCheck.php index 809496c9a6a03..959c4ccc64d51 100644 --- a/setup/src/Magento/Setup/Controller/DatabaseCheck.php +++ b/setup/src/Magento/Setup/Controller/DatabaseCheck.php @@ -10,16 +10,10 @@ use Zend\Json\Json; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; +use Magento\Setup\Validator\DbValidator; class DatabaseCheck extends AbstractActionController { - /** - * Installer service factory - * - * @var \Magento\Setup\Model\InstallerFactory - */ - private $installerFactory; - /** * WebLogger to access log * @@ -27,16 +21,22 @@ class DatabaseCheck extends AbstractActionController */ private $webLogger; + /** + * @var DbValidator + */ + private $dbValidator; + + /** * Constructor * - * @param InstallerFactory $installerFactory * @param WebLogger $webLogger + * @param DbValidator $dbValidator */ - public function __construct(InstallerFactory $installerFactory, WebLogger $webLogger) + public function __construct(WebLogger $webLogger, DbValidator $dbValidator) { - $this->installerFactory = $installerFactory; $this->webLogger = $webLogger; + $this->dbValidator = $dbValidator; } /** @@ -49,11 +49,10 @@ public function indexAction() $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); try { - $installer = $this->installerFactory->create($this->webLogger); $password = isset($params['password']) ? $params['password'] : ''; - $installer->checkDatabaseConnection($params['name'], $params['host'], $params['user'], $password); + $this->dbValidator->checkDatabaseConnection($params['name'], $params['host'], $params['user'], $password); $tablePrefix = isset($params['tablePrefix']) ? $params['tablePrefix'] : ''; - $installer->checkDatabaseTablePrefix($tablePrefix); + $this->dbValidator->checkDatabaseTablePrefix($tablePrefix); return new JsonModel(['success' => true]); } catch (\Exception $e) { return new JsonModel(['success' => false, 'error' => $e->getMessage()]); diff --git a/setup/src/Magento/Setup/Controller/Index.php b/setup/src/Magento/Setup/Controller/Index.php index 54a8eac9901da..1c239ab77aaac 100644 --- a/setup/src/Magento/Setup/Controller/Index.php +++ b/setup/src/Magento/Setup/Controller/Index.php @@ -8,14 +8,51 @@ use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; +use Magento\Setup\Model\ObjectManagerProvider; +/** + * Main controller of the Setup Wizard + */ class Index extends AbstractActionController { /** - * @return ViewModel + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + /** + * @param ObjectManagerProvider $objectManagerProvider + */ + public function __construct( + ObjectManagerProvider $objectManagerProvider + ) { + $this->objectManager = $objectManagerProvider->get(); + } + + /** + * @return ViewModel|\Zend\Http\Response */ public function indexAction() { - return new ViewModel; + if ($this->objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { + /** @var \Magento\Framework\App\State $adminAppState */ + $adminAppState = $this->objectManager->get('Magento\Framework\App\State'); + $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); + + $this->objectManager->create( + 'Magento\Backend\Model\Auth\Session', + [ + 'sessionConfig' => $this->objectManager->get('Magento\Backend\Model\Session\AdminConfig'), + 'appState' => $adminAppState + ] + ); + if (!$this->objectManager->get('Magento\Backend\Model\Auth')->isLoggedIn()) { + $view = new ViewModel(); + $view->setTemplate('/error/401.phtml'); + $this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_401); + return $view; + } + } + return new ViewModel(); } } diff --git a/setup/src/Magento/Setup/Controller/Install.php b/setup/src/Magento/Setup/Controller/Install.php index 87ca5ba26940a..7333add5e8aed 100644 --- a/setup/src/Magento/Setup/Controller/Install.php +++ b/setup/src/Magento/Setup/Controller/Install.php @@ -7,7 +7,7 @@ namespace Magento\Setup\Controller; use Magento\Setup\Model\AdminAccount; -use Magento\Framework\Config\ConfigOptionsList as SetupConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants as SetupConfigOptionsList; use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList; use Magento\Setup\Model\Installer; use Magento\Setup\Model\Installer\ProgressFactory; diff --git a/dev/tools/performance-toolkit/fixtures/cart_price_rules.php b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php similarity index 91% rename from dev/tools/performance-toolkit/fixtures/cart_price_rules.php rename to setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php index 93a95e98c9f8c..3cb6ab044b099 100644 --- a/dev/tools/performance-toolkit/fixtures/cart_price_rules.php +++ b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class CartPriceRulesFixture */ -class CartPriceRulesFixture extends \Magento\ToolkitFramework\Fixture +class CartPriceRulesFixture extends Fixture { /** * @var int @@ -16,25 +18,26 @@ class CartPriceRulesFixture extends \Magento\ToolkitFramework\Fixture /** * {@inheritdoc} + * @SuppressWarnings(PHPMD) */ public function execute() { - $this->application->resetObjectManager(); - $cartPriceRulesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('cart_price_rules', 0); + $this->fixtureModel->resetObjectManager(); + $cartPriceRulesCount = $this->fixtureModel->getValue('cart_price_rules', 0); if (!$cartPriceRulesCount) { return; } - $cartPriceRulesProductsFloor = \Magento\ToolkitFramework\Config::getInstance()->getValue( + $cartPriceRulesProductsFloor = $this->fixtureModel->getValue( 'cart_price_rules_floor', 3 ); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); /** @var $model \Magento\SalesRule\Model\Rule*/ - $model = $this->application->getObjectManager()->get('Magento\SalesRule\Model\Rule'); + $model = $this->fixtureModel->getObjectManager()->get('Magento\SalesRule\Model\Rule'); //Get all websites $categoriesArray = []; @@ -192,5 +195,3 @@ public function introduceParamLabels() ]; } } - -return new CartPriceRulesFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/catalog_price_rules.php b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php similarity index 89% rename from dev/tools/performance-toolkit/fixtures/catalog_price_rules.php rename to setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php index 8ccf546687232..3fd0e674ec200 100644 --- a/dev/tools/performance-toolkit/fixtures/catalog_price_rules.php +++ b/setup/src/Magento/Setup/Fixtures/CatalogPriceRulesFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class CatalogPriceRulesFixture */ -class CatalogPriceRulesFixture extends \Magento\ToolkitFramework\Fixture +class CatalogPriceRulesFixture extends Fixture { /** * @var int @@ -16,21 +18,22 @@ class CatalogPriceRulesFixture extends \Magento\ToolkitFramework\Fixture /** * {@inheritdoc} + * @SuppressWarnings(PHPMD) */ public function execute() { - $catalogPriceRulesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('catalog_price_rules', 0); + $catalogPriceRulesCount = $this->fixtureModel->getValue('catalog_price_rules', 0); if (!$catalogPriceRulesCount) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); /** @var $model \Magento\CatalogRule\Model\Rule*/ - $model = $this->application->getObjectManager()->get('Magento\CatalogRule\Model\Rule'); + $model = $this->fixtureModel->getObjectManager()->get('Magento\CatalogRule\Model\Rule'); //Get all websites $categoriesArray = []; $websites = $storeManager->getWebsites(); @@ -146,5 +149,3 @@ public function introduceParamLabels() ]; } } - -return new CatalogPriceRulesFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/categories.php b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php similarity index 76% rename from dev/tools/performance-toolkit/fixtures/categories.php rename to setup/src/Magento/Setup/Fixtures/CategoriesFixture.php index 75b2444ff38d4..f4e52eac26142 100644 --- a/dev/tools/performance-toolkit/fixtures/categories.php +++ b/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class CategoriesFixture */ -class CategoriesFixture extends \Magento\ToolkitFramework\Fixture +class CategoriesFixture extends Fixture { /** * @var int @@ -19,19 +21,18 @@ class CategoriesFixture extends \Magento\ToolkitFramework\Fixture */ public function execute() { - $categoriesNumber = \Magento\ToolkitFramework\Config::getInstance()->getValue('categories', 0); + $categoriesNumber = $this->fixtureModel->getValue('categories', 0); if (!$categoriesNumber) { return; } - $maxNestingLevel = \Magento\ToolkitFramework\Config::getInstance()->getValue('categories_nesting_level', 3); - $this->application->resetObjectManager(); + $maxNestingLevel = $this->fixtureModel->getValue('categories_nesting_level', 3); + $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->create('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\Category'); - $groups = []; $storeGroups = $storeManager->getGroups(); $i = 0; foreach ($storeGroups as $storeGroup) { @@ -42,7 +43,6 @@ public function execute() $i++; } $groupNumber = 0; - $anchorStep = 2; $categoryIndex = 1; while ($categoryIndex <= $categoriesNumber) { @@ -52,11 +52,10 @@ public function execute() ->setName("Category $categoryIndex") ->setParentId($parentCategoryId[$groupNumber]) ->setPath($nestingPath[$groupNumber]) - ->setLevel($nestingLevel[$groupNumber]) + ->setLevel($nestingLevel[$groupNumber] + 1) ->setAvailableSortBy('name') ->setDefaultSortBy('name') ->setIsActive(true) - //->setIsAnchor($categoryIndex++ % $anchorStep == 0) ->save(); $categoryIndex++; $categoryPath[$groupNumber] .= '/' . $category->getName(); @@ -96,5 +95,3 @@ public function introduceParamLabels() ]; } } - -return new CategoriesFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/configs_apply.php b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php similarity index 69% rename from dev/tools/performance-toolkit/fixtures/configs_apply.php rename to setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php index 0317935fa3bd8..1dfd544552adb 100644 --- a/dev/tools/performance-toolkit/fixtures/configs_apply.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigsApplyFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class ConfigsApplyFixture */ -class ConfigsApplyFixture extends \Magento\ToolkitFramework\Fixture +class ConfigsApplyFixture extends Fixture { /** * @var int @@ -19,24 +21,24 @@ class ConfigsApplyFixture extends \Magento\ToolkitFramework\Fixture */ public function execute() { - $configs = \Magento\ToolkitFramework\Config::getInstance()->getValue('configs', array()); + $configs = $this->fixtureModel->getValue('configs', []); if (empty($configs)) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); foreach ($configs['config'] as $config) { /** * @var \Magento\Framework\App\Config\Value $configData */ - $configData = $this->application->getObjectManager()->create('Magento\Framework\App\Config\Value'); + $configData = $this->fixtureModel->getObjectManager()->create('Magento\Framework\App\Config\Value'); $configData->setPath($config['path']) ->setScope($config['scope']) ->setScopeId($config['scopeId']) ->setValue($config['value']) ->save(); } - $this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface') + $this->fixtureModel->getObjectManager()->get('Magento\Framework\App\CacheInterface') ->clean([\Magento\Framework\App\Config::CACHE_TAG]); } @@ -56,5 +58,3 @@ public function introduceParamLabels() return []; } } - -return new ConfigsApplyFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/configurable_products.php b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php similarity index 97% rename from dev/tools/performance-toolkit/fixtures/configurable_products.php rename to setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php index 4184c3c49ea9e..7d8297a1a6480 100644 --- a/dev/tools/performance-toolkit/fixtures/configurable_products.php +++ b/setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php @@ -4,19 +4,25 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + +use Magento\Setup\Model\Complex\Pattern; +use Magento\Setup\Model\Complex\Generator; + /** * Class ConfigurableProductsFixture */ -class ConfigurableProductsFixture extends \Magento\ToolkitFramework\Fixture +class ConfigurableProductsFixture extends Fixture { /** * @var int */ protected $priority = 50; + //@codingStandardsIgnoreStart /** * Get CSV template headers - * + * @SuppressWarnings(PHPMD) * @return array */ protected function getHeaders() @@ -140,6 +146,9 @@ protected function getHeaders() * @param Closure|mixed $productCategory * @param Closure|mixed $productRootCategory * @param Closure|mixed $productWebsite + * + * @SuppressWarnings(PHPMD) + * * @return array */ protected function getRows($productCategory, $productRootCategory, $productWebsite) @@ -820,16 +829,16 @@ protected function getRows($productCategory, $productRootCategory, $productWebsi */ public function execute() { - $configurablesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('configurable_products', 0); + $configurablesCount = $this->fixtureModel->getValue('configurable_products', 0); if (!$configurablesCount) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); $result = []; //Get all websites @@ -881,23 +890,24 @@ public function execute() /** * Create configurable products */ - $pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern(); + $pattern = new Pattern(); $pattern->setHeaders($this->getHeaders()); $pattern->setRowsSet($this->getRows($productCategory, $productRootCategory, $productWebsite)); /** @var \Magento\ImportExport\Model\Import $import */ - $import = $this->application->getObjectManager()->create( + $import = $this->fixtureModel->getObjectManager()->create( 'Magento\ImportExport\Model\Import', ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']] ); - $source = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator($pattern, $configurablesCount); + $source = new Generator($pattern, $configurablesCount); // it is not obvious, but the validateSource() will actually save import queue data to DB $import->validateSource($source); // this converts import queue into actual entities $import->importSource(); } + // @codingStandardsIgnoreEnd /** * {@inheritdoc} @@ -917,5 +927,3 @@ public function introduceParamLabels() ]; } } - -return new ConfigurableProductsFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/customers.php b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php similarity index 85% rename from dev/tools/performance-toolkit/fixtures/customers.php rename to setup/src/Magento/Setup/Fixtures/CustomersFixture.php index 9a11fb93ac9ed..c2390cd989164 100644 --- a/dev/tools/performance-toolkit/fixtures/customers.php +++ b/setup/src/Magento/Setup/Fixtures/CustomersFixture.php @@ -4,10 +4,14 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + +use Magento\Setup\Model\Generator; + /** * Class CustomersFixture */ -class CustomersFixture extends \Magento\ToolkitFramework\Fixture +class CustomersFixture extends Fixture { /** * @var int @@ -19,16 +23,14 @@ class CustomersFixture extends \Magento\ToolkitFramework\Fixture */ public function execute() { - $customersNumber = \Magento\ToolkitFramework\Config::getInstance()->getValue('customers', 0); + $customersNumber = $this->fixtureModel->getValue('customers', 0); if (!$customersNumber) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); - /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $defaultStoreView \Magento\Store\Model\Store */ $defaultStoreView = $storeManager->getDefaultStoreView(); $defaultStoreViewId = $defaultStoreView->getStoreId(); @@ -88,9 +90,9 @@ public function execute() '_address_default_billing_' => '1', '_address_default_shipping_' => '1', ]; - $generator = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator($pattern, $customersNumber); + $generator = new Generator($pattern, $customersNumber); /** @var Magento\ImportExport\Model\Import $import */ - $import = $this->application->getObjectManager()->create( + $import = $this->fixtureModel->getObjectManager()->create( 'Magento\ImportExport\Model\Import', ['data' => ['entity' => 'customer_composite', 'behavior' => 'append']] ); @@ -118,5 +120,3 @@ public function introduceParamLabels() ]; } } - -return new CustomersFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/eav_variations.php b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php similarity index 77% rename from dev/tools/performance-toolkit/fixtures/eav_variations.php rename to setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php index 5587ab258b6a0..c5ea2edf5f29f 100644 --- a/dev/tools/performance-toolkit/fixtures/eav_variations.php +++ b/setup/src/Magento/Setup/Fixtures/EavVariationsFixture.php @@ -4,35 +4,35 @@ * See COPYING.txt for license details. */ -define('ATTRIBUTE_SET_ID', 4); +namespace Magento\Setup\Fixtures; /** * Class EavVariationsFixture */ -class EavVariationsFixture extends \Magento\ToolkitFramework\Fixture +class EavVariationsFixture extends Fixture { /** * @var int */ protected $priority = 40; + const ATTRIBUTE_SET_ID = 4; + /** * {@inheritdoc} */ public function execute() { - $configurablesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('configurable_products', 0); + $configurablesCount = $this->fixtureModel->getValue('configurable_products', 0); if (!$configurablesCount) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /* @var $model \Magento\Catalog\Model\Resource\Eav\Attribute */ - $model = $this->application->getObjectManager()->create('Magento\Catalog\Model\Resource\Eav\Attribute'); - /* @var $helper \Magento\Catalog\Helper\Product */ - $helper = $this->application->getObjectManager()->get('Magento\Catalog\Helper\Product'); + $model = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\Resource\Eav\Attribute'); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); $stores = $storeManager->getStores(); $storeViewsCount = count($stores); @@ -89,17 +89,17 @@ public function execute() * See MAGETWO-16492 */ $model->addData($data); - $attributeSet = $this->application->getObjectManager()->get('Magento\Eav\Model\Entity\Attribute\Set'); - $attributeSet->load(ATTRIBUTE_SET_ID); - $model->setAttributeSetId(ATTRIBUTE_SET_ID) + $attributeSet = $this->fixtureModel->getObjectManager()->get('Magento\Eav\Model\Entity\Attribute\Set'); + $attributeSet->load(self::ATTRIBUTE_SET_ID); + $model->setAttributeSetId(self::ATTRIBUTE_SET_ID) ->setAttributeGroupId($attributeSet->getDefaultGroupId(4)) ->save(); - $model->setAttributeSetId(ATTRIBUTE_SET_ID); + $model->setAttributeSetId(self::ATTRIBUTE_SET_ID); $model->save(); /* @var $cache \Magento\Framework\App\CacheInterface */ - $cache = $this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface'); + $cache = $this->fixtureModel->getObjectManager()->get('Magento\Framework\App\CacheInterface'); $cacheKey = \Magento\Eav\Model\Config::ATTRIBUTES_CACHE_ID . \Magento\Catalog\Model\Product::ENTITY; $cache->remove($cacheKey); @@ -121,5 +121,3 @@ public function introduceParamLabels() return []; } } - -return new EavVariationsFixture($this); diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Fixture.php b/setup/src/Magento/Setup/Fixtures/Fixture.php similarity index 72% rename from dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Fixture.php rename to setup/src/Magento/Setup/Fixtures/Fixture.php index 9a6a1a7e3d4fc..cd53518a1715e 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Fixture.php +++ b/setup/src/Magento/Setup/Fixtures/Fixture.php @@ -4,11 +4,10 @@ * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework; +namespace Magento\Setup\Fixtures; /** * Class Fixture - * @package Magento\ToolkitFramework */ abstract class Fixture { @@ -18,16 +17,16 @@ abstract class Fixture protected $priority; /** - * @var Application + * @var FixtureModel */ - protected $application; + protected $fixtureModel; /** - * @param Application $application + * @param FixtureModel $fixtureModel */ - public function __construct(\Magento\ToolkitFramework\Application $application) + public function __construct(FixtureModel $fixtureModel) { - $this->application = $application; + $this->fixtureModel = $fixtureModel; } /** diff --git a/setup/src/Magento/Setup/Fixtures/FixtureModel.php b/setup/src/Magento/Setup/Fixtures/FixtureModel.php new file mode 100644 index 0000000000000..f414e1a2884b3 --- /dev/null +++ b/setup/src/Magento/Setup/Fixtures/FixtureModel.php @@ -0,0 +1,226 @@ +initArguments = $initArguments; + $this->reindexCommand = $reindexCommand; + $this->fileParser = $fileParser; + } + + /** + * Run reindex + * + * @param OutputInterface $output + * @return void + */ + public function reindex(OutputInterface $output) + { + $input = new ArrayInput([]); + $this->reindexCommand->run($input, $output); + } + + /** + * Load fixtures + * + * @return $this + * @throws \Exception + */ + public function loadFixtures() + { + if (!is_readable(__DIR__)) { + throw new \Exception( + 'Fixtures set directory `' . __DIR__ . '` is not readable or does not exists.' + ); + } + $files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN); + + foreach ($files as $file) { + $file = basename($file, '.php'); + /** @var \Magento\Setup\Fixtures\Fixture $fixture */ + $fixture = $this->objectManager->create( + 'Magento\Setup\Fixtures' . '\\' . $file, + [ + 'fixtureModel' => $this + ] + ); + $this->fixtures[$fixture->getPriority()] = $fixture; + } + + ksort($this->fixtures); + foreach ($this->fixtures as $fixture) { + $this->paramLabels = array_merge($this->paramLabels, $fixture->introduceParamLabels()); + } + return $this; + } + + /** + * Get param labels + * + * @return array + */ + public function getParamLabels() + { + return $this->paramLabels; + } + + /** + * Get fixtures + * + * @return Fixture[] + */ + public function getFixtures() + { + return $this->fixtures; + } + + /** + * Get object manager + * + * @return \Magento\Framework\ObjectManagerInterface + */ + public function getObjectManager() + { + if (!$this->objectManager) { + $objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory( + BP, + $this->initArguments + ); + $this->objectManager = $objectManagerFactory->create($this->initArguments); + $this->objectManager->get('Magento\Framework\App\State')->setAreaCode(self::AREA_CODE); + } + return $this->objectManager; + } + + /** + * Init Object Manager + * + * @return FixtureModel + */ + public function initObjectManager() + { + $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; + } + + /** + * Reset object manager + * + * @return \Magento\Framework\ObjectManagerInterface + */ + public function resetObjectManager() + { + $this->objectManager = null; + $this->initObjectManager(); + return $this; + } + + /** + * Load config from file + * + * @param string $filename + * @throws \Exception + * + * @return void + */ + public function loadConfig($filename) + { + if (!is_readable($filename)) { + throw new \Exception("Profile configuration file `{$filename}` is not readable or does not exists."); + } + $this->config = $this->fileParser->load($filename)->xmlToArray(); + } + + /** + * Get profile configuration value + * + * @param string $key + * @param null|mixed $default + * + * @return mixed + */ + public function getValue($key, $default = null) + { + return isset($this->config['config']['profile'][$key]) ? $this->config['config']['profile'][$key] : $default; + } +} diff --git a/dev/tools/performance-toolkit/fixtures/indexers_states_apply.php b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php similarity index 62% rename from dev/tools/performance-toolkit/fixtures/indexers_states_apply.php rename to setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php index 8b072e2b68995..f238fd6552609 100644 --- a/dev/tools/performance-toolkit/fixtures/indexers_states_apply.php +++ b/setup/src/Magento/Setup/Fixtures/IndexersStatesApplyFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class IndexersStatesApplyFixture */ -class IndexersStatesApplyFixture extends \Magento\ToolkitFramework\Fixture +class IndexersStatesApplyFixture extends Fixture { /** * @var int @@ -19,15 +21,15 @@ class IndexersStatesApplyFixture extends \Magento\ToolkitFramework\Fixture */ public function execute() { - $indexers = \Magento\ToolkitFramework\Config::getInstance()->getValue('indexers', []); + $indexers = $this->fixtureModel->getValue('indexers', []); if (!isset($indexers["indexer"]) || empty($indexers["indexer"])) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); foreach ($indexers["indexer"] as $indexer) { - $this->application->indexersStates[$indexer['id']] = ($indexer['set_scheduled'] == "true"); + $this->fixtureModel->indexersStates[$indexer['id']] = ($indexer['set_scheduled'] == "true"); } - $this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface') + $this->fixtureModel->getObjectManager()->get('Magento\Framework\App\CacheInterface') ->clean([\Magento\Framework\App\Config::CACHE_TAG]); } @@ -47,5 +49,3 @@ public function introduceParamLabels() return []; } } - -return new IndexersStatesApplyFixture($this); diff --git a/setup/src/Magento/Setup/Fixtures/OrdersFixture.php b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php new file mode 100644 index 0000000000000..0be4568b4bcbe --- /dev/null +++ b/setup/src/Magento/Setup/Fixtures/OrdersFixture.php @@ -0,0 +1,321 @@ +fixtureModel->getValue('orders', 0); + if ($ordersCount < 1) { + return; + } + $this->fixtureModel->resetObjectManager(); + + $writeAdapter = $this->getConnection('write'); + + $quoteTableName = $this->getTableName( + 'quote', + 'Magento\Quote\Model\Resource\Quote' + ); + $quoteAddressTableName = $this->getTableName( + 'quote_address', + 'Magento\Quote\Model\Resource\Quote\Address' + ); + $quoteItemTableName = $this->getTableName( + 'quote_item', + 'Magento\Quote\Model\Resource\Quote\Item' + ); + $quoteItemOptionTableName = $this->getTableName( + 'quote_item_option', + 'Magento\Quote\Model\Resource\Quote\Item\Option' + ); + $quotePaymentTableName = $this->getTableName( + 'quote_payment', + 'Magento\Quote\Model\Resource\Quote\Payment' + ); + $quoteAddressRateTableName = $this->getTableName( + 'quote_shipping_rate', + 'Magento\Quote\Model\Resource\Quote\Address\Rate' + ); + $reportEventTableName = $this->getTableName( + 'report_event', + 'Magento\Reports\Model\Resource\Event' + ); + $salesOrderTableName = $this->getTableName( + 'sales_order', + 'Magento\Sales\Model\Resource\Order' + ); + $salesOrderAddressTableName = $this->getTableName( + 'sales_order_address', + 'Magento\Sales\Model\Resource\Order' + ); + $salesOrderGridTableName = $this->getTableName( + 'sales_order_grid', + 'Magento\Sales\Model\Resource\Order\Grid' + ); + $salesOrderItemTableName = $this->getTableName( + 'sales_order_item', + 'Magento\Sales\Model\Resource\Order\Item' + ); + $salesOrderPaymentTableName = $this->getTableName( + 'sales_order_payment', + 'Magento\Sales\Model\Resource\Order\Payment' + ); + $salesOrderStatusHistoryTableName = $this->getTableName( + 'sales_order_status_history', + 'Magento\Sales\Model\Resource\Order\Status\History' + ); + $eavEntityStoreTableName = $this->getTableName( + 'eav_entity_store', + '\Magento\Eav\Model\Resource\Entity\Store' + ); + /** @var \Magento\Store\Model\StoreManager $storeManager */ + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); + /** @var $category \Magento\Catalog\Model\Category */ + $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + /** @var $product \Magento\Catalog\Model\Product */ + $product = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Product'); + + $result = []; + $stores = $storeManager->getStores(); + foreach ($stores as $store) { + $storeId = $store->getStoreId(); + $websiteId = $store->getWebsite()->getId(); + $websiteName = $store->getWebsite()->getName(); + $groupName = $store->getGroup()->getName(); + $storeName = $store->getName(); + $storeRootCategory = $store->getRootCategoryId(); + $category->load($storeRootCategory); + $categoryResource = $category->getResource(); + //Get all categories + $resultsCategories = $categoryResource->getAllChildren($category); + foreach ($resultsCategories as $resultsCategory) { + $category->load($resultsCategory); + $structure = explode('/', $category->getPath()); + $pathSize = count($structure); + if ($pathSize > 1) { + $path = []; + for ($i = 1; $i < $pathSize; $i++) { + $path[] = $category->load($structure[$i])->getName(); + } + array_shift($path); + $resultsCategoryName = implode('/', $path); + } else { + $resultsCategoryName = $category->getName(); + } + //Not use root categories + if (trim($resultsCategoryName) != '') { + /** @var $productCategory \Magento\Catalog\Model\Category */ + $productCategory = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); + + /** @var $simpleProductCollection \Magento\Catalog\Model\Resource\Product\Collection */ + $simpleProductCollection = $this->fixtureModel->getObjectManager()->create( + 'Magento\Catalog\Model\Resource\Product\Collection' + ); + + $simpleProductCollection->addStoreFilter($storeId); + $simpleProductCollection->addWebsiteFilter($websiteId); + $simpleProductCollection->addCategoryFilter($productCategory->load($resultsCategory)); + $simpleProductCollection->getSelect()->where(" type_id = 'simple' "); + $simpleIds = $simpleProductCollection->getAllIds(2); + $simpleProductsResult = []; + foreach ($simpleIds as $key => $simpleId) { + $simpleProduct = $product->load($simpleId); + $simpleProductsResult[$key]['simpleProductId'] = $simpleId; + $simpleProductsResult[$key]['simpleProductSku'] = $simpleProduct->getSku(); + $simpleProductsResult[$key]['simpleProductName'] = $simpleProduct->getName(); + } + + $result[] = [ + $storeId, + $websiteName. '\n'. $groupName . '\n' . $storeName, + $simpleProductsResult + ]; + } + } + } + + $productStoreId = function ($index) use ($result) { + return $result[$index % count($result)][0]; + }; + $productStoreName = function ($index) use ($result) { + return $result[$index % count($result)][1]; + }; + + $simpleProductId[0] = function ($index) use ($result) { + return $result[$index % count($result)][2][0]['simpleProductId']; + }; + $simpleProductId[1] = function ($index) use ($result) { + return $result[$index % count($result)][2][1]['simpleProductId']; + }; + $simpleProductSku[0] = function ($index) use ($result) { + return $result[$index % count($result)][2][0]['simpleProductSku']; + }; + $simpleProductSku[1] = function ($index) use ($result) { + return $result[$index % count($result)][2][1]['simpleProductSku']; + }; + $simpleProductName[0] = function ($index) use ($result) { + return $result[$index % count($result)][2][0]['simpleProductName']; + }; + $simpleProductName[1] = function ($index) use ($result) { + return $result[$index % count($result)][2][1]['simpleProductName']; + }; + + $entityId = 1; + while ($entityId <= $ordersCount) { + $queries = []; + + $orderNumber = 100000000 * $productStoreId($entityId) + $entityId; + $email = 'order_' . $entityId . '@example.com'; + $firstName = 'First Name'; + $lastName = 'Last Name'; + $company = 'Company'; + $address = 'Address'; + $city = 'City'; + $state = 'Alabama'; + $country = 'US'; + $zip = '11111'; + $phone = '911'; + $dateStart = new \DateTime(); + $time = $dateStart->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); + + $simpleProductIdLen[0] = strlen($simpleProductId[0]($entityId)); + $simpleProductIdLen[1] = strlen($simpleProductId[1]($entityId)); + + //@codingStandardsIgnoreStart + + $queries[] = "INSERT INTO `{$eavEntityStoreTableName}` (`entity_store_id`, `entity_type_id`, `store_id`, `increment_prefix`, `increment_last_id`) VALUES ({$productStoreId($entityId)}, 5, {$productStoreId($entityId)}, '{$productStoreId($entityId)}', '{$orderNumber}') ON DUPLICATE KEY UPDATE `increment_last_id`='{$orderNumber}';"; + + $quoteId = $entityId; + $queries[] = "INSERT INTO `{$quoteTableName}` (`entity_id`, `store_id`, `created_at`, `updated_at`, `converted_at`, `is_active`, `is_virtual`, `is_multi_shipping`, `items_count`, `items_qty`, `orig_order_id`, `store_to_base_rate`, `store_to_quote_rate`, `base_currency_code`, `store_currency_code`, `quote_currency_code`, `grand_total`, `base_grand_total`, `checkout_method`, `customer_id`, `customer_tax_class_id`, `customer_group_id`, `customer_email`, `customer_prefix`, `customer_firstname`, `customer_middlename`, `customer_lastname`, `customer_suffix`, `customer_dob`, `customer_note`, `customer_note_notify`, `customer_is_guest`, `remote_ip`, `applied_rule_ids`, `reserved_order_id`, `password_hash`, `coupon_code`, `global_currency_code`, `base_to_global_rate`, `base_to_quote_rate`, `customer_taxvat`, `customer_gender`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `is_changed`, `trigger_recollect`, `ext_shipping_info`, `is_persistent`, `gift_message_id`) VALUES ({$quoteId}, {$productStoreId($entityId)}, '{$time}', '1970-01-01 03:00:00', NULL, 0, 0, 0, 2, 2.0000, 0, 0.0000, 0.0000, 'USD', 'USD', 'USD', 25.3000, 25.3000, 'guest', NULL, 3, 0, '{$email}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, '127.0.0.1', '1', NULL, NULL, NULL, 'USD', 1.0000, 1.0000, NULL, NULL, 17.0000, 17.0000, 15.3000, 15.3000, 1, 0, NULL, 0, NULL);"; + + $quoteAddressId[0] = $entityId * 2 - 1; + $quoteAddressId[1] = $entityId * 2; + $queries[] = "INSERT INTO `{$quoteAddressTableName}` (`address_id`, `quote_id`, `created_at`, `updated_at`, `customer_id`, `save_in_address_book`, `customer_address_id`, `address_type`, `email`, `prefix`, `firstname`, `middlename`, `lastname`, `suffix`, `company`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `fax`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `shipping_tax_amount`, `base_shipping_tax_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `customer_notes`, `applied_taxes`, `discount_description`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `base_subtotal_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `base_shipping_hidden_tax_amnt`, `shipping_incl_tax`, `base_shipping_incl_tax`, `free_shipping`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`, `gift_message_id`) VALUES ({$quoteAddressId[0]}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', NULL, 1, NULL, 'billing', '{$email}', NULL, '{$firstName}', NULL, '{$lastName}', NULL, '{$company}', '{$address}', '{$city}', '{$state}', 1, '{$zip}', '{$country}', '{$phone}', NULL, 0, 0, NULL, NULL, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, NULL, NULL, 0.0000, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, 0.0000, NULL, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);"; + $queries[] = "INSERT INTO `{$quoteAddressTableName}` (`address_id`, `quote_id`, `created_at`, `updated_at`, `customer_id`, `save_in_address_book`, `customer_address_id`, `address_type`, `email`, `prefix`, `firstname`, `middlename`, `lastname`, `suffix`, `company`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `fax`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `shipping_tax_amount`, `base_shipping_tax_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `customer_notes`, `applied_taxes`, `discount_description`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `base_subtotal_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `base_shipping_hidden_tax_amnt`, `shipping_incl_tax`, `base_shipping_incl_tax`, `free_shipping`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`, `gift_message_id`) VALUES ({$quoteAddressId[1]}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', NULL, 0, NULL, 'shipping', '{$email}', NULL, '{$firstName}', NULL, '{$lastName}', NULL, '{$company}', '{$address}', '{$city}', '{$state}', 1, '{$zip}', '{$country}', '{$phone}', NULL, 1, 0, 'flatrate_flatrate', 'Flat Rate - Fixed', 2.0000, 17.0000, 17.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 10.0000, 0.0000, 0.0000, -1.7000, -1.7000, 25.3000, 25.3000, NULL, 'a:0:{}', NULL, 0.0000, 0.0000, 17.0000, NULL, 0.0000, 0.0000, 0.0000, NULL, 10.0000, 10.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL);"; + + $quoteItemId[0] = $entityId * 4 - 3; + $quoteItemId[1] = $entityId * 4 - 2; + $quoteItemId[2] = $entityId * 4 - 1; + $quoteItemId[3] = $entityId * 4; + $queries[] = "INSERT INTO `{$quoteItemTableName}` (`item_id`, `quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `parent_item_id`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `custom_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `product_type`, `base_tax_before_discount`, `tax_before_discount`, `original_custom_price`, `redirect_url`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `free_shipping`, `gift_message_id`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$quoteItemId[0]}, {$quoteId}, '1970-01-01 03:00:00', '1970-01-01 03:00:00', {$simpleProductId[0]($entityId)}, {$productStoreId($entityId)}, NULL, 0, '{$simpleProductSku[0]($entityId)}', '{$simpleProductName[0]($entityId)}', NULL, '1', NULL, 0, 0, 1.0000, 1.0000, 8.5000, 8.5000, NULL, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 1.0000, 'simple', NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; + $queries[] = "INSERT INTO `{$quoteItemTableName}` (`item_id`, `quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `parent_item_id`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `custom_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `product_type`, `base_tax_before_discount`, `tax_before_discount`, `original_custom_price`, `redirect_url`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `free_shipping`, `gift_message_id`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$quoteItemId[1]}, {$quoteId}, '1970-01-01 03:00:00', '1970-01-01 03:00:00', {$simpleProductId[1]($entityId)}, {$productStoreId($entityId)}, NULL, 0, '{$simpleProductSku[1]($entityId)}', '{$simpleProductName[1]($entityId)}', NULL, '1', NULL, 0, 0, 1.0000, 1.0000, 8.5000, 8.5000, NULL, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 1.0000, 'simple', NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; + + $quoteItemOptionId[0] = $entityId * 8 - 7; + $quoteItemOptionId[1] = $entityId * 8 - 6; + $quoteItemOptionId[2] = $entityId * 8 - 5; + $quoteItemOptionId[3] = $entityId * 8 - 4; + $quoteItemOptionId[4] = $entityId * 8 - 3; + $quoteItemOptionId[5] = $entityId * 8 - 2; + $quoteItemOptionId[6] = $entityId * 8 - 1; + $quoteItemOptionId[7] = $entityId * 8; + $queries[] = "INSERT INTO `{$quoteItemOptionTableName}` (`option_id`, `item_id`, `product_id`, `code`, `value`) VALUES ({$quoteItemOptionId[0]}, {$quoteItemId[0]}, {$simpleProductId[0]($entityId)}, 'info_buyRequest', 'a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[0]}:\"{$simpleProductId[0]($entityId)}\";s:3:\"qty\";i:1;}');"; + $queries[] = "INSERT INTO `{$quoteItemOptionTableName}` (`option_id`, `item_id`, `product_id`, `code`, `value`) VALUES ({$quoteItemOptionId[1]}, {$quoteItemId[1]}, {$simpleProductId[1]($entityId)}, 'info_buyRequest', 'a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[1]}:\"{$simpleProductId[1]($entityId)}\";s:3:\"qty\";i:1;}');"; + + $quotePaymentId = $quoteId; + $queries[] = "INSERT INTO `{$quotePaymentTableName}` (`payment_id`, `quote_id`, `created_at`, `updated_at`, `method`, `cc_type`, `cc_number_enc`, `cc_last_4`, `cc_cid_enc`, `cc_owner`, `cc_exp_month`, `cc_exp_year`, `cc_ss_owner`, `cc_ss_start_month`, `cc_ss_start_year`, `po_number`, `additional_data`, `cc_ss_issue`, `additional_information`) VALUES ({$quotePaymentId}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', 'checkmo', NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL, NULL, NULL, NULL);"; + + $quoteShippingRateId = $quoteAddressId[1]; + $queries[] = "INSERT INTO `{$quoteAddressRateTableName}` (`rate_id`, `address_id`, `created_at`, `updated_at`, `carrier`, `carrier_title`, `code`, `method`, `method_description`, `price`, `error_message`, `method_title`) VALUES ({$quoteShippingRateId}, {$quoteAddressId[1]}, '{$time}', '1970-01-01 03:00:00', 'flatrate', 'Flat Rate', 'flatrate_flatrate', 'flatrate', NULL, 10.0000, NULL, 'Fixed');"; + + $reportEventId[0] = $quoteItemId[0]; + $reportEventId[1] = $quoteItemId[1]; + $reportEventId[2] = $quoteItemId[2]; + $reportEventId[3] = $quoteItemId[3]; + $queries[] = "INSERT INTO `{$reportEventTableName}` (`event_id`, `logged_at`, `event_type_id`, `object_id`, `subject_id`, `subtype`, `store_id`) VALUES ({$reportEventId[0]}, '{$time}', 4, {$simpleProductId[0]($entityId)}, 2, 1, {$productStoreId($entityId)});"; + $queries[] = "INSERT INTO `{$reportEventTableName}` (`event_id`, `logged_at`, `event_type_id`, `object_id`, `subject_id`, `subtype`, `store_id`) VALUES ({$reportEventId[1]}, '{$time}', 4, {$simpleProductId[1]($entityId)}, 2, 1, {$productStoreId($entityId)});"; + + $salesOrderId = $quoteId; + $queries[] = "INSERT INTO `{$salesOrderTableName}` (`entity_id`, `state`, `status`, `coupon_code`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`, `base_discount_canceled`, `base_discount_invoiced`, `base_discount_refunded`, `base_grand_total`, `base_shipping_amount`, `base_shipping_canceled`, `base_shipping_invoiced`, `base_shipping_refunded`, `base_shipping_tax_amount`, `base_shipping_tax_refunded`, `base_subtotal`, `base_subtotal_canceled`, `base_subtotal_invoiced`, `base_subtotal_refunded`, `base_tax_amount`, `base_tax_canceled`, `base_tax_invoiced`, `base_tax_refunded`, `base_to_global_rate`, `base_to_order_rate`, `base_total_canceled`, `base_total_invoiced`, `base_total_invoiced_cost`, `base_total_offline_refunded`, `base_total_online_refunded`, `base_total_paid`, `base_total_qty_ordered`, `base_total_refunded`, `discount_amount`, `discount_canceled`, `discount_invoiced`, `discount_refunded`, `grand_total`, `shipping_amount`, `shipping_canceled`, `shipping_invoiced`, `shipping_refunded`, `shipping_tax_amount`, `shipping_tax_refunded`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `subtotal_canceled`, `subtotal_invoiced`, `subtotal_refunded`, `tax_amount`, `tax_canceled`, `tax_invoiced`, `tax_refunded`, `total_canceled`, `total_invoiced`, `total_offline_refunded`, `total_online_refunded`, `total_paid`, `total_qty_ordered`, `total_refunded`, `can_ship_partially`, `can_ship_partially_item`, `customer_is_guest`, `customer_note_notify`, `billing_address_id`, `customer_group_id`, `edit_increment`, `email_sent`, `send_email`, `forced_shipment_with_invoice`, `payment_auth_expiration`, `quote_address_id`, `quote_id`, `shipping_address_id`, `adjustment_negative`, `adjustment_positive`, `base_adjustment_negative`, `base_adjustment_positive`, `base_shipping_discount_amount`, `base_subtotal_incl_tax`, `base_total_due`, `payment_authorization_amount`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `customer_dob`, `increment_id`, `applied_rule_ids`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `customer_middlename`, `customer_prefix`, `customer_suffix`, `customer_taxvat`, `discount_description`, `ext_customer_id`, `ext_order_id`, `global_currency_code`, `hold_before_state`, `hold_before_status`, `order_currency_code`, `original_increment_id`, `relation_child_id`, `relation_child_real_id`, `relation_parent_id`, `relation_parent_real_id`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `x_forwarded_for`, `customer_note`, `created_at`, `updated_at`, `total_item_count`, `customer_gender`, `hidden_tax_amount`, `base_hidden_tax_amount`, `shipping_hidden_tax_amount`, `base_shipping_hidden_tax_amnt`, `hidden_tax_invoiced`, `base_hidden_tax_invoiced`, `hidden_tax_refunded`, `base_hidden_tax_refunded`, `shipping_incl_tax`, `base_shipping_incl_tax`, `coupon_rule_name`, `gift_message_id`) VALUES ({$salesOrderId}, 'new', 'pending', NULL, '272ecb', 'Flat Rate - Fixed', 0, {$productStoreId($entityId)}, NULL, -1.7000, NULL, NULL, NULL, 25.3000, 10.0000, NULL, NULL, NULL, 0.0000, NULL, 17.0000, NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, 1.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1.7000, NULL, NULL, NULL, 25.3000, 10.0000, NULL, NULL, NULL, 0.0000, NULL, 0.0000, 0.0000, 17.0000, NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2.0000, NULL, NULL, NULL, 1, 1, 2, 0, NULL, 1, 1, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, 17.0000, 25.3000, NULL, NULL, 17.0000, 25.3000, 2.0000, NULL, {$orderNumber}, '1', 'USD', '{$email}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'USD', NULL, NULL, 'USD', NULL, NULL, NULL, NULL, NULL, '127.0.0.1', 'flatrate_flatrate', 'USD', '{$productStoreName($entityId)}', NULL, NULL, '{$time}', '{$time}', 2, NULL, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, 10.0000, 10.0000, NULL, NULL);"; + + $salesOrderAddressId[0] = $quoteAddressId[0]; + $salesOrderAddressId[1] = $quoteAddressId[1]; + $queries[] = "INSERT INTO `{$salesOrderAddressTableName}` (`entity_id`, `parent_id`, `customer_address_id`, `quote_address_id`, `region_id`, `customer_id`, `fax`, `region`, `postcode`, `lastname`, `street`, `city`, `email`, `telephone`, `country_id`, `firstname`, `address_type`, `prefix`, `middlename`, `suffix`, `company`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`) VALUES ({$salesOrderAddressId[0]}, {$salesOrderId}, NULL, NULL, 1, NULL, NULL, '{$state}', '{$zip}', '{$lastName}', '{$address}', '{$city}', '{$email}', '{$phone}', '{$country}', '{$firstName}', 'shipping', NULL, NULL, NULL, '{$company}', NULL, NULL, NULL, NULL, NULL);"; + $queries[] = "INSERT INTO `{$salesOrderAddressTableName}` (`entity_id`, `parent_id`, `customer_address_id`, `quote_address_id`, `region_id`, `customer_id`, `fax`, `region`, `postcode`, `lastname`, `street`, `city`, `email`, `telephone`, `country_id`, `firstname`, `address_type`, `prefix`, `middlename`, `suffix`, `company`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`) VALUES ({$salesOrderAddressId[1]}, {$salesOrderId}, NULL, NULL, 1, NULL, NULL, '{$state}', '{$zip}', '{$lastName}', '{$address}', '{$city}', '{$email}', '{$phone}', '{$country}', '{$firstName}', 'billing', NULL, NULL, NULL, '{$company}', NULL, NULL, NULL, NULL, NULL);"; + + $salesOrderGridId = $salesOrderId; + $queries[] = "INSERT INTO `{$salesOrderGridTableName}` (`entity_id`, `status`, `store_id`, `store_name`, `customer_id`, `base_grand_total`, `base_total_paid`, `grand_total`, `total_paid`, `increment_id`, `base_currency_code`, `order_currency_code`, `shipping_name`, `billing_name`, `created_at`, `updated_at`) VALUES ({$salesOrderGridId}, 'pending', {$productStoreId($entityId)}, '{$productStoreName($entityId)}', NULL, 25.3000, NULL, 25.3000, NULL, {$orderNumber}, 'USD', 'USD', '', '', '{$time}', NULL);"; + + $salesOrderItemId[0] = $quoteItemId[0]; + $salesOrderItemId[1] = $quoteItemId[1]; + $salesOrderItemId[2] = $quoteItemId[2]; + $salesOrderItemId[3] = $quoteItemId[3]; + $queries[] = "INSERT INTO `{$salesOrderItemTableName}` (`item_id`, `order_id`, `parent_item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `ext_order_item_id`, `locked_do_invoice`, `locked_do_ship`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `hidden_tax_invoiced`, `base_hidden_tax_invoiced`, `hidden_tax_refunded`, `base_hidden_tax_refunded`, `tax_canceled`, `hidden_tax_canceled`, `tax_refunded`, `base_tax_refunded`, `discount_refunded`, `base_discount_refunded`, `free_shipping`, `gift_message_id`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$salesOrderItemId[0]}, {$salesOrderId}, NULL, {$quoteItemId[0]}, {$productStoreId($entityId)}, '{$time}', '0000-00-00 00:00:00', {$simpleProductId[0]($entityId)}, 'simple', 'a:1:{s:15:\"info_buyRequest\";a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[0]}:\"{$simpleProductId[0]($entityId)}\";s:3:\"qty\";i:1;}}', 1.0000, 0, '{$simpleProductSku[0]($entityId)}', '{$simpleProductName[0]($entityId)}', NULL, '1', NULL, 0, 0, NULL, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, NULL, 8.5000, 8.5000, 10.0000, 10.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 0.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; + $queries[] = "INSERT INTO `{$salesOrderItemTableName}` (`item_id`, `order_id`, `parent_item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `ext_order_item_id`, `locked_do_invoice`, `locked_do_ship`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `hidden_tax_amount`, `base_hidden_tax_amount`, `hidden_tax_invoiced`, `base_hidden_tax_invoiced`, `hidden_tax_refunded`, `base_hidden_tax_refunded`, `tax_canceled`, `hidden_tax_canceled`, `tax_refunded`, `base_tax_refunded`, `discount_refunded`, `base_discount_refunded`, `free_shipping`, `gift_message_id`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$salesOrderItemId[1]}, {$salesOrderId}, NULL, {$quoteItemId[1]}, {$productStoreId($entityId)}, '{$time}', '0000-00-00 00:00:00', {$simpleProductId[1]($entityId)}, 'simple', 'a:1:{s:15:\"info_buyRequest\";a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[1]}:\"{$simpleProductId[1]($entityId)}\";s:3:\"qty\";i:1;}}', 1.0000, 0, '{$simpleProductSku[1]($entityId)}', '{$simpleProductName[1]($entityId)}', NULL, '1', NULL, 0, 0, NULL, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, NULL, 8.5000, 8.5000, 10.0000, 10.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 0.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; + + $salesOrderPaymentId = $salesOrderId; + $queries[] = "INSERT INTO `{$salesOrderPaymentTableName}` (`entity_id`, `parent_id`, `base_shipping_captured`, `shipping_captured`, `amount_refunded`, `base_amount_paid`, `amount_canceled`, `base_amount_authorized`, `base_amount_paid_online`, `base_amount_refunded_online`, `base_shipping_amount`, `shipping_amount`, `amount_paid`, `amount_authorized`, `base_amount_ordered`, `base_shipping_refunded`, `shipping_refunded`, `base_amount_refunded`, `amount_ordered`, `base_amount_canceled`, `quote_payment_id`, `additional_data`, `cc_exp_month`, `cc_ss_start_year`, `echeck_bank_name`, `method`, `cc_debug_request_body`, `cc_secure_verify`, `protection_eligibility`, `cc_approval`, `cc_last_4`, `cc_status_description`, `echeck_type`, `cc_debug_response_serialized`, `cc_ss_start_month`, `echeck_account_type`, `last_trans_id`, `cc_cid_status`, `cc_owner`, `cc_type`, `po_number`, `cc_exp_year`, `cc_status`, `echeck_routing_number`, `account_status`, `anet_trans_method`, `cc_debug_response_body`, `cc_ss_issue`, `echeck_account_name`, `cc_avs_status`, `cc_number_enc`, `cc_trans_id`, `address_status`, `additional_information`) VALUES ({$salesOrderPaymentId}, {$salesOrderId}, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10.0000, 10.0000, NULL, NULL, 25.3000, NULL, NULL, NULL, 25.3000, NULL, NULL, NULL, NULL, '0', NULL, 'checkmo', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'a:1:{s:53:\"a:1:{s:12:\"method_title\";s:19:\"Check / Money order\";}\";N;}');"; + + $salesOrderStatusHistoryId = $salesOrderId; + $queries[] = "INSERT INTO `{$salesOrderStatusHistoryTableName}` (`entity_id`, `parent_id`, `is_customer_notified`, `is_visible_on_front`, `comment`, `status`, `created_at`, `entity_name`) VALUES ({$salesOrderStatusHistoryId}, {$salesOrderId}, 1, 0, NULL, 'pending', '{$time}', 'order');"; + + // @codingStandardsIgnoreEnd + foreach ($queries as $query) { + $writeAdapter->query($query); + } + + $entityId++; + } + } + + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating orders'; + } + + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return [ + 'orders' => 'Orders' + ]; + } + + /** + * Get real table name for db table, validated by db adapter + * + * @param string $tableName + * @param string $resourceName + * @return string + */ + public function getTableName($tableName, $resourceName) + { + $resource = $this->fixtureModel->getObjectManager()->get($resourceName); + return $this->getConnection('write')->getTableName($resource->getTable($tableName)); + } + + /** + * Retrieve connection to resource specified by $resourceName + * + * @param string $resourceName + * @return \Magento\Framework\DB\Adapter\AdapterInterface|false + */ + public function getConnection($resourceName) + { + return $this->fixtureModel->getObjectManager()->get( + 'Magento\Framework\App\Resource' + )->getConnection($resourceName); + } +} diff --git a/dev/tools/performance-toolkit/fixtures/simple_products.php b/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php similarity index 89% rename from dev/tools/performance-toolkit/fixtures/simple_products.php rename to setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php index c38059cab07a1..56e255e87eabf 100644 --- a/dev/tools/performance-toolkit/fixtures/simple_products.php +++ b/setup/src/Magento/Setup/Fixtures/SimpleProductsFixture.php @@ -4,10 +4,14 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + +use Magento\Setup\Model\Generator; + /** * Class SimpleProductsFixture */ -class SimpleProductsFixture extends \Magento\ToolkitFramework\Fixture +class SimpleProductsFixture extends Fixture { /** * @var int @@ -19,16 +23,16 @@ class SimpleProductsFixture extends \Magento\ToolkitFramework\Fixture */ public function execute() { - $simpleProductsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('simple_products', 0); + $simpleProductsCount = $this->fixtureModel->getValue('simple_products', 0); if (!$simpleProductsCount) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->get('Magento\Catalog\Model\Category'); $result = []; //Get all websites @@ -73,12 +77,12 @@ public function execute() return $result[$index % count($result)][1]; }; - $generator = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator( + $generator = new Generator( $this->getPattern($productWebsite, $productCategory), $simpleProductsCount ); /** @var \Magento\ImportExport\Model\Import $import */ - $import = $this->application->getObjectManager()->create( + $import = $this->fixtureModel->getObjectManager()->create( 'Magento\ImportExport\Model\Import', ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']] ); @@ -146,5 +150,3 @@ public function introduceParamLabels() ]; } } - -return new SimpleProductsFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/stores.php b/setup/src/Magento/Setup/Fixtures/StoresFixture.php similarity index 89% rename from dev/tools/performance-toolkit/fixtures/stores.php rename to setup/src/Magento/Setup/Fixtures/StoresFixture.php index 04978e151777b..8e4c7f7517a87 100644 --- a/dev/tools/performance-toolkit/fixtures/stores.php +++ b/setup/src/Magento/Setup/Fixtures/StoresFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class StoresFixture */ -class StoresFixture extends \Magento\ToolkitFramework\Fixture +class StoresFixture extends Fixture { /** * @var int @@ -16,21 +18,22 @@ class StoresFixture extends \Magento\ToolkitFramework\Fixture /** * {@inheritdoc} + * @SuppressWarnings(PHPMD) */ public function execute() { - $websitesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('websites', 0); - $storeGroupsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_groups', 0); - $storesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_views', 0); + $websitesCount = $this->fixtureModel->getValue('websites', 0); + $storeGroupsCount = $this->fixtureModel->getValue('store_groups', 0); + $storesCount = $this->fixtureModel->getValue('store_views', 0); if (!$websitesCount || !$storeGroupsCount || !$storesCount) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /** @var \Magento\Store\Model\StoreManager $storeManager */ - $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $storeManager = $this->fixtureModel->getObjectManager()->create('Magento\Store\Model\StoreManager'); /** @var $category \Magento\Catalog\Model\Category */ - $category = $this->application->getObjectManager()->create('Magento\Catalog\Model\Category'); + $category = $this->fixtureModel->getObjectManager()->create('Magento\Catalog\Model\Category'); /** @var $defaultWebsite \Magento\Store\Model\Website */ $defaultWebsite = $storeManager->getWebsite(); @@ -178,5 +181,3 @@ public function introduceParamLabels() ]; } } - -return new StoresFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/tax_rates.php b/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php similarity index 75% rename from dev/tools/performance-toolkit/fixtures/tax_rates.php rename to setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php index 22abecea441f4..818da63a4ceac 100644 --- a/dev/tools/performance-toolkit/fixtures/tax_rates.php +++ b/setup/src/Magento/Setup/Fixtures/TaxRatesFixture.php @@ -4,10 +4,12 @@ * See COPYING.txt for license details. */ +namespace Magento\Setup\Fixtures; + /** * Class TaxRatesFixture */ -class TaxRatesFixture extends \Magento\ToolkitFramework\Fixture +class TaxRatesFixture extends Fixture { /** * @var int @@ -19,18 +21,18 @@ class TaxRatesFixture extends \Magento\ToolkitFramework\Fixture */ public function execute() { - $taxRatesFile = \Magento\ToolkitFramework\Config::getInstance()->getValue('tax_rates_file', null); + $taxRatesFile = $this->fixtureModel->getValue('tax_rates_file', null); if (empty($taxRatesFile)) { return; } - $this->application->resetObjectManager(); + $this->fixtureModel->resetObjectManager(); /** Clean predefined tax rates to maintain consistency */ /** @var $collection Magento\Tax\Model\Resource\Calculation\Rate\Collection */ - $collection = $this->application->getObjectManager() + $collection = $this->fixtureModel->getObjectManager() ->get('Magento\Tax\Model\Resource\Calculation\Rate\Collection'); /** @var $model Magento\Tax\Model\Calculation\Rate */ - $model = $this->application->getObjectManager() + $model = $this->fixtureModel->getObjectManager() ->get('Magento\Tax\Model\Calculation\Rate'); foreach ($collection->getAllIds() as $id) { @@ -43,12 +45,12 @@ public function execute() $filename = realpath(__DIR__ . '/' . $taxRatesFile); $file = [ 'name' => $filename, - 'type' => 'application/vnd.ms-excel', + 'type' => 'fixtureModel/vnd.ms-excel', 'tmp_name' => $filename, 'error' => 0, 'size' => filesize($filename), ]; - $importHandler = $this->application->getObjectManager() + $importHandler = $this->fixtureModel->getObjectManager() ->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); $importHandler->importFromCsvFile($file); @@ -70,5 +72,3 @@ public function introduceParamLabels() return []; } } - -return new TaxRatesFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/tax_rates.csv b/setup/src/Magento/Setup/Fixtures/tax_rates.csv similarity index 100% rename from dev/tools/performance-toolkit/fixtures/tax_rates.csv rename to setup/src/Magento/Setup/Fixtures/tax_rates.csv diff --git a/setup/src/Magento/Setup/Model/AdminAccount.php b/setup/src/Magento/Setup/Model/AdminAccount.php index 7e52b2b604e10..5642dda6afb31 100644 --- a/setup/src/Magento/Setup/Model/AdminAccount.php +++ b/setup/src/Magento/Setup/Model/AdminAccount.php @@ -17,11 +17,11 @@ class AdminAccount /**#@+ * Data keys */ - const KEY_USER = 'admin_user'; - const KEY_PASSWORD = 'admin_password'; - const KEY_EMAIL = 'admin_email'; - const KEY_FIRST_NAME = 'admin_firstname'; - const KEY_LAST_NAME = 'admin_lastname'; + const KEY_USER = 'admin-user'; + const KEY_PASSWORD = 'admin-password'; + const KEY_EMAIL = 'admin-email'; + const KEY_FIRST_NAME = 'admin-firstname'; + const KEY_LAST_NAME = 'admin-lastname'; /**#@- */ /** diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Complex/Generator.php b/setup/src/Magento/Setup/Model/Complex/Generator.php similarity index 91% rename from dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Complex/Generator.php rename to setup/src/Magento/Setup/Model/Complex/Generator.php index 59f341057ef90..d2001b2a3ff13 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Complex/Generator.php +++ b/setup/src/Magento/Setup/Model/Complex/Generator.php @@ -4,19 +4,21 @@ * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework\ImportExport\Fixture\Complex; +namespace Magento\Setup\Model\Complex; + +use Magento\ImportExport\Model\Import\AbstractSource; /** * Class Generator * * */ -class Generator extends \Magento\ImportExport\Model\Import\AbstractSource +class Generator extends AbstractSource { /** * Data row pattern * - * @var \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern + * @var Pattern */ protected $_pattern; diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Complex/Pattern.php b/setup/src/Magento/Setup/Model/Complex/Pattern.php similarity index 97% rename from dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Complex/Pattern.php rename to setup/src/Magento/Setup/Model/Complex/Pattern.php index 78f8405cf582a..04ddf96ff3553 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Complex/Pattern.php +++ b/setup/src/Magento/Setup/Model/Complex/Pattern.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework\ImportExport\Fixture\Complex; +namespace Magento\Setup\Model\Complex; /** * Complex pattern class for complex generator (used for creating configurable products) diff --git a/setup/src/Magento/Setup/Model/ConfigGenerator.php b/setup/src/Magento/Setup/Model/ConfigGenerator.php new file mode 100644 index 0000000000000..a1a07d52e20bd --- /dev/null +++ b/setup/src/Magento/Setup/Model/ConfigGenerator.php @@ -0,0 +1,213 @@ + ConfigOptionsListConstants::KEY_HOST, + ConfigOptionsListConstants::INPUT_KEY_DB_NAME => ConfigOptionsListConstants::KEY_NAME, + ConfigOptionsListConstants::INPUT_KEY_DB_USER => ConfigOptionsListConstants::KEY_USER, + ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD => ConfigOptionsListConstants::KEY_PASSWORD, + ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX => ConfigOptionsListConstants::KEY_PREFIX, + ConfigOptionsListConstants::INPUT_KEY_DB_MODEL => ConfigOptionsListConstants::KEY_MODEL, + ConfigOptionsListConstants::INPUT_KEY_DB_ENGINE => ConfigOptionsListConstants::KEY_ENGINE, + ConfigOptionsListConstants::INPUT_KEY_DB_INIT_STATEMENTS => ConfigOptionsListConstants::KEY_INIT_STATEMENTS, + ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY => ConfigOptionsListConstants::KEY_ENCRYPTION_KEY, + ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE => ConfigOptionsListConstants::KEY_SAVE, + ConfigOptionsListConstants::INPUT_KEY_RESOURCE => ConfigOptionsListConstants::KEY_RESOURCE, + ]; + + /** + * @var Random + */ + protected $random; + + /** + * @var DeploymentConfig + */ + protected $deploymentConfig; + + /** + * Constructor + * + * @param Random $random + * @param DeploymentConfig $deploymentConfig + */ + public function __construct(Random $random, DeploymentConfig $deploymentConfig) + { + $this->random = $random; + $this->deploymentConfig = $deploymentConfig; + } + + /** + * Creates install segment config data + * + * @return ConfigData + */ + public function createInstallConfig() + { + $configData = new ConfigData(ConfigFilePool::APP_ENV); + + if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE) === null) { + $configData->set(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE, date('r')); + } + return $configData; + } + + /** + * Creates encryption key config data + * @param array $data + * @return ConfigData + */ + public function createCryptConfig(array $data) + { + $currentKey = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); + + $configData = new ConfigData(ConfigFilePool::APP_ENV); + if (isset($data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY])) { + if ($currentKey !== null) { + $key = $currentKey . "\n" . $data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY]; + } else { + $key = $data[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY]; + } + + $configData->set(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, $key); + } else { + if ($currentKey === null) { + $configData->set( + ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, + md5($this->random->getRandomString(10)) + ); + } + } + + return $configData; + } + + /** + * Creates session config data + * + * @param array $data + * @return ConfigData + */ + public function createSessionConfig(array $data) + { + $configData = new ConfigData(ConfigFilePool::APP_ENV); + + if (isset($data[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE])) { + $configData->set( + ConfigOptionsListConstants::CONFIG_PATH_SESSION_SAVE, + $data[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE] + ); + } + + return $configData; + } + + /** + * Creates definitions config data + * + * @param array $data + * @return ConfigData + */ + public function createDefinitionsConfig(array $data) + { + $configData = new ConfigData(ConfigFilePool::APP_ENV); + + if (!empty($data[ConfigOptionsListConstants::INPUT_KEY_DEFINITION_FORMAT])) { + $configData->set( + ConfigOptionsListConstants::CONFIG_PATH_DEFINITION_FORMAT, + $data[ConfigOptionsListConstants::INPUT_KEY_DEFINITION_FORMAT] + ); + } + + return $configData; + } + + /** + * Creates db config data + * + * @param array $data + * @return ConfigData + */ + public function createDbConfig(array $data) + { + $configData = new ConfigData(ConfigFilePool::APP_ENV); + + $optional = [ + ConfigOptionsListConstants::INPUT_KEY_DB_HOST, + ConfigOptionsListConstants::INPUT_KEY_DB_NAME, + ConfigOptionsListConstants::INPUT_KEY_DB_USER, + ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD, + ConfigOptionsListConstants::INPUT_KEY_DB_MODEL, + ConfigOptionsListConstants::INPUT_KEY_DB_ENGINE, + ConfigOptionsListConstants::INPUT_KEY_DB_INIT_STATEMENTS, + ]; + + if (isset($data[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX])) { + $configData->set( + ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX, + $data[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX] + ); + } + + foreach ($optional as $key) { + if (isset($data[$key])) { + $configData->set( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . self::$paramMap[$key], + $data[$key] + ); + } + } + + $currentStatus = $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_ACTIVE + ); + + if ($currentStatus === null) { + $configData->set( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT + . '/' . ConfigOptionsListConstants::KEY_ACTIVE, + '1' + ); + } + + return $configData; + } + + /** + * Creates resource config data + * + * @return ConfigData + */ + public function createResourceConfig() + { + $configData = new ConfigData(ConfigFilePool::APP_ENV); + + if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_RESOURCE_DEFAULT_SETUP) === null) { + $configData->set(ConfigOptionsListConstants::CONFIG_PATH_RESOURCE_DEFAULT_SETUP, 'default'); + } + + return $configData; + } +} diff --git a/setup/src/Magento/Setup/Model/ConfigModel.php b/setup/src/Magento/Setup/Model/ConfigModel.php index 056ab89681c33..f812279bd6a3c 100644 --- a/setup/src/Magento/Setup/Model/ConfigModel.php +++ b/setup/src/Magento/Setup/Model/ConfigModel.php @@ -148,7 +148,7 @@ public function validate(array $inputOptions) $options = $this->collector->collectOptionsLists(); foreach ($options as $option) { - $errors = array_merge($errors, $option->validate($inputOptions)); + $errors = array_merge($errors, $option->validate($inputOptions, $this->deploymentConfig)); } return $errors; diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList.php b/setup/src/Magento/Setup/Model/ConfigOptionsList.php new file mode 100644 index 0000000000000..64f2a58515eca --- /dev/null +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList.php @@ -0,0 +1,296 @@ +configGenerator = $configGenerator; + $this->dbValidator = $dbValidator; + } + + /** + * {@inheritdoc} + */ + public function getOptions() + { + return [ + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, + 'Encryption key' + ), + new SelectConfigOption( + ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE, + SelectConfigOption::FRONTEND_WIZARD_SELECT, + [ConfigOptionsListConstants::SESSION_SAVE_FILES, ConfigOptionsListConstants::SESSION_SAVE_DB], + ConfigOptionsListConstants::CONFIG_PATH_SESSION_SAVE, + 'Session save location', + ConfigOptionsListConstants::SESSION_SAVE_FILES + ), + new SelectConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DEFINITION_FORMAT, + SelectConfigOption::FRONTEND_WIZARD_SELECT, + DefinitionFactory::getSupportedFormats(), + ConfigOptionsListConstants::CONFIG_PATH_DEFINITION_FORMAT, + 'Type of definitions used by Object Manager' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_HOST, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_HOST, + 'Database server host', + 'localhost' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_NAME, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_NAME, + 'Database name', + 'magento2' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_USER, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_USER, + 'Database server username', + 'root' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_ENGINE, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_ENGINE, + 'Database server engine', + 'innodb' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD, + TextConfigOption::FRONTEND_WIZARD_PASSWORD, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_PASSWORD, + 'Database server password', + '' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX, + 'Database table prefix', + '' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_MODEL, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_MODEL, + 'Database type', + 'mysql4' + ), + new TextConfigOption( + ConfigOptionsListConstants::INPUT_KEY_DB_INIT_STATEMENTS, + TextConfigOption::FRONTEND_WIZARD_TEXT, + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_INIT_STATEMENTS, + 'Database initial set of commands', + 'SET NAMES utf8;' + ), + new FlagConfigOption( + ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION, + '', + 'If specified, then db connection validation will be skipped', + '-s' + ), + ]; + } + + /** + * {@inheritdoc} + */ + public function createConfig(array $data, DeploymentConfig $deploymentConfig) + { + $configData = []; + $configData[] = $this->configGenerator->createInstallConfig($deploymentConfig); + $configData[] = $this->configGenerator->createCryptConfig($data, $deploymentConfig); + $configData[] = $this->configGenerator->createSessionConfig($data); + $definitionConfig = $this->configGenerator->createDefinitionsConfig($data); + if (isset($definitionConfig)) { + $configData[] = $definitionConfig; + } + $configData[] = $this->configGenerator->createDbConfig($data); + $configData[] = $this->configGenerator->createResourceConfig(); + return $configData; + } + + /** + * {@inheritdoc} + */ + public function validate(array $options, DeploymentConfig $deploymentConfig) + { + $errors = []; + + if (isset($options[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX])) { + try { + $this->dbValidator->checkDatabaseTablePrefix($options[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX]); + } catch (\InvalidArgumentException $exception) { + $errors[] = $exception->getMessage(); + } + } + + if (!$options[ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION] && + ( + $options[ConfigOptionsListConstants::INPUT_KEY_DB_NAME] !== null + || $options[ConfigOptionsListConstants::INPUT_KEY_DB_HOST] !== null + || $options[ConfigOptionsListConstants::INPUT_KEY_DB_USER] !== null + || $options[ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD] !== null + ) + ) { + try { + + $options = $this->getDbSettings($options, $deploymentConfig); + + $this->dbValidator->checkDatabaseConnection( + $options[ConfigOptionsListConstants::INPUT_KEY_DB_NAME], + $options[ConfigOptionsListConstants::INPUT_KEY_DB_HOST], + $options[ConfigOptionsListConstants::INPUT_KEY_DB_USER], + $options[ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD] + ); + } catch (\Exception $exception) { + $errors[] = $exception->getMessage(); + } + } + + $errors = array_merge( + $errors, + $this->validateSessionSave($options), + $this->validateEncryptionKey($options) + ); + + return $errors; + } + + /** + * Returns other parts of existing db config in case is only one value is presented by user + * + * @param array $options + * @param DeploymentConfig $deploymentConfig + * + * @return array + */ + private function getDbSettings(array $options, DeploymentConfig $deploymentConfig) + { + if ($options[ConfigOptionsListConstants::INPUT_KEY_DB_NAME] === null) { + $options[ConfigOptionsListConstants::INPUT_KEY_DB_NAME] = + $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_NAME + ); + } + + if ($options[ConfigOptionsListConstants::INPUT_KEY_DB_HOST] === null) { + $options[ConfigOptionsListConstants::INPUT_KEY_DB_HOST] = + $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_HOST + ); + } + + if ($options[ConfigOptionsListConstants::INPUT_KEY_DB_USER] === null) { + $options[ConfigOptionsListConstants::INPUT_KEY_DB_USER] = + $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_USER + ); + } + + if ($options[ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD] === null) { + $options[ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD] = + $deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_PASSWORD + ); + } + + return $options; + } + + /** + * Validates session save param + * + * @param array $options + * @return string[] + */ + private function validateSessionSave(array $options) + { + $errors = []; + + if (isset($options[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE])) { + if ($options[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE] + != ConfigOptionsListConstants::SESSION_SAVE_FILES + && $options[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE] + != ConfigOptionsListConstants::SESSION_SAVE_DB + ) { + $errors[] = 'Invalid session save location.'; + } + } + + return $errors; + } + + /** + * Validates encryption key param + * + * @param array $options + * @return string[] + */ + private function validateEncryptionKey(array $options) + { + $errors = []; + + if (isset($options[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY]) + && !$options[ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY]) { + $errors[] = 'Invalid encryption key.'; + } + + return $errors; + } +} diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php b/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php index 1c07a2394f51f..4e5d65a84ae53 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php @@ -9,6 +9,7 @@ use Magento\Framework\Filesystem; use Magento\Framework\Module\FullModuleList; use Magento\Framework\Setup\ConfigOptionsListInterface; +use Zend\ServiceManager\ServiceLocatorInterface; /** * Collects all ConfigOptionsList class in modules and setup @@ -43,6 +44,13 @@ class ConfigOptionsListCollector */ private $objectManagerProvider; + /** + * Service locator + * + * @var ServiceLocatorInterface + */ + private $serviceLocator; + /** * Constructor * @@ -50,17 +58,20 @@ class ConfigOptionsListCollector * @param Filesystem $filesystem * @param FullModuleList $fullModuleList * @param ObjectManagerProvider $objectManagerProvider + * @param ServiceLocatorInterface $serviceLocator */ public function __construct( DirectoryList $directoryList, Filesystem $filesystem, FullModuleList $fullModuleList, - ObjectManagerProvider $objectManagerProvider + ObjectManagerProvider $objectManagerProvider, + ServiceLocatorInterface $serviceLocator ) { $this->directoryList = $directoryList; $this->filesystem = $filesystem; $this->fullModuleList = $fullModuleList; $this->objectManagerProvider = $objectManagerProvider; + $this->serviceLocator = $serviceLocator; } /** @@ -84,10 +95,10 @@ public function collectOptionsLists() } } - // check Framework - $setupOptionsClassName = 'Magento\Framework\Config\ConfigOptionsList'; + // check Setup + $setupOptionsClassName = 'Magento\Setup\Model\ConfigOptionsList'; if (class_exists($setupOptionsClassName)) { - $setupOptionsClass = $this->objectManagerProvider->get()->create($setupOptionsClassName); + $setupOptionsClass = $this->serviceLocator->get($setupOptionsClassName); if ($setupOptionsClass instanceof ConfigOptionsListInterface) { $optionsList['setup'] = $setupOptionsClass; } diff --git a/setup/src/Magento/Setup/Model/Deployer.php b/setup/src/Magento/Setup/Model/Deployer.php index 96883fa8c0ee6..b7b02d7d14ed6 100644 --- a/setup/src/Magento/Setup/Model/Deployer.php +++ b/setup/src/Magento/Setup/Model/Deployer.php @@ -125,8 +125,10 @@ public function deploy(ObjectManagerFactory $omFactory, array $locales) $this->count = 0; $this->errorCount = 0; foreach ($appFiles as $info) { - list(, , , $module, $filePath) = $info; - $this->deployFile($filePath, $area, $themePath, $locale, $module); + list($fileArea, , , $module, $filePath) = $info; + if ($fileArea == $area || $fileArea == 'base') { + $this->deployFile($filePath, $area, $themePath, $locale, $module); + } } foreach ($libFiles as $filePath) { $this->deployFile($filePath, $area, $themePath, $locale, null); diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Generator.php b/setup/src/Magento/Setup/Model/Generator.php similarity index 93% rename from dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Generator.php rename to setup/src/Magento/Setup/Model/Generator.php index e7fdaabdea400..5c59b2319b341 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/ImportExport/Fixture/Generator.php +++ b/setup/src/Magento/Setup/Model/Generator.php @@ -7,9 +7,11 @@ /** * A custom "Import" adapter for Magento_ImportExport module that allows generating arbitrary data rows */ -namespace Magento\ToolkitFramework\ImportExport\Fixture; +namespace Magento\Setup\Model; -class Generator extends \Magento\ImportExport\Model\Import\AbstractSource +use Magento\ImportExport\Model\Import\AbstractSource; + +class Generator extends AbstractSource { /** * Data row pattern diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 7dd717f0c4a72..7edb61f9763c2 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -11,7 +11,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\MaintenanceMode; use Magento\Framework\App\Resource\Config; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; use Magento\Framework\Filesystem; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Model\Resource\Db\Context; @@ -31,6 +31,7 @@ use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\App\State\CleanupFiles; use Magento\Setup\Console\Command\InstallCommand; +use Magento\Setup\Validator\DbValidator; /** * Class Installer contains the logic to install Magento application. @@ -185,6 +186,11 @@ class Installer */ private $cleanupFiles; + /** + * @var DbValidator + */ + private $dbValidator; + /** * Constructor * @@ -204,6 +210,7 @@ class Installer * @param Context $context * @param SetupConfigModel $setupConfigModel * @param CleanupFiles $cleanupFiles + * @param DbValidator $dbValidator * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -223,7 +230,8 @@ public function __construct( ObjectManagerProvider $objectManagerProvider, Context $context, SetupConfigModel $setupConfigModel, - CleanupFiles $cleanupFiles + CleanupFiles $cleanupFiles, + DbValidator $dbValidator ) { $this->filePermissions = $filePermissions; $this->deploymentConfigWriter = $deploymentConfigWriter; @@ -242,6 +250,7 @@ public function __construct( $this->context = $context; $this->setupConfigModel = $setupConfigModel; $this->cleanupFiles = $cleanupFiles; + $this->dbValidator = $dbValidator; } /** @@ -417,9 +426,9 @@ public function installDeploymentConfig($data) $userData = is_array($data) ? $data : $data->getArrayCopy(); $this->setupConfigModel->process($userData); if ($this->deploymentConfig->isAvailable()) { - $deploymentConfigData = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_CRYPT_KEY); + $deploymentConfigData = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); if (isset($deploymentConfigData)) { - $this->installInfo[ConfigOptionsList::KEY_ENCRYPTION_KEY] = $deploymentConfigData; + $this->installInfo[ConfigOptionsListConstants::KEY_ENCRYPTION_KEY] = $deploymentConfigData; } } // reset object manager now that there is a deployment config @@ -804,6 +813,25 @@ public function installUserConfig($data) } } + /** + * Creates data handler + * @param string $className + * @param string $interfaceName + * @return mixed|null + * @throws \Magento\Setup\Exception + */ + protected function createSchemaDataHandler($className, $interfaceName) + { + if (class_exists($className)) { + if (!is_subclass_of($className, $interfaceName) && $className !== $interfaceName) { + throw new \Magento\Setup\Exception($className . ' must implement \\' . $interfaceName); + } else { + return $this->objectManagerProvider->get()->create($className); + } + } + return null; + } + /** * Creates store order increment prefix configuration * @@ -955,63 +983,6 @@ private function setMaintenanceMode($value) $this->maintenanceMode->set($value); } - /** - * Checks Database Connection - * - * @param string $dbName - * @param string $dbHost - * @param string $dbUser - * @param string $dbPass - * @return boolean - * @throws \Magento\Setup\Exception - */ - public function checkDatabaseConnection($dbName, $dbHost, $dbUser, $dbPass = '') - { - $connection = $this->connectionFactory->create([ - 'dbname' => $dbName, - 'host' => $dbHost, - 'username' => $dbUser, - 'password' => $dbPass, - 'active' => true, - ]); - - if (!$connection) { - throw new \Magento\Setup\Exception('Database connection failure.'); - } - - $mysqlVersion = $connection->fetchOne('SELECT version()'); - if ($mysqlVersion) { - if (preg_match('/^([0-9\.]+)/', $mysqlVersion, $matches)) { - if (isset($matches[1]) && !empty($matches[1])) { - if (version_compare($matches[1], self::MYSQL_VERSION_REQUIRED) < 0) { - throw new \Magento\Setup\Exception( - 'Sorry, but we support MySQL version '. self::MYSQL_VERSION_REQUIRED . ' or later.' - ); - } - } - } - } - return true; - } - - /** - * Check if database table prefix is valid - * - * @param string $prefix - * @return boolean - * @throws \InvalidArgumentException - */ - public function checkDatabaseTablePrefix($prefix) - { - //The table prefix should contain only letters (a-z), numbers (0-9) or underscores (_); - // the first character should be a letter. - if ($prefix !== '' && !preg_match('/^([a-zA-Z])([[:alnum:]_]+)$/', $prefix)) { - throw new \InvalidArgumentException('Please correct the table prefix format.'); - } - - return true; - } - /** * Return messages * @@ -1029,11 +1000,9 @@ public function getInstallInfo() */ public function cleanupDb() { - // stops cleanup if app/etc/config.php does not exist + // stops cleanup if configuration does not exist if ($this->deploymentConfig->isAvailable()) { - $dbConfig = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $config = $dbConfig['connection'][Config::DEFAULT_SETUP_CONNECTION]; - + $config = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT); if ($config) { try { $connection = $this->connectionFactory->create($config); @@ -1044,7 +1013,7 @@ public function cleanupDb() $this->log->log($e->getMessage() . ' - skipping database cleanup'); return; } - $dbName = $connection->quoteIdentifier($config['dbname']); + $dbName = $connection->quoteIdentifier($config[ConfigOptionsListConstants::KEY_NAME]); $this->log->log("Recreating database {$dbName}"); $connection->query("DROP DATABASE IF EXISTS {$dbName}"); $connection->query("CREATE DATABASE IF NOT EXISTS {$dbName}"); @@ -1062,17 +1031,19 @@ public function cleanupDb() private function deleteDeploymentConfig() { $configDir = $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG); - $file = 'config.php'; - $absolutePath = $configDir->getAbsolutePath($file); - if (!$configDir->isFile($file)) { - $this->log->log("The file '{$absolutePath}' doesn't exist - skipping cleanup"); - return; - } - try { - $this->log->log($absolutePath); - $configDir->delete($file); - } catch (FileSystemException $e) { - $this->log->log($e->getMessage()); + $configFiles = $this->deploymentConfigReader->getFiles(); + foreach ($configFiles as $configFile) { + $absolutePath = $configDir->getAbsolutePath($configFile); + if (!$configDir->isFile($configFile)) { + $this->log->log("The file '{$absolutePath}' doesn't exist - skipping cleanup"); + continue; + } + try { + $this->log->log($absolutePath); + $configDir->delete($configFile); + } catch (FileSystemException $e) { + $this->log->log($e->getMessage()); + } } } @@ -1096,16 +1067,30 @@ private function assertDeploymentConfigExists() */ private function assertDbAccessible() { - $dbConfig = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_DB); - $connectionConfig = $dbConfig['connection'][Config::DEFAULT_SETUP_CONNECTION]; - $this->checkDatabaseConnection( - $connectionConfig[ConfigOptionsList::KEY_NAME], - $connectionConfig[ConfigOptionsList::KEY_HOST], - $connectionConfig[ConfigOptionsList::KEY_USER], - $connectionConfig[ConfigOptionsList::KEY_PASS] + $this->dbValidator->checkDatabaseConnection( + $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_NAME + ), + $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_HOST + ), + $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_USER + ), + $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_PASSWORD + ) + ); + $prefix = $this->deploymentConfig->get( + ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . + '/' . ConfigOptionsListConstants::KEY_PREFIX ); - if (isset($connectionConfig[ConfigOptionsList::KEY_PREFIX])) { - $this->checkDatabaseTablePrefix($connectionConfig[ConfigOptionsList::KEY_PREFIX]); + if (null !== $prefix) { + $this->dbValidator->checkDatabaseTablePrefix($prefix); } } @@ -1131,8 +1116,6 @@ private function installSampleData($request) * @param string $type * @return InstallSchemaInterface | UpgradeSchemaInterface | InstallDataInterface | UpgradeDataInterface | null * @throws \Magento\Setup\Exception - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function getSchemaDataHandler($moduleName, $type) { @@ -1140,67 +1123,29 @@ private function getSchemaDataHandler($moduleName, $type) switch ($type) { case 'schema-install': $className .= '\InstallSchema'; - if (class_exists($className)) { - if (false == is_subclass_of($className, self::SCHEMA_INSTALL) - && $className !== self::SCHEMA_INSTALL) { - throw new \Magento\Setup\Exception($className . ' must implement \\' . self::SCHEMA_INSTALL); - } else { - return $this->objectManagerProvider->get()->create($className); - } - } + $interface = self::SCHEMA_INSTALL; break; case 'schema-upgrade': $className .= '\UpgradeSchema'; - if (class_exists($className)) { - if (false == is_subclass_of($className, self::SCHEMA_UPGRADE) - && $className !== self::SCHEMA_UPGRADE - ) { - throw new \Magento\Setup\Exception($className . ' must implement \\' . self::SCHEMA_UPGRADE); - } else { - return $this->objectManagerProvider->get()->create($className); - } - } + $interface = self::SCHEMA_UPGRADE; break; case 'schema-recurring': $className .= '\Recurring'; - if (class_exists($className)) { - if (false == is_subclass_of($className, self::SCHEMA_INSTALL) - && $className !== self::SCHEMA_INSTALL) { - throw new \Magento\Setup\Exception($className . ' must implement \\' . self::SCHEMA_INSTALL); - } else { - return $this->objectManagerProvider->get()->create($className); - } - } + $interface = self::SCHEMA_INSTALL; break; case 'data-install': $className .= '\InstallData'; - if (class_exists($className)) { - if (false == is_subclass_of($className, self::DATA_INSTALL) - && $className !== self::DATA_INSTALL - ) { - throw new \Magento\Setup\Exception($className . ' must implement \\' . self::DATA_INSTALL); - } else { - return $this->objectManagerProvider->get()->create($className); - } - } + $interface = self::DATA_INSTALL; break; case 'data-upgrade': $className .= '\UpgradeData'; - if (class_exists($className)) { - if (false == is_subclass_of($className, self::DATA_UPGRADE) - && $className !== self::DATA_UPGRADE - ) { - throw new \Magento\Setup\Exception($className . ' must implement \\' . self::DATA_UPGRADE); - } else { - return $this->objectManagerProvider->get()->create($className); - } - } + $interface = self::DATA_UPGRADE; break; default: - throw new \Magento\Setup\Exception("$className does not exist"); + throw new \Magento\Setup\Exception("$className does not exist"); } - return null; + return $this->createSchemaDataHandler($className, $interface); } /** diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php index ce6bb1c994345..32a1e693df30e 100644 --- a/setup/src/Magento/Setup/Model/InstallerFactory.php +++ b/setup/src/Magento/Setup/Model/InstallerFactory.php @@ -68,7 +68,8 @@ public function create(LoggerInterface $log) $this->serviceLocator->get('Magento\Framework\Model\Resource\Db\ObjectRelationProcessor') ), $this->serviceLocator->get('Magento\Setup\Model\ConfigModel'), - $this->serviceLocator->get('Magento\Framework\App\State\CleanupFiles') + $this->serviceLocator->get('Magento\Framework\App\State\CleanupFiles'), + $this->serviceLocator->get('Magento\Setup\Validator\DbValidator') ); } diff --git a/setup/src/Magento/Setup/Model/ModuleStatus.php b/setup/src/Magento/Setup/Model/ModuleStatus.php index d49206b274a48..715d3c75b67a8 100644 --- a/setup/src/Magento/Setup/Model/ModuleStatus.php +++ b/setup/src/Magento/Setup/Model/ModuleStatus.php @@ -10,7 +10,7 @@ use Magento\Framework\Module\ModuleList\Loader as ModuleLoader; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Module\DependencyChecker; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants; class ModuleStatus { @@ -145,7 +145,7 @@ public function setIsEnabled($status, $moduleName) */ private function deselectDisabledModules() { - $existingModules = $this->deploymentConfig->getConfigData(ConfigOptionsList::KEY_MODULES); + $existingModules = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_MODULES); if (isset($existingModules)) { foreach ($existingModules as $module => $value) { if (!$value) { diff --git a/setup/src/Magento/Setup/Model/SampleData.php b/setup/src/Magento/Setup/Model/SampleData.php index 0e9e4eaeea9b9..ad75e70bb72a5 100644 --- a/setup/src/Magento/Setup/Model/SampleData.php +++ b/setup/src/Magento/Setup/Model/SampleData.php @@ -20,19 +20,21 @@ class SampleData /** * Path to the sample data application */ - const PATH = 'dev/tools/Magento/Tools/SampleData'; + const PATH = '/Magento/SampleData'; /** - * @var \Magento\Framework\Filesystem\Directory\ReadInterface + * Filesystem Directory List + * + * @var DirectoryList */ - private $rootDir; + private $directoryList; /** - * @param Filesystem $filesystem + * @param DirectoryList $directoryList */ - public function __construct(Filesystem $filesystem) + public function __construct(DirectoryList $directoryList) { - $this->rootDir = $filesystem->getDirectoryRead(DirectoryList::ROOT); + $this->directoryList = $directoryList; } /** @@ -42,7 +44,7 @@ public function __construct(Filesystem $filesystem) */ public function isDeployed() { - return $this->rootDir->isExist(self::PATH); + return file_exists($this->directoryList->getPath(DirectoryList::MODULES) . self::PATH); } /** @@ -51,13 +53,18 @@ public function isDeployed() * @param ObjectManagerInterface $objectManager * @param LoggerInterface $logger * @param string $userName + * @param array $modules * @throws \Exception * @return void */ - public function install(ObjectManagerInterface $objectManager, LoggerInterface $logger, $userName) - { - /** @var \Magento\Tools\SampleData\Logger $sampleDataLogger */ - $sampleDataLogger = $objectManager->get('Magento\Tools\SampleData\Logger'); + public function install( + ObjectManagerInterface $objectManager, + LoggerInterface $logger, + $userName, + array $modules = [] + ) { + /** @var \Magento\SampleData\Model\Logger $sampleDataLogger */ + $sampleDataLogger = $objectManager->get('Magento\SampleData\Model\Logger'); $sampleDataLogger->setSubject($logger); $areaCode = 'adminhtml'; @@ -68,8 +75,8 @@ public function install(ObjectManagerInterface $objectManager, LoggerInterface $ $configLoader = $objectManager->get('Magento\Framework\App\ObjectManager\ConfigLoader'); $objectManager->configure($configLoader->load($areaCode)); - /** @var \Magento\Tools\SampleData\Installer $installer */ - $installer = $objectManager->get('Magento\Tools\SampleData\Installer'); - $installer->run($userName); + /** @var \Magento\SampleData\Model\Installer $installer */ + $installer = $objectManager->get('Magento\SampleData\Model\Installer'); + $installer->run($userName, $modules); } } diff --git a/setup/src/Magento/Setup/Model/StoreConfigurationDataMapper.php b/setup/src/Magento/Setup/Model/StoreConfigurationDataMapper.php index 0fa3c23524456..11a3a36e4cd38 100644 --- a/setup/src/Magento/Setup/Model/StoreConfigurationDataMapper.php +++ b/setup/src/Magento/Setup/Model/StoreConfigurationDataMapper.php @@ -22,15 +22,15 @@ class StoreConfigurationDataMapper /**#@+ * Model data keys */ - const KEY_USE_SEF_URL = 'use_rewrites'; - const KEY_BASE_URL = 'base_url'; - const KEY_BASE_URL_SECURE = 'base_url_secure'; - const KEY_IS_SECURE = 'use_secure'; - const KEY_IS_SECURE_ADMIN = 'use_secure_admin'; + const KEY_USE_SEF_URL = 'use-rewrites'; + const KEY_BASE_URL = 'base-url'; + const KEY_BASE_URL_SECURE = 'base-url-secure'; + const KEY_IS_SECURE = 'use-secure'; + const KEY_IS_SECURE_ADMIN = 'use-secure-admin'; const KEY_LANGUAGE = 'language'; const KEY_TIMEZONE = 'timezone'; const KEY_CURRENCY = 'currency'; - const KEY_ADMIN_USE_SECURITY_KEY = 'admin_use_security_key'; + const KEY_ADMIN_USE_SECURITY_KEY = 'admin-use-security-key'; /**#@- */ /** diff --git a/dev/tools/Magento/Tools/Dependency/Circular.php b/setup/src/Magento/Setup/Module/Dependency/Circular.php similarity index 98% rename from dev/tools/Magento/Tools/Dependency/Circular.php rename to setup/src/Magento/Setup/Module/Dependency/Circular.php index 1589083ab0490..0f939ea5d5419 100644 --- a/dev/tools/Magento/Tools/Dependency/Circular.php +++ b/setup/src/Magento/Setup/Module/Dependency/Circular.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency; +namespace Magento\Setup\Module\Dependency; use Magento\Framework\Data\Graph; diff --git a/dev/tools/Magento/Tools/Dependency/Parser/Code.php b/setup/src/Magento/Setup/Module/Dependency/Parser/Code.php similarity index 96% rename from dev/tools/Magento/Tools/Dependency/Parser/Code.php rename to setup/src/Magento/Setup/Module/Dependency/Parser/Code.php index 133836c21293f..39d30a1557a95 100644 --- a/dev/tools/Magento/Tools/Dependency/Parser/Code.php +++ b/setup/src/Magento/Setup/Module/Dependency/Parser/Code.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Parser; +namespace Magento\Setup\Module\Dependency\Parser; -use Magento\Tools\Dependency\ParserInterface; +use Magento\Setup\Module\Dependency\ParserInterface; /** * Code parser diff --git a/dev/tools/Magento/Tools/Dependency/Parser/Composer/Json.php b/setup/src/Magento/Setup/Module/Dependency/Parser/Composer/Json.php similarity index 96% rename from dev/tools/Magento/Tools/Dependency/Parser/Composer/Json.php rename to setup/src/Magento/Setup/Module/Dependency/Parser/Composer/Json.php index cf1ce6504f8da..f8a2efc05aa51 100644 --- a/dev/tools/Magento/Tools/Dependency/Parser/Composer/Json.php +++ b/setup/src/Magento/Setup/Module/Dependency/Parser/Composer/Json.php @@ -3,10 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Parser\Composer; +namespace Magento\Setup\Module\Dependency\Parser\Composer; use Magento\Framework\Config\Composer\Package; -use Magento\Tools\Dependency\ParserInterface; +use Magento\Setup\Module\Dependency\ParserInterface; /** * Composer Json parser diff --git a/dev/tools/Magento/Tools/Dependency/Parser/Config/Xml.php b/setup/src/Magento/Setup/Module/Dependency/Parser/Config/Xml.php similarity index 94% rename from dev/tools/Magento/Tools/Dependency/Parser/Config/Xml.php rename to setup/src/Magento/Setup/Module/Dependency/Parser/Config/Xml.php index 127cb6c4cc290..aec365bd41363 100644 --- a/dev/tools/Magento/Tools/Dependency/Parser/Config/Xml.php +++ b/setup/src/Magento/Setup/Module/Dependency/Parser/Config/Xml.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Parser\Config; +namespace Magento\Setup\Module\Dependency\Parser\Config; -use Magento\Tools\Dependency\ParserInterface; +use Magento\Setup\Module\Dependency\ParserInterface; /** * Config xml parser diff --git a/dev/tools/Magento/Tools/Dependency/ParserInterface.php b/setup/src/Magento/Setup/Module/Dependency/ParserInterface.php similarity index 87% rename from dev/tools/Magento/Tools/Dependency/ParserInterface.php rename to setup/src/Magento/Setup/Module/Dependency/ParserInterface.php index bd851f518fc97..d9d9552e37da5 100644 --- a/dev/tools/Magento/Tools/Dependency/ParserInterface.php +++ b/setup/src/Magento/Setup/Module/Dependency/ParserInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency; +namespace Magento\Setup\Module\Dependency; /** * Parser Interface diff --git a/dev/tools/Magento/Tools/Dependency/Report/Builder/AbstractBuilder.php b/setup/src/Magento/Setup/Module/Dependency/Report/Builder/AbstractBuilder.php similarity index 81% rename from dev/tools/Magento/Tools/Dependency/Report/Builder/AbstractBuilder.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Builder/AbstractBuilder.php index aebde9c6cfb96..b8c73a114b1ef 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Builder/AbstractBuilder.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Builder/AbstractBuilder.php @@ -3,11 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Builder; +namespace Magento\Setup\Module\Dependency\Report\Builder; -use Magento\Tools\Dependency\ParserInterface; -use Magento\Tools\Dependency\Report\BuilderInterface; -use Magento\Tools\Dependency\Report\WriterInterface; +use Magento\Setup\Module\Dependency\ParserInterface; +use Magento\Setup\Module\Dependency\Report\BuilderInterface; +use Magento\Setup\Module\Dependency\Report\WriterInterface; /** * Abstract report builder by config files @@ -17,14 +17,14 @@ abstract class AbstractBuilder implements BuilderInterface /** * Dependencies parser * - * @var \Magento\Tools\Dependency\ParserInterface + * @var \Magento\Setup\Module\Dependency\ParserInterface */ protected $dependenciesParser; /** * Report writer * - * @var \Magento\Tools\Dependency\Report\WriterInterface + * @var \Magento\Setup\Module\Dependency\Report\WriterInterface */ protected $reportWriter; @@ -81,7 +81,7 @@ protected function checkOptions($options) * Template method. Prepare data for writer step * * @param array $modulesData - * @return \Magento\Tools\Dependency\Report\Data\ConfigInterface + * @return \Magento\Setup\Module\Dependency\Report\Data\ConfigInterface */ abstract protected function buildData($modulesData); } diff --git a/dev/tools/Magento/Tools/Dependency/Report/BuilderInterface.php b/setup/src/Magento/Setup/Module/Dependency/Report/BuilderInterface.php similarity index 85% rename from dev/tools/Magento/Tools/Dependency/Report/BuilderInterface.php rename to setup/src/Magento/Setup/Module/Dependency/Report/BuilderInterface.php index 5cbb5f020dc4b..53aabb8ef11f5 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/BuilderInterface.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/BuilderInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report; +namespace Magento\Setup\Module\Dependency\Report; /** * Builder Interface diff --git a/dev/tools/Magento/Tools/Dependency/Report/Circular/Builder.php b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Builder.php similarity index 72% rename from dev/tools/Magento/Tools/Dependency/Report/Circular/Builder.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Circular/Builder.php index 4e306689c7b14..2f2d3a7ea78fb 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Circular/Builder.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Builder.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Circular; +namespace Magento\Setup\Module\Dependency\Report\Circular; -use Magento\Tools\Dependency\Circular; -use Magento\Tools\Dependency\ParserInterface; -use Magento\Tools\Dependency\Report\Builder\AbstractBuilder; -use Magento\Tools\Dependency\Report\WriterInterface; +use Magento\Setup\Module\Dependency\Circular; +use Magento\Setup\Module\Dependency\ParserInterface; +use Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder; +use Magento\Setup\Module\Dependency\Report\WriterInterface; /** * Dependencies report builder @@ -18,16 +18,16 @@ class Builder extends AbstractBuilder /** * Circular dependencies builder * - * @var \Magento\Tools\Dependency\Circular + * @var \Magento\Setup\Module\Dependency\Circular */ protected $circularBuilder; /** * Builder constructor * - * @param \Magento\Tools\Dependency\ParserInterface $dependenciesParser - * @param \Magento\Tools\Dependency\Report\WriterInterface $reportWriter - * @param \Magento\Tools\Dependency\Circular $circularBuilder + * @param \Magento\Setup\Module\Dependency\ParserInterface $dependenciesParser + * @param \Magento\Setup\Module\Dependency\Report\WriterInterface $reportWriter + * @param \Magento\Setup\Module\Dependency\Circular $circularBuilder */ public function __construct( ParserInterface $dependenciesParser, @@ -43,7 +43,7 @@ public function __construct( * Template method. Prepare data for writer step * * @param array $modulesData - * @return \Magento\Tools\Dependency\Report\Circular\Data\Config + * @return \Magento\Setup\Module\Dependency\Report\Circular\Data\Config */ protected function buildData($modulesData) { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Chain.php b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Chain.php similarity index 87% rename from dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Chain.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Chain.php index 256d9dd81ec81..a0d3e88f4919c 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Chain.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Chain.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Circular\Data; +namespace Magento\Setup\Module\Dependency\Report\Circular\Data; /** * Chain diff --git a/dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Config.php b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Config.php similarity index 66% rename from dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Config.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Config.php index 6f10a943b332a..87e4c35eb98c1 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Config.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Config.php @@ -3,14 +3,14 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Circular\Data; +namespace Magento\Setup\Module\Dependency\Report\Circular\Data; -use Magento\Tools\Dependency\Report\Data\Config\AbstractConfig; +use Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig; /** * Config * - * @method \Magento\Tools\Dependency\Report\Circular\Data\Module[] getModules() + * @method \Magento\Setup\Module\Dependency\Report\Circular\Data\Module[] getModules() */ class Config extends AbstractConfig { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Module.php b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Module.php similarity index 76% rename from dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Module.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Module.php index fdb6691d97dae..0a85611034588 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Circular/Data/Module.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Data/Module.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Circular\Data; +namespace Magento\Setup\Module\Dependency\Report\Circular\Data; /** * Module @@ -20,7 +20,7 @@ class Module /** * Circular dependencies chains * - * @var \Magento\Tools\Dependency\Report\Circular\Data\Chain[] + * @var \Magento\Setup\Module\Dependency\Report\Circular\Data\Chain[] */ protected $chains; @@ -28,7 +28,7 @@ class Module * Module construct * * @param array $name - * @param \Magento\Tools\Dependency\Report\Circular\Data\Chain[] $chains + * @param \Magento\Setup\Module\Dependency\Report\Circular\Data\Chain[] $chains */ public function __construct($name, array $chains = []) { @@ -49,7 +49,7 @@ public function getName() /** * Get circular dependencies chains * - * @return \Magento\Tools\Dependency\Report\Circular\Data\Chain[] + * @return \Magento\Setup\Module\Dependency\Report\Circular\Data\Chain[] */ public function getChains() { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Circular/Writer.php b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Writer.php similarity index 83% rename from dev/tools/Magento/Tools/Dependency/Report/Circular/Writer.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Circular/Writer.php index 57538f4767ce2..a1e57ab038331 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Circular/Writer.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Circular/Writer.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Circular; +namespace Magento\Setup\Module\Dependency\Report\Circular; -use Magento\Tools\Dependency\Report\Writer\Csv\AbstractWriter; +use Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter; /** * Csv file writer for circular dependencies report @@ -20,7 +20,7 @@ class Writer extends AbstractWriter /** * Template method. Prepare data step * - * @param \Magento\Tools\Dependency\Report\Circular\Data\Config $config + * @param \Magento\Setup\Module\Dependency\Report\Circular\Data\Config $config * @return array */ protected function prepareData($config) diff --git a/dev/tools/Magento/Tools/Dependency/Report/Data/Config/AbstractConfig.php b/setup/src/Magento/Setup/Module/Dependency/Report/Data/Config/AbstractConfig.php similarity index 83% rename from dev/tools/Magento/Tools/Dependency/Report/Data/Config/AbstractConfig.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Data/Config/AbstractConfig.php index 0719d84e7e4f6..c04192d7a240a 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Data/Config/AbstractConfig.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Data/Config/AbstractConfig.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Data\Config; +namespace Magento\Setup\Module\Dependency\Report\Data\Config; -use Magento\Tools\Dependency\Report\Data\ConfigInterface; +use Magento\Setup\Module\Dependency\Report\Data\ConfigInterface; /** * Config diff --git a/dev/tools/Magento/Tools/Dependency/Report/Data/ConfigInterface.php b/setup/src/Magento/Setup/Module/Dependency/Report/Data/ConfigInterface.php similarity index 87% rename from dev/tools/Magento/Tools/Dependency/Report/Data/ConfigInterface.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Data/ConfigInterface.php index c1108df9e486d..d204e5fd93258 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Data/ConfigInterface.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Data/ConfigInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Data; +namespace Magento\Setup\Module\Dependency\Report\Data; /** * Config diff --git a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Builder.php b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Builder.php similarity index 79% rename from dev/tools/Magento/Tools/Dependency/Report/Dependency/Builder.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Builder.php index 473f30313608a..b0f5fa3b8778e 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Builder.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Builder.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Dependency; +namespace Magento\Setup\Module\Dependency\Report\Dependency; -use Magento\Tools\Dependency\Report\Builder\AbstractBuilder; +use Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder; /** * Modules dependencies report builder @@ -16,7 +16,7 @@ class Builder extends AbstractBuilder * Template method. Prepare data for writer step * * @param array $modulesData - * @return \Magento\Tools\Dependency\Report\Dependency\Data\Config + * @return \Magento\Setup\Module\Dependency\Report\Dependency\Data\Config */ protected function buildData($modulesData) { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Config.php b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Config.php similarity index 81% rename from dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Config.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Config.php index 7ecc5e61aceb4..518bf6ccabbd1 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Config.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Config.php @@ -3,14 +3,14 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Dependency\Data; +namespace Magento\Setup\Module\Dependency\Report\Dependency\Data; -use Magento\Tools\Dependency\Report\Data\Config\AbstractConfig; +use Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig; /** * Config * - * @method \Magento\Tools\Dependency\Report\Dependency\Data\Module[] getModules() + * @method \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module[] getModules() */ class Config extends AbstractConfig { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Dependency.php b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Dependency.php similarity index 95% rename from dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Dependency.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Dependency.php index 4b33bc8737486..ba97debadead4 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Dependency.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Dependency.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Dependency\Data; +namespace Magento\Setup\Module\Dependency\Report\Dependency\Data; /** * Dependency diff --git a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Module.php b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Module.php similarity index 83% rename from dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Module.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Module.php index 5c99904d381b8..32e26bb123440 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Data/Module.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Data/Module.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Dependency\Data; +namespace Magento\Setup\Module\Dependency\Report\Dependency\Data; /** * Module @@ -20,7 +20,7 @@ class Module /** * Module dependencies * - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Dependency[] + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency[] */ protected $dependencies; @@ -28,7 +28,7 @@ class Module * Module construct * * @param array $name - * @param \Magento\Tools\Dependency\Report\Dependency\Data\Dependency[] $dependencies + * @param \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency[] $dependencies */ public function __construct($name, array $dependencies = []) { @@ -49,7 +49,7 @@ public function getName() /** * Get dependencies * - * @return \Magento\Tools\Dependency\Report\Dependency\Data\Dependency[] + * @return \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency[] */ public function getDependencies() { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Writer.php b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Writer.php similarity index 88% rename from dev/tools/Magento/Tools/Dependency/Report/Dependency/Writer.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Writer.php index d34c954f5112a..651d800e7dc54 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Dependency/Writer.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Dependency/Writer.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Dependency; +namespace Magento\Setup\Module\Dependency\Report\Dependency; -use Magento\Tools\Dependency\Report\Writer\Csv\AbstractWriter; +use Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter; /** * Csv file writer for modules dependencies report @@ -15,7 +15,7 @@ class Writer extends AbstractWriter /** * Template method. Prepare data step * - * @param \Magento\Tools\Dependency\Report\Dependency\Data\Config $config + * @param \Magento\Setup\Module\Dependency\Report\Dependency\Data\Config $config * @return array */ protected function prepareData($config) diff --git a/dev/tools/Magento/Tools/Dependency/Report/Framework/Builder.php b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Builder.php similarity index 85% rename from dev/tools/Magento/Tools/Dependency/Report/Framework/Builder.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Framework/Builder.php index a4b2140060284..d498d2074c05a 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Framework/Builder.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Builder.php @@ -3,11 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Framework; +namespace Magento\Setup\Module\Dependency\Report\Framework; -use Magento\Tools\Dependency\ParserInterface; -use Magento\Tools\Dependency\Report\Builder\AbstractBuilder; -use Magento\Tools\Dependency\Report\WriterInterface; +use Magento\Setup\Module\Dependency\ParserInterface; +use Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder; +use Magento\Setup\Module\Dependency\Report\WriterInterface; /** * Framework dependencies report builder @@ -17,7 +17,7 @@ class Builder extends AbstractBuilder /** * Config parser * - * @var \Magento\Tools\Dependency\ParserInterface + * @var \Magento\Setup\Module\Dependency\ParserInterface */ protected $configParser; @@ -58,7 +58,7 @@ protected function checkOptions($options) * Template method. Prepare data for writer step * * @param array $modulesData - * @return \Magento\Tools\Dependency\Report\Framework\Data\Config + * @return \Magento\Setup\Module\Dependency\Report\Framework\Data\Config */ protected function buildData($modulesData) { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Config.php b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Config.php similarity index 67% rename from dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Config.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Config.php index 464664593c4f0..8c3f0b6b5e6be 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Config.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Config.php @@ -3,14 +3,14 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Framework\Data; +namespace Magento\Setup\Module\Dependency\Report\Framework\Data; -use Magento\Tools\Dependency\Report\Data\Config\AbstractConfig; +use Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig; /** * Config * - * @method \Magento\Tools\Dependency\Report\Framework\Data\Module[] getModules() + * @method \Magento\Setup\Module\Dependency\Report\Framework\Data\Module[] getModules() */ class Config extends AbstractConfig { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Dependency.php b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Dependency.php similarity index 92% rename from dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Dependency.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Dependency.php index 95deff3c8065b..b1bd6038425d1 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Dependency.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Dependency.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Framework\Data; +namespace Magento\Setup\Module\Dependency\Report\Framework\Data; /** * Dependency diff --git a/dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Module.php b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Module.php similarity index 74% rename from dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Module.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Module.php index 50093ad2f003c..006d56b76fe3f 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Framework/Data/Module.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Data/Module.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Framework\Data; +namespace Magento\Setup\Module\Dependency\Report\Framework\Data; /** * Module @@ -20,7 +20,7 @@ class Module /** * Module dependencies * - * @var \Magento\Tools\Dependency\Report\Framework\Data\Dependency[] + * @var \Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency[] */ protected $dependencies; @@ -28,7 +28,7 @@ class Module * Module construct * * @param array $name - * @param \Magento\Tools\Dependency\Report\Framework\Data\Dependency[] $dependencies + * @param \Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency[] $dependencies */ public function __construct($name, array $dependencies = []) { @@ -49,7 +49,7 @@ public function getName() /** * Get dependencies * - * @return \Magento\Tools\Dependency\Report\Framework\Data\Dependency[] + * @return \Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency[] */ public function getDependencies() { diff --git a/dev/tools/Magento/Tools/Dependency/Report/Framework/Writer.php b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Writer.php similarity index 82% rename from dev/tools/Magento/Tools/Dependency/Report/Framework/Writer.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Framework/Writer.php index 756256f68f7a4..d6fb3341c3c88 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Framework/Writer.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Framework/Writer.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Framework; +namespace Magento\Setup\Module\Dependency\Report\Framework; -use Magento\Tools\Dependency\Report\Writer\Csv\AbstractWriter; +use Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter; /** * Csv file writer for framework dependencies report @@ -15,7 +15,7 @@ class Writer extends AbstractWriter /** * Template method. Prepare data step * - * @param \Magento\Tools\Dependency\Report\Framework\Data\Config $config + * @param \Magento\Setup\Module\Dependency\Report\Framework\Data\Config $config * @return array */ protected function prepareData($config) diff --git a/dev/tools/Magento/Tools/Dependency/Report/Writer/Csv/AbstractWriter.php b/setup/src/Magento/Setup/Module/Dependency/Report/Writer/Csv/AbstractWriter.php similarity index 85% rename from dev/tools/Magento/Tools/Dependency/Report/Writer/Csv/AbstractWriter.php rename to setup/src/Magento/Setup/Module/Dependency/Report/Writer/Csv/AbstractWriter.php index c62e02bad8e4c..d5013a1508756 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/Writer/Csv/AbstractWriter.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/Writer/Csv/AbstractWriter.php @@ -3,10 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report\Writer\Csv; +namespace Magento\Setup\Module\Dependency\Report\Writer\Csv; -use Magento\Tools\Dependency\Report\Data\ConfigInterface; -use Magento\Tools\Dependency\Report\WriterInterface; +use Magento\Setup\Module\Dependency\Report\Data\ConfigInterface; +use Magento\Setup\Module\Dependency\Report\WriterInterface; /** * Abstract csv file writer for reports @@ -59,7 +59,7 @@ protected function checkOptions($options) /** * Template method. Prepare data step * - * @param \Magento\Tools\Dependency\Report\Data\ConfigInterface $config + * @param \Magento\Setup\Module\Dependency\Report\Data\ConfigInterface $config * @return array */ abstract protected function prepareData($config); diff --git a/dev/tools/Magento/Tools/Dependency/Report/WriterInterface.php b/setup/src/Magento/Setup/Module/Dependency/Report/WriterInterface.php similarity index 62% rename from dev/tools/Magento/Tools/Dependency/Report/WriterInterface.php rename to setup/src/Magento/Setup/Module/Dependency/Report/WriterInterface.php index 0b2f0bfafec08..74780c5816e35 100644 --- a/dev/tools/Magento/Tools/Dependency/Report/WriterInterface.php +++ b/setup/src/Magento/Setup/Module/Dependency/Report/WriterInterface.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Report; +namespace Magento\Setup\Module\Dependency\Report; -use Magento\Tools\Dependency\Report\Data\ConfigInterface; +use Magento\Setup\Module\Dependency\Report\Data\ConfigInterface; /** * Writer Interface @@ -16,7 +16,7 @@ interface WriterInterface * Write a report file * * @param array $options - * @param \Magento\Tools\Dependency\Report\Data\ConfigInterface $config + * @param \Magento\Setup\Module\Dependency\Report\Data\ConfigInterface $config * @return void */ public function write(array $options, ConfigInterface $config); diff --git a/dev/tools/Magento/Tools/Dependency/ServiceLocator.php b/setup/src/Magento/Setup/Module/Dependency/ServiceLocator.php similarity index 76% rename from dev/tools/Magento/Tools/Dependency/ServiceLocator.php rename to setup/src/Magento/Setup/Module/Dependency/ServiceLocator.php index eb4427480652a..dc4c45f9962f5 100644 --- a/dev/tools/Magento/Tools/Dependency/ServiceLocator.php +++ b/setup/src/Magento/Setup/Module/Dependency/ServiceLocator.php @@ -3,13 +3,13 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency; +namespace Magento\Setup\Module\Dependency; use Magento\Framework\File\Csv; -use Magento\Tools\Dependency\Circular as CircularTool; -use Magento\Tools\Dependency\Report\Circular as CircularReport; -use Magento\Tools\Dependency\Report\Dependency; -use Magento\Tools\Dependency\Report\Framework; +use Magento\Setup\Module\Dependency\Circular as CircularTool; +use Magento\Setup\Module\Dependency\Report\Circular as CircularReport; +use Magento\Setup\Module\Dependency\Report\Dependency; +use Magento\Setup\Module\Dependency\Report\Framework; /** * Service Locator (instead DI container) @@ -21,42 +21,42 @@ class ServiceLocator /** * Xml config dependencies parser * - * @var \Magento\Tools\Dependency\ParserInterface + * @var \Magento\Setup\Module\Dependency\ParserInterface */ private static $xmlConfigParser; /** * Composer Json parser * - * @var \Magento\Tools\Dependency\ParserInterface + * @var \Magento\Setup\Module\Dependency\ParserInterface */ private static $composerJsonParser; /** * Framework dependencies parser * - * @var \Magento\Tools\Dependency\ParserInterface + * @var \Magento\Setup\Module\Dependency\ParserInterface */ private static $frameworkDependenciesParser; /** * Modules dependencies report builder * - * @var \Magento\Tools\Dependency\Report\BuilderInterface + * @var \Magento\Setup\Module\Dependency\Report\BuilderInterface */ private static $dependenciesReportBuilder; /** * Modules circular dependencies report builder * - * @var \Magento\Tools\Dependency\Report\BuilderInterface + * @var \Magento\Setup\Module\Dependency\Report\BuilderInterface */ private static $circularDependenciesReportBuilder; /** * Framework dependencies report builder * - * @var \Magento\Tools\Dependency\Report\BuilderInterface + * @var \Magento\Setup\Module\Dependency\Report\BuilderInterface */ private static $frameworkDependenciesReportBuilder; @@ -70,7 +70,7 @@ class ServiceLocator /** * Get modules dependencies report builder * - * @return \Magento\Tools\Dependency\Report\BuilderInterface + * @return \Magento\Setup\Module\Dependency\Report\BuilderInterface */ public static function getDependenciesReportBuilder() { @@ -86,7 +86,7 @@ public static function getDependenciesReportBuilder() /** * Get modules circular dependencies report builder * - * @return \Magento\Tools\Dependency\Report\BuilderInterface + * @return \Magento\Setup\Module\Dependency\Report\BuilderInterface */ public static function getCircularDependenciesReportBuilder() { @@ -103,7 +103,7 @@ public static function getCircularDependenciesReportBuilder() /** * Get framework dependencies report builder * - * @return \Magento\Tools\Dependency\Report\BuilderInterface + * @return \Magento\Setup\Module\Dependency\Report\BuilderInterface */ public static function getFrameworkDependenciesReportBuilder() { @@ -120,7 +120,7 @@ public static function getFrameworkDependenciesReportBuilder() /** * Get modules dependencies parser * - * @return \Magento\Tools\Dependency\ParserInterface + * @return \Magento\Setup\Module\Dependency\ParserInterface */ private static function getXmlConfigParser() { @@ -133,7 +133,7 @@ private static function getXmlConfigParser() /** * Get modules dependencies from composer.json parser * - * @return \Magento\Tools\Dependency\ParserInterface + * @return \Magento\Setup\Module\Dependency\ParserInterface */ private static function getComposerJsonParser() { @@ -146,7 +146,7 @@ private static function getComposerJsonParser() /** * Get framework dependencies parser * - * @return \Magento\Tools\Dependency\ParserInterface + * @return \Magento\Setup\Module\Dependency\ParserInterface */ private static function getFrameworkDependenciesParser() { @@ -164,7 +164,7 @@ private static function getFrameworkDependenciesParser() private static function getCsvWriter() { if (null === self::$csvWriter) { - self::$csvWriter = (new Csv())->setDelimiter(';'); + self::$csvWriter = new Csv(); } return self::$csvWriter; } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php new file mode 100644 index 0000000000000..eed75e7e329ea --- /dev/null +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php @@ -0,0 +1,67 @@ +directoryScanner = $directoryScanner; + $this->serviceDataAttributesScanner = $repositoryScanner; + $this->data = $data; + } + + /** + * Processes operation task + * + * @return void + */ + public function doOperation() + { + if (array_diff(array_keys($this->data), ['filePatterns', 'path']) + !== array_diff(['filePatterns', 'path'], array_keys($this->data))) { + return; + } + + $files = $this->directoryScanner->scan($this->data['path'], $this->data['filePatterns']); + $repositories = $this->serviceDataAttributesScanner->collectEntities($files['service_data_attributes']); + foreach ($repositories as $entityName) { + class_exists($entityName); + } + } +} diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php b/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php index a2505bad47a0e..69406279ccab9 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php @@ -32,6 +32,11 @@ class OperationFactory */ const REPOSITORY_GENERATOR = 'repository_generator'; + /** + * Service data attributes generator + */ + const DATA_ATTRIBUTES_GENERATOR = 'service_data_attributes_generator'; + /** * Application code generator */ @@ -43,6 +48,7 @@ class OperationFactory * @var array */ private $operationsDefinitions = [ + self::DATA_ATTRIBUTES_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator', self::AREA_CONFIG_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\Area', self::APPLICATION_CODE_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator', self::INTERCEPTION => 'Magento\Setup\Module\Di\App\Task\Operation\Interception', diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/ServiceDataAttributesScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/ServiceDataAttributesScanner.php new file mode 100644 index 0000000000000..6fc9e34100810 --- /dev/null +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/ServiceDataAttributesScanner.php @@ -0,0 +1,35 @@ +loadXML(file_get_contents($fileName)); + $xpath = new \DOMXPath($dom); + /** @var $node \DOMNode */ + foreach ($xpath->query('//extension_attributes') as $node) { + $forType = $node->attributes->getNamedItem('for')->nodeValue; + $extensionClasses[] = str_replace('Interface', 'ExtensionInterface', $forType); + $extensionClasses[] = str_replace('Interface', 'Extension', $forType); + } + } + return $extensionClasses; + } +} diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 1d229e825f9c8..e2525c9e4fbe1 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -30,7 +30,7 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface /** * A CLI parameter for injecting bootstrap variables */ - const BOOTSTRAP_PARAM = 'magento_init_params'; + const BOOTSTRAP_PARAM = 'magento-init-params'; /** * List of ZF event listeners diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php index 3e8ad803fd37a..867cd2df7b241 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php @@ -8,6 +8,7 @@ use Magento\Setup\Model\AdminAccount; use Magento\Setup\Console\Command\AdminUserCreateCommand; use Magento\Setup\Mvc\Bootstrap\InitParamListener; +use Magento\User\Model\UserValidationRules; use Symfony\Component\Console\Tester\CommandTester; class AdminUserCreateCommandTest extends \PHPUnit_Framework_TestCase @@ -25,7 +26,7 @@ class AdminUserCreateCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->installerFactoryMock = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->command = new AdminUserCreateCommand($this->installerFactoryMock); + $this->command = new AdminUserCreateCommand($this->installerFactoryMock, new UserValidationRules()); } public function testExecute() @@ -81,12 +82,36 @@ public function testValidate(array $options, array $errors) public function validateDataProvider() { return [ - [[false, true, true, true, true], ['Missing option ' . AdminAccount::KEY_USER]], + [[null, 'Doe', 'admin', 'test@test.com', '123123q'], ['First Name is a required field.']], [ - [true, false, false, true, true], - ['Missing option ' . AdminAccount::KEY_PASSWORD, 'Missing option ' . AdminAccount::KEY_EMAIL], + ['John', null, null, 'test@test.com', '123123q'], + ['User Name is a required field.', 'Last Name is a required field.'], ], - [[true, true, true, true, true], []], + [['John', 'Doe', 'admin', null, '123123q'], ['Please enter a valid email.']], + [ + ['John', 'Doe', 'admin', 'test', '123123q'], + ["'test' is not a valid email address in the basic format local-part@hostname"] + ], + [ + ['John', 'Doe', 'admin', 'test@test.com', ''], + [ + 'Password is required field.', + 'Your password must be at least 7 characters.', + 'Your password must include both numeric and alphabetic characters.' + ] + ], + [ + ['John', 'Doe', 'admin', 'test@test.com', '123123'], + [ + 'Your password must be at least 7 characters.', + 'Your password must include both numeric and alphabetic characters.' + ] + ], + [ + ['John', 'Doe', 'admin', 'test@test.com', '1231231'], + ['Your password must include both numeric and alphabetic characters.'] + ], + [['John', 'Doe', 'admin', 'test@test.com', '123123q'], []], ]; } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php index 11e08c4faf778..5e7ee9a76a399 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php @@ -33,7 +33,7 @@ public function setUp() $option ->expects($this->any()) ->method('getName') - ->will($this->returnValue('db_host')); + ->will($this->returnValue('db-host')); $this->configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false); $this->configModel ->expects($this->exactly(2)) @@ -53,9 +53,9 @@ public function testExecuteNoInteractive() $this->configModel ->expects($this->once()) ->method('process') - ->with(['db_host' => 'host']); + ->with(['db-host' => 'host']); $commandTester = new CommandTester($this->command); - $commandTester->execute(['--db_host' => 'host']); + $commandTester->execute(['--db-host' => 'host']); $this->assertSame( 'You saved the new configuration.' . PHP_EOL, $commandTester->getDisplay() @@ -71,7 +71,7 @@ public function testExecuteInteractiveWithYes() $this->configModel ->expects($this->once()) ->method('process') - ->with(['db_host' => 'host']); + ->with(['db-host' => 'host']); $this->checkInteraction(true); } @@ -112,7 +112,7 @@ private function checkInteraction($interactionType) $this->command->setHelperSet($helperSet); $commandTester = new CommandTester($this->command); - $commandTester->execute(['--db_host' => 'host']); + $commandTester->execute(['--db-host' => 'host']); if ($interactionType) { $message = 'You saved the new configuration.' . PHP_EOL; } else { diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php index 9f8d24d51667c..40ad3ab8c6be2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php @@ -7,6 +7,7 @@ use Magento\Setup\Console\Command\DeployStaticContentCommand; use Symfony\Component\Console\Tester\CommandTester; +use Magento\Framework\Validator\Locale; class DeployStaticContentCommandTest extends \PHPUnit_Framework_TestCase { @@ -40,6 +41,11 @@ class DeployStaticContentCommandTest extends \PHPUnit_Framework_TestCase */ private $command; + /** + * @var Locale|\PHPUnit_Framework_MockObject_MockObject + */ + private $validator; + protected function setUp() { $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); @@ -47,7 +53,12 @@ protected function setUp() $this->deployer = $this->getMock('Magento\Setup\Model\Deployer', [], [], '', false); $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->filesUtil = $this->getMock('Magento\Framework\App\Utility\Files', [], [], '', false); - $this->command = new DeployStaticContentCommand($this->objectManagerProvider, $this->deploymentConfig); + $this->validator = $this->getMock('Magento\Framework\Validator\Locale', [], [], '', false); + $this->command = new DeployStaticContentCommand( + $this->objectManagerProvider, + $this->deploymentConfig, + $this->validator + ); } public function testExecute() @@ -72,6 +83,8 @@ public function testExecute() ->method('create') ->willReturn($this->deployer); + $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true); + $this->deploymentConfig->expects($this->once()) ->method('isAvailable') ->will($this->returnValue(true)); @@ -95,7 +108,7 @@ public function testExecuteNotInstalled() /** * @expectedException \InvalidArgumentException - * @expectedExceptionMessage ARG_IS_WRONG argument has invalid value format + * @expectedExceptionMessage ARG_IS_WRONG argument has invalid value, please run info:language:list */ public function testExecuteInvalidLanguageArgument() { diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php index b2c5e9a65254d..f307af40de473 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php @@ -73,7 +73,7 @@ public function testExecute() { $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true); $this->objectManager->expects($this->once())->method('configure'); - $this->manager->expects($this->exactly(5))->method('addOperation'); + $this->manager->expects($this->exactly(6))->method('addOperation'); $this->manager->expects($this->once())->method('process'); $tester = new CommandTester($this->command); $tester->execute([]); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php new file mode 100644 index 0000000000000..0290915484c71 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php @@ -0,0 +1,74 @@ +getMock( + 'Magento\Setup\Model\ObjectManagerProvider', + [], + [], + '', + false + ); + $objectManager = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManagerInterface', + [], + '', + false + ); + $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); + $directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $command = new DiCompileMultiTenantCommand($objectManagerProvider, $directoryList); + $commandTester = new CommandTester($command); + $commandTester->execute($option); + $this->assertEquals($error . PHP_EOL, $commandTester->getDisplay()); + } + + /** + * @return array + */ + public function validateDataProvider() + { + return [ + [ + ['--' . DiCompileMultiTenantCommand::INPUT_KEY_SERIALIZER => 'invalidSerializer'], + 'Invalid value for command option \'' . DiCompileMultiTenantCommand::INPUT_KEY_SERIALIZER + . '\'. Possible values (serialize|igbinary).' + ], + [ + ['--' . DiCompileMultiTenantCommand::INPUT_KEY_EXTRA_CLASSES_FILE => '/wrong/file/path'], + 'Path does not exist for the value of command option \'' + . DiCompileMultiTenantCommand::INPUT_KEY_EXTRA_CLASSES_FILE . '\'.' + ], + [ + ['--' . DiCompileMultiTenantCommand::INPUT_KEY_GENERATION => '/wrong/path'], + 'Path does not exist for the value of command option \'' + . DiCompileMultiTenantCommand::INPUT_KEY_GENERATION . '\'.' + ], + [ + ['--' . DiCompileMultiTenantCommand::INPUT_KEY_DI => '/wrong/path'], + 'Path does not exist for the value of command option \'' + . DiCompileMultiTenantCommand::INPUT_KEY_DI . '\'.' + ], + [ + ['--' . DiCompileMultiTenantCommand::INPUT_KEY_EXCLUDE_PATTERN => '%wrongPattern'], + 'Invalid pattern for command option \'' + . DiCompileMultiTenantCommand::INPUT_KEY_EXCLUDE_PATTERN . '\'.' + ], + ]; + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php new file mode 100644 index 0000000000000..cb2655aec8436 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/GenerateFixturesCommandTest.php @@ -0,0 +1,59 @@ +fixtureModel = $this->getMock('Magento\Setup\Fixtures\FixtureModel', [], [], '', false); + $this->command = new GenerateFixturesCommand($this->fixtureModel); + } + + public function testExecute() + { + $this->fixtureModel->expects($this->once())->method('loadConfig')->with('path_to_profile.xml'); + $this->fixtureModel->expects($this->once())->method('initObjectManager'); + $this->fixtureModel->expects($this->once())->method('loadFixtures'); + + $commandTester = new CommandTester($this->command); + $commandTester->execute(['profile' => 'path_to_profile.xml']); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Not enough arguments. + */ + public function testExecuteInvalidLanguageArgument() + { + + $commandTester = new CommandTester($this->command); + $commandTester->execute([]); + } + + public function testSkipReindexOption() + { + $this->fixtureModel->expects($this->never())->method('reindex'); + + $commandTester = new CommandTester($this->command); + $commandTester->execute(['profile' => 'path_to_profile.xml', '--skip-reindex' => true]); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php index a7e087f94bd2b..6feae82566309 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoCurrencyListCommandTest.php @@ -17,14 +17,20 @@ public function testExecute() 'CUR' => 'Currency description' ]; - /** @var \Magento\Setup\Model\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ - $list = $this->getMock('Magento\Setup\Model\Lists', [], [], '', false); + $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table->expects($this->once())->method('setHeaders')->with(['Currency', 'Code']); + $table->expects($this->once())->method('addRow')->with(['Currency description', 'CUR']); + + /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ + $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); + + /** @var \Magento\Framework\Setup\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ + $list = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); $list->expects($this->once())->method('getCurrencyList')->will($this->returnValue($currencies)); - $commandTester = new CommandTester(new InfoCurrencyListCommand($list)); + $command = new InfoCurrencyListCommand($list); + $command->setHelperSet($helperSet); + $commandTester = new CommandTester($command); $commandTester->execute([]); - $this->assertStringMatchesFormat( - 'CUR => Currency description', - $commandTester->getDisplay() - ); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php index 938fb53f72590..ca5f6e006efb0 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoLanguageListCommandTest.php @@ -16,14 +16,21 @@ public function testExecute() $languages = [ 'LNG' => 'Language description' ]; - /** @var \Magento\Setup\Model\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ - $list = $this->getMock('Magento\Setup\Model\Lists', [], [], '', false); + + $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table->expects($this->once())->method('setHeaders')->with(['Language', 'Code']); + $table->expects($this->once())->method('addRow')->with(['Language description', 'LNG']); + + /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ + $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); + + /** @var \Magento\Framework\Setup\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ + $list = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); $list->expects($this->once())->method('getLocaleList')->will($this->returnValue($languages)); - $commandTester = new CommandTester(new InfoLanguageListCommand($list)); + $command = new InfoLanguageListCommand($list); + $command->setHelperSet($helperSet); + $commandTester = new CommandTester($command); $commandTester->execute([]); - $this->assertStringMatchesFormat( - 'LNG => Language description', - $commandTester->getDisplay() - ); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php index 6b1be6a5e9bc1..b93600a3d40e3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InfoTimezoneListCommandTest.php @@ -17,15 +17,20 @@ public function testExecute() 'timezone' => 'timezone description' ]; - /** @var \Magento\Setup\Model\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ - $list = $this->getMock('Magento\Setup\Model\Lists', [], [], '', false); + $table = $this->getMock('Symfony\Component\Console\Helper\Table', [], [], '', false); + $table->expects($this->once())->method('setHeaders')->with(['Timezone', 'Code']); + $table->expects($this->once())->method('addRow')->with(['timezone description', 'timezone']); + + /** @var \Symfony\Component\Console\Helper\HelperSet|\PHPUnit_Framework_MockObject_MockObject $helperSet */ + $helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); + $helperSet->expects($this->once())->method('get')->with('table')->will($this->returnValue($table)); + + /** @var \Magento\Framework\Setup\Lists|\PHPUnit_Framework_MockObject_MockObject $list */ + $list = $this->getMock('Magento\Framework\Setup\Lists', [], [], '', false); $list->expects($this->once())->method('getTimezoneList')->will($this->returnValue($timezones)); - $commandTester = new CommandTester(new InfoTimezoneListCommand($list)); + $command = new InfoTimezoneListCommand($list); + $command->setHelperSet($helperSet); + $commandTester = new CommandTester($command); $commandTester->execute([]); - $this->assertStringMatchesFormat( - 'timezone => timezone description', - $commandTester->getDisplay() - ); - } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php index a358368092f03..bff33de6c1f84 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallCommandTest.php @@ -10,15 +10,34 @@ use Symfony\Component\Console\Tester\CommandTester; use Magento\Setup\Model\AdminAccount; use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList; -use Magento\Framework\Config\ConfigOptionsList as SetupConfigOptionsList; -use Magento\Setup\Console\Command\InstallStoreConfigurationCommand; +use Magento\Framework\Config\ConfigOptionsListConstants as SetupConfigOptionsList; use Magento\Setup\Model\StoreConfigurationDataMapper; class InstallCommandTest extends \PHPUnit_Framework_TestCase { - public function testExecute() + /** + * @var array + */ + private $input; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|InstallCommand + */ + private $command; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\InstallerFactory + */ + private $installerFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\Installer + */ + private $installer; + + public function setUp() { - $input = [ + $this->input = [ '--' . SetupConfigOptionsList::INPUT_KEY_DB_HOST => 'localhost', '--' . SetupConfigOptionsList::INPUT_KEY_DB_NAME => 'magento', '--' . SetupConfigOptionsList::INPUT_KEY_DB_USER => 'root', @@ -55,6 +74,10 @@ public function testExecute() ->expects($this->once()) ->method('getOptionsList') ->will($this->returnValue($this->getOptionsListUserConfig())); + $userConfig + ->expects($this->once()) + ->method('validate') + ->will($this->returnValue([])); $adminUser = $this->getMock('Magento\Setup\Console\Command\AdminUserCreateCommand', [], [], '', false); $adminUser @@ -66,19 +89,25 @@ public function testExecute() ->method('validate') ->will($this->returnValue([])); - $installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); - $installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); - $installerFactory->expects($this->once()) - ->method('create') - ->will($this->returnValue($installer)); - $installer->expects($this->once())->method('install'); - $commandTester = new CommandTester(new InstallCommand( - $installerFactory, + $this->installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); + $this->installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); + $this->command = new InstallCommand( + $this->installerFactory, $configModel, $userConfig, $adminUser - )); - $commandTester->execute($input); + ); + } + + public function testExecute() + { + $this->installerFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->installer)); + $this->installer->expects($this->once())->method('install'); + + $commandTester = new CommandTester($this->command); + $commandTester->execute($this->input); } /** @@ -175,4 +204,64 @@ private function getOptionsListAdminUser() ->will($this->returnValue(AdminAccount::KEY_LAST_NAME)); return [$option1, $option2, $option3, $option4, $option5]; } + + /** + * Test install command with valid sales_order_increment_prefix value + * + * @dataProvider validateDataProvider + * @param $prefixValue + */ + public function testValidate($prefixValue) + { + $this->installerFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->installer)); + $this->installer->expects($this->once())->method('install'); + $this->input['--' . InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX] = $prefixValue; + + $commandTester = new CommandTester($this->command); + $commandTester->execute($this->input); + } + + /** + * Test install command with invalid sales_order_increment_prefix value + * + * @expectedException \InvalidArgumentException + * @dataProvider validateWithExceptionDataProvider + * @param $prefixValue + */ + public function testValidateWithException($prefixValue) + { + $this->installerFactory->expects($this->never()) + ->method('create') + ->will($this->returnValue($this->installer)); + $this->installer->expects($this->never())->method('install'); + $this->input['--' . InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX] = $prefixValue; + + $commandTester = new CommandTester($this->command); + $commandTester->execute($this->input); + } + + /** + * @return array + */ + public function validateDataProvider() + { + return [ + 'without option' => ['', ''], + 'normal case' => ['abcde', ''], + '20 chars' => ['12345678901234567890', ''] + ]; + } + + /** + * @return array + */ + public function validateWithExceptionDataProvider() + { + return [ + ['123456789012345678901', 'InvalidArgumentException'], + ['abcdefghijk12345678fdgsdfgsdfgsdfsgsdfg90abcdefgdfddgsdfg', 'InvalidArgumentException'] + ]; + } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php index 65e5ded76910b..a68260a487e42 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/InstallStoreConfigurationCommandTest.php @@ -8,6 +8,10 @@ use Magento\Setup\Console\Command\InstallStoreConfigurationCommand; use Symfony\Component\Console\Tester\CommandTester; +use Magento\Setup\Model\Installer; +use Magento\Framework\ObjectManagerInterface; +use Magento\Setup\Model\StoreConfigurationDataMapper; +use Magento\Framework\Url\Validator; class InstallStoreConfigurationCommandTest extends \PHPUnit_Framework_TestCase { @@ -26,6 +30,11 @@ class InstallStoreConfigurationCommandTest extends \PHPUnit_Framework_TestCase */ private $installer; + /** + * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManager; + /** * @var InstallStoreConfigurationCommand */ @@ -36,7 +45,25 @@ protected function setUp() $this->installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false); $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); - $this->command = new InstallStoreConfigurationCommand($this->installerFactory, $this->deploymentConfig); + $objectManagerProvider = $this->getMock( + 'Magento\Setup\Model\ObjectManagerProvider', + [], + [], + '', + false + ); + $this->objectManager = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManagerInterface', + [], + '', + false + ); + $objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); + $this->command = new InstallStoreConfigurationCommand( + $this->installerFactory, + $this->deploymentConfig, + $objectManagerProvider + ); } public function testExecute() @@ -67,4 +94,109 @@ public function testExecuteNotInstalled() $tester->getDisplay() ); } + + /** + * @dataProvider validateDataProvider + * @param array $option + * @param string $error + */ + public function testExecuteInvalidData(array $option, $error) + { + $url= $this->getMock('Magento\Framework\Url\Validator', [], [], '', false); + $url->expects($this->any())->method('isValid')->will($this->returnValue(false)); + if (!isset($option['--' . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE])) { + $url->expects($this->any())->method('getMessages')->will($this->returnValue([ + Validator::INVALID_URL => 'Invalid URL.' + ])); + } + $localeLists= $this->getMock('Magento\Framework\Validator\Locale', [], [], '', false); + $localeLists->expects($this->any())->method('isValid')->will($this->returnValue(false)); + $timezoneLists= $this->getMock('Magento\Framework\Validator\Timezone', [], [], '', false); + $timezoneLists->expects($this->any())->method('isValid')->will($this->returnValue(false)); + $currencyLists= $this->getMock('Magento\Framework\Validator\Currency', [], [], '', false); + $currencyLists->expects($this->any())->method('isValid')->will($this->returnValue(false)); + + $returnValueMapOM = [ + [ + 'Magento\Framework\Url\Validator', + $url + ], + [ + 'Magento\Framework\Validator\Locale', + $localeLists + ], + [ + 'Magento\Framework\Validator\Timezone', + $timezoneLists + ], + [ + 'Magento\Framework\Validator\Currency', + $currencyLists + ], + ]; + $this->objectManager->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($returnValueMapOM)); + $this->deploymentConfig->expects($this->once()) + ->method('isAvailable') + ->will($this->returnValue(true)); + $this->installerFactory->expects($this->never()) + ->method('create'); + $commandTester = new CommandTester($this->command); + $commandTester->execute($option); + $this->assertEquals($error . PHP_EOL, $commandTester->getDisplay()); + } + + /** + * @return array + */ + public function validateDataProvider() + { + return [ + [ + ['--' . StoreConfigurationDataMapper::KEY_BASE_URL => 'sampleUrl'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_BASE_URL . '\': Invalid URL.' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_LANGUAGE => 'sampleLanguage'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_LANGUAGE + . '\': Invalid value. To see possible values, run command \'bin/magento info:language:list\'.' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_TIMEZONE => 'sampleTimezone'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_TIMEZONE + . '\': Invalid value. To see possible values, run command \'bin/magento info:timezone:list\'.' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_CURRENCY => 'sampleLanguage'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_CURRENCY + . '\': Invalid value. To see possible values, run command \'bin/magento info:currency:list\'.' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_USE_SEF_URL => 'invalidValue'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_USE_SEF_URL + . '\': Invalid value. Possible values (0|1).' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_IS_SECURE => 'invalidValue'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_IS_SECURE + . '\': Invalid value. Possible values (0|1).' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE => 'http://www.sample.com'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE + . '\': Invalid secure URL.' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_IS_SECURE_ADMIN => 'invalidValue'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_IS_SECURE_ADMIN + . '\': Invalid value. Possible values (0|1).' + ], + [ + ['--' . StoreConfigurationDataMapper::KEY_ADMIN_USE_SECURITY_KEY => 'invalidValue'], + 'Command option \'' . StoreConfigurationDataMapper::KEY_ADMIN_USE_SECURITY_KEY + . '\': Invalid value. Possible values (0|1).' + ], + ]; + } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php index b129552455218..c03b023c9900a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php @@ -7,6 +7,7 @@ namespace Magento\Setup\Test\Unit\Console\Command; use Magento\Setup\Console\Command\MaintenanceAllowIpsCommand; +use Magento\Setup\Validator\IpValidator; use Symfony\Component\Console\Tester\CommandTester; class MaintenanceAllowIpsCommandTest extends \PHPUnit_Framework_TestCase @@ -16,6 +17,11 @@ class MaintenanceAllowIpsCommandTest extends \PHPUnit_Framework_TestCase */ private $maintenanceMode; + /** + * @var IpValidator|\PHPUnit_Framework_MockObject_MockObject + */ + private $ipValidator; + /** * @var MaintenanceAllowIpsCommand */ @@ -24,21 +30,36 @@ class MaintenanceAllowIpsCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->command = new MaintenanceAllowIpsCommand($this->maintenanceMode); + $this->ipValidator = $this->getMock('Magento\Setup\Validator\IpValidator', [], [], '', false); + $this->command = new MaintenanceAllowIpsCommand($this->maintenanceMode, $this->ipValidator); } /** * @param array $input + * @param array $validatorMessages * @param string $expectedMessage * @dataProvider executeDataProvider */ - public function testExecute(array $input, $expectedMessage) + public function testExecute(array $input, array $validatorMessages, $expectedMessage) { if (isset($input['--none']) && !$input['--none'] && isset($input['ip'])) { + $this->ipValidator->expects($this->once())->method('validateIps')->willReturn($validatorMessages); + if (empty($validatorMessages) && !empty($input['ip'])) { + $this->maintenanceMode + ->expects($this->once()) + ->method('setAddresses') + ->with(implode(',', $input['ip'])); + $this->maintenanceMode + ->expects($this->once()) + ->method('getAddressInfo') + ->willReturn($input['ip']); + } + } elseif (isset($input['--none']) && $input['--none']) { + $this->ipValidator->expects($this->never())->method('validateIps')->willReturn($validatorMessages); $this->maintenanceMode ->expects($this->once()) - ->method('getAddressInfo') - ->willReturn($input['ip']); + ->method('setAddresses') + ->with(''); } $tester = new CommandTester($this->command); $tester->execute($input); @@ -54,17 +75,26 @@ public function executeDataProvider() return [ [ ['ip' => ['127.0.0.1', '127.0.0.2'], '--none' => false], + [], 'Set exempt IP-addresses: 127.0.0.1, 127.0.0.2' . PHP_EOL ], [ ['--none' => true], + [], 'Set exempt IP-addresses: none' . PHP_EOL ], [ ['ip' => ['127.0.0.1', '127.0.0.2'], '--none' => true], + [], 'Set exempt IP-addresses: none' . PHP_EOL ], [ + ['ip' => ['127.0'], '--none' => false], + ['Invalid IP 127.0'], + 'Invalid IP 127.0' . PHP_EOL + ], + [ + ['ip' => [], '--none' => false], [], '' ] diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php index e32acacb15aaa..88b158961cf73 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceDisableCommandTest.php @@ -7,6 +7,7 @@ namespace Magento\Setup\Test\Unit\Console\Command; use Magento\Setup\Console\Command\MaintenanceDisableCommand; +use Magento\Setup\Validator\IpValidator; use Symfony\Component\Console\Tester\CommandTester; class MaintenanceDisableCommandTest extends \PHPUnit_Framework_TestCase @@ -16,6 +17,11 @@ class MaintenanceDisableCommandTest extends \PHPUnit_Framework_TestCase */ private $maintenanceMode; + /** + * @var IpValidator|\PHPUnit_Framework_MockObject_MockObject + */ + private $ipValidator; + /** * @var MaintenanceDisableCommand */ @@ -24,21 +30,24 @@ class MaintenanceDisableCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->command = new MaintenanceDisableCommand($this->maintenanceMode); + $this->ipValidator = $this->getMock('Magento\Setup\Validator\IpValidator', [], [], '', false); + $this->command = new MaintenanceDisableCommand($this->maintenanceMode, $this->ipValidator); } /** * @param array $input + * @param array $validatorMessages * @param string $expectedMessage * @dataProvider executeDataProvider */ - public function testExecute(array $input, $expectedMessage) + public function testExecute(array $input, array $validatorMessages, $expectedMessage) { $return = isset($input['--ip']) ? ($input['--ip'] !== ['none'] ? $input['--ip'] : []) : []; $this->maintenanceMode ->expects($this->any()) ->method('getAddressInfo') ->willReturn($return); + $this->ipValidator->expects($this->once())->method('validateIps')->willReturn($validatorMessages); $tester = new CommandTester($this->command); $tester->execute($input); $this->assertEquals($expectedMessage, $tester->getDisplay()); @@ -52,17 +61,25 @@ public function executeDataProvider() return [ [ ['--ip' => ['127.0.0.1', '127.0.0.2']], + [], 'Disabled maintenance mode' . PHP_EOL . 'Set exempt IP-addresses: 127.0.0.1, 127.0.0.2' . PHP_EOL ], [ + ['--ip' => ['none']], + [], + 'Disabled maintenance mode' . PHP_EOL . + 'Set exempt IP-addresses: none' . PHP_EOL + ], + [ + [], [], 'Disabled maintenance mode' . PHP_EOL ], [ - ['--ip' => ['none']], - 'Disabled maintenance mode' . PHP_EOL . - 'Set exempt IP-addresses: none' . PHP_EOL + ['--ip' => ['127.0']], + ['Invalid IP 127.0'], + 'Invalid IP 127.0' . PHP_EOL ], ]; } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php index 7615de13c617e..c2e3a514dce2c 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceEnableCommandTest.php @@ -7,6 +7,7 @@ namespace Magento\Setup\Test\Unit\Console\Command; use Magento\Setup\Console\Command\MaintenanceEnableCommand; +use Magento\Setup\Validator\IpValidator; use Symfony\Component\Console\Tester\CommandTester; class MaintenanceEnableCommandTest extends \PHPUnit_Framework_TestCase @@ -16,6 +17,11 @@ class MaintenanceEnableCommandTest extends \PHPUnit_Framework_TestCase */ private $maintenanceMode; + /** + * @var IpValidator|\PHPUnit_Framework_MockObject_MockObject + */ + private $ipValidator; + /** * @var MaintenanceEnableCommand */ @@ -24,21 +30,24 @@ class MaintenanceEnableCommandTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); - $this->command = new MaintenanceEnableCommand($this->maintenanceMode); + $this->ipValidator = $this->getMock('Magento\Setup\Validator\IpValidator', [], [], '', false); + $this->command = new MaintenanceEnableCommand($this->maintenanceMode, $this->ipValidator); } /** * @param array $input + * @param array $validatorMessages * @param string $expectedMessage * @dataProvider executeDataProvider */ - public function testExecute(array $input, $expectedMessage) + public function testExecute(array $input, array $validatorMessages, $expectedMessage) { $return = isset($input['--ip']) ? ($input['--ip'] !== ['none'] ? $input['--ip'] : []) : []; $this->maintenanceMode ->expects($this->any()) ->method('getAddressInfo') ->willReturn($return); + $this->ipValidator->expects($this->once())->method('validateIps')->willReturn($validatorMessages); $tester = new CommandTester($this->command); $tester->execute($input); $this->assertEquals($expectedMessage, $tester->getDisplay()); @@ -53,18 +62,26 @@ public function executeDataProvider() return [ [ ['--ip' => ['127.0.0.1', '127.0.0.2']], + [], 'Enabled maintenance mode' . PHP_EOL . 'Set exempt IP-addresses: 127.0.0.1, 127.0.0.2' . PHP_EOL ], [ ['--ip' => ['none']], + [], 'Enabled maintenance mode' . PHP_EOL . 'Set exempt IP-addresses: none' . PHP_EOL ], [ + [], [], 'Enabled maintenance mode' . PHP_EOL ], + [ + ['--ip' => ['127.0']], + ['Invalid IP 127.0'], + 'Invalid IP 127.0' . PHP_EOL + ], ]; } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php index b0fdb27794887..a72e47b4111c8 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php @@ -126,6 +126,30 @@ public function executeDataProvider() ]; } + public function testExecuteEnableInvalidModule() + { + $this->status->expects($this->once()) + ->method('getModulesToChange') + ->with(true, ['invalid']) + ->willThrowException(new \LogicException('Unknown module(s): invalid')); + $commandTester = new CommandTester(new ModuleEnableCommand($this->objectManagerProvider)); + $input = ['module' => ['invalid']]; + $commandTester->execute($input); + $this->assertEquals('Unknown module(s): invalid' . PHP_EOL, $commandTester->getDisplay()); + } + + public function testExecuteDisableInvalidModule() + { + $this->status->expects($this->once()) + ->method('getModulesToChange') + ->with(false, ['invalid']) + ->willThrowException(new \LogicException('Unknown module(s): invalid')); + $commandTester = new CommandTester(new ModuleDisableCommand($this->objectManagerProvider)); + $input = ['module' => ['invalid']]; + $commandTester->execute($input); + $this->assertEquals('Unknown module(s): invalid' . PHP_EOL, $commandTester->getDisplay()); + } + /** * @param bool $isEnable * @param string $expectedMessage diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php index 79c209a2f81d1..2c1d1169ac7c5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/CustomizeYourStoreTest.php @@ -10,6 +10,28 @@ class CustomizeYourStoreTest extends \PHPUnit_Framework_TestCase { + /** + * @var \Magento\Setup\Controller\CustomizeYourStore + */ + private $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\SampleData + */ + private $sampleData; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\Lists + */ + private $lists; + + public function setup() + { + $this->sampleData = $this->getMock('\Magento\Setup\Model\SampleData', [], [], '', false); + $this->lists = $this->getMock('\Magento\Framework\Setup\Lists', [], [], '', false); + $this->controller = new CustomizeYourStore($this->lists, $this->sampleData); + } + /** * @param array $expected * @@ -17,16 +39,12 @@ class CustomizeYourStoreTest extends \PHPUnit_Framework_TestCase */ public function testIndexAction($expected) { - $sampleData = $this->getMock('\Magento\Setup\Model\SampleData', [], [], '', false); - $lists = $this->getMock('\Magento\Setup\Model\Lists', [], [], '', false); - $controller = new CustomizeYourStore($lists, $sampleData); + $this->sampleData->expects($this->once())->method('isDeployed')->willReturn($expected['isSampledataEnabled']); + $this->lists->expects($this->once())->method('getTimezoneList')->willReturn($expected['timezone']); + $this->lists->expects($this->once())->method('getCurrencyList')->willReturn($expected['currency']); + $this->lists->expects($this->once())->method('getLocaleList')->willReturn($expected['language']); - $sampleData->expects($this->once())->method('isDeployed')->willReturn($expected['isSampledataEnabled']); - $lists->expects($this->once())->method('getTimezoneList')->willReturn($expected['timezone']); - $lists->expects($this->once())->method('getCurrencyList')->willReturn($expected['currency']); - $lists->expects($this->once())->method('getLocaleList')->willReturn($expected['language']); - - $viewModel = $controller->indexAction(); + $viewModel = $this->controller->indexAction(); $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); $this->assertTrue($viewModel->terminate()); @@ -61,4 +79,11 @@ public function indexActionDataProvider() 'no_sample_data' => [array_merge($timezones, $currency, $language, ['isSampledataEnabled' => null])], ]; } + + public function testDefaultTimeZoneAction() + { + $jsonModel = $this->controller->defaultTimeZoneAction(); + $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel); + $this->assertArrayHasKey('defaultTimeZone', $jsonModel->getVariables()); + } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/DatabaseCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/DatabaseCheckTest.php index 99829fcb505b0..b813bc506ef32 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/DatabaseCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/DatabaseCheckTest.php @@ -7,13 +7,14 @@ namespace Magento\Setup\Test\Unit\Controller; use \Magento\Setup\Controller\DatabaseCheck; +use Magento\Setup\Validator\DbValidator; class DatabaseCheckTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\Installer + * @var DbValidator|\PHPUnit_Framework_MockObject_MockObject */ - private $installer; + private $dbValidator; /** * Controller @@ -25,17 +26,13 @@ class DatabaseCheckTest extends \PHPUnit_Framework_TestCase public function setUp() { $webLogger = $this->getMock('\Magento\Setup\Model\WebLogger', [], [], '', false); - $installerFactory = $this->getMock('\Magento\Setup\Model\InstallerFactory', [], [], '', false); - $this->installer = $this->getMock('\Magento\Setup\Model\Installer', [], [], '', false); - $installerFactory->expects($this->once())->method('create')->with($webLogger)->willReturn( - $this->installer - ); - $this->controller = new DatabaseCheck($installerFactory, $webLogger); + $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); + $this->controller = new DatabaseCheck($webLogger, $this->dbValidator); } public function testIndexAction() { - $this->installer->expects($this->once())->method('checkDatabaseConnection'); + $this->dbValidator->expects($this->once())->method('checkDatabaseConnection'); $jsonModel = $this->controller->indexAction(); $this->assertInstanceOf('Zend\View\Model\ViewModel', $jsonModel); $variables = $jsonModel->getVariables(); @@ -45,7 +42,7 @@ public function testIndexAction() public function testIndexActionWithError() { - $this->installer->expects($this->once())->method('checkDatabaseConnection')->will( + $this->dbValidator->expects($this->once())->method('checkDatabaseConnection')->will( $this->throwException(new \Exception) ); $jsonModel = $this->controller->indexAction(); @@ -58,7 +55,7 @@ public function testIndexActionWithError() public function testIndexActionCheckPrefix() { - $this->installer->expects($this->once())->method('checkDatabaseTablePrefix'); + $this->dbValidator->expects($this->once())->method('checkDatabaseTablePrefix'); $this->controller->indexAction(); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php index 60e150ae8665f..e5a3e2829ccfe 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/IndexTest.php @@ -10,10 +10,37 @@ class IndexTest extends \PHPUnit_Framework_TestCase { + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\ObjectManagerProvider + */ + private $objectManagerProvider; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DeploymentConfig + */ + private $deploymentConfig; + public function testIndexAction() { + $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerProvider = $this->getMock( + 'Magento\Setup\Model\ObjectManagerProvider', + ['get'], + [], + '', + false + ); + $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager); + $this->objectManager->expects($this->once())->method('get')->willReturn($this->deploymentConfig); + $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false); /** @var $controller Index */ - $controller = new Index(); + $controller = new Index($this->objectManagerProvider); $viewModel = $controller->indexAction(); $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); $this->assertFalse($viewModel->terminate()); diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/Complex/ComplexGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Complex/ComplexGeneratorTest.php similarity index 75% rename from dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/Complex/ComplexGeneratorTest.php rename to setup/src/Magento/Setup/Test/Unit/Model/Complex/ComplexGeneratorTest.php index e36f8b2ddc913..1481a3c6ee957 100644 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/Complex/ComplexGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Complex/ComplexGeneratorTest.php @@ -4,7 +4,10 @@ * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework\ImportExport\Fixture\Complex; +namespace Magento\Setup\Test\Unit\Model\Complex; + +use Magento\Setup\Model\Complex\Pattern; +use Magento\Setup\Model\Complex\Generator; /** * Class ComplexGeneratorTest @@ -15,18 +18,18 @@ class ComplexGeneratorTest extends \PHPUnit_Framework_TestCase /** * Pattern instance * - * @var \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern + * @var Pattern */ protected $_pattern; /** * Get pattern instance * - * @return \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern + * @return Pattern */ protected function getPattern() { - if (!$this->_pattern instanceof \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern) { + if (!$this->_pattern instanceof Pattern) { $patternData = [ [ 'id' => '%s', @@ -42,7 +45,7 @@ protected function getPattern() 'name' => 'yyy %s' ], ]; - $this->_pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern(); + $this->_pattern = new Pattern(); $this->_pattern->setHeaders(array_keys($patternData[0])); $this->_pattern->setRowsSet($patternData); } @@ -56,7 +59,7 @@ protected function getPattern() */ public function testIteratorInterface() { - $model = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator($this->getPattern(), 2); + $model = new Generator($this->getPattern(), 2); $rows = []; foreach ($model as $row) { $rows[] = $row; @@ -81,7 +84,7 @@ public function testIteratorInterface() */ public function testGetIndex() { - $model = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator($this->getPattern(), 4); + $model = new Generator($this->getPattern(), 4); for ($i = 0; $i < 32; $i++) { $this->assertEquals($model->getIndex($i), floor($i / $this->getPattern()->getRowsCount()) + 1); } diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/Complex/PatternTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Complex/PatternTest.php similarity index 88% rename from dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/Complex/PatternTest.php rename to setup/src/Magento/Setup/Test/Unit/Model/Complex/PatternTest.php index d01751fbbb713..e1c89934f7a8a 100644 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/Complex/PatternTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Complex/PatternTest.php @@ -4,7 +4,9 @@ * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework\ImportExport\Fixture\Complex; +namespace Magento\Setup\Test\Unit\Model\Complex; + +use Magento\Setup\Model\Complex\Pattern; /** * Class PatternTest @@ -17,11 +19,11 @@ class PatternTest extends \PHPUnit_Framework_TestCase * * @param array $patternData * - * @return \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern + * @return \Magento\Setup\Model\Complex\Pattern */ protected function getPattern($patternData) { - $pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern(); + $pattern = new Pattern(); $pattern->setHeaders(array_keys($patternData[0])); $pattern->setRowsSet($patternData); return $pattern; @@ -32,7 +34,7 @@ protected function getPattern($patternData) * * @return array */ - public function patternDataPrivider() + public function patternDataProvider() { $result = [ 0 => [ @@ -82,7 +84,7 @@ public function patternDataPrivider() * @param int $expectedRowsCount * @param array $expectedRowsResult * - * @dataProvider patternDataPrivider + * @dataProvider patternDataProvider * @test * * @return void diff --git a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/GeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/GeneratorTest.php similarity index 84% rename from dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/GeneratorTest.php rename to setup/src/Magento/Setup/Test/Unit/Model/GeneratorTest.php index 64d91414f6977..02b2f25f31596 100644 --- a/dev/tools/performance-toolkit/framework/tests/unit/testsuite/Magento/ToolkitFramework/ImportExport/Fixture/GeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/GeneratorTest.php @@ -4,7 +4,9 @@ * See COPYING.txt for license details. */ -namespace Magento\ToolkitFramework\ImportExport\Fixture; +namespace Magento\Setup\Test\Unit\Model; + +use Magento\Setup\Model\Generator; class GeneratorTest extends \PHPUnit_Framework_TestCase { @@ -22,7 +24,7 @@ public function testIteratorInterface() return $index * 10; }, ]; - $model = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator($pattern, 2); + $model = new Generator($pattern, 2); $rows = []; foreach ($model as $row) { $rows[] = $row; diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php index 291fee230a4bc..8e881bada2d98 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php @@ -77,6 +77,10 @@ public function testCreate() 'Magento\Framework\App\State\CleanupFiles', $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false), ], + [ + 'Magento\Setup\Validator\DbValidator', + $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false), + ], ]; $serviceLocatorMock = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']); $serviceLocatorMock diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index de43acfede727..0fb1ca0c6b16f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -7,12 +7,13 @@ namespace Magento\Setup\Test\Unit\Model; use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList; -use Magento\Framework\Config\ConfigOptionsList as SetupConfigOptionsList; +use Magento\Framework\Config\ConfigOptionsListConstants as SetupConfigOptionsList; use \Magento\Setup\Model\Installer; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\App\State\CleanupFiles; +use Magento\Setup\Validator\DbValidator; /** * @SuppressWarnings(PHPMD.TooManyFields) @@ -110,21 +111,21 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $cleanupFiles; + /** + * @var DbValidator|\PHPUnit_Framework_MockObject_MockObject + */ + private $dbValidator; + /** * Sample DB configuration segment * * @var array */ private static $dbConfig = [ - SetupConfigOptionsList::KEY_PREFIX => '', - 'connection' => [ - 'default' => [ - SetupConfigOptionsList::KEY_HOST => '127.0.0.1', - SetupConfigOptionsList::KEY_NAME => 'magento', - SetupConfigOptionsList::KEY_USER => 'magento', - SetupConfigOptionsList::KEY_PASS => '', - ], - ], + SetupConfigOptionsList::KEY_HOST => '127.0.0.1', + SetupConfigOptionsList::KEY_NAME => 'magento', + SetupConfigOptionsList::KEY_USER => 'magento', + SetupConfigOptionsList::KEY_PASSWORD => '', ]; /** @@ -159,6 +160,7 @@ protected function setUp() $this->contextMock = $this->getMock('Magento\Framework\Model\Resource\Db\Context', [], [], '', false); $this->configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false); $this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); + $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); $this->object = $this->createObject(); } @@ -196,7 +198,8 @@ private function createObject($connectionFactory = false, $objectManagerProvider $objectManagerProvider, $this->contextMock, $this->configModel, - $this->cleanupFiles + $this->cleanupFiles, + $this->dbValidator ); } @@ -210,13 +213,6 @@ public function testInstall() BackendConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'backend', ]; $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); - $this->config->expects($this->any())->method('getSegment')->will($this->returnValueMap([ - [SetupConfigOptionsList::KEY_DB, self::$dbConfig], - [ - 'crypt', - [SetupConfigOptionsList::KEY_ENCRYPTION_KEY => 'encryption_key'] - ] - ])); $allModules = ['Foo_One' => [], 'Bar_Two' => []]; $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); $setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); @@ -366,8 +362,19 @@ public function testUpdateModulesSequence() public function testUninstall() { $this->config->expects($this->once())->method('isAvailable')->willReturn(false); + $this->configReader->expects($this->once())->method('getFiles')->willReturn(['ConfigOne.php', 'ConfigTwo.php']); $configDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); - $configDir->expects($this->once())->method('getAbsolutePath')->willReturn('/config/config.php'); + $configDir + ->expects($this->exactly(2)) + ->method('getAbsolutePath') + ->will( + $this->returnValueMap( + [ + ['ConfigOne.php', '/config/ConfigOne.php'], + ['ConfigTwo.php', '/config/ConfigTwo.php'] + ] + ) + ); $this->filesystem ->expects($this->any()) ->method('getDirectoryWrite') @@ -399,7 +406,11 @@ public function testUninstall() $this->logger ->expects($this->at(6)) ->method('log') - ->with("The file '/config/config.php' doesn't exist - skipping cleanup"); + ->with("The file '/config/ConfigOne.php' doesn't exist - skipping cleanup"); + $this->logger + ->expects($this->at(7)) + ->method('log') + ->with("The file '/config/ConfigTwo.php' doesn't exist - skipping cleanup"); $this->logger->expects($this->once())->method('logSuccess')->with('Magento uninstallation complete.'); $this->cleanupFiles->expects($this->once())->method('clearAllFiles')->will( $this->returnValue( @@ -417,8 +428,8 @@ public function testCleanupDb() { $this->config->expects($this->once())->method('isAvailable')->willReturn(true); $this->config->expects($this->once()) - ->method('getConfigData') - ->with(SetupConfigOptionsList::KEY_DB) + ->method('get') + ->with(SetupConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT) ->willReturn(self::$dbConfig); $this->connection->expects($this->at(0))->method('quoteIdentifier')->with('magento')->willReturn('`magento`'); $this->connection->expects($this->at(1))->method('query')->with('DROP DATABASE IF EXISTS `magento`'); @@ -426,40 +437,4 @@ public function testCleanupDb() $this->logger->expects($this->once())->method('log')->with('Recreating database `magento`'); $this->object->cleanupDb(); } - - public function testCheckDatabaseConnection() - { - $this->connection - ->expects($this->once()) - ->method('fetchOne') - ->with('SELECT version()') - ->willReturn('5.6.0-0ubuntu0.12.04.1'); - $this->assertEquals(true, $this->object->checkDatabaseConnection('name', 'host', 'user', 'password')); - } - - /** - * @expectedException \Magento\Setup\Exception - * @expectedExceptionMessage Database connection failure. - */ - public function testCheckDatabaseConnectionFailed() - { - $connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false); - $connectionFactory->expects($this->once())->method('create')->willReturn(false); - $object = $this->createObject($connectionFactory); - $object->checkDatabaseConnection('name', 'host', 'user', 'password'); - } - - /** - * @expectedException \Magento\Setup\Exception - * @expectedExceptionMessage Sorry, but we support MySQL version - */ - public function testCheckDatabaseConnectionIncompatible() - { - $this->connection - ->expects($this->once()) - ->method('fetchOne') - ->with('SELECT version()') - ->willReturn('5.5.40-0ubuntu0.12.04.1'); - $this->object->checkDatabaseConnection('name', 'host', 'user', 'password'); - } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php index a4e71aeb602a9..2c27da1d94a8e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ModuleStatusTest.php @@ -57,7 +57,7 @@ public function setUp() public function testGetAllModules($expectedAllModules, $expectedConfig, $expectedResult) { $this->moduleLoader->expects($this->once())->method('load')->will($this->returnValue($expectedAllModules)); - $this->deploymentConfig->expects($this->once())->method('getConfigData') + $this->deploymentConfig->expects($this->once())->method('get') ->will($this->returnValue($expectedConfig)); $this->dependencyChecker->expects($this->any())->method('checkDependenciesWhenDisableModules')->willReturn( ['module1' => [], 'module2' => [], 'module3' => [], 'module4' => []] @@ -82,7 +82,7 @@ public function testGetAllModules($expectedAllModules, $expectedConfig, $expecte public function testGetAllModulesWithInputs($expectedAllModules, $expectedConfig, $expectedResult) { $this->moduleLoader->expects($this->once())->method('load')->will($this->returnValue($expectedAllModules)); - $this->deploymentConfig->expects($this->never())->method('getConfigData') + $this->deploymentConfig->expects($this->never())->method('get') ->will($this->returnValue($expectedConfig)); $this->dependencyChecker->expects($this->any())->method('checkDependenciesWhenDisableModules')->willReturn( ['module1' => [], 'module2' => [], 'module3' => [], 'module4' => []] @@ -106,7 +106,7 @@ public function testGetAllModulesWithInputs($expectedAllModules, $expectedConfig public function testSetIsEnabled($expectedAllModules, $expectedConfig, $expectedResult) { $this->moduleLoader->expects($this->once())->method('load')->will($this->returnValue($expectedAllModules)); - $this->deploymentConfig->expects($this->once())->method('getConfigData') + $this->deploymentConfig->expects($this->once())->method('get') ->will($this->returnValue($expectedConfig)); $this->dependencyChecker->expects($this->any())->method('checkDependenciesWhenDisableModules')->willReturn( ['module1' => [], 'module2' => [], 'module3' => [], 'module4' => []] diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php similarity index 65% rename from lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php index 8479894c4e7ba..82c9840e03aa5 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ConfigGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php @@ -3,16 +3,16 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Config\Test\Unit; +namespace Magento\Setup\Test\Unit\Module; use Magento\Framework\Config\File\ConfigFilePool; -use Magento\Framework\Config\ConfigGenerator; -use Magento\Framework\Config\ConfigOptionsList; +use Magento\Setup\Model\ConfigGenerator; +use Magento\Framework\Config\ConfigOptionsListConstants; class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Config\ConfigGenerator + * @var ConfigGenerator */ private $configGeneratorObject; @@ -29,62 +29,68 @@ public function testCreateInstallConfig() { $returnValue = $this->configGeneratorObject->createInstallConfig([]); $this->assertInstanceOf('Magento\Framework\Config\Data\ConfigData', $returnValue); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); } public function testCreateCryptConfigWithInput() { - $testData = [ConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY => 'some-test_key']; + $testData = [ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY => 'some-test_key']; $returnValue = $this->configGeneratorObject->createCryptConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['crypt' => ['key' => 'some-test_key']], $returnValue->getData()); } public function testCreateCryptConfigWithoutInput() { $returnValue = $this->configGeneratorObject->createCryptConfig([]); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['crypt' => ['key' => md5('key')]], $returnValue->getData()); } public function testCreateSessionConfigWithInput() { - $testData = [ConfigOptionsList::INPUT_KEY_SESSION_SAVE => 'files']; + $testData = [ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE => 'files']; $returnValue = $this->configGeneratorObject->createSessionConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); - $this->assertEquals(['session' => ['save' => ConfigOptionsList::SESSION_SAVE_FILES]], $returnValue->getData()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); + $this->assertEquals( + ['session' => ['save' => ConfigOptionsListConstants::SESSION_SAVE_FILES]], + $returnValue->getData() + ); - $testData = [ConfigOptionsList::INPUT_KEY_SESSION_SAVE => 'db']; + $testData = [ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE => 'db']; $returnValue = $this->configGeneratorObject->createSessionConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); - $this->assertEquals(['session' => ['save' => ConfigOptionsList::SESSION_SAVE_DB]], $returnValue->getData()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); + $this->assertEquals( + ['session' => ['save' => ConfigOptionsListConstants::SESSION_SAVE_DB]], + $returnValue->getData() + ); } public function testCreateSessionConfigWithoutInput() { $returnValue = $this->configGeneratorObject->createSessionConfig([]); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals([], $returnValue->getData()); } public function testCreateDefinitionsConfig() { - $testData = [\Magento\Framework\Config\ConfigOptionsList::INPUT_KEY_DEFINITION_FORMAT => 'test-format']; + $testData = [ConfigOptionsListConstants::INPUT_KEY_DEFINITION_FORMAT => 'test-format']; $returnValue = $this->configGeneratorObject->createDefinitionsConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['definition' => ['format' => 'test-format']], $returnValue->getData()); } public function testCreateDbConfig() { $testData = [ - ConfigOptionsList::INPUT_KEY_DB_HOST => 'testLocalhost', - ConfigOptionsList::INPUT_KEY_DB_NAME => 'testDbName', - ConfigOptionsList::INPUT_KEY_DB_USER => 'testDbUser', - ConfigOptionsList::INPUT_KEY_DB_PREFIX => 'testSomePrefix', + ConfigOptionsListConstants::INPUT_KEY_DB_HOST => 'testLocalhost', + ConfigOptionsListConstants::INPUT_KEY_DB_NAME => 'testDbName', + ConfigOptionsListConstants::INPUT_KEY_DB_USER => 'testDbUser', + ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX => 'testSomePrefix', ]; $returnValue = $this->configGeneratorObject->createDbConfig($testData); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $dbData = $returnValue->getData(); $dbData = $dbData['db']; $this->assertArrayHasKey('table_prefix', $dbData); @@ -104,7 +110,7 @@ public function testCreateDbConfig() public function testCreateResourceConfig() { $returnValue = $this->configGeneratorObject->createResourceConfig(); - $this->assertEquals(ConfigFilePool::APP_CONFIG, $returnValue->getFileKey()); + $this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey()); $this->assertEquals(['resource' => ['default_setup' => ['connection' => 'default']]], $returnValue->getData()); } } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ConfigOptionsListTest.php b/setup/src/Magento/Setup/Test/Unit/Module/ConfigOptionsListTest.php similarity index 84% rename from lib/internal/Magento/Framework/Config/Test/Unit/ConfigOptionsListTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/ConfigOptionsListTest.php index 3992e2bbdea90..f972d2e802b46 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ConfigOptionsListTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/ConfigOptionsListTest.php @@ -3,10 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Config\Test\Unit; -use Magento\Framework\Config\ConfigGenerator; -use Magento\Framework\Config\ConfigOptionsList; +namespace Magento\Setup\Test\Unit\Module; + +use Magento\Setup\Model\ConfigGenerator; +use Magento\Setup\Model\ConfigOptionsList; +use Magento\Setup\Validator\DbValidator; class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase { @@ -25,11 +27,17 @@ class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase */ private $deploymentConfig; + /** + * @var DbValidator|\PHPUnit_Framework_MockObject_MockObject + */ + private $dbValidator; + protected function setUp() { - $this->generator = $this->getMock('Magento\Framework\Config\ConfigGenerator', [], [], '', false); + $this->generator = $this->getMock('Magento\Setup\Model\ConfigGenerator', [], [], '', false); $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); - $this->object = new ConfigOptionsList($this->generator); + $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); + $this->object = new ConfigOptionsList($this->generator, $this->dbValidator); } public function testGetOptions() @@ -57,7 +65,12 @@ public function testGetOptions() $this->assertSame('Database type', $options[9]->getDescription()); $this->assertInstanceOf('Magento\Framework\Setup\Option\TextConfigOption', $options[10]); $this->assertSame('Database initial set of commands', $options[10]->getDescription()); - $this->assertEquals(11, count($options)); + $this->assertInstanceOf('Magento\Framework\Setup\Option\FlagConfigOption', $options[11]); + $this->assertSame( + 'If specified, then db connection validation will be skipped', + $options[11]->getDescription() + ); + $this->assertEquals(12, count($options)); } public function testCreateOptions() diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/CodeTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php similarity index 92% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/CodeTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php index c591bd39ddfe9..655b459dd08f5 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/CodeTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/CodeTest.php @@ -3,21 +3,21 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Parser; +namespace Magento\Setup\Test\Unit\Module\Dependency\Parser; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CodeTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Parser\Code + * @var \Magento\Setup\Module\Dependency\Parser\Code */ protected $parser; protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->parser = $objectManagerHelper->getObject('Magento\Tools\Dependency\Parser\Code'); + $this->parser = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Parser\Code'); } /** diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/Composer/JsonTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php similarity index 85% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/Composer/JsonTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php index 0aa80ac637d37..c8fb94785e06e 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/Composer/JsonTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Composer/JsonTest.php @@ -3,21 +3,21 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Parser\Composer; +namespace Magento\Setup\Test\Unit\Module\Dependency\Parser\Composer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class JsonTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Parser\Config\Xml + * @var \Magento\Setup\Module\Dependency\Parser\Config\Xml */ protected $parser; protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->parser = $objectManagerHelper->getObject('Magento\Tools\Dependency\Parser\Composer\Json'); + $this->parser = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Parser\Composer\Json'); } /** diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/Config/XmlTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php similarity index 85% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/Config/XmlTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php index 39ade55ab1ea0..4c0b9ad1f0236 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Parser/Config/XmlTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Parser/Config/XmlTest.php @@ -3,21 +3,21 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Parser\Config; +namespace Magento\Setup\Test\Unit\Module\Dependency\Parser\Config; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class XmlTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Parser\Config\Xml + * @var \Magento\Setup\Module\Dependency\Parser\Config\Xml */ protected $parser; protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->parser = $objectManagerHelper->getObject('Magento\Tools\Dependency\Parser\Config\Xml'); + $this->parser = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Parser\Config\Xml'); } /** diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Builder/AbstractBuilderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php similarity index 78% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Builder/AbstractBuilderTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php index f19faccb90a83..dce2cdcda680c 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Builder/AbstractBuilderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Builder/AbstractBuilderTest.php @@ -3,32 +3,32 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Builder; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Builder; class AbstractBuilderTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\ParserInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\ParserInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $dependenciesParserMock; /** - * @var \Magento\Tools\Dependency\Report\WriterInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\WriterInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $reportWriterMock; /** - * @var \Magento\Tools\Dependency\Report\Builder\AbstractBuilder|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $builder; protected function setUp() { - $this->dependenciesParserMock = $this->getMock('Magento\Tools\Dependency\ParserInterface'); - $this->reportWriterMock = $this->getMock('Magento\Tools\Dependency\Report\WriterInterface'); + $this->dependenciesParserMock = $this->getMock('Magento\Setup\Module\Dependency\ParserInterface'); + $this->reportWriterMock = $this->getMock('Magento\Setup\Module\Dependency\Report\WriterInterface'); $this->builder = $this->getMockForAbstractClass( - 'Magento\Tools\Dependency\Report\Builder\AbstractBuilder', + 'Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder', ['dependenciesParser' => $this->dependenciesParserMock, 'reportWriter' => $this->reportWriterMock] ); } @@ -79,7 +79,7 @@ public function testBuild() ]; $parseResult = ['foo', 'bar', 'baz']; - $configMock = $this->getMock('\Magento\Tools\Dependency\Report\Data\ConfigInterface'); + $configMock = $this->getMock('\Magento\Setup\Module\Dependency\Report\Data\ConfigInterface'); $this->dependenciesParserMock->expects( $this->once() diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ChainTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php similarity index 69% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ChainTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php index e2d73594b87ba..1e0ebda735d21 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ChainTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ChainTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Circular\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Circular\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -14,9 +14,9 @@ public function testGetModules() $modules = ['foo', 'baz', 'bar']; $objectManagerHelper = new ObjectManager($this); - /** @var \Magento\Tools\Dependency\Report\Circular\Data\Chain $chain */ + /** @var \Magento\Setup\Module\Dependency\Report\Circular\Data\Chain $chain */ $chain = $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Circular\Data\Chain', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Chain', ['modules' => $modules] ); diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php similarity index 66% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ConfigTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php index c8d2ebba4bc48..a171dc132be2e 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ConfigTest.php @@ -3,38 +3,38 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Circular\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Circular\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class ConfigTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Report\Circular\Data\Module|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Circular\Data\Module|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleFirst; /** - * @var \Magento\Tools\Dependency\Report\Circular\Data\Module|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Circular\Data\Module|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleSecond; /** - * @var \Magento\Tools\Dependency\Report\Circular\Data\Config + * @var \Magento\Setup\Module\Dependency\Report\Circular\Data\Config */ protected $config; public function setUp() { $this->moduleFirst = $this->getMock( - 'Magento\Tools\Dependency\Report\Circular\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', [], [], '', false ); $this->moduleSecond = $this->getMock( - 'Magento\Tools\Dependency\Report\Circular\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', [], [], '', @@ -43,7 +43,7 @@ public function setUp() $objectManagerHelper = new ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Circular\Data\Config', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Config', ['modules' => [$this->moduleFirst, $this->moduleSecond]] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php similarity index 83% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ModuleTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php index 6321fc522a742..9564f7c3a2c11 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Circular/Data/ModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Circular/Data/ModuleTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Circular\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Circular\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -12,13 +12,13 @@ class ModuleTest extends \PHPUnit_Framework_TestCase /** * @param string $name * @param array $chains - * @return \Magento\Tools\Dependency\Report\Circular\Data\Module + * @return \Magento\Setup\Module\Dependency\Report\Circular\Data\Module */ protected function createModule($name, $chains = []) { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Circular\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Circular\Data\Module', ['name' => $name, 'chains' => $chains] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Data/Config/AbstractConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php similarity index 63% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Data/Config/AbstractConfigTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php index e19c231513b62..55ff0b734cf89 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Data/Config/AbstractConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Data/Config/AbstractConfigTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Data\Config; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Data\Config; class AbstractConfigTest extends \PHPUnit_Framework_TestCase { @@ -11,9 +11,9 @@ public function testGetModules() { $modules = ['foo', 'baz', 'bar']; - /** @var \Magento\Tools\Dependency\Report\Data\Config\AbstractConfig $config */ + /** @var \Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig $config */ $config = $this->getMockForAbstractClass( - 'Magento\Tools\Dependency\Report\Data\Config\AbstractConfig', + 'Magento\Setup\Module\Dependency\Report\Data\Config\AbstractConfig', ['modules' => $modules] ); diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/ConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php similarity index 80% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/ConfigTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php index 791c8fb56735a..7225eb7d88edc 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/ConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ConfigTest.php @@ -3,38 +3,38 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Dependency\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Dependency\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class ConfigTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Module|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleFirst; /** - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Module|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleSecond; /** - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Config + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Config */ protected $config; public function setUp() { $this->moduleFirst = $this->getMock( - 'Magento\Tools\Dependency\Report\Dependency\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', [], [], '', false ); $this->moduleSecond = $this->getMock( - 'Magento\Tools\Dependency\Report\Dependency\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', [], [], '', @@ -43,7 +43,7 @@ public function setUp() $objectManagerHelper = new ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Dependency\Data\Config', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Config', ['modules' => [$this->moduleFirst, $this->moduleSecond]] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/DependencyTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php similarity index 76% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/DependencyTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php index 4f563acf6fdec..98eb160634a4d 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/DependencyTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/DependencyTest.php @@ -3,9 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Dependency\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Dependency\Data; -use \Magento\Tools\Dependency\Report\Dependency\Data\Dependency; +use \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,14 +13,14 @@ class DependencyTest extends \PHPUnit_Framework_TestCase { /** * @param string $module - * @param string|null $type One of \Magento\Tools\Dependency\Dependency::TYPE_ const - * @return \Magento\Tools\Dependency\Report\Dependency\Data\Dependency + * @param string|null $type One of \Magento\Setup\Module\Dependency\Dependency::TYPE_ const + * @return \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency */ protected function createDependency($module, $type = null) { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Dependency\Data\Dependency', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', ['module' => $module, 'type' => $type] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/ModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php similarity index 78% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/ModuleTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php index 84d67f2d47030..460cff3f68bfb 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Dependency/Data/ModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Dependency/Data/ModuleTest.php @@ -3,38 +3,38 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Dependency\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Dependency\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class ModuleTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Dependency|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency|\PHPUnit_Framework_MockObject_MockObject */ protected $dependencyFirst; /** - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Dependency|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency|\PHPUnit_Framework_MockObject_MockObject */ protected $dependencySecond; /** - * @var \Magento\Tools\Dependency\Report\Dependency\Data\Module + * @var \Magento\Setup\Module\Dependency\Report\Dependency\Data\Module */ protected $module; public function setUp() { $this->dependencyFirst = $this->getMock( - 'Magento\Tools\Dependency\Report\Dependency\Data\Dependency', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', [], [], '', false ); $this->dependencySecond = $this->getMock( - 'Magento\Tools\Dependency\Report\Dependency\Data\Dependency', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Dependency', [], [], '', @@ -43,7 +43,7 @@ public function setUp() $objectManagerHelper = new ObjectManager($this); $this->module = $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Dependency\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Dependency\Data\Module', ['name' => 'name', 'dependencies' => [$this->dependencyFirst, $this->dependencySecond]] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/BuilderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php similarity index 85% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/BuilderTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php index dda31cd755bf2..da63288718797 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/BuilderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/BuilderTest.php @@ -3,21 +3,21 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Framework; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Framework; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class BuilderTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Report\Framework\Builder + * @var \Magento\Setup\Module\Dependency\Report\Framework\Builder */ protected $builder; protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->builder = $objectManagerHelper->getObject('Magento\Tools\Dependency\Report\Framework\Builder'); + $this->builder = $objectManagerHelper->getObject('Magento\Setup\Module\Dependency\Report\Framework\Builder'); } /** diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/ConfigTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php similarity index 66% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/ConfigTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php index 9b21758710001..799a7650635e8 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/ConfigTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ConfigTest.php @@ -3,38 +3,38 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Framework\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Framework\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class ConfigTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Report\Framework\Data\Module|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Framework\Data\Module|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleFirst; /** - * @var \Magento\Tools\Dependency\Report\Framework\Data\Module|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Framework\Data\Module|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleSecond; /** - * @var \Magento\Tools\Dependency\Report\Framework\Data\Config + * @var \Magento\Setup\Module\Dependency\Report\Framework\Data\Config */ protected $config; public function setUp() { $this->moduleFirst = $this->getMock( - 'Magento\Tools\Dependency\Report\Framework\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', [], [], '', false ); $this->moduleSecond = $this->getMock( - 'Magento\Tools\Dependency\Report\Framework\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', [], [], '', @@ -43,7 +43,7 @@ public function setUp() $objectManagerHelper = new ObjectManager($this); $this->config = $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Framework\Data\Config', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Config', ['modules' => [$this->moduleFirst, $this->moduleSecond]] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/DependencyTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php similarity index 79% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/DependencyTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php index f89a3669702f6..8633152c5f9e5 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/DependencyTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/DependencyTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Framework\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Framework\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -12,13 +12,13 @@ class DependencyTest extends \PHPUnit_Framework_TestCase /** * @param string $lib * @param int $count - * @return \Magento\Tools\Dependency\Report\Framework\Data\Dependency + * @return \Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency */ protected function createDependency($lib, $count) { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Framework\Data\Dependency', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Dependency', ['lib' => $lib, 'count' => $count] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/ModuleTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php similarity index 83% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/ModuleTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php index c9e49b9d1a5f4..a6ed71292efa6 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Framework/Data/ModuleTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Framework/Data/ModuleTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Framework\Data; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Framework\Data; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -12,13 +12,13 @@ class ModuleTest extends \PHPUnit_Framework_TestCase /** * @param string $name * @param array $dependencies - * @return \Magento\Tools\Dependency\Report\Framework\Data\Module + * @return \Magento\Setup\Module\Dependency\Report\Framework\Data\Module */ protected function createModule($name, $dependencies = []) { $objectManagerHelper = new ObjectManager($this); return $objectManagerHelper->getObject( - 'Magento\Tools\Dependency\Report\Framework\Data\Module', + 'Magento\Setup\Module\Dependency\Report\Framework\Data\Module', ['name' => $name, 'dependencies' => $dependencies] ); } diff --git a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Writer/Csv/AbstractWriterTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php similarity index 78% rename from dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Writer/Csv/AbstractWriterTest.php rename to setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php index 18084a75eb36f..280679e2fa107 100644 --- a/dev/tools/Magento/Tools/Dependency/Test/Unit/Report/Writer/Csv/AbstractWriterTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Dependency/Report/Writer/Csv/AbstractWriterTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Tools\Dependency\Test\Unit\Report\Writer\Csv; +namespace Magento\Setup\Test\Unit\Module\Dependency\Report\Writer\Csv; class AbstractWriterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tools\Dependency\Report\Writer\Csv\AbstractWriter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter|\PHPUnit_Framework_MockObject_MockObject */ protected $writer; @@ -22,7 +22,7 @@ protected function setUp() $this->csvMock = $this->getMock('Magento\Framework\File\Csv'); $this->writer = $this->getMockForAbstractClass( - 'Magento\Tools\Dependency\Report\Writer\Csv\AbstractWriter', + 'Magento\Setup\Module\Dependency\Report\Writer\Csv\AbstractWriter', ['writer' => $this->csvMock] ); } @@ -30,7 +30,7 @@ protected function setUp() public function testWrite() { $options = ['report_filename' => 'some_filename']; - $configMock = $this->getMock('Magento\Tools\Dependency\Report\Data\ConfigInterface'); + $configMock = $this->getMock('Magento\Setup\Module\Dependency\Report\Data\ConfigInterface'); $preparedData = ['foo', 'baz', 'bar']; $this->writer->expects( @@ -55,7 +55,7 @@ public function testWrite() */ public function testWriteWithWrongOptionReportFilename($options) { - $configMock = $this->getMock('Magento\Tools\Dependency\Report\Data\ConfigInterface'); + $configMock = $this->getMock('Magento\Setup\Module\Dependency\Report\Data\ConfigInterface'); $this->writer->write($options, $configMock); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php new file mode 100644 index 0000000000000..dc11cccd59662 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php @@ -0,0 +1,99 @@ +directoryScannerMock = $this->getMock( + 'Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner', + [], + [], + '', + false + ); + $this->serviceDataAttributesScannerMock = $this->getMock( + 'Magento\Setup\Module\Di\Code\Scanner\ServiceDataAttributesScanner', + [], + [], + '', + false + ); + } + + /** + * @param $data array + * @dataProvider doOperationDataProvider + */ + public function testDoOperationEmptyData($data) + { + $model = new ServiceDataAttributesGenerator( + $this->directoryScannerMock, + $this->serviceDataAttributesScannerMock, + $data + ); + $this->directoryScannerMock->expects($this->never())->method('scan'); + + $model->doOperation(); + } + + /** + * @return array + */ + public function doOperationDataProvider() + { + return [ + [[]], + [['filePatterns' => ['php' => '*.php']]], + [['path' => 'path']] + ]; + } + + public function testDoOperation() + { + $data = [ + 'path' => 'path/to/app', + 'filePatterns' => ['di' => 'di.xml'], + ]; + $files = ['service_data_attributes' => []]; + $model = new ServiceDataAttributesGenerator( + $this->directoryScannerMock, + $this->serviceDataAttributesScannerMock, + $data + ); + + $this->directoryScannerMock->expects($this->once()) + ->method('scan') + ->with( + $data['path'], + $data['filePatterns'] + )->willReturn($files); + $this->serviceDataAttributesScannerMock->expects($this->once()) + ->method('collectEntities') + ->with($files['service_data_attributes']) + ->willReturn([]); + + $model->doOperation(); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php new file mode 100644 index 0000000000000..e96951ab59e9d --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ServiceDataAttributesScannerTest.php @@ -0,0 +1,45 @@ +model = new ServiceDataAttributesScanner(); + $this->testFile = str_replace('\\', '/', realpath(__DIR__ . '/../../') . '/_files/service_data_attributes.xml'); + } + + public function testCollectEntities() + { + $files = [$this->testFile]; + $expectedResult = [ + 'Magento\Sales\Api\Data\OrderExtensionInterface', + 'Magento\Sales\Api\Data\OrderExtension', + 'Magento\Sales\Api\Data\OrderItemExtensionInterface', + 'Magento\Sales\Api\Data\OrderItemExtension', + 'Magento\GiftMessage\Api\Data\MessageExtensionInterface', + 'Magento\GiftMessage\Api\Data\MessageExtension', + 'Magento\Quote\Api\Data\TotalsAdditionalDataExtensionInterface', + 'Magento\Quote\Api\Data\TotalsAdditionalDataExtension' + ]; + + $this->assertSame($expectedResult, $this->model->collectEntities($files)); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/service_data_attributes.xml b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/service_data_attributes.xml new file mode 100644 index 0000000000000..bc8a926dfb86f --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/service_data_attributes.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php b/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php index 778c734d7e599..d0e06963c70ef 100644 --- a/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php @@ -119,7 +119,7 @@ public function testCreateService($zfAppConfig, $env, $cliParam, $expectedArray) $request->expects($this->any()) ->method('getContent') ->willReturn( - $cliParam ? ['install', '--magento_init_params=' . $cliParam ] : ['install'] + $cliParam ? ['install', '--magento-init-params=' . $cliParam ] : ['install'] ); $mvcApplication->expects($this->any())->method('getConfig')->willReturn( $zfAppConfig ? [InitParamListener::BOOTSTRAP_PARAM => $zfAppConfig]:[] diff --git a/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php new file mode 100644 index 0000000000000..7a447d942ed68 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Validator/DbValidatorTest.php @@ -0,0 +1,87 @@ +connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false); + $this->connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); + $this->connectionFactory->expects($this->any())->method('create')->willReturn($this->connection); + $this->dbValidator = new DbValidator($this->connectionFactory); + } + + public function testCheckDatabaseConnection() + { + $this->connection + ->expects($this->once()) + ->method('fetchOne') + ->with('SELECT version()') + ->willReturn('5.6.0-0ubuntu0.12.04.1'); + $this->assertEquals(true, $this->dbValidator->checkDatabaseConnection('name', 'host', 'user', 'password')); + } + + public function testCheckDatabaseTablePrefix() + { + $this->assertEquals(true, $this->dbValidator->checkDatabaseTablePrefix('test')); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Please correct the table prefix format + */ + public function testCheckDatabaseTablePrefixWrongFormat() + { + $this->assertEquals(true, $this->dbValidator->checkDatabaseTablePrefix('_wrong_format')); + } + + /** + * @expectedException \Magento\Setup\Exception + * @expectedExceptionMessage Database connection failure. + */ + public function testCheckDatabaseConnectionFailed() + { + $connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false); + $connectionFactory->expects($this->once())->method('create')->willReturn(false); + $this->dbValidator = new DbValidator($connectionFactory); + $this->dbValidator->checkDatabaseConnection('name', 'host', 'user', 'password'); + } + + /** + * @expectedException \Magento\Setup\Exception + * @expectedExceptionMessage Sorry, but we support MySQL version + */ + public function testCheckDatabaseConnectionIncompatible() + { + $this->connection + ->expects($this->once()) + ->method('fetchOne') + ->with('SELECT version()') + ->willReturn('5.5.40-0ubuntu0.12.04.1'); + $this->dbValidator->checkDatabaseConnection('name', 'host', 'user', 'password'); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Validator/IpValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Validator/IpValidatorTest.php new file mode 100644 index 0000000000000..9de751bc6d66a --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Validator/IpValidatorTest.php @@ -0,0 +1,75 @@ +ipValidator = new IpValidator(); + } + + /** + * @dataProvider validateIpsNoneAllowedDataProvider + * @param string[] $ips + * @param string[] $expectedMessages + */ + public function testValidateIpsNoneAllowed($ips, $expectedMessages) + { + $this->assertEquals($expectedMessages, $this->ipValidator->validateIps($ips, true)); + } + + /** + * @return array + */ + public function validateIpsNoneAllowedDataProvider() + { + return [ + [['127.0.0.1', '127.0.0.2'], []], + [['none'], []], + [['none', '127.0.0.1'], ["Multiple values are not allowed when 'none' is used"]], + [['127.0.0.1', 'none'], ["Multiple values are not allowed when 'none' is used"]], + [['none', 'invalid'], ["Multiple values are not allowed when 'none' is used"]], + [['invalid', 'none'], ["Multiple values are not allowed when 'none' is used"]], + [['none', 'none'], ["'none' can be only used once"]], + [['invalid'], ['Invalid IP invalid']], + ]; + } + + /** + * @dataProvider validateIpsNoneNotAllowedDataProvider + * @param string[] $ips + * @param string[] $expectedMessages + */ + public function testValidateIpsNoneNotAllowed($ips, $expectedMessages) + { + $this->assertEquals($expectedMessages, $this->ipValidator->validateIps($ips, false)); + } + + /** + * @return array + */ + public function validateIpsNoneNotAllowedDataProvider() + { + return [ + [['127.0.0.1', '127.0.0.2'], []], + [['none'], ["'none' is not allowed"]], + [['none', '127.0.0.1'], ["'none' is not allowed"]], + [['127.0.0.1', 'none'], ["'none' is not allowed"]], + [['none', 'invalid'], ["'none' is not allowed"]], + [['invalid', 'none'], ["'none' is not allowed"]], + [['none', 'none'], ["'none' is not allowed"]], + [['invalid'], ['Invalid IP invalid']], + ]; + } +} diff --git a/setup/src/Magento/Setup/Validator/DbValidator.php b/setup/src/Magento/Setup/Validator/DbValidator.php new file mode 100644 index 0000000000000..500f8969c44ca --- /dev/null +++ b/setup/src/Magento/Setup/Validator/DbValidator.php @@ -0,0 +1,90 @@ +connectionFactory = $connectionFactory; + } + + /** + * Check if database table prefix is valid + * + * @param string $prefix + * @return boolean + * @throws \InvalidArgumentException + */ + public function checkDatabaseTablePrefix($prefix) + { + //The table prefix should contain only letters (a-z), numbers (0-9) or underscores (_); + // the first character should be a letter. + if ($prefix !== '' && !preg_match('/^([a-zA-Z])([[:alnum:]_]+)$/', $prefix)) { + throw new \InvalidArgumentException('Please correct the table prefix format.'); + } + + return true; + } + + /** + * Checks Database Connection + * + * @param string $dbName + * @param string $dbHost + * @param string $dbUser + * @param string $dbPass + * @return boolean + * @throws \Magento\Setup\Exception + */ + public function checkDatabaseConnection($dbName, $dbHost, $dbUser, $dbPass = '') + { + $connection = $this->connectionFactory->create([ + 'dbname' => $dbName, + 'host' => $dbHost, + 'username' => $dbUser, + 'password' => $dbPass, + 'active' => true, + ]); + + if (!$connection) { + throw new \Magento\Setup\Exception('Database connection failure.'); + } + + $mysqlVersion = $connection->fetchOne('SELECT version()'); + if ($mysqlVersion) { + if (preg_match('/^([0-9\.]+)/', $mysqlVersion, $matches)) { + if (isset($matches[1]) && !empty($matches[1])) { + if (version_compare($matches[1], Installer::MYSQL_VERSION_REQUIRED) < 0) { + throw new \Magento\Setup\Exception( + 'Sorry, but we support MySQL version '. Installer::MYSQL_VERSION_REQUIRED . ' or later.' + ); + } + } + } + } + return true; + } +} diff --git a/setup/src/Magento/Setup/Validator/IpValidator.php b/setup/src/Magento/Setup/Validator/IpValidator.php new file mode 100644 index 0000000000000..45b405d68082b --- /dev/null +++ b/setup/src/Magento/Setup/Validator/IpValidator.php @@ -0,0 +1,79 @@ +none = []; + $this->validIps = []; + $this->invalidIps = []; + $messages = []; + + $this->filterIps($ips); + + if (sizeof($this->none) > 0 && !$noneAllowed) { + $messages[] = "'none' is not allowed"; + } elseif ($noneAllowed && sizeof($this->none) > 1) { + $messages[] = "'none' can be only used once"; + } elseif ($noneAllowed && sizeof($this->none) > 0 && + (sizeof($this->validIps) > 0 || sizeof($this->invalidIps) > 0) + ) { + $messages[] = "Multiple values are not allowed when 'none' is used"; + } else { + foreach ($this->invalidIps as $invalidIp) { + $messages[] = "Invalid IP $invalidIp"; + } + } + return $messages; + } + + /** + * Filter ips into 'none', valid and invalid ips + * + * @param string[] $ips + * @return void + */ + private function filterIps(array $ips) + { + foreach ($ips as $ip) { + if (filter_var($ip, FILTER_VALIDATE_IP)) { + $this->validIps[] = $ip; + } elseif ($ip == 'none') { + $this->none[] = $ip; + } else { + $this->invalidIps[] = $ip; + } + } + } +} diff --git a/setup/view/error/401.phtml b/setup/view/error/401.phtml new file mode 100644 index 0000000000000..d1656c2868a2f --- /dev/null +++ b/setup/view/error/401.phtml @@ -0,0 +1,17 @@ + +
      + +

      + Welcome to Magento Admin, your online store headquarters. +
      + To use the Magento setup wizard sign into your Admin account and navigate to System => Tools => Web Setup Wizard +

      +
      diff --git a/setup/view/magento/setup/success.phtml b/setup/view/magento/setup/success.phtml index dd8e0b316094c..f0c2867f9b727 100644 --- a/setup/view/magento/setup/success.phtml +++ b/setup/view/magento/setup/success.phtml @@ -30,12 +30,12 @@
      Your Store Address:
      - {{config.address.actual_base_url}} + {{url.front}}
      Magento Admin Address:
      - {{config.address.actual_base_url}}{{config.address.admin}}/ + {{url.admin}}
      Encryption Key:
      @@ -62,7 +62,7 @@