diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fe6136eae11b77787726d44f517df9e536c0cdb..a1d98332be0d5c39a997f7ce570933320e08c8e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,42 @@ +0.74.0-beta14 +============= +* Framework improvements: + * Introduced an ability to uninstall modules which were installed via composer (bin/magento module:uninstall <moduleName>) + * Introduced an ability to uninstall themes (bin/magento theme:uninstall <themeName>) + * Introduced an ability to backup and rollback DB and Media via CLI (bin/magento setup:backup, options are --code, --db or --media) + * Introduced an ability to uninstall language packages (bin/magento i18n:uninstall <languagePack>) + * Introduced API notation for the following modules: Backend, Backup, Cron, Log, PageCache + * Added join processors to search services, joined config for services with extension attributes + * Renamed hidden_tax to discount_tax_compensation + * The customer address entity table was transformed from EAV into a flat model to minimize database operations +* Fixed bugs: + * Fixed an issue where Setup Wizard failed on readiness check when Magento was deployed by composer create-project + * Fixed the local file path disclosure when trying to browse image cache directory + * Fixed an issue where development errors resulted in too many redirects + * Fixed an integration test failure in Reports ViewedTest + * Fixed an issue where it was impossible to save existent Grouped Product with no child items + * Fixed an issue where message "We don't have as many "conf1" as you requested" appeared + * Fixed an issue where second product from bundle product was ordered as separate item after checkout + * Fixed an issue where configs for payments and shippings were not encrypted + * Fixed an issue where Table Rates shipping method did not work + * Fixed an issue where admin could not set locale properly on Account page + * Fixed incomplete generated results of single tenant compiler + * Fixed an issue with full page caching where one set of prices was cached for all customers + * Fixed incorrect urls for private content + * Fixed an issue where it was not possible to assign a product link to another product using API + * Fixed an issue where zipcode was not displayed as required field on Create New Order page + * Fixed the Sample Data re-installation + * Fixed random fails on inventory tab for test CreateSimpleProductEntityTest +* Tests: + * Covered various modules with unit tests + * Functional tests fixed and maintained +* GitHub issues: + * [#1156](https://github.com/magento/magento2/pull/1156) -- Moves common code to all auto-generated Interceptor classes into a trait + * [#1206](https://github.com/magento/magento2/pull/1206) -- Allow modules to live outside of app/code directory + * [#1245](https://github.com/magento/magento2/pull/1245) -- Unable to save product per website wise + * [#1347](https://github.com/magento/magento2/pull/1347) -- Fixed failing Install during integration tests (MAGETWO-38482) + * [#1368](https://github.com/magento/magento2/pull/1368) -- Fix typo in getCurrentCategoryKey + 0.74.0-beta13 ============= * Framework improvements: diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index d26dfd7372721000e9973b16a3ea720e1e09a6e5..5ae1d3e4e2009835a572a2c9081ee74619532b51 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/AdvancedPricingImportExport/composer.json b/app/code/Magento/AdvancedPricingImportExport/composer.json index c8b52c1509eb996357137da8f799be5d85c864d7..3e7abff2e19eca58d7d762c6f90932188af3aef6 100644 --- a/app/code/Magento/AdvancedPricingImportExport/composer.json +++ b/app/code/Magento/AdvancedPricingImportExport/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-catalog-import-export": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-catalog-import-export": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index 9225d004e7ce2f5753e0f21d8f95ca2fb7cbe9cf..9ce77947a0b214ceb0d0dd04c9e35f6e6c602ca2 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-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index b7e2b7bc15ba6f54e72cc1d6b084c18876592c52..b2b20216cf652a430d51f44492332e150011cd7d 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-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-developer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-cron": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-reports": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-user": "0.74.0-beta13", - "magento/module-backup": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-translation": "0.74.0-beta13", - "magento/module-require-js": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-developer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-cron": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-reports": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-user": "0.74.0-beta14", + "magento/module-backup": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-translation": "0.74.0-beta14", + "magento/module-require-js": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 30ca528748ce5de5d93f6cf933d2b5bc8bc24cd1..74b0a704e1de9374392c01a64e69b075fc416fde 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-cron": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-cron": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Bundle/Model/Resource/Indexer/Price.php b/app/code/Magento/Bundle/Model/Resource/Indexer/Price.php index e4a7ceb99903b0987bbd38eebc3464895efe4d25..f216ecfc5b4e9f749eeac10696bcf202b83a6db6 100644 --- a/app/code/Magento/Bundle/Model/Resource/Indexer/Price.php +++ b/app/code/Magento/Bundle/Model/Resource/Indexer/Price.php @@ -20,7 +20,7 @@ class Price extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defaul */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { @@ -54,10 +54,7 @@ class Price extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defaul */ protected function _getBundlePriceTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_bundle_idx'); - } - return $this->getTable('catalog_product_index_price_bundle_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_bundle'); } /** @@ -67,10 +64,7 @@ class Price extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defaul */ protected function _getBundleSelectionTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_bundle_sel_idx'); - } - return $this->getTable('catalog_product_index_price_bundle_sel_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_bundle_sel'); } /** @@ -80,10 +74,7 @@ class Price extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defaul */ protected function _getBundleOptionTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_bundle_opt_idx'); - } - return $this->getTable('catalog_product_index_price_bundle_opt_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_bundle_opt'); } /** diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index ddc09411834f50f6715db4ad8103539915f34a44..f3017a3a8dda032fb32a79cff12622d3cb601bc2 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,28 +3,28 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-catalog-rule": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-gift-message": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-catalog-rule": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-gift-message": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-webapi": "0.74.0-beta13" + "magento/module-webapi": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/BundleImportExport/composer.json b/app/code/Magento/BundleImportExport/composer.json index ddbc85cb67cb1d20f44a4bdb9c64ab3bf44f0127..78b23b0ff876b31caff7359c35e625ee986e6100 100755 --- a/app/code/Magento/BundleImportExport/composer.json +++ b/app/code/Magento/BundleImportExport/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-catalog-import-export": "0.74.0-beta13", - "magento/module-bundle": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-catalog-import-export": "0.74.0-beta14", + "magento/module-bundle": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CacheInvalidate/composer.json b/app/code/Magento/CacheInvalidate/composer.json index 5045f5b065cb0b6b80ecc9810dd84ed828bc7c26..5f5a8b2ce39bfa5fff3162892d333dcbd8c1659f 100644 --- a/app/code/Magento/CacheInvalidate/composer.json +++ b/app/code/Magento/CacheInvalidate/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-page-cache": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-page-cache": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index 8e61f79ac764e5f722d5de600b515d27f5abc4be..044ade39edc271c3b8d5d1b4f9aebcb1cc740e90 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php index 54a51a1a55148aee7edeb0d7fb509d7175b408e4..ee730b9be8157e2d794ff954d9e173676cf4b32b 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php @@ -132,7 +132,7 @@ class Category extends \Magento\Framework\Data\Form\Element\Multiselect 'id' => 'add_category_button', 'label' => $newCategoryCaption, 'title' => $newCategoryCaption, - 'onclick' => 'jQuery("#new-category").trigger("openModal")', + 'onclick' => 'jQuery("#new-category").modal("openModal")', 'disabled' => $this->getDisabled(), ] ); diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php index 0b62afa09de3400b5e24dff8f464d3a7dd5242d8..08617d3ebd8d49aeca3d59db2f58838cd16c03c7 100644 --- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php @@ -598,4 +598,48 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } + + /** + * Retrieve product details html + * + * @param \Magento\Catalog\Model\Product $product + * @return mixed + */ + public function getProductDetailsHtml(\Magento\Catalog\Model\Product $product) + { + $renderer = $this->getDetailsRenderer($product->getTypeId()); + if ($renderer) { + $renderer->setProduct($product); + return $renderer->toHtml(); + } + return ''; + } + + /** + * @param null $type + * @return bool|\Magento\Framework\View\Element\AbstractBlock + */ + public function getDetailsRenderer($type = null) + { + if ($type === null) { + $type = 'default'; + } + $rendererList = $this->getDetailsRendererList(); + if ($rendererList) { + return $rendererList->getRenderer($type, 'default'); + } + return null; + } + + /** + * @return \Magento\Framework\View\Element\RendererList + */ + protected function getDetailsRendererList() + { + return $this->getDetailsRendererListName() ? $this->getLayout()->getBlock( + $this->getDetailsRendererListName() + ) : $this->getChildBlock( + 'details.renderers' + ); + } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 6e43b0666791cf26a65df23d3dbd6809bbc48b2f..c6da03c6a48ee2dd466f15ffe71f3e1d9a33c7b6 100755 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -15,16 +15,9 @@ abstract class AbstractAction /** * Default Product Type Price indexer resource model * - * @var string + * @var \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice */ - protected $_defaultPriceIndexer; - - /** - * Resource instance - * - * @var \Magento\Framework\App\Resource - */ - protected $_resource; + protected $_defaultIndexerResource; /** * @var \Magento\Framework\DB\Adapter\AdapterInterface @@ -78,14 +71,6 @@ abstract class AbstractAction protected $_indexers; /** - * Flag that defines if need to use "_idx" index table suffix instead of "_tmp" - * - * @var bool - */ - protected $_useIdxTable = false; - - /** - * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory @@ -93,10 +78,9 @@ abstract class AbstractAction * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Product\Type $catalogProductType * @param \Magento\Catalog\Model\Resource\Product\Indexer\Price\Factory $indexerPriceFactory - * @param string $defaultPriceIndexer + * @param \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice $defaultIndexerResource */ public function __construct( - \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, @@ -104,9 +88,8 @@ abstract class AbstractAction \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Catalog\Model\Resource\Product\Indexer\Price\Factory $indexerPriceFactory, - $defaultPriceIndexer + \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice $defaultIndexerResource ) { - $this->_resource = $resource; $this->_config = $config; $this->_storeManager = $storeManager; $this->_currencyFactory = $currencyFactory; @@ -114,20 +97,8 @@ abstract class AbstractAction $this->_dateTime = $dateTime; $this->_catalogProductType = $catalogProductType; $this->_indexerPriceFactory = $indexerPriceFactory; - $this->_defaultPriceIndexer = $defaultPriceIndexer; - } - - /** - * Retrieve connection instance - * - * @return bool|\Magento\Framework\DB\Adapter\AdapterInterface - */ - protected function _getConnection() - { - if (null === $this->_connection) { - $this->_connection = $this->_resource->getConnection('write'); - } - return $this->_connection; + $this->_defaultIndexerResource = $defaultIndexerResource; + $this->_connection = $this->_defaultIndexerResource->getWriteConnection(); } /** @@ -147,11 +118,11 @@ abstract class AbstractAction protected function _syncData(array $processIds = []) { // delete invalid rows - $select = $this->_getConnection()->select()->from( - ['index_price' => $this->_getTable('catalog_product_index_price')], + $select = $this->_connection->select()->from( + ['index_price' => $this->_defaultIndexerResource->getTable('catalog_product_index_price')], null )->joinLeft( - ['ip_tmp' => $this->_getIdxTable()], + ['ip_tmp' => $this->_defaultIndexerResource->getIdxTable()], 'index_price.entity_id = ip_tmp.entity_id AND index_price.website_id = ip_tmp.website_id', [] )->where( @@ -161,23 +132,15 @@ abstract class AbstractAction $select->where('index_price.entity_id IN(?)', $processIds); } $sql = $select->deleteFromSelect('index_price'); - $this->_getConnection()->query($sql); + $this->_connection->query($sql); - $this->_insertFromTable($this->_getIdxTable(), $this->_getTable('catalog_product_index_price')); + $this->_insertFromTable( + $this->_defaultIndexerResource->getIdxTable(), + $this->_defaultIndexerResource->getTable('catalog_product_index_price') + ); return $this; } - /** - * Returns table name for given entity - * - * @param string $entityName - * @return string - */ - protected function _getTable($entityName) - { - return $this->_resource->getTableName($entityName); - } - /** * Prepare website current dates table * @@ -185,14 +148,13 @@ abstract class AbstractAction */ protected function _prepareWebsiteDateTable() { - $write = $this->_getConnection(); $baseCurrency = $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE); - $select = $write->select()->from( - ['cw' => $this->_getTable('store_website')], + $select = $this->_connection->select()->from( + ['cw' => $this->_defaultIndexerResource->getTable('store_website')], ['website_id'] )->join( - ['csg' => $this->_getTable('store_group')], + ['csg' => $this->_defaultIndexerResource->getTable('store_group')], 'cw.default_group_id = csg.group_id', ['store_id' => 'default_store_id'] )->where( @@ -200,7 +162,7 @@ abstract class AbstractAction ); $data = []; - foreach ($write->fetchAll($select) as $item) { + foreach ($this->_connection->fetchAll($select) as $item) { /** @var $website \Magento\Store\Model\Website */ $website = $this->_storeManager->getWebsite($item['website_id']); @@ -229,10 +191,12 @@ abstract class AbstractAction } } - $table = $this->_getTable('catalog_product_index_website'); + $table = $this->_defaultIndexerResource->getTable('catalog_product_index_website'); $this->_emptyTable($table); if ($data) { - $write->insertMultiple($table, $data); + foreach ($data as $row) { + $this->_connection->insertOnDuplicate($table, $row, array_keys($row)); + } } return $this; @@ -246,24 +210,27 @@ abstract class AbstractAction */ protected function _prepareTierPriceIndex($entityIds = null) { - $write = $this->_getConnection(); - $table = $this->_getTable('catalog_product_index_tier_price'); + $table = $this->_defaultIndexerResource->getTable('catalog_product_index_tier_price'); $this->_emptyTable($table); - $websiteExpression = $write->getCheckSql('tp.website_id = 0', 'ROUND(tp.value * cwd.rate, 4)', 'tp.value'); - $select = $write->select()->from( - ['tp' => $this->_getTable(['catalog_product_entity', 'tier_price'])], + $websiteExpression = $this->_connection->getCheckSql( + 'tp.website_id = 0', + 'ROUND(tp.value * cwd.rate, 4)', + 'tp.value' + ); + $select = $this->_connection->select()->from( + ['tp' => $this->_defaultIndexerResource->getTable(['catalog_product_entity', 'tier_price'])], ['entity_id'] )->join( - ['cg' => $this->_getTable('customer_group')], + ['cg' => $this->_defaultIndexerResource->getTable('customer_group')], 'tp.all_groups = 1 OR (tp.all_groups = 0 AND tp.customer_group_id = cg.customer_group_id)', ['customer_group_id'] )->join( - ['cw' => $this->_getTable('store_website')], + ['cw' => $this->_defaultIndexerResource->getTable('store_website')], 'tp.website_id = 0 OR tp.website_id = cw.website_id', ['website_id'] )->join( - ['cwd' => $this->_getTable('catalog_product_index_website')], + ['cwd' => $this->_defaultIndexerResource->getTable('catalog_product_index_website')], 'cw.website_id = cwd.website_id', [] )->where( @@ -279,7 +246,7 @@ abstract class AbstractAction } $query = $select->insertFromSelect($table); - $write->query($query); + $this->_connection->query($query); return $this; } @@ -292,24 +259,27 @@ abstract class AbstractAction */ protected function _prepareGroupPriceIndex($entityIds = null) { - $write = $this->_getConnection(); - $table = $this->_getTable('catalog_product_index_group_price'); + $table = $this->_defaultIndexerResource->getTable('catalog_product_index_group_price'); $this->_emptyTable($table); - $websiteExpression = $write->getCheckSql('gp.website_id = 0', 'ROUND(gp.value * cwd.rate, 4)', 'gp.value'); - $select = $write->select()->from( - ['gp' => $this->_getTable(['catalog_product_entity', 'group_price'])], + $websiteExpression = $this->_connection->getCheckSql( + 'gp.website_id = 0', + 'ROUND(gp.value * cwd.rate, 4)', + 'gp.value' + ); + $select = $this->_connection->select()->from( + ['gp' => $this->_defaultIndexerResource->getTable(['catalog_product_entity', 'group_price'])], ['entity_id'] )->join( - ['cg' => $this->_getTable('customer_group')], + ['cg' => $this->_defaultIndexerResource->getTable('customer_group')], 'gp.all_groups = 1 OR (gp.all_groups = 0 AND gp.customer_group_id = cg.customer_group_id)', ['customer_group_id'] )->join( - ['cw' => $this->_getTable('store_website')], + ['cw' => $this->_defaultIndexerResource->getTable('store_website')], 'gp.website_id = 0 OR gp.website_id = cw.website_id', ['website_id'] )->join( - ['cwd' => $this->_getTable('catalog_product_index_website')], + ['cwd' => $this->_defaultIndexerResource->getTable('catalog_product_index_website')], 'cw.website_id = cwd.website_id', [] )->where( @@ -325,7 +295,7 @@ abstract class AbstractAction } $query = $select->insertFromSelect($table); - $write->query($query); + $this->_connection->query($query); return $this; } @@ -343,7 +313,7 @@ abstract class AbstractAction foreach ($types as $typeId => $typeInfo) { $modelName = isset( $typeInfo['price_indexer'] - ) ? $typeInfo['price_indexer'] : $this->_defaultPriceIndexer; + ) ? $typeInfo['price_indexer'] : get_class($this->_defaultIndexerResource); $isComposite = !empty($typeInfo['composite']); $indexer = $this->_indexerPriceFactory->create( @@ -377,7 +347,7 @@ abstract class AbstractAction } /** - * Copy data from source table of read adapter to destination table of index adapter + * Copy data from source table to destination * * @param string $sourceTable * @param string $destTable @@ -386,47 +356,19 @@ abstract class AbstractAction */ protected function _insertFromTable($sourceTable, $destTable, $where = null) { - $connection = $this->_getConnection(); - $sourceColumns = array_keys($connection->describeTable($sourceTable)); - $targetColumns = array_keys($connection->describeTable($destTable)); - $select = $connection->select()->from($sourceTable, $sourceColumns); + $sourceColumns = array_keys($this->_connection->describeTable($sourceTable)); + $targetColumns = array_keys($this->_connection->describeTable($destTable)); + $select = $this->_connection->select()->from($sourceTable, $sourceColumns); if ($where) { $select->where($where); } - $query = $connection->insertFromSelect( + $query = $this->_connection->insertFromSelect( $select, $destTable, $targetColumns, \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE ); - $connection->query($query); - } - - /** - * Set or get what either "_idx" or "_tmp" suffixed temporary index table need to use - * - * @param bool $value - * @return bool - */ - protected function _useIdxTable($value = null) - { - if ($value !== null) { - $this->_useIdxTable = (bool)$value; - } - return $this->_useIdxTable; - } - - /** - * Retrieve temporary index table name - * - * @return string - */ - protected function _getIdxTable() - { - if ($this->_useIdxTable()) { - return $this->_getTable('catalog_product_index_price_idx'); - } - return $this->_getTable('catalog_product_index_price_tmp'); + $this->_connection->query($query); } /** @@ -437,7 +379,7 @@ abstract class AbstractAction */ protected function _emptyTable($table) { - $this->_getConnection()->delete($table); + $this->_connection->delete($table); } /** @@ -449,11 +391,11 @@ abstract class AbstractAction */ protected function _reindexRows($changedIds = []) { - $this->_emptyTable($this->_getIdxTable()); + $this->_emptyTable($this->_defaultIndexerResource->getIdxTable()); $this->_prepareWebsiteDateTable(); $select = $this->_connection->select()->from( - $this->_getTable('catalog_product_entity'), + $this->_defaultIndexerResource->getTable('catalog_product_entity'), ['entity_id', 'type_id'] )->where( 'entity_id IN(?)', @@ -479,10 +421,10 @@ abstract class AbstractAction if (!empty($notCompositeIds)) { $select = $this->_connection->select()->from( - ['l' => $this->_getTable('catalog_product_relation')], + ['l' => $this->_defaultIndexerResource->getTable('catalog_product_relation')], 'parent_id' )->join( - ['e' => $this->_getTable('catalog_product_entity')], + ['e' => $this->_defaultIndexerResource->getTable('catalog_product_entity')], 'e.entity_id = l.parent_id', ['type_id'] )->where( @@ -525,9 +467,8 @@ abstract class AbstractAction */ protected function _copyRelationIndexData($parentIds, $excludeIds = null) { - $write = $this->_connection; - $select = $write->select()->from( - $this->_getTable('catalog_product_relation'), + $select = $this->_connection->select()->from( + $this->_defaultIndexerResource->getTable('catalog_product_relation'), ['child_id'] )->where( 'parent_id IN(?)', @@ -537,17 +478,17 @@ abstract class AbstractAction $select->where('child_id NOT IN(?)', $excludeIds); } - $children = $write->fetchCol($select); + $children = $this->_connection->fetchCol($select); if ($children) { - $select = $write->select()->from( - $this->_getTable('catalog_product_index_price') + $select = $this->_connection->select()->from( + $this->_defaultIndexerResource->getTable('catalog_product_index_price') )->where( 'entity_id IN(?)', $children ); - $query = $select->insertFromSelect($this->_getIdxTable(), [], false); - $write->query($query); + $query = $select->insertFromSelect($this->_defaultIndexerResource->getIdxTable(), [], false); + $this->_connection->query($query); } return $this; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php index 61700737da9d279d805533bc4421db2bbfb18182..ac9c4391efaa1bf23198ef8ec07c16436f5666eb 100755 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php @@ -21,8 +21,8 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction public function execute($ids = null) { try { - $this->_useIdxTable(true); - $this->_emptyTable($this->_getIdxTable()); + $this->_defaultIndexerResource->getTableStrategy()->setUseIdxTable(true); + $this->_emptyTable($this->_defaultIndexerResource->getIdxTable()); $this->_prepareWebsiteDateTable(); $this->_prepareTierPriceIndex(); $this->_prepareGroupPriceIndex(); diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php index 01f2fa19a59ca5163d06d995796414944bb60cc5..fcc0fbf435f681062bdf3f39a0ab9e21d9dbeaad 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php @@ -11,6 +11,7 @@ use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; * Category flat model * * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Flat extends \Magento\Indexer\Model\Resource\AbstractResource { @@ -78,7 +79,10 @@ class Flat extends \Magento\Indexer\Model\Resource\AbstractResource protected $_categoryFactory; /** + * Class constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param CollectionFactory $categoryCollectionFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -88,6 +92,7 @@ class Flat extends \Magento\Indexer\Model\Resource\AbstractResource */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, @@ -100,7 +105,7 @@ class Flat extends \Magento\Indexer\Model\Resource\AbstractResource $this->_storeManager = $storeManager; $this->_catalogConfig = $catalogConfig; $this->_eventManager = $eventManager; - parent::__construct($context, $resourcePrefix); + parent::__construct($context, $tableStrategy, $resourcePrefix); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php index 0b27b2e351936a40021478bad8332133315a2625..03a082ac070ccf8f1aec001af905968183588585 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php @@ -23,16 +23,18 @@ abstract class AbstractIndexer extends \Magento\Indexer\Model\Resource\AbstractR * Class constructor * * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param string|null $resourcePrefix */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, $resourcePrefix = null ) { $this->_eavConfig = $eavConfig; - parent::__construct($context, $resourcePrefix); + parent::__construct($context, $tableStrategy, $resourcePrefix); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php index 450b8207a86a2a979a0977eb079e9832e4e32c71..a156d0282926d13ad1a39ff29e3a4bdc5dbbe129 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php @@ -23,18 +23,20 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index * Construct * * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param string|null $resourcePrefix */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, $resourcePrefix = null ) { $this->_eventManager = $eventManager; - parent::__construct($context, $eavConfig, $resourcePrefix); + parent::__construct($context, $tableStrategy, $eavConfig, $resourcePrefix); } /** @@ -45,21 +47,19 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { $this->clearTemporaryIndexTable(); $this->_prepareIndex(); $this->_prepareRelationIndex(); $this->_removeNotVisibleEntityFromIndex(); - $this->syncData(); $this->commit(); } catch (\Exception $e) { $this->rollBack(); throw $e; } - return $this; } @@ -107,7 +107,6 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index $adapter->rollBack(); throw $e; } - return $this; } @@ -174,12 +173,12 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index } /** - * Prepare data index for product relations + * Prepare data index select for product relations * * @param array $parentIds the parent entity ids limitation - * @return $this + * @return \Magento\Framework\DB\Select */ - protected function _prepareRelationIndex($parentIds = null) + protected function _prepareRelationIndexSelect($parentIds = null) { $write = $this->_getWriteAdapter(); $idxTable = $this->getIdxTable(); @@ -215,8 +214,22 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index ] ); + return $select; + } + + /** + * Prepare data index for product relations + * + * @param array $parentIds the parent entity ids limitation + * @return $this + */ + protected function _prepareRelationIndex($parentIds = null) + { + $write = $this->_getWriteAdapter(); + $idxTable = $this->getIdxTable(); + $query = $write->insertFromSelect( - $select, + $this->_prepareRelationIndexSelect($parentIds), $idxTable, [], \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_IGNORE @@ -259,10 +272,9 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index $adapter->delete($this->getMainTable(), $where); $adapter->commit(); } catch (\Exception $e) { - $adapter->rollback(); + $adapter->rollBack(); throw $e; } - return $this; } @@ -284,13 +296,11 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index // insert new index $this->insertFromTable($this->getIdxTable(), $this->getMainTable()); - $adapter->commit(); } catch (\Exception $e) { - $adapter->rollback(); + $adapter->rollBack(); throw $e; } - return $this; } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php index 49c694355daf768f44f156f4e91ada07ce3fe52c..f8e73ca886a6c22c3af6b5b634bd0131ae5faa8b 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php @@ -131,9 +131,6 @@ class Decimal extends AbstractEav */ public function getIdxTable($table = null) { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_eav_decimal_idx'); - } - return $this->getTable('catalog_product_index_eav_decimal_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_eav_decimal'); } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php index 287847f4acf445a582a4f32f80d8128cdfe9e2eb..f5899d9a55c7996ce8b2980ba865bd792724f975 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php @@ -25,6 +25,7 @@ class Source extends AbstractEav * Construct * * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper @@ -32,13 +33,14 @@ class Source extends AbstractEav */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Resource\Helper $resourceHelper, $resourcePrefix = null ) { $this->_resourceHelper = $resourceHelper; - parent::__construct($context, $eavConfig, $eventManager, $resourcePrefix); + parent::__construct($context, $tableStrategy, $eavConfig, $eventManager, $resourcePrefix); } /** @@ -321,9 +323,6 @@ class Source extends AbstractEav */ public function getIdxTable($table = null) { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_eav_idx'); - } - return $this->getTable('catalog_product_index_eav_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_eav'); } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php index 7c488ecf2ec36d3bc050d1726df25a72d6d365fb..467091e3c42ed9e29542d5624ae9fc5dfdd6e1ee 100755 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php @@ -42,7 +42,10 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr protected $_eventManager = null; /** + * Class constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Module\Manager $moduleManager @@ -50,6 +53,7 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Module\Manager $moduleManager, @@ -57,7 +61,27 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr ) { $this->_eventManager = $eventManager; $this->moduleManager = $moduleManager; - parent::__construct($context, $eavConfig, $resourcePrefix); + parent::__construct($context, $tableStrategy, $eavConfig, $resourcePrefix); + } + + /** + * Get Table strategy + * + * @return \Magento\Indexer\Model\Indexer\Table\StrategyInterface + */ + public function getTableStrategy() + { + return $this->tableStrategy; + } + + /** + * Get write connection + * + * @return false|\Magento\Framework\DB\Adapter\AdapterInterface + */ + public function getWriteConnection() + { + return $this->_getWriteAdapter(); } /** @@ -129,7 +153,7 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { $this->reindex(); @@ -176,10 +200,7 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ protected function _getDefaultFinalPriceTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_final_idx'); - } - return $this->getTable('catalog_product_index_price_final_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_final'); } /** @@ -330,10 +351,7 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ protected function _getCustomOptionAggregateTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_opt_agr_idx'); - } - return $this->getTable('catalog_product_index_price_opt_agr_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_opt_agr'); } /** @@ -343,10 +361,7 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ protected function _getCustomOptionPriceTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_opt_idx'); - } - return $this->getTable('catalog_product_index_price_opt_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_opt'); } /** @@ -630,10 +645,7 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ public function getIdxTable($table = null) { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_idx'); - } - return $this->getTable('catalog_product_index_price_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price'); } /** diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 2c1ac69b4bbf736b53a62ea9d6387171ece6e7f4..7c1d49431e273833b821bae24c446d3364c6b458 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -3,37 +3,37 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-indexer": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-log": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-wishlist": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-msrp": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-catalog-rule": "0.74.0-beta13", - "magento/module-product-alert": "0.74.0-beta13", - "magento/module-url-rewrite": "0.74.0-beta13", - "magento/module-catalog-url-rewrite": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-indexer": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-log": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-wishlist": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-msrp": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-catalog-rule": "0.74.0-beta14", + "magento/module-product-alert": "0.74.0-beta14", + "magento/module-url-rewrite": "0.74.0-beta14", + "magento/module-catalog-url-rewrite": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.74.0-beta13" + "magento/module-cookie": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index f4aad2caa251e2efce7f66c472eb76c8e17c5c6d..40b644c226a2ae2af8135aee265bcbe473480f98 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -185,7 +185,7 @@ </type> <type name="Magento\Catalog\Model\Indexer\Product\Price\AbstractAction"> <arguments> - <argument name="defaultPriceIndexer" xsi:type="string">Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice</argument> + <argument name="defaultPriceIndexer" xsi:type="object">Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice</argument> </arguments> </type> <type name="Magento\Eav\Model\Entity\Attribute\Set"> diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js b/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js index 552e6a3a70ee729d5bcc8367b3f50312d5061adf..d70f2e17193afe202495b505a22cf26416dbdae7 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js @@ -111,7 +111,7 @@ define([ $('#new_category_name, #new_category_parent-suggest').val(''); $suggest.val(''); clearParentCategory(); - widget.element.trigger('closeModal'); + $(widget.element).modal('closeModal'); } else { $('#new_category_messages').html(data.messages); } diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml index f13c637c087fa6fb212bfd6ffec39d644a672213..dbc1ff5933f3b96bc560a9415461395cf9596319 100644 --- a/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml +++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml @@ -18,6 +18,9 @@ <block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml"> <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml"> <container name="category.product.list.additional" as="additional" /> + <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers"> + <block class="Magento\Framework\View\Element\Template" as="default"/> + </block> <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="product/list/toolbar.phtml"> <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/> <!-- The following code shows how to set your own pager increments --> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml index 154454f16dbfe579d73ac63eab37ae723710f7d5..c376d81d7fae39cbd40de974793de4129085bac2 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml @@ -69,6 +69,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I </strong> <?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?> <?php echo $block->getProductPrice($_product) ?> + <?php echo $block->getProductDetailsHtml($_product); ?> <div class="product-item-inner"> <div class="product actions product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>> @@ -94,7 +95,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I </div> <div data-role="add-to-links" class="actions-secondary"<?php echo strpos($pos, $viewMode . '-secondary') ? $position : ''; ?>> <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?> - <a href="#" + <a href="#" class="action towishlist" title="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>" aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>" @@ -107,7 +108,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare'); ?> - <a href="#" + <a href="#" class="action tocompare" title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>" aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>" diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index fe82fc10d1355d83dbc6a71cbe7ec882504f4f0d..ca381cabc50404db10ec64a2c7e635b69124c128 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-indexer": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-indexer": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php index 92704735fe73e9978cb0f321f9058a28ff4933e1..ee34eeea325a2a439cf5b6fae82180df8ee83a8a 100644 --- a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php @@ -11,13 +11,15 @@ use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\Customer\Api\GroupManagementInterface; use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Api\ExtensionAttributesFactory; +use Magento\Framework\Object\IdentityInterface; +use Magento\Catalog\Model\Product; /** * Catalog Inventory Stock Model for adminhtml area * @method \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Item extends \Magento\CatalogInventory\Model\Stock\Item +class Item extends \Magento\CatalogInventory\Model\Stock\Item implements IdentityInterface { /** * @var GroupManagementInterface @@ -122,4 +124,17 @@ class Item extends \Magento\CatalogInventory\Model\Stock\Item { return true; } + + /** + * @inheritdoc + */ + public function getIdentities() + { + $tags = []; + if ($this->getProductId()) { + $tags[] = Product::CACHE_TAG . '_' . $this->getProductId(); + } + + return $tags; + } } diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php index 05de6b3ffe27586b7f67cf22684ea4049210db6a..8667d4765713ea38e548b44867262df173d63406 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php @@ -36,18 +36,20 @@ class DefaultStock extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr * Class constructor * * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param string|null $resourcePrefix */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, $resourcePrefix = null ) { $this->_scopeConfig = $scopeConfig; - parent::__construct($context, $eavConfig, $resourcePrefix); + parent::__construct($context, $tableStrategy, $eavConfig, $resourcePrefix); } /** @@ -68,7 +70,7 @@ class DefaultStock extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { $this->_prepareIndexTable(); @@ -287,9 +289,6 @@ class DefaultStock extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr */ public function getIdxTable($table = null) { - if ($this->useIdxTable()) { - return $this->getTable('cataloginventory_stock_status_idx'); - } - return $this->getTable('cataloginventory_stock_status_tmp'); + return $this->tableStrategy->getTableName('cataloginventory_stock_status'); } } diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php index b182d738370fcf152295f199814a120ebbff8604..ee653da73580405bdb9f219ef4793e6b5adc0783 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php @@ -123,6 +123,7 @@ class Item extends \Magento\Framework\Model\Resource\Db\AbstractDb parent::_afterSave($object); /** @var StockItemInterface $object */ if ($this->processIndexEvents) { + $this->stockIndexerProcessor->markIndexerAsInvalid(); $this->stockIndexerProcessor->reindexRow($object->getProductId()); } return $this; diff --git a/app/code/Magento/CatalogInventory/Model/StockRegistry.php b/app/code/Magento/CatalogInventory/Model/StockRegistry.php index f32aeb2104b686091e06120271c462ec33542f08..059910b98b6f6b5dee0cf76426d92074e4f1a548 100644 --- a/app/code/Magento/CatalogInventory/Model/StockRegistry.php +++ b/app/code/Magento/CatalogInventory/Model/StockRegistry.php @@ -172,7 +172,7 @@ class StockRegistry implements StockRegistryInterface $criteria = $this->criteriaFactory->create(); $criteria->setLimit($currentPage, $pageSize); $criteria->setWebsiteFilter($websiteId); - $criteria->setQtyFilter('>=', $qty); + $criteria->setQtyFilter('<=', $qty); $criteria->addField('qty'); return $this->stockItemRepository->getList($criteria); } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4edffd7709f010ce79108f022e22a3e1c19ce03c --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CatalogInventory\Test\Unit\Block\Plugin; + +class ProductViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogInventory\Block\Plugin\ProductView + */ + protected $block; + + /** + * @var \Magento\CatalogInventory\Api\Data\StockItemInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockItem; + + /** + * @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockRegistry; + + protected function setUp() + { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->stockItem = $this->getMockBuilder('\Magento\CatalogInventory\Model\Stock\Item') + ->disableOriginalConstructor() + ->setMethods(['getQtyMinAllowed', 'getQtyMaxAllowed', 'getQtyIncrements']) + ->getMock(); + + $this->stockRegistry = $this->getMockBuilder('Magento\CatalogInventory\Api\StockRegistryInterface') + ->getMock(); + + $this->block = $objectManager->getObject( + 'Magento\CatalogInventory\Block\Plugin\ProductView', + [ + 'stockRegistry' => $this->stockRegistry + ] + ); + } + + public function testAfterGetQuantityValidators() + { + $result = [ + 'validate-item-quantity' => + [ + 'minAllowed' => 2, + 'maxAllowed' => 5, + 'qtyIncrements' => 3 + ] + ]; + $validators = []; + $productViewBlock = $this->getMockBuilder('Magento\Catalog\Block\Product\View') + ->disableOriginalConstructor() + ->getMock(); + $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->setMethods(['_wakeup', 'getId', 'getStore']) + ->getMock(); + $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->setMethods(['getWebsiteId', '_wakeup']) + ->getMock(); + + $productViewBlock->expects($this->any())->method('getProduct')->willReturn($productMock); + $productMock->expects($this->once())->method('getId')->willReturn('productId'); + $productMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $storeMock->expects($this->once())->method('getWebsiteId')->willReturn('websiteId'); + $this->stockRegistry->expects($this->once()) + ->method('getStockItem') + ->with('productId', 'websiteId') + ->willReturn($this->stockItem); + $this->stockItem->expects($this->once())->method('getQtyMinAllowed')->willReturn(2); + $this->stockItem->expects($this->any())->method('getQtyMaxAllowed')->willReturn(5); + $this->stockItem->expects($this->any())->method('getQtyIncrements')->willReturn(3); + + $this->assertEquals($result, $this->block->afterGetQuantityValidators($productViewBlock, $validators)); + } +} diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php index a513382ecc9c08706363240c69c0e210e5e4d5cc..fd247ef871523bf14f3ee2480af22f3c648d6627 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php @@ -30,6 +30,11 @@ class DefaultStockqtyTest extends \PHPUnit_Framework_TestCase */ protected $stockRegistryMock; + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -44,12 +49,16 @@ class DefaultStockqtyTest extends \PHPUnit_Framework_TestCase $this->stockRegistryMock = $this->getMockBuilder('Magento\CatalogInventory\Api\StockRegistryInterface') ->disableOriginalConstructor() ->getMock(); + $this->scopeConfigMock = $this->getMockBuilder('\Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); $this->block = $objectManager->getObject( 'Magento\CatalogInventory\Block\Stockqty\DefaultStockqty', [ 'registry' => $this->registryMock, 'stockState' => $this->stockState, - 'stockRegistry' => $this->stockRegistryMock + 'stockRegistry' => $this->stockRegistryMock, + 'scopeConfig' => $this->scopeConfigMock ] ); } @@ -198,4 +207,10 @@ class DefaultStockqtyTest extends \PHPUnit_Framework_TestCase $dataArray[$key] = $value; $property->setValue($this->block, $dataArray); } + + public function testGetThresholdQty() + { + $this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(5); + $this->assertEquals(5, $this->block->getThresholdQty()); + } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php index bcf805e7260685689b0fda77d1026a91c8aa006b..096c3e60ebde0867c7288c24cec2efeb66651921 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php @@ -58,4 +58,10 @@ class ItemTest extends \PHPUnit_Framework_TestCase $this->_model->setCustomerGroupId(2); $this->assertEquals(2, $this->_model->getCustomerGroupId()); } + + public function testGetIdentities() + { + $this->_model->setProductId(1); + $this->assertEquals(['catalog_product_1'], $this->_model->getIdentities()); + } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php index 6de9c01656aecb292c061550e65c69bc000ee0c1..14b5bebfb49f0ac812c2a283a58ac61f5632cbbe 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php @@ -259,4 +259,14 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase ]; $this->assertEquals($fields, $this->model->getConfigItemOptions()); } + + public function testGetManageStock() + { + $store = 1; + $this->scopeConfigMock->expects($this->once()) + ->method('isSetFlag') + ->with(Configuration::XML_PATH_MANAGE_STOCK, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store) + ->willReturn(1); + $this->assertEquals(1, $this->model->getManageStock($store)); + } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index f6cfa8b4e7e6643d3b4df80ae83fe79bd57dd0fc..93f078e9ca11d272ef5abc37b8d2c73820cf9096 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -403,4 +403,58 @@ class ItemTest extends \PHPUnit_Framework_TestCase $this->item->setLowStockDate($date); $this->assertEquals($date, $this->item->getLowStockDate()); } + + /** + * @param array $config + * @param mixed $expected + * @dataProvider getQtyIncrementsDataProvider( + */ + public function testGetQtyIncrements($config, $expected) + { + $this->setDataArrayValue('qty_increments', $config['qty_increments']); + $this->setDataArrayValue('enable_qty_increments', $config['enable_qty_increments']); + $this->setDataArrayValue('use_config_qty_increments', $config['use_config_qty_increments']); + if ($config['use_config_qty_increments']) { + $this->stockConfiguration->expects($this->once()) + ->method('getQtyIncrements') + ->with($this->storeId) + ->willReturn($config['qty_increments']); + } else { + $this->setDataArrayValue('qty_increments', $config['qty_increments']); + } + $this->assertEquals($expected, $this->item->getQtyIncrements()); + } + + /** + * @return array + */ + public function getQtyIncrementsDataProvider() + { + return [ + [ + [ + 'qty_increments' => 1, + 'enable_qty_increments' => true, + 'use_config_qty_increments' => true + ], + 1 + ], + [ + [ + 'qty_increments' => -2, + 'enable_qty_increments' => true, + 'use_config_qty_increments' => true + ], + false + ], + [ + [ + 'qty_increments' => 3, + 'enable_qty_increments' => true, + 'use_config_qty_increments' => false + ], + 3 + ], + ]; + } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php index d01e095949ef6020c099d017e7dd15cca5a30e7f..ed72a425ea8fb2b4d67ec6a75fbf405dfb79505a 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php @@ -6,9 +6,12 @@ namespace Magento\CatalogInventory\Test\Unit\Model\Stock; use \Magento\CatalogInventory\Model\Stock\StockItemRepository; +use \Magento\CatalogInventory\Api\Data as InventoryApiData; /** * Class StockItemRepositoryTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -18,7 +21,11 @@ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\CatalogInventory\Model\Stock\Item |\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockItemMock; + /** + * @var \Magento\CatalogInventory\Api\StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $stockConfigurationMock; @@ -28,42 +35,42 @@ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase protected $productMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $stockStateProviderMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\CatalogInventory\Model\Resource\Stock\Item|\PHPUnit_Framework_MockObject_MockObject */ protected $stockItemResourceMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var InventoryApiData\StockItemInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockItemMock; + protected $stockItemFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var InventoryApiData\StockItemCollectionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $stockItemCollectionMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $productFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\DB\QueryBuilderFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $queryBuilderMock; + protected $queryBuilderFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\DB\MapperFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $mapperMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $localeDateMock; @@ -74,6 +81,27 @@ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->stockItemMock = $this->getMockBuilder('\Magento\CatalogInventory\Model\Stock\Item') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getItemId', + 'getProductId', + 'setIsInStock', + 'setStockStatusChangedAutomaticallyFlag', + 'getStockStatusChangedAutomaticallyFlag', + 'getManageStock', + 'setLowStockDate', + 'setStockStatusChangedAuto', + 'hasStockStatusChangedAutomaticallyFlag', + 'setQty', + 'getWebsiteId', + 'setWebsiteId', + 'getStockId', + 'setStockId' + ] + ) + ->getMock(); $this->stockConfigurationMock = $this->getMockBuilder( 'Magento\CatalogInventory\Api\StockConfigurationInterface' ) @@ -87,12 +115,16 @@ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase $this->stockItemResourceMock = $this->getMockBuilder('Magento\CatalogInventory\Model\Resource\Stock\Item') ->disableOriginalConstructor() ->getMock(); - $this->stockItemMock = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory') + $this->stockItemFactoryMock = $this->getMockBuilder( + 'Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory' + ) + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->stockItemCollectionMock = $this->getMockBuilder( 'Magento\CatalogInventory\Api\Data\StockItemCollectionInterfaceFactory' ) + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->productFactoryMock = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') @@ -101,12 +133,14 @@ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') ->disableOriginalConstructor() + ->setMethods(['load', 'getId', 'getTypeId', '__wakeup']) ->getMock(); $this->productFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->productMock); - $this->queryBuilderMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilderFactory') + $this->queryBuilderFactoryMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilderFactory') + ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); $this->mapperMock = $this->getMockBuilder('Magento\Framework\DB\MapperFactory') @@ -127,29 +161,167 @@ class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase $this->stockConfigurationMock, $this->stockStateProviderMock, $this->stockItemResourceMock, - $this->stockItemMock, + $this->stockItemFactoryMock, $this->stockItemCollectionMock, $this->productFactoryMock, - $this->queryBuilderMock, + $this->queryBuilderFactoryMock, $this->mapperMock, $this->localeDateMock, $this->indexProcessorMock ); } + public function testDelete() + { + $this->stockItemResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockItemMock) + ->willReturnSelf(); + + $this->assertTrue($this->model->delete($this->stockItemMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteException() + { + $this->stockItemResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockItemMock) + ->willThrowException(new \Exception()); + + $this->model->delete($this->stockItemMock); + } + + public function testDeleteById() + { + $id = 1; + + $this->stockItemFactoryMock->expects($this->once())->method('create')->willReturn($this->stockItemMock); + $this->stockItemResourceMock->expects($this->once())->method('load')->with($this->stockItemMock, $id); + $this->stockItemMock->expects($this->once())->method('getItemId')->willReturn($id); + + $this->assertTrue($this->model->deleteById($id)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + * @expectedExceptionMessage Stock Item with id "1" does not exist. + */ + public function testDeleteByIdException() + { + $id = 1; + + $this->stockItemFactoryMock->expects($this->once())->method('create')->willReturn($this->stockItemMock); + $this->stockItemResourceMock->expects($this->once())->method('load')->with($this->stockItemMock, $id); + $this->stockItemMock->expects($this->once())->method('getItemId')->willReturn(null); + + $this->assertTrue($this->model->deleteById($id)); + } + public function testSave() { - $params = []; + $productId = 1; + + $this->stockItemMock->expects($this->any())->method('getProductId')->willReturn($productId); + $this->productMock->expects($this->once())->method('load')->with($productId)->willReturnSelf(); + $this->productMock->expects($this->once())->method('getId')->willReturn($productId); + $this->productMock->expects($this->once())->method('getTypeId')->willReturn('typeId'); + $this->stockConfigurationMock->expects($this->once())->method('isQty')->with('typeId')->willReturn(true); + $this->stockStateProviderMock->expects($this->once()) + ->method('verifyStock') + ->with($this->stockItemMock) + ->willReturn(false); + $this->stockItemMock->expects($this->once())->method('getManageStock')->willReturn(true); + $this->stockItemMock->expects($this->once())->method('setIsInStock')->with(false)->willReturnSelf(); + $this->stockItemMock->expects($this->once()) + ->method('setStockStatusChangedAutomaticallyFlag') + ->with(true) + ->willReturnSelf(); + $this->stockItemMock->expects($this->any())->method('setLowStockDate')->willReturnSelf(); + $this->stockStateProviderMock->expects($this->once()) + ->method('verifyNotification') + ->with($this->stockItemMock) + ->willReturn(true); + $this->stockItemMock->expects($this->atLeastOnce())->method('setStockStatusChangedAuto')->willReturnSelf(); + $this->stockItemMock->expects($this->once()) + ->method('hasStockStatusChangedAutomaticallyFlag') + ->willReturn(true); + $this->stockItemMock->expects($this->once()) + ->method('getStockStatusChangedAutomaticallyFlag') + ->willReturn(true); + $this->stockItemMock->expects($this->once())->method('getWebsiteId')->willReturn(1); + $this->stockItemMock->expects($this->once())->method('setWebsiteId')->with(1)->willReturnSelf(); + $this->stockItemMock->expects($this->once())->method('getStockId')->willReturn(1); + $this->stockItemMock->expects($this->once())->method('setStockId')->with(1)->willReturnSelf(); + $this->stockItemResourceMock->expects($this->once()) + ->method('save') + ->with($this->stockItemMock) + ->willReturnSelf(); + $this->indexProcessorMock->expects($this->once())->method('reindexRow')->with($productId); + + $this->assertEquals($this->stockItemMock, $this->model->save($this->stockItemMock)); + } + + public function testSaveWithoutProductId() + { + $productId = 1; + + $this->stockItemMock->expects($this->any())->method('getProductId')->willReturn($productId); + $this->productMock->expects($this->once())->method('load')->with($productId)->willReturnSelf(); + $this->productMock->expects($this->once())->method('getId')->willReturn(null); + + $this->assertEquals($this->stockItemMock, $this->model->save($this->stockItemMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testSaveException() + { + $productId = 1; + + $this->stockItemMock->expects($this->any())->method('getProductId')->willReturn($productId); + $this->productMock->expects($this->once())->method('load')->with($productId)->willReturnSelf(); + $this->productMock->expects($this->once())->method('getId')->willReturn($productId); + $this->productMock->expects($this->once())->method('getTypeId')->willReturn('typeId'); + $this->stockConfigurationMock->expects($this->once())->method('isQty')->with('typeId')->willReturn(false); + $this->stockItemMock->expects($this->once())->method('setQty')->with(0)->willReturnSelf(); + $this->stockItemMock->expects($this->once())->method('getWebsiteId')->willReturn(1); + $this->stockItemMock->expects($this->once())->method('setWebsiteId')->with(1)->willReturnSelf(); + $this->stockItemMock->expects($this->once())->method('getStockId')->willReturn(1); + $this->stockItemMock->expects($this->once())->method('setStockId')->with(1)->willReturnSelf(); + $this->stockItemResourceMock->expects($this->once()) + ->method('save') + ->with($this->stockItemMock) + ->willThrowException(new \Exception()); + + $this->model->save($this->stockItemMock); + } - $stockItemMock = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockItemInterface') + public function testGetList() + { + $criteriaMock = $this->getMockBuilder('Magento\CatalogInventory\Api\StockItemCriteriaInterface') + ->getMock(); + $queryBuilderMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilder') ->disableOriginalConstructor() + ->setMethods(['setCriteria', 'setResource', 'create']) ->getMock(); - $this->indexProcessorMock->expects($this->any()) - ->method('reindexRow') - ->withAnyParameters(); - $this->assertInstanceOf( - 'Magento\CatalogInventory\Api\Data\StockItemInterface', - $this->model->save($stockItemMock, $params) - ); + $queryMock = $this->getMockBuilder('Magento\Framework\DB\QueryInterface') + ->getMock(); + $queryCollectionMock = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockItemCollectionInterface') + ->getMock(); + + $this->queryBuilderFactoryMock->expects($this->once())->method('create')->willReturn($queryBuilderMock); + $queryBuilderMock->expects($this->once())->method('setCriteria')->with($criteriaMock)->willReturnSelf(); + $queryBuilderMock->expects($this->once()) + ->method('setResource') + ->with($this->stockItemResourceMock) + ->willReturnSelf(); + $queryBuilderMock->expects($this->once())->method('create')->willReturn($queryMock); + $this->stockItemCollectionMock->expects($this->once())->method('create')->willReturn($queryCollectionMock); + + $this->assertEquals($queryCollectionMock, $this->model->getList($criteriaMock)); } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dc13237c4677445f25dd6d6107100a8345e61b9c --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php @@ -0,0 +1,186 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CatalogInventory\Test\Unit\Model\Stock; + +use \Magento\CatalogInventory\Model\Stock\StockRepository; + +/** + * Class StockRepositoryTest + */ +class StockRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var StockRepository + */ + protected $model; + + /** + * @var \Magento\CatalogInventory\Model\Stock |\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockMock; + + /** + * @var \Magento\CatalogInventory\Model\Resource\Stock|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockResourceMock; + + /** + * @var Magento\CatalogInventory\Model\StockFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockFactoryMock; + + /** + * @var Magento\CatalogInventory\Api\Data\StockCollectionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockCollectionMock; + + /** + * @var \Magento\Framework\DB\QueryBuilderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $queryBuilderFactoryMock; + + /** + * @var \Magento\Framework\DB\MapperFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $mapperMock; + + protected function setUp() + { + + $this->stockMock = $this->getMockBuilder('\Magento\CatalogInventory\Model\Stock') + ->disableOriginalConstructor() + ->getMock(); + + $this->stockResourceMock = $this->getMockBuilder('\Magento\CatalogInventory\Model\Resource\Stock') + ->disableOriginalConstructor() + ->getMock(); + $this->stockFactoryMock = $this->getMockBuilder( + 'Magento\CatalogInventory\Model\StockFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->stockCollectionMock = $this->getMockBuilder( + 'Magento\CatalogInventory\Api\Data\StockCollectionInterfaceFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->queryBuilderFactoryMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilderFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->mapperMock = $this->getMockBuilder('Magento\Framework\DB\MapperFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new StockRepository( + $this->stockResourceMock, + $this->stockFactoryMock, + $this->stockCollectionMock, + $this->queryBuilderFactoryMock, + $this->mapperMock + ); + } + + public function testSave() + { + $this->stockResourceMock->expects($this->once()) + ->method('save') + ->with($this->stockMock) + ->willReturnSelf(); + + $this->assertEquals($this->stockMock, $this->model->save($this->stockMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testSaveException() + { + $this->stockResourceMock->expects($this->once()) + ->method('save') + ->with($this->stockMock) + ->willThrowException(new \Exception()); + + $this->model->save($this->stockMock); + } + + public function testGetList() + { + $criteriaMock = $this->getMockBuilder('Magento\CatalogInventory\Api\StockCriteriaInterface') + ->getMock(); + $queryBuilderMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilder') + ->disableOriginalConstructor() + ->setMethods(['setCriteria', 'setResource', 'create']) + ->getMock(); + $queryMock = $this->getMockBuilder('Magento\Framework\DB\QueryInterface') + ->getMock(); + $queryCollectionMock = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockCollectionInterface') + ->getMock(); + + $this->queryBuilderFactoryMock->expects($this->once())->method('create')->willReturn($queryBuilderMock); + $queryBuilderMock->expects($this->once())->method('setCriteria')->with($criteriaMock)->willReturnSelf(); + $queryBuilderMock->expects($this->once()) + ->method('setResource') + ->with($this->stockResourceMock) + ->willReturnSelf(); + $queryBuilderMock->expects($this->once())->method('create')->willReturn($queryMock); + $this->stockCollectionMock->expects($this->once())->method('create')->willReturn($queryCollectionMock); + + $this->assertEquals($queryCollectionMock, $this->model->getList($criteriaMock)); + } + + public function testDelete() + { + $this->stockResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockMock) + ->willReturnSelf(); + + $this->assertTrue($this->model->delete($this->stockMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteException() + { + $this->stockResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockMock) + ->willThrowException(new \Exception()); + + $this->model->delete($this->stockMock); + } + + public function testDeleteById() + { + $id = 1; + + $this->stockFactoryMock->expects($this->once())->method('create')->willReturn($this->stockMock); + $this->stockResourceMock->expects($this->once())->method('load')->with($this->stockMock, $id); + $this->stockMock->expects($this->once())->method('getId')->willReturn($id); + + $this->assertTrue($this->model->deleteById($id)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + * @expectedExceptionMessage Stock with id "1" does not exist. + */ + public function testDeleteByIdException() + { + $id = 1; + + $this->stockFactoryMock->expects($this->once())->method('create')->willReturn($this->stockMock); + $this->stockResourceMock->expects($this->once())->method('load')->with($this->stockMock, $id); + $this->stockMock->expects($this->once())->method('getId')->willReturn(null); + + $this->assertTrue($this->model->deleteById($id)); + } +} diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..19eadb2165460d9f9ba2428d652580f6f78a0b6b --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php @@ -0,0 +1,185 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CatalogInventory\Test\Unit\Model\Stock; + +use \Magento\CatalogInventory\Model\Stock\StockStatusRepository; +use \Magento\CatalogInventory\Api\Data as InventoryApiData; + +/** + * Class StockStatusRepositoryTest + */ +class StockStatusRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var StockStatusRepository + */ + protected $model; + + /** + * @var \Magento\CatalogInventory\Model\Stock\Status|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockStatusMock; + + /** + * @var \Magento\CatalogInventory\Model\Resource\Stock\Status|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockStatusResourceMock; + + /** + * @var Magento\CatalogInventory\Model\Stock\StatusFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockStatusFactoryMock; + + /** + * @var InventoryApiData\StockStatusCollectionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stockStatusCollectionMock; + + /** + * @var \Magento\Framework\DB\QueryBuilderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $queryBuilderFactoryMock; + + /** + * @var \Magento\Framework\DB\MapperFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $mapperMock; + + protected function setUp() + { + $this->stockStatusMock = $this->getMockBuilder('\Magento\CatalogInventory\Model\Stock\Status') + ->disableOriginalConstructor() + ->getMock(); + $this->stockStatusResourceMock = $this->getMockBuilder('\Magento\CatalogInventory\Model\Resource\Stock\Status') + ->disableOriginalConstructor() + ->getMock(); + $this->stockStatusFactoryMock = $this->getMockBuilder( + 'Magento\CatalogInventory\Model\Stock\StatusFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->stockStatusCollectionMock = $this->getMockBuilder( + 'Magento\CatalogInventory\Api\Data\StockStatusCollectionInterfaceFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->queryBuilderFactoryMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilderFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->mapperMock = $this->getMockBuilder('Magento\Framework\DB\MapperFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new StockStatusRepository( + $this->stockStatusResourceMock, + $this->stockStatusFactoryMock, + $this->stockStatusCollectionMock, + $this->queryBuilderFactoryMock, + $this->mapperMock + ); + } + + public function testSave() + { + $this->stockStatusResourceMock->expects($this->once()) + ->method('save') + ->with($this->stockStatusMock) + ->willReturnSelf(); + + $this->assertEquals($this->stockStatusMock, $this->model->save($this->stockStatusMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testSaveException() + { + $this->stockStatusResourceMock->expects($this->once()) + ->method('save') + ->with($this->stockStatusMock) + ->willThrowException(new \Exception()); + + $this->model->save($this->stockStatusMock); + } + + public function testGetList() + { + $criteriaMock = $this->getMockBuilder('Magento\CatalogInventory\Api\StockStatusCriteriaInterface') + ->getMock(); + $queryBuilderMock = $this->getMockBuilder('Magento\Framework\DB\QueryBuilder') + ->disableOriginalConstructor() + ->setMethods(['setCriteria', 'setResource', 'create']) + ->getMock(); + $queryMock = $this->getMockBuilder('Magento\Framework\DB\QueryInterface') + ->getMock(); + $queryCollectionMock = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockStatusCollectionInterface') + ->getMock(); + + $this->queryBuilderFactoryMock->expects($this->once())->method('create')->willReturn($queryBuilderMock); + $queryBuilderMock->expects($this->once())->method('setCriteria')->with($criteriaMock)->willReturnSelf(); + $queryBuilderMock->expects($this->once()) + ->method('setResource') + ->with($this->stockStatusResourceMock) + ->willReturnSelf(); + $queryBuilderMock->expects($this->once())->method('create')->willReturn($queryMock); + $this->stockStatusCollectionMock->expects($this->once())->method('create')->willReturn($queryCollectionMock); + + $this->assertEquals($queryCollectionMock, $this->model->getList($criteriaMock)); + } + + public function testDelete() + { + $this->stockStatusResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockStatusMock) + ->willReturnSelf(); + + $this->assertTrue($this->model->delete($this->stockStatusMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteException() + { + $this->stockStatusResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockStatusMock) + ->willThrowException(new \Exception()); + + $this->model->delete($this->stockStatusMock); + } + + public function testDeleteById() + { + $id = 1; + + $this->stockStatusFactoryMock->expects($this->once())->method('create')->willReturn($this->stockStatusMock); + $this->stockStatusResourceMock->expects($this->once())->method('load')->with($this->stockStatusMock, $id); + + $this->assertTrue($this->model->deleteById($id)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteByIdException() + { + $id = 1; + + $this->stockStatusFactoryMock->expects($this->once())->method('create')->willReturn($this->stockStatusMock); + $this->stockStatusResourceMock->expects($this->once())->method('load')->with($this->stockStatusMock, $id); + $this->stockStatusResourceMock->expects($this->once()) + ->method('delete') + ->with($this->stockStatusMock) + ->willThrowException(new \Exception()); + + $this->assertTrue($this->model->deleteById($id)); + } +} diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0c7cdea123e283baf3a5f2f9021e5dcb057fbbf4 --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CatalogInventory\Test\Unit\Model; + +/** + * Class StockRegistryTest + */ +class StockRegistryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogInventory\Model\StockRegistry + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $criteria; + + public function setUp() + { + $this->criteria = $this->getMockBuilder('Magento\CatalogInventory\Api\StockItemCriteriaInterface') + ->disableOriginalConstructor() + ->getMock(); + + $criteriaFactory = $this->getMockBuilder('Magento\CatalogInventory\Api\StockItemCriteriaInterfaceFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $criteriaFactory->expects($this->once())->method('create')->willReturn($this->criteria); + + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManager->getObject( + 'Magento\CatalogInventory\Model\StockRegistry', + [ + 'criteriaFactory' => $criteriaFactory + ] + ); + } + + public function testGetLowStockItems() + { + $this->criteria->expects($this->once())->method('setLimit')->with(1, 0); + $this->criteria->expects($this->once())->method('setWebsiteFilter')->with(1); + $this->criteria->expects($this->once())->method('setQtyFilter')->with('<='); + $this->criteria->expects($this->once())->method('addField')->with('qty'); + $this->model->getLowStockItems(1, 100); + } +} diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 17807abf00284e37befeee24f9146e7822ab1675..fa1c799fe739d3bcf87ca6f916bcde0962624808 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-indexer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-indexer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogInventory/etc/webapi.xml b/app/code/Magento/CatalogInventory/etc/webapi.xml index 80317eccf51a7dd8ba3e7d24fe0497cef61e9df2..fe200c8628cb130aa2f3847283c7b52e0bac3b23 100644 --- a/app/code/Magento/CatalogInventory/etc/webapi.xml +++ b/app/code/Magento/CatalogInventory/etc/webapi.xml @@ -13,7 +13,7 @@ <resource ref="Magento_CatalogInventory::cataloginventory"/> </resources> </route> - <route url="/V1/stockItems/:productSku" method="PUT"> + <route url="/V1/products/:productSku/stockItems/:itemId" method="PUT"> <service class="Magento\CatalogInventory\Api\StockRegistryInterface" method="updateStockItemBySku"/> <resources> <resource ref="Magento_CatalogInventory::cataloginventory"/> diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php index 3b20dec460b319b8386ec39fde6ce99298870cfc..5ab7a97bf4a0048e6f4bbfb29a2e35594370b517 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Backend Catalog Price Rules controller * @@ -36,11 +34,15 @@ class Catalog extends Action protected $_coreRegistry = null; /** + * Date filter instance + * * @var \Magento\Framework\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; /** + * Constructor + * * @param Context $context * @param Registry $coreRegistry * @param Date $dateFilter @@ -53,6 +55,8 @@ class Catalog extends Action } /** + * Init action + * * @return $this */ protected function _initAction() @@ -68,6 +72,8 @@ class Catalog extends Action } /** + * Is access to section allowed + * * @return bool */ protected function _isAllowed() @@ -94,7 +100,8 @@ class Catalog extends Action public function getDirtyRulesNoticeMessage() { $defaultMessage = __( - 'There are rules that have been changed but were not applied. Please, click Apply Rules in order to see immediate effect in the catalog.' + 'There are rules that have been changed but were not applied. ' + . 'Please, click Apply Rules in order to see immediate effect in the catalog.' ); return $this->_dirtyRulesNoticeMessage ? $this->_dirtyRulesNoticeMessage : $defaultMessage; } diff --git a/app/code/Magento/CatalogRule/Helper/Data.php b/app/code/Magento/CatalogRule/Helper/Data.php index 439cff46006938de35eb744508e7b7424413c2fa..33ff883655675bf067876ac24d74ef0248ed99ce 100644 --- a/app/code/Magento/CatalogRule/Helper/Data.php +++ b/app/code/Magento/CatalogRule/Helper/Data.php @@ -12,13 +12,12 @@ namespace Magento\CatalogRule\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { /** - * Algorithm for calculating price rule + * Algorithm for calculating price by rule * * @param string $actionOperator * @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 55b77da9849cec49ac94e2af32d15e6caf00aeb8..cef79f4f73706fba4969a990a42bc5836f244701 100755 --- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php @@ -18,6 +18,15 @@ class IndexBuilder { const SECONDS_IN_DAY = 86400; + /** + * CatalogRuleGroupWebsite columns list + * + * This array contain list of CatalogRuleGroupWebsite table columns + * + * @var array + */ + protected $_catalogRuleGroupWebsiteColumnsList = ['rule_id', 'customer_group_id', 'website_id']; + /** * @var \Magento\Framework\App\Resource */ @@ -415,8 +424,6 @@ class IndexBuilder */ protected function applyAllRules(Product $product = null) { - $write = $this->getWriteAdapter(); - $fromDate = mktime(0, 0, 0, date('m'), date('d') - 1); $toDate = mktime(0, 0, 0, date('m'), date('d') + 1); @@ -499,6 +506,17 @@ class IndexBuilder $this->saveRuleProductPrices($dayPrices); } + return $this->updateCatalogRuleGroupWebsiteData(); + } + + /** + * Update CatalogRuleGroupWebsite data + * + * @return $this + */ + protected function updateCatalogRuleGroupWebsiteData() + { + $write = $this->getWriteAdapter(); $write->delete($this->getTable('catalogrule_group_website'), []); $timestamp = $this->dateTime->gmtTimestamp(); @@ -507,11 +525,15 @@ class IndexBuilder true )->from( $this->getTable('catalogrule_product'), - ['rule_id', 'customer_group_id', 'website_id'] + $this->_catalogRuleGroupWebsiteColumnsList )->where( "{$timestamp} >= from_time AND (({$timestamp} <= to_time AND to_time > 0) OR to_time = 0)" ); - $query = $select->insertFromSelect($this->getTable('catalogrule_group_website')); + $query = $select->insertFromSelect( + $this->getTable('catalogrule_group_website'), + $this->_catalogRuleGroupWebsiteColumnsList + ); + $write->query($query); return $this; @@ -658,7 +680,6 @@ class IndexBuilder $arrData[$key]['latest_start_date'] = $this->dateFormat->formatDate($data['latest_start_date'], false); $arrData[$key]['earliest_end_date'] = $this->dateFormat->formatDate($data['earliest_end_date'], false); } - $adapter->insertOnDuplicate($this->getTable('catalogrule_affected_product'), array_unique($productIds)); $adapter->insertOnDuplicate($this->getTable('catalogrule_product_price'), $arrData); } catch (\Exception $e) { throw $e; diff --git a/app/code/Magento/CatalogRule/Setup/InstallSchema.php b/app/code/Magento/CatalogRule/Setup/InstallSchema.php index 5c4700a3fb0ae645f1861a08a69526b407ed7e1d..68629bbadabce2551c3b3c2c74bcce3f44e26024 100644 --- a/app/code/Magento/CatalogRule/Setup/InstallSchema.php +++ b/app/code/Magento/CatalogRule/Setup/InstallSchema.php @@ -358,22 +358,6 @@ class InstallSchema implements InstallSchemaInterface $installer->getConnection()->createTable($table); - /** - * Create table 'catalogrule_affected_product' - */ - $table = $installer->getConnection() - ->newTable($installer->getTable('catalogrule_affected_product')) - ->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Product Id' - ) - ->setComment('CatalogRule Affected Product'); - - $installer->getConnection()->createTable($table); - /** * Create table 'catalogrule_group_website' */ diff --git a/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php b/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0d75d688a07a164bb674fa343d97800049173af0 --- /dev/null +++ b/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\CatalogRule\Test\Unit\Helper; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** + * Helper object + * + * @var \Magento\CatalogRule\Helper\Data + */ + protected $helper; + + protected function setUp() + { + $this->helper = (new ObjectManager($this))->getObject('Magento\CatalogRule\Helper\Data'); + } + + /** + * Test price rule calculation + * + * @param string $actionOperator + * @param int|float $ruleAmount + * @param int|float $price + * @param int|float $expectedAmount + * + * @dataProvider calcPriceRuleDataProvider + */ + public function testCalcPriceRule($actionOperator, $ruleAmount, $price, $expectedAmount) + { + $this->assertEquals($expectedAmount, $this->helper->calcPriceRule($actionOperator, $ruleAmount, $price)); + } + + /** + * Data provider for cal price rule test + * + * @return array + */ + public function calcPriceRuleDataProvider() + { + return [ + ['to_fixed', 10, 10, 10], + ['to_fixed', 0, 10, 0], + ['to_fixed', 10, 0, 0], + ['to_fixed', 0, 0, 0], + ['to_percent', 100, 100, 100], + ['to_percent', 10, 100, 10], + ['to_percent', 10, 70, 7], + ['to_percent', 100, 10, 10], + ['by_fixed', 100, 100, 0], + ['by_fixed', 10, 100, 90], + ['by_fixed', 100, 10, 0], + ['by_percent', 100, 100, 0], + ['by_percent', 100, 10, 0], + ['by_percent', 100, 1, 0], + ['by_percent', 10, 100, 90], + ['by_percent', 10, 10, 9], + ['by_percent', 1, 10, 9.90], + ]; + } +} diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php index 07e27c6398a6a8678788390b12e5fd0076cea02e..2d8f4b8b8a6a95955be084fcda3a2a6ad25dab6c 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/CronTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,23 +11,35 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CronTest extends \PHPUnit_Framework_TestCase { /** + * Processor + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Cron object + * * @var \Magento\CatalogRule\Model\Cron */ protected $cron; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); - - $this->cron = (new ObjectManager($this))->getObject('Magento\CatalogRule\Model\Cron', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); + + $this->cron = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Model\Cron', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testDailyCatalogUpdate() diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8c41a3c24276dcad12e5733216b5eb2a21cc3640 --- /dev/null +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php @@ -0,0 +1,213 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\CatalogRule\Test\Unit\Model\Indexer; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.TooManyFields) + */ +class IndexBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder + */ + protected $indexBuilder; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + + /** + * @var \Magento\CatalogRule\Model\Resource\Rule\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleCollectionFactory; + + /** + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $logger; + + /** + * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceCurrency; + + + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfig; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateFormat; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTime; + + /** + * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productFactory; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connection; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $select; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $db; + + /** + * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject + */ + protected $website; + + /** + * @var \Magento\Rule\Model\Condition\Combine|\PHPUnit_Framework_MockObject_MockObject + */ + protected $combine; + + /** + * @var \Magento\CatalogRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject + */ + protected $rules; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + protected $product; + + /** + * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attribute; + + /** + * @var \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\PHPUnit_Framework_MockObject_MockObject + */ + protected $backend; + + /** + * Set up test + * + * @return void + */ + protected function setUp() + { + $this->resource = $this->getMock( + 'Magento\Framework\App\Resource', + ['getConnection', 'getTableName'], + [], + '', + false + ); + $this->ruleCollectionFactory = $this->getMock( + 'Magento\CatalogRule\Model\Resource\Rule\CollectionFactory', + ['create', 'addFieldToFilter'], + [], + '', + false + ); + $this->backend = $this->getMock( + 'Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', + [], + [], + '', + false + ); + $this->select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->connection = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); + $this->db = $this->getMock('Zend_Db_Statement_Interface', [], [], '', false); + $this->website = $this->getMock('Magento\Store\Model\Website', [], [], '', false); + $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->combine = $this->getMock('Magento\Rule\Model\Condition\Combine', [], [], '', false); + $this->rules = $this->getMock('Magento\CatalogRule\Model\Rule', [], [], '', false); + $this->logger = $this->getMock('Psr\Log\LoggerInterface', [], [], '', false); + $this->attribute = $this->getMock('Magento\Eav\Model\Entity\Attribute\AbstractAttribute', [], [], '', false); + $this->priceCurrency = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->dateFormat = $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false); + $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); + $this->eavConfig = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory', ['create'], [], '', false); + + $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select)); + $this->connection->expects($this->any())->method('query')->will($this->returnValue($this->db)); + + $this->select->expects($this->any())->method('distinct')->will($this->returnSelf()); + $this->select->expects($this->any())->method('where')->will($this->returnSelf()); + $this->select->expects($this->any())->method('from')->will($this->returnSelf()); + $this->select->expects($this->any())->method('order')->will($this->returnSelf()); + + $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection)); + $this->resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); + + $this->storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue([$this->website])); + $this->storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website)); + + $this->rules->expects($this->any())->method('getId')->will($this->returnValue(1)); + $this->rules->expects($this->any())->method('getWebsiteIds')->will($this->returnValue([1])); + $this->rules->expects($this->any())->method('getConditions')->will($this->returnValue($this->combine)); + $this->rules->expects($this->any())->method('getCustomerGroupIds')->will($this->returnValue([1])); + + $this->ruleCollectionFactory->expects($this->any())->method('create')->will($this->returnSelf()); + $this->ruleCollectionFactory->expects($this->any())->method('addFieldToFilter')->will( + $this->returnValue([$this->rules]) + ); + + $this->product->expects($this->any())->method('load')->will($this->returnSelf()); + $this->product->expects($this->any())->method('getId')->will($this->returnValue(1)); + $this->product->expects($this->any())->method('getWebsiteIds')->will($this->returnValue([1])); + + $this->combine->expects($this->any())->method('validate')->will($this->returnValue(true)); + $this->attribute->expects($this->any())->method('getBackend')->will($this->returnValue($this->backend)); + $this->eavConfig->expects($this->any())->method('getAttribute')->will($this->returnValue($this->attribute)); + $this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product)); + + $this->indexBuilder = new \Magento\CatalogRule\Model\Indexer\IndexBuilder( + $this->ruleCollectionFactory, + $this->priceCurrency, + $this->resource, + $this->storeManager, + $this->logger, + $this->eavConfig, + $this->dateFormat, + $this->dateTime, + $this->productFactory + ); + } + + /** + * Test UpdateCatalogRuleGroupWebsiteData + * + * @covers \Magento\CatalogRule\Model\Indexer\IndexBuilder::updateCatalogRuleGroupWebsiteData + * @return void + */ + public function testUpdateCatalogRuleGroupWebsiteData() + { + $this->select->expects($this->once())->method('insertFromSelect')->with('catalogrule_group_website'); + + $this->indexBuilder->reindexByIds([1]); + } +} diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php index 4814767f39d9e8017bd8e45804c5b8a670a2bd1c..59bd89d00579eff03f37dc0293027240c303c5e3 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -29,20 +27,37 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productRuleProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor', - [], [], '', false); - $this->subject = $this->getMock('Magento\Catalog\Model\Category', ['getAffectedProductIds', '__wakeUp'], [], - '', false); - - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\Category', [ - 'productRuleProcessor' => $this->productRuleProcessor, - ]); + $this->productRuleProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor', + [], + [], + '', + false + ); + $this->subject = $this->getMock( + 'Magento\Catalog\Model\Category', + ['getAffectedProductIds', '__wakeUp'], + [], + '', + false + ); + + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\Category', + [ + 'productRuleProcessor' => $this->productRuleProcessor, + ] + ); } public function testAfterSaveWithoutAffectedProductIds() { - $this->subject->expects($this->any())->method('getAffectedProductIds')->will($this->returnValue([])); - $this->productRuleProcessor->expects($this->never())->method('reindexList'); + $this->subject->expects($this->any()) + ->method('getAffectedProductIds') + ->will($this->returnValue([])); + + $this->productRuleProcessor->expects($this->never()) + ->method('reindexList'); $this->assertEquals($this->subject, $this->plugin->afterSave($this->subject, $this->subject)); } @@ -51,15 +66,21 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $productIds = [1, 2, 3]; - $this->subject->expects($this->any())->method('getAffectedProductIds')->will($this->returnValue($productIds)); - $this->productRuleProcessor->expects($this->once())->method('reindexList')->with($productIds); + $this->subject->expects($this->any()) + ->method('getAffectedProductIds') + ->will($this->returnValue($productIds)); + + $this->productRuleProcessor->expects($this->once()) + ->method('reindexList') + ->with($productIds); $this->assertEquals($this->subject, $this->plugin->afterSave($this->subject, $this->subject)); } public function testAfterDelete() { - $this->productRuleProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->productRuleProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php index f0c7283f1d4eb081ed736b11591521036d21560d..fb911fb1cdbd7211e3d39b5ea2528587d9c3f343 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,34 +11,55 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CustomerGroupTest extends \PHPUnit_Framework_TestCase { /** + * Rule processor mock + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Subject group + * * @var \Magento\Customer\Model\Group|\PHPUnit_Framework_MockObject_MockObject */ protected $subject; /** + * Tested plugin + * * @var \Magento\CatalogRule\Plugin\Indexer\CustomerGroup */ protected $plugin; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); - $this->subject = $this->getMock('Magento\Customer\Model\Group', [], [], '', false); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); + $this->subject = $this->getMock( + 'Magento\Customer\Model\Group', + [], + [], + '', + false + ); - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\CustomerGroup', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\CustomerGroup', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testAfterDelete() { - $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->ruleProductProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php index eac185dcc129f308874f6c412f24655dbcaaf0b1..68a4dae5ef04fae0434f9af375015454afe8e238 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,36 +11,51 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class ImportExportTest extends \PHPUnit_Framework_TestCase { /** + * Indexer processor mock + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Import model mock + * * @var \Magento\ImportExport\Model\Import|\PHPUnit_Framework_MockObject_MockObject */ protected $subject; /** + * Tested plugin + * * @var \Magento\CatalogRule\Plugin\Indexer\ImportExport */ protected $plugin; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); $this->subject = $this->getMock('Magento\ImportExport\Model\Import', [], [], '', false); - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\ImportExport', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\ImportExport', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testAfterImportSource() { $result = true; - $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->ruleProductProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($result, $this->plugin->afterImportSource($this->subject, $result)); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php index 2fca372e8e4ac7d196b2ac4bff988dc8c57a41f7..39571d32c38003914838a6d702817d09e44e8e76 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\CatalogRule\Test\Unit\Plugin\Indexer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,34 +11,49 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class WebsiteTest extends \PHPUnit_Framework_TestCase { /** + * Indexer processor mock + * * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $ruleProductProcessor; /** + * Website mock + * * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject */ protected $subject; /** + * Tested plugin + * * @var \Magento\CatalogRule\Plugin\Indexer\Website */ protected $plugin; protected function setUp() { - $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', - [], [], '', false); + $this->ruleProductProcessor = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); $this->subject = $this->getMock('Magento\Store\Model\Website', [], [], '', false); - $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\Website', [ - 'ruleProductProcessor' => $this->ruleProductProcessor, - ]); + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\Website', + [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ] + ); } public function testAfterDelete() { - $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + $this->ruleProductProcessor->expects($this->once()) + ->method('markIndexerAsInvalid'); $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); } diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 3611281f1c69d49dd4efc8f6044045e0f33614c9..539ca4af208560e40d7f890c9550308bde89485e 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-beta13", - "magento/module-rule": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-indexer": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-rule": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-indexer": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index 307467c3c6217b54f23acdee9766524ef5817723..1d8292288c1c06458eea32cb0b3985d82f3147a4 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-search": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-indexer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-search": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-indexer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_advanced_result.xml b/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_advanced_result.xml index 4fe368190cb1e08847a32dc916048ad659e3bc68..5dc1857a43c04b5f4638453f213a574bbb3b382c 100644 --- a/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_advanced_result.xml +++ b/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_advanced_result.xml @@ -22,6 +22,9 @@ <action method="setToolbarBlockName"> <argument name="name" xsi:type="string">product_list_toolbar</argument> </action> + <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers"> + <block class="Magento\Framework\View\Element\Template" as="default"/> + </block> </block> <action method="setListOrders"/> <action method="setListModes"/> diff --git a/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_result_index.xml b/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_result_index.xml index b3c7f66aef61059bbe1e053d6d560e7e282453f0..34a0e54cfc942d52f591c471d13f06a5a835c7ce 100644 --- a/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_result_index.xml +++ b/app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_result_index.xml @@ -23,6 +23,9 @@ <action method="setToolbarBlockName"> <argument name="name" xsi:type="string">product_list_toolbar</argument> </action> + <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers"> + <block class="Magento\Framework\View\Element\Template" as="default"/> + </block> </block> <action method="setListOrders"/> <action method="setListModes"/> diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index a4fdb35d55615c085511be97e462cfba358b6794..764fb5ed8db3fc88023dba3f275a543386e34315 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-catalog-import-export": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-url-rewrite": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-catalog-import-export": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-url-rewrite": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CatalogWidget/composer.json b/app/code/Magento/CatalogWidget/composer.json index 633cc2a7cc48e4ab5bcf48ef3a976ae1bbb6302f..a1708c5aa5d6b1c14848114666f7bb6e520eaa00 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-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-rule": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-wishlist": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-rule": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-wishlist": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 089f137466960e552b05f4530da1102a27529402..7aac4e4eeb32402cdcf6a15b14a9a2488203b5a7 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,31 +3,32 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-gift-message": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-msrp": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-gift-message": "0.74.0-beta14", + "magento/module-wishlist": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-msrp": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.74.0-beta13" + "magento/module-cookie": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index bea7e49ea19fc077686d3e7ba0e73bec7beb2978..28936c416e31dc474a95b0687d98edef469ba886 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" 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 index a3a2fbda293c06f45808c5087ec56c5d1eeb45de..21c1d2ec4994eac7671fd832e4c5e3e0751313d4 100644 --- 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 @@ -5,56 +5,84 @@ */ namespace Magento\Cms\Test\Unit\Ui\Component\Listing\Column; +use Magento\Cms\Ui\Component\Listing\Column\PageActions; + class PageActionsTest extends \PHPUnit_Framework_TestCase { public function testPrepareItemsByPageId() { + $pageId = 1; // Create Mocks and SUT $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); /** @var \PHPUnit_Framework_MockObject_MockObject $urlBuilderMock */ $urlBuilderMock = $this->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 + $items = [ + 'data' => [ + 'items' => [ + [ + 'page_id' => $pageId + ] + ] + ] ]; + $name = 'item_name'; $expectedItems = [ [ - 'page_id' => 1, - $name => ['edit' => $editArray] + 'page_id' => $pageId, + $name => [ + 'edit' => [ + 'href' => 'test/url/edit', + 'label' => __('Edit'), + ], + 'delete' => [ + 'href' => 'test/url/delete', + 'label' => __('Delete'), + 'confirm' => [ + 'title' => __('Delete "${ $.$data.title }"'), + 'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?') + ], + ] + ], ] ]; // Configure mocks and object data - $urlBuilderMock->expects($this->once()) + $urlBuilderMock->expects($this->any()) ->method('getUrl') - ->with($inputUrl, ['page_id' => 1]) - ->willReturn($fullUrl); + ->willReturnMap( + [ + [ + PageActions::CMS_URL_PATH_EDIT, + [ + 'page_id' => $pageId + ], + 'test/url/edit', + ], + [ + PageActions::CMS_URL_PATH_DELETE, + [ + 'page_id' => $pageId + ], + 'test/url/delete', + ], + ] + ); $model->setName($name); $model->prepareDataSource($items); // Run test - $this->assertEquals( - $expectedItems, - $items['data']['items'] - ); + $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 d93cc635d9e8b716382fd682929cefc4d6e24049..617af42cb6122136cf933ade622dc169846d075b 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -18,7 +18,9 @@ class BlockActions extends Column /** * Url path */ - const URL_PATH = 'cms/block/edit'; + const URL_PATH_EDIT = 'cms/block/edit'; + const URL_PATH_DELETE = 'cms/block/delete'; + const URL_PATH_DETAILS = 'cms/block/details'; /** * @var UrlInterface @@ -45,6 +47,10 @@ class BlockActions extends Column parent::__construct($context, $uiComponentFactory, $components, $data); } + /** + * @param array $items + * @return array + */ /** * Prepare Data Source * @@ -58,8 +64,35 @@ class BlockActions extends Column if (isset($item['block_id'])) { $item[$this->getData('name')] = [ 'edit' => [ - 'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['block_id' => $item['block_id']]), - 'label' => __('Edit'), + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_EDIT, + [ + 'block_id' => $item['block_id'] + ] + ), + 'label' => __('Edit') + ], + 'details' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_DETAILS, + [ + 'block_id' => $item['block_id'] + ] + ), + 'label' => __('Details') + ], + 'delete' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_DELETE, + [ + 'block_id' => $item['block_id'] + ] + ), + 'label' => __('Delete'), + 'confirm' => [ + 'title' => __('Delete "${ $.$data.title }"'), + 'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?') + ] ] ]; } 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 59edfeded291c2bd809dfa28f4ee9bf0d3a3b1ff..c28a8d4d07093cbd44506b57a0688615e18e78fe 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -17,7 +17,8 @@ use Magento\Framework\UrlInterface; class PageActions extends Column { /** Url path */ - const CMS_URL_PATH = 'cms/page/edit'; + const CMS_URL_PATH_EDIT = 'cms/page/edit'; + const CMS_URL_PATH_DELETE = 'cms/page/delete'; /** @var UrlBuilder */ protected $actionUrlBuilder; @@ -25,10 +26,6 @@ class PageActions extends Column /** @var UrlInterface */ protected $urlBuilder; - /** @var string */ - private $url; - - /** * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory @@ -36,7 +33,6 @@ class PageActions extends Column * @param UrlInterface $urlBuilder * @param array $components * @param array $data - * @param string $url */ public function __construct( ContextInterface $context, @@ -44,12 +40,10 @@ class PageActions extends Column UrlBuilder $actionUrlBuilder, UrlInterface $urlBuilder, array $components = [], - array $data = [], - $url = self::CMS_URL_PATH + array $data = [] ) { $this->urlBuilder = $urlBuilder; $this->actionUrlBuilder = $actionUrlBuilder; - $this->url = $url; parent::__construct($context, $uiComponentFactory, $components, $data); } @@ -63,15 +57,23 @@ class PageActions extends Column { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { + $name = $this->getData('name'); 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 + $item[$name]['edit'] = [ + 'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_EDIT, ['page_id' => $item['page_id']]), + 'label' => __('Edit') + ]; + $item[$name]['delete'] = [ + 'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_DELETE, ['page_id' => $item['page_id']]), + 'label' => __('Delete'), + 'confirm' => [ + 'title' => __('Delete "${ $.$data.title }"'), + 'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?') + ] ]; } if (isset($item['identifier'])) { - $item[$this->getData('name')]['preview'] = [ + $item[$name]['preview'] = [ 'href' => $this->actionUrlBuilder->getUrl( $item['identifier'], isset($item['_first_store_id']) ? $item['_first_store_id'] : null, diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 73cbc55bc1d1818796bc345b579f2eb594d2d192..74159635377d7d0ac47f23cd8474b47b4415610b 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-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-email": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", - "magento/module-variable": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-email": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", + "magento/module-variable": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "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 44f4c1deea21702fdaca687e632e77d087536173..2936cb163fc6f91713a4ebeaa1ae0650b8976702 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 @@ -61,6 +61,9 @@ <container name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="columnsData" xsi:type="array"> + <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns</item> + </item> <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> <item name="displayArea" xsi:type="string">dataGridActions</item> </item> @@ -225,13 +228,17 @@ <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item> <item name="displayArea" xsi:type="string">bottom</item> <item name="actions" xsi:type="array"> <item name="delete" xsi:type="array"> - <item name="confirm" xsi:type="string" translate="true">Are you sure you want to perform this action?</item> <item name="type" xsi:type="string">delete</item> <item name="label" xsi:type="string" translate="true">Delete</item> <item name="url" xsi:type="string">cms/block/massDelete</item> + <item name="confirm" xsi:type="array"> + <item name="title" xsi:type="string" translate="true">Delete items</item> + <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item> + </item> </item> </item> <item name="indexField" xsi:type="string">block_id</item> @@ -245,6 +252,7 @@ <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.paging</item> </item> + <item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item> <item name="displayArea" xsi:type="string">bottom</item> <item name="options" xsi:type="array"> <item name="20" xsi:type="array"> @@ -275,10 +283,14 @@ <columns name="cms_block_columns"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current</item> + </item> <item name="childDefaults" xsi:type="array"> + <item name="controlVisibility" xsi:type="boolean">true</item> <item name="actionField" xsi:type="string">actions</item> <item name="clickAction" xsi:type="string">edit</item> - <item name="appendTo" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.columns_controls</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -294,14 +306,14 @@ </item> <item name="config" xsi:type="array"> <item name="indexField" xsi:type="string">block_id</item> - <item name="appendTo" xsi:type="boolean">false</item> + <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> </column> <column name="block_id"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -314,7 +326,7 @@ <column name="title"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -326,7 +338,7 @@ <column name="identifier"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -397,7 +409,9 @@ <column name="actions" class="Magento\Cms\Ui\Component\Listing\Column\BlockActions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> <item name="dataType" xsi:type="string">actions</item> + <item name="indexField" xsi:type="string">block_id</item> <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Action</item> <item name="data_type" xsi:type="string">actions</item> 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 7d154b524cdacc874bbf5a52daf8dc7dcda81d65..5df70e67bcf95379186052a5575a0793fbf0ede3 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 @@ -61,6 +61,9 @@ <container name="columns_controls"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="columnsData" xsi:type="array"> + <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns</item> + </item> <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> <item name="displayArea" xsi:type="string">dataGridActions</item> </item> @@ -237,13 +240,17 @@ <massaction name="listing_massaction"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="selectProvider" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns.ids</item> <item name="displayArea" xsi:type="string">bottom</item> <item name="actions" xsi:type="array"> <item name="delete" xsi:type="array"> - <item name="confirm" xsi:type="string" translate="true">Delete selected items?</item> <item name="type" xsi:type="string">delete</item> <item name="label" xsi:type="string" translate="true">Delete</item> <item name="url" xsi:type="string">cms/page/massDelete</item> + <item name="confirm" xsi:type="array"> + <item name="title" xsi:type="string" translate="true">Delete items</item> + <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item> + </item> </item> <item name="disable" xsi:type="array"> <item name="type" xsi:type="string">disable</item> @@ -267,6 +274,7 @@ <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.bookmarks</item> <item name="namespace" xsi:type="string">current.paging</item> </item> + <item name="selectProvider" xsi:type="string">cms_page_listing.cms_page_listing.cms_page_columns.ids</item> <item name="displayArea" xsi:type="string">bottom</item> <item name="options" xsi:type="array"> <item name="20" xsi:type="array"> @@ -297,10 +305,14 @@ <columns name="cms_page_columns"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current</item> + </item> <item name="childDefaults" xsi:type="array"> <item name="actionField" xsi:type="string">actions</item> <item name="clickAction" xsi:type="string">edit</item> - <item name="appendTo" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.columns_controls</item> + <item name="controlVisibility" xsi:type="boolean">true</item> <item name="storageConfig" xsi:type="array"> <item name="provider" xsi:type="string">cms_page_listing.cms_page_listing.listing_top.bookmarks</item> <item name="root" xsi:type="string">columns.${ $.index }</item> @@ -315,15 +327,16 @@ <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> </item> <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> <item name="indexField" xsi:type="string">page_id</item> - <item name="appendTo" xsi:type="string"></item> + <item name="controlVisibility" xsi:type="boolean">false</item> </item> </argument> </column> <column name="page_id"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -336,7 +349,7 @@ <column name="title"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -348,7 +361,7 @@ <column name="identifier"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -373,7 +386,7 @@ <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> @@ -480,7 +493,7 @@ <column name="meta_keywords"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -493,7 +506,7 @@ <column name="meta_description"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> - <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> </item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> @@ -506,7 +519,9 @@ <column name="actions" class="Magento\Cms\Ui\Component\Listing\Column\PageActions"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> <item name="dataType" xsi:type="string">actions</item> + <item name="indexField" xsi:type="string">page_id</item> <item name="align" xsi:type="string">left</item> <item name="label" xsi:type="string" translate="true">Action</item> <item name="data_type" xsi:type="string">actions</item> diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index f469ccf9a8a16e50c34bcc66cac4a59c1dc7df58..c5d23577dd32064af54e69ea0c18bf918232f32a 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-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-url-rewrite": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-url-rewrite": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Config/composer.json b/app/code/Magento/Config/composer.json index 99e065fbf08f55ac4666e3c27b6944de65d9f4e0..cc83e07515d7c6e3f56c531d84d10edcceb1226e 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-cron": "0.74.0-beta13", - "magento/module-email": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-cron": "0.74.0-beta14", + "magento/module-email": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index 54fb284e622096d698a49ea4154a0ad47fe4f037..8d04a7bae07ab90d74604415193102a43f299075 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-beta13", - "magento/module-catalog-import-export": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-configurable-product": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-catalog-import-export": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-configurable-product": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Indexer/Price/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Indexer/Price/Configurable.php index 086efbbf9f8ff8a995a15eeb283026924322288d..2dc2f6d2c88f2ee28b27916108ea451727845ad6 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Indexer/Price/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Indexer/Price/Configurable.php @@ -17,7 +17,7 @@ class Configurable extends \Magento\Catalog\Model\Resource\Product\Indexer\Price */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { $this->reindex(); @@ -63,10 +63,7 @@ class Configurable extends \Magento\Catalog\Model\Resource\Product\Indexer\Price */ protected function _getConfigurableOptionAggregateTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_cfg_opt_agr_idx'); - } - return $this->getTable('catalog_product_index_price_cfg_opt_agr_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_cfg_opt_agr'); } /** @@ -76,10 +73,7 @@ class Configurable extends \Magento\Catalog\Model\Resource\Product\Indexer\Price */ protected function _getConfigurableOptionPriceTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_cfg_opt_idx'); - } - return $this->getTable('catalog_product_index_price_cfg_opt_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_cfg_opt'); } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/SuggestedAttributeList.php b/app/code/Magento/ConfigurableProduct/Model/SuggestedAttributeList.php index 5a47edceda3f8b03677e55a2d7816351654acdfb..610d597a08ad7896500ba50d4e2d7995b184b067 100644 --- a/app/code/Magento/ConfigurableProduct/Model/SuggestedAttributeList.php +++ b/app/code/Magento/ConfigurableProduct/Model/SuggestedAttributeList.php @@ -14,25 +14,45 @@ class SuggestedAttributeList * * @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory */ - protected $_attributeColFactory; + protected $attributeCollectionFactory; /** * Catalog resource helper * * @var \Magento\Catalog\Model\Resource\Helper */ - protected $_resourceHelper; + protected $resourceHelper; /** - * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory + * Application Event Dispatcher + * + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $eventManager; + + /** + * Object Factory + * + * @var \Magento\Framework\ObjectFactory + */ + protected $objectFactory; + + /** + * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Framework\ObjectFactory $objectFactory */ public function __construct( - \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory, - \Magento\Catalog\Model\Resource\Helper $resourceHelper + \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, + \Magento\Catalog\Model\Resource\Helper $resourceHelper, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Framework\ObjectFactory $objectFactory ) { - $this->_attributeColFactory = $attributeColFactory; - $this->_resourceHelper = $resourceHelper; + $this->attributeCollectionFactory = $attributeCollectionFactory; + $this->resourceHelper = $resourceHelper; + $this->objectFactory = $objectFactory; + $this->eventManager = $eventManager; } /** @@ -43,12 +63,14 @@ class SuggestedAttributeList */ public function getSuggestedAttributes($labelPart) { - $escapedLabelPart = $this->_resourceHelper->addLikeEscape($labelPart, ['position' => 'any']); + $escapedLabelPart = $this->resourceHelper->addLikeEscape($labelPart, ['position' => 'any']); + $availableFrontendTypes = $this->getAvailableFrontendTypes(); + /** @var $collection \Magento\Catalog\Model\Resource\Product\Attribute\Collection */ - $collection = $this->_attributeColFactory->create(); + $collection = $this->attributeCollectionFactory->create(); $collection->addFieldToFilter( - 'frontend_input', - 'select' + 'main_table.frontend_input', + ['in' => $availableFrontendTypes->getData('values')] )->addFieldToFilter( 'frontend_label', ['like' => $escapedLabelPart] @@ -79,4 +101,22 @@ class SuggestedAttributeList } return $result; } + + /** + * @return \Magento\Framework\Object + */ + private function getAvailableFrontendTypes() + { + $availableFrontendTypes = $this->objectFactory->create(); + $availableFrontendTypes->setData( + [ + 'values' => ['select'] + ] + ); + $this->eventManager->dispatch( + 'product_suggested_attribute_frontend_type_init_after', + ['types_dto' => $availableFrontendTypes] + ); + return $availableFrontendTypes; + } } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php index cf9344a03bb5c84e66d0ff3795dac67f5ade26c2..72ee34783301ec735a5114c27b845e6e58c82ada 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php @@ -20,6 +20,16 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase */ protected $attributeFactoryMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectFactoryMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -53,6 +63,20 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase '', false ); + $this->eventManagerMock = $this->getMock( + '\Magento\Framework\Event\ManagerInterface', + [], + [], + '', + false + ); + $this->objectFactoryMock = $this->getMock( + '\Magento\Framework\ObjectFactory', + ['create'], + [], + '', + false + ); $this->collectionMock = $this->getMock( 'Magento\Catalog\Model\Resource\Product\Attribute\Collection', [], @@ -78,7 +102,7 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->collectionMock) ); $valueMap = [ - ['frontend_input', 'select', $this->collectionMock], + ['main_table.frontend_input', ['in' => 123 ], $this->collectionMock], ['frontend_label', ['like' => $this->labelPart], $this->collectionMock], ['is_user_defined', 1, $this->collectionMock], ['is_global', \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL, $this->collectionMock], @@ -107,12 +131,19 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase ); $this->suggestedListModel = new \Magento\ConfigurableProduct\Model\SuggestedAttributeList( $this->attributeFactoryMock, - $this->resourceHelperMock + $this->resourceHelperMock, + $this->eventManagerMock, + $this->objectFactoryMock ); } public function testGetSuggestedAttributesIfTheyApplicable() { + $object = $this->getMock('\Magento\Framework\Object', [], [], '', false); + $object->expects($this->once())->method('setData'); + $object->expects($this->once())->method('getData')->willReturn(123); + $this->objectFactoryMock->expects($this->once())->method('create')->willReturn($object); + $source = $this->getMock( 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource', [], @@ -132,6 +163,10 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase public function testGetSuggestedAttributesIfTheyNotApplicable() { + $object = $this->getMock('\Magento\Framework\Object', [], [], '', false); + $object->expects($this->once())->method('setData'); + $object->expects($this->once())->method('getData')->willReturn(123); + $this->objectFactoryMock->expects($this->once())->method('create')->willReturn($object); $this->attributeMock->expects($this->any())->method('getApplyTo')->will($this->returnValue(['simple'])); $this->attributeMock->expects($this->never())->method('getId'); $this->attributeMock->expects($this->never())->method('getFrontendLabel'); diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index a59d294e11653be15c3407afdddc78db584f82eb..d67c88a3d956bb5c369acb68c95818f9d10047c2 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-msrp": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-catalog-rule": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-msrp": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-catalog-rule": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-webapi": "0.74.0-beta13" + "magento/module-webapi": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" 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 2865b30b7710771e8fa63e2542f8f08e08c5c68e..a997ad893456cef5e3ff769f50a3881cdcb8fa12 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 @@ -149,14 +149,14 @@ <div class="fields-group-2"> <div class="field field-pricing-value"> <div class="control"> - <input type="text" class="pricing-value validate-number" + <input type="text" class="pricing-value validate-number" <?php if(!$block->getCanEditPrice()): ?> 'disabled="disabled"' <?php endif; ?> name="product[configurable_attributes_data][<%- data.attribute.id %>][values][<%- data.option.id %>][pricing_value]" /> </div> </div> <div class="field field-pricing-measure"> <div class="actions dropdown actions-select"> <input type="hidden" value="0" name="product[configurable_attributes_data][<%- data.attribute.id %>][values][<%- data.option.id %>][is_percent]"/> - <button type="button" class="action toggle" data-toggle="dropdown" data-mage-init='{"dropdown":{}}'> + <button type="button" class="action toggle" data-toggle="dropdown" data-mage-init='{"dropdown":{}}' <?php if(!$block->getCanEditPrice()): ?> 'disabled="disabled"' <?php endif; ?>> <span><?php echo $block->getBaseCurrency()->getSymbol() ?></span> </button> <ul class="dropdown" data-role="dropdown-menu" data-mage-init='{"menu":{}}'> 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 9a50b287313e96ffbf5d4335e1fb8c9563ee5f8e..dd8a327146c9e87e81db2815df1a84ec4d9afcf2 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 @@ -118,7 +118,7 @@ $id = $block->escapeHtml($attribute['attribute_id']); <div class="fields-group-2"> <div class="field field-pricing-value"> <div class="control"> - <input type="text" class="pricing-value validate-number" + <input type="text" <?php if (!$block->getCanEditPrice()): ?> disabled="disabled";<?php endif; ?> class="pricing-value validate-number" name="<?php echo $namePrefix ?>[<?php echo $valueIndex ?>][pricing_value]" value="<?php echo $block->escapeHtml($pricingValue); ?>"> @@ -128,7 +128,7 @@ $id = $block->escapeHtml($attribute['attribute_id']); <div class="actions dropdown actions-select"> <input name="<?php echo $namePrefix ?>[<?php echo $valueIndex ?>][is_percent]" type="hidden" value="<?php echo $isPercent ? 1 : 0; ?>"/> - <button type="button" class="action toggle" data-toggle="dropdown" data-mage-init='{"dropdown":{}}'> + <button type="button" class="action toggle" <?php if (!$block->getCanEditPrice()): ?> disabled="disabled" <?php endif; ?> data-toggle="dropdown" data-mage-init='{"dropdown":{}}'> <span><?php echo $isPercent ? __('%') : $block->getBaseCurrency()->getSymbol() ?></span> </button> <ul class="dropdown" data-role="dropdown-menu" data-mage-init='{"menu":{}}'> 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 bb59c0e78c7425e6c3e38d1428574a7b738758c2..ccaec64fabb98588414aac86ae67c5e8b14bd956 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php @@ -1,32 +1,37 @@ <?php /** - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Contact\Test\Unit\Controller\Index; class IndexTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Contact\Controller\Index\Index|\PHPUnit_Framework_MockObject_MockObject + * Controller + * + * @var \Magento\Contact\Controller\Index\Index */ protected $_controller; /** + * Scope config mock + * * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** + * View mock + * * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_view; /** + * Url mock + * * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_url; @@ -34,7 +39,10 @@ class IndexTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->_scopeConfig = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + '\Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag'], + '', + false ); $context = $this->getMock( '\Magento\Framework\App\Action\Context', diff --git a/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php b/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php index 9db82a0300c8dfcc1fb590aa2f7bf329596dd736..609eaddcc4b579de6c613e1855fda232937ea2d2 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php @@ -4,18 +4,20 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Contact\Test\Unit\Controller; class IndexTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Contact\Controller\Index|\PHPUnit_Framework_MockObject_MockObject + * Controller instance + * + * @var \Magento\Contact\Controller\Index */ protected $_controller; /** + * Scope config instance + * * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; @@ -23,7 +25,10 @@ class IndexTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->_scopeConfig = $this->getMockForAbstractClass( - '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + '\Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag'], + '', + false ); $context = $this->getMock( '\Magento\Framework\App\Action\Context', @@ -33,23 +38,21 @@ class IndexTest extends \PHPUnit_Framework_TestCase false ); - $context->expects( - $this->any() - )->method( - 'getRequest' - )->will( - $this->returnValue($this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false)) - ); + $context->expects($this->any()) + ->method('getRequest') + ->will( + $this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) + ) + ); - $context->expects( - $this->any() - )->method( - 'getResponse' - )->will( - $this->returnValue( - $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) - ) - ); + $context->expects($this->any()) + ->method('getResponse') + ->will( + $this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) + ) + ); $this->_controller = new \Magento\Contact\Controller\Index( $context, @@ -61,20 +64,20 @@ class IndexTest extends \PHPUnit_Framework_TestCase } /** + * Dispatch test + * * @expectedException \Magento\Framework\Exception\NotFoundException */ public function testDispatch() { - $this->_scopeConfig->expects( - $this->once() - )->method( - 'isSetFlag' - )->with( - \Magento\Contact\Controller\Index::XML_PATH_ENABLED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will( - $this->returnValue(false) - ); + $this->_scopeConfig->expects($this->once()) + ->method('isSetFlag') + ->with( + \Magento\Contact\Controller\Index::XML_PATH_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->will($this->returnValue(false)); + $this->_controller->dispatch( $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) ); diff --git a/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php b/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php index cffd617f422b4327608f4a626a17a5772dc94a12..057cc4672acf0dcf72ce5b5df73a778e8bbd5f57 100644 --- a/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php @@ -4,28 +4,34 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Contact\Test\Unit\Helper; class DataTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Contact\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + * Helper + * + * @var \Magento\Contact\Helper\Data */ protected $_helper; /** + * Scope config mock + * * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** + * Customer session mock + * * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ protected $_customerSession; /** + * Customer view helper mock + * * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject */ protected $_customerViewHelper; @@ -35,7 +41,9 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $className = '\Magento\Contact\Helper\Data'; $arguments = $objectManagerHelper->getConstructArguments($className); - /** @var \Magento\Framework\App\Helper\Context $context */ + /** + * @var \Magento\Framework\App\Helper\Context $context + */ $context = $arguments['context']; $this->_scopeConfig = $context->getScopeConfig(); $this->_customerSession = $arguments['customerSession']; @@ -58,7 +66,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->method('getValue') ->will($this->returnValue(null)); - $this->assertTrue(is_null($this->_helper->isEnabled())); + $this->assertTrue(null === $this->_helper->isEnabled()); } public function testGetUserNameNotLoggedIn() @@ -104,8 +112,12 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_customerSession->expects($this->once()) ->method('isLoggedIn') ->will($this->returnValue(true)); + $customerDataObject = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); - $customerDataObject->expects($this->once())->method('getEmail')->will($this->returnValue('customer@email.com')); + $customerDataObject->expects($this->once()) + ->method('getEmail') + ->will($this->returnValue('customer@email.com')); + $this->_customerSession->expects($this->once()) ->method('getCustomerDataObject') ->will($this->returnValue($customerDataObject)); diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index 855dc95f1b15efa4b57d63915006bfb38028b121..b439ea140c197b1ed56baf1e2d815da1401ad79b 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Cookie/composer.json b/app/code/Magento/Cookie/composer.json index f407a5b8678efc0b356538691028f981353d3ba4..544fd07a9c3789660daca22b02bfc19ba3f3aef5 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-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-backend": "0.74.0-beta13" + "magento/module-backend": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index 2b1ebf6e958d6c4629e5205532dfc0b182d8d6a6..6399fb6b9e9020bfbbdcd39b429d38acd51db867 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 87a1ae6197aed04f3647858aaf8ae5c6c3b727f7..84def1d3cbe14acfc288d09d027e68ac7ef0514f 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 69fc3efec3823f3e47c02b91eb7c6dc6d3a9a20e..0eece788e93cecb4c80b798123ea44284882baca 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,33 +3,33 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-newsletter": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-wishlist": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-review": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", - "magento/module-integration": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-newsletter": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-wishlist": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-review": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", + "magento/module-integration": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.74.0-beta13" + "magento/module-cookie": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml index 0f86b821eeed054a234713c3db93a056fedeb4ab..21762022d84e565b42a9808389c03c6777d0d5ae 100644 --- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml +++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml @@ -413,18 +413,6 @@ </item> </argument> </field> - <field name="country_id"> - <argument name="data" xsi:type="array"> - <item name="config" xsi:type="array"> - <item name="dataType" xsi:type="string">text</item> - <item name="formElement" xsi:type="string">select</item> - <item name="source" xsi:type="string">address</item> - <item name="validation" xsi:type="array"> - <item name="required-entry" xsi:type="boolean">true</item> - </item> - </item> - </argument> - </field> <field name="region"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -437,7 +425,6 @@ </field> <field name="region_id"> <argument name="data" xsi:type="array"> - <item name="customEntry" xsi:type="string">region</item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> <item name="formElement" xsi:type="string">select</item> diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index 0fca4e85cc1316d04098a0685fdc613ab7af42c1..b6a1e407f40a90d40681457f8b3c44f71a51810b 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index c74e983baf4c68378fe6735571211cdf05e11cb0..b1da5a0bdcd348ed89d44f6c55133d29d268e728 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-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-translation": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-translation": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Developer/composer.json b/app/code/Magento/Developer/composer.json index 159132b761c1f3ac35336599634434a2cf489651..a48bb0105867b156433a4addf530adbefcf87e48 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-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index 844caf08a5f13cf23065ae0ed66adcc52014cb3b..02b7d41aa6e9cb7951f25396c7d440274d5b0d56 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index bc48bec5995d1768c6b6963bd2d72689a5bca4cf..23ab56ed5a4f107e2748d9c98f7a78fe3b762bc4 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Downloadable/Model/Resource/Indexer/Price.php b/app/code/Magento/Downloadable/Model/Resource/Indexer/Price.php index accf63a02ea487aeb397b6dc83987364145259c9..4245dede4be09a31918bc40c0814e7d8f628134f 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Indexer/Price.php +++ b/app/code/Magento/Downloadable/Model/Resource/Indexer/Price.php @@ -20,7 +20,7 @@ class Price extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defaul */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { $this->reindex(); @@ -68,10 +68,7 @@ class Price extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defaul */ protected function _getDownloadableLinkPriceTable() { - if ($this->useIdxTable()) { - return $this->getTable('catalog_product_index_price_downlod_idx'); - } - return $this->getTable('catalog_product_index_price_downlod_tmp'); + return $this->tableStrategy->getTableName('catalog_product_index_price_downlod'); } /** diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index 465c23eb67814037d652d4da4632a1546ad4ab45..b28ee43df4619e46d9314a36a88369cb34ce7a94 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-gift-message": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-msrp": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-gift-message": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-msrp": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php index 13a9b831f2b43a9e5aec96db58821ec003f4607e..d25fdcc5d8bb80241adee1b2ef26843fd5e1ab35 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php @@ -268,7 +268,7 @@ class Options extends \Magento\Backend\Block\Template * * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */ - private function getAttributeObject() + protected function getAttributeObject() { return $this->_registry->registry('entity_attribute'); } diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 5f243b8986208869e385aebfcbb4b57e28615de6..27a79fab2f4a2d182e3df0749481b2877d6eb5cf 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php index 4eba984b8fcfa243c684cce9019a51444cad3283..4b92506e5118417cdba79e7b8556afd8974fe8da 100644 --- a/app/code/Magento/Email/Model/AbstractTemplate.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.php @@ -71,22 +71,26 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn * @param \Magento\Framework\Registry $registry * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, - \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, + \Magento\Framework\View\DesignInterface $design, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, - array $data = [] + array $data = [], + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null ) { $this->_design = $design; $this->_area = isset($data['area']) ? $data['area'] : null; $this->_store = isset($data['store']) ? $data['store'] : null; $this->_appEmulation = $appEmulation; $this->_storeManager = $storeManager; - parent::__construct($context, $registry, null, null, $data); + parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php index c8bc6b34398e0c492f9123cfaeedc8182da23299..e95278407067921ce22144ee327204e518b60625 100644 --- a/app/code/Magento/Email/Model/BackendTemplate.php +++ b/app/code/Magento/Email/Model/BackendTemplate.php @@ -38,8 +38,8 @@ class BackendTemplate extends Template */ public function __construct( \Magento\Framework\Model\Context $context, - \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, + \Magento\Framework\View\DesignInterface $design, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Filesystem $filesystem, @@ -53,8 +53,8 @@ class BackendTemplate extends Template ) { parent::__construct( $context, - $design, $registry, + $design, $appEmulation, $storeManager, $filesystem, diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index 577393b498924af0885edb1affd4f97c6feec9bb..30f8ae33f00615c9968ae62e2d4e41e71f7acc12 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -156,10 +156,10 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento /** * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Store\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param StoreManagerInterface $storeManager * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\FileSystem $viewFileSystem @@ -167,13 +167,15 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento * @param Template\FilterFactory $emailFilterFactory * @param Template\Config $emailConfig * @param array $data + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\Model\Context $context, - \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, + \Magento\Framework\View\DesignInterface $design, \Magento\Store\Model\App\Emulation $appEmulation, StoreManagerInterface $storeManager, \Magento\Framework\Filesystem $filesystem, @@ -182,7 +184,9 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Email\Model\Template\FilterFactory $emailFilterFactory, \Magento\Email\Model\Template\Config $emailConfig, - array $data = [] + array $data = [], + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null ) { $this->_scopeConfig = $scopeConfig; $this->_filesystem = $filesystem; @@ -190,7 +194,16 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento $this->_viewFileSystem = $viewFileSystem; $this->_emailFilterFactory = $emailFilterFactory; $this->_emailConfig = $emailConfig; - parent::__construct($context, $design, $registry, $appEmulation, $storeManager, $data); + parent::__construct( + $context, + $registry, + $design, + $appEmulation, + $storeManager, + $data, + $resource, + $resourceCollection + ); } /** diff --git a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php index 47d4e8e0929ac4722552617b51d069385d24d2be..3c89c3a8532971729ea0a7fcbb408ef0854fb2a3 100644 --- a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php @@ -122,8 +122,8 @@ class TemplateTest extends \PHPUnit_Framework_TestCase ->setConstructorArgs( [ $this->context, - $this->design, $this->registry, + $this->design, $this->appEmulation, $this->storeManager, $this->filesystem, @@ -758,8 +758,8 @@ class TemplateTest extends \PHPUnit_Framework_TestCase )->setConstructorArgs( [ $this->getMock('Magento\Framework\Model\Context', [], [], '', false), - $this->getMock('Magento\Theme\Model\View\Design', [], [], '', false), $this->getMock('Magento\Framework\Registry', [], [], '', false), + $this->getMock('Magento\Theme\Model\View\Design', [], [], '', false), $this->getMock('Magento\Store\Model\App\Emulation', [], [], '', false), $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false), $this->getMock('Magento\Framework\Filesystem', [], [], '', false), diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index e1be936adc070dc4d55a948b467c7e147cd8193d..337caab036bcf8efe39b14f1d7d22bf534a38f02 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-variable": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-variable": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 2fe10a640638848100355b7e0b1c66a8b5244292..63f7f335ce91ef6b55f722c63265ca6cc57f560a 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-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index 2e2e4b6a8e46e6c2d9cb6a63e3b6a69c5ef0c69d..6159ad811b2306d08af85bd45cd0475e3ca56cfe 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-multishipping": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-multishipping": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 304cc1bf791158d545194f29f2c3be44a9b8c097..5cc77002b47154ceced14a609d6e0d41282926d7 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-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 92aee5dbd021df882f73761a6b368c905fdcc83e..09c1724be6bc16c662205bef182abc2a677a37b0 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-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-cookie": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-cookie": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index f046d154cbcf7acf581a241c374e026df489efc2..97573703a09a74e685922b0b3948f6af8e30aa73 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-beta13", - "magento/module-google-analytics": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-google-analytics": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 564c50bd7a9c4929da303ab754797a91b5c26994..1e2387799214e5b48fe356487cc1ea18ce2d030f 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index d17ec6ec9e8dfa34f60b13a34725d2c7fea5abca..33a57b24cb7193f6bb5f3b2f0eef591837005946 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-beta13", - "magento/module-import-export": "0.74.0-beta13", - "magento/module-catalog-import-export": "0.74.0-beta13", - "magento/module-grouped-product": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-import-export": "0.74.0-beta14", + "magento/module-catalog-import-export": "0.74.0-beta14", + "magento/module-grouped-product": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Product/Indexer/Price/Grouped.php b/app/code/Magento/GroupedProduct/Model/Resource/Product/Indexer/Price/Grouped.php index 1aa5d99953baecbd2efc8ca05b4a9d961d5fb70e..78155ac89acefd03b022fec7e2f7cb7fc1c70b3f 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Product/Indexer/Price/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Product/Indexer/Price/Grouped.php @@ -17,7 +17,7 @@ class Grouped extends \Magento\Catalog\Model\Resource\Product\Indexer\Price\Defa */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); $this->beginTransaction(); try { $this->_prepareGroupedProductPriceData(); diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index d108bccbced3c09fa8991ae13fbf15296e7075f4..4ee6e8762d9b6760ce1ad74e9978af483e913f0d 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/module-msrp": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/module-msrp": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js b/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js index c5437123aea58b42d4c3cb41d21a076709d3a7eb..b7badba6e79c142c8c1a92e0d60cdb41500507d4 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js +++ b/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js @@ -7,6 +7,7 @@ define([ 'jquery', 'mage/template', 'jquery/ui', + 'Magento_Ui/js/modal/modal', 'mage/translate', 'mage/adminhtml/grid' ], function ($, mageTemplate) { @@ -94,7 +95,7 @@ define([ }, /** - * Create dialog for show product + * Create modal for show product * * @private */ @@ -103,30 +104,14 @@ define([ selectedProductList = {}, popup = $('[data-role=add-product-dialog]'); - popup.dialog({ + popup.modal({ + type: 'slide', + innerScroll: true, title: $.mage.__('Add Products to Group'), - autoOpen: false, - minWidth: 980, - width: '75%', - modal: true, - resizable: true, - dialogClass: 'grouped', - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, + modalClass: 'grouped', open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 55; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - $(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal }, - close: function () { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - }, buttons: [{ id: 'grouped-product-dialog-apply-button', text: $.mage.__('Add Selected Products'), @@ -137,14 +122,7 @@ define([ }); widget._resort(); widget._updateGridVisibility(); - $(this).dialog('close'); - } - }, { - id: 'grouped-product-dialog-cancel-button', - text: $.mage.__('Cancel'), - 'class': 'action-close', - click: function () { - $(this).dialog('close'); + popup.modal('closeModal'); } }] }); @@ -186,7 +164,7 @@ define([ $('[data-role=add-product]').on('click', function (event) { event.preventDefault(); - popup.dialog('open'); + popup.modal('openModal'); gridPopup.reload(); selectedProductList = {}; }); diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index e7cbb957d07e0c2be37df045848e2ba04994930c..e5e58f1eeb8b2d8329b2789124b0a372ca75ef3a 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-indexer": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-indexer": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Indexer/Model/Indexer/Table/Strategy.php b/app/code/Magento/Indexer/Model/Indexer/Table/Strategy.php new file mode 100644 index 0000000000000000000000000000000000000000..2d6c154a2a707879fc47cd6bd5720806b2e96733 --- /dev/null +++ b/app/code/Magento/Indexer/Model/Indexer/Table/Strategy.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Indexer\Model\Indexer\Table; + +/** + * Class Strategy + * @package Magento\Indexer + */ +class Strategy implements StrategyInterface +{ + /** + * Application resource + * + * @var \Magento\Framework\App\Resource + */ + protected $resource; + + /** + * Constructor + * + * @param \Magento\Framework\App\Resource $resource + */ + public function __construct( + \Magento\Framework\App\Resource $resource + ) { + $this->resource = $resource; + } + + /** + * Use index table directly + * + * @var bool + */ + protected $useIdxTable = false; + + /** + * {@inheritdoc} + */ + public function getUseIdxTable() + { + return $this->useIdxTable; + } + + /** + * {@inheritdoc} + */ + public function setUseIdxTable($value = false) + { + $this->useIdxTable = (bool) $value; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getTableName($tablePrefix) + { + return $this->resource->getTableName($this->prepareTableName($tablePrefix)); + } + + /** + * Prepare index table name + * + * @param string $tablePrefix + * + * @return string + */ + public function prepareTableName($tablePrefix) + { + return $this->getUseIdxTable() + ? $tablePrefix . self::IDX_SUFFIX + : $tablePrefix . self::TMP_SUFFIX; + } +} diff --git a/app/code/Magento/Indexer/Model/Indexer/Table/StrategyInterface.php b/app/code/Magento/Indexer/Model/Indexer/Table/StrategyInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..c1693ceb44cd47f8a7d7e7de2649e6264985ad77 --- /dev/null +++ b/app/code/Magento/Indexer/Model/Indexer/Table/StrategyInterface.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Indexer\Model\Indexer\Table; + +/** + * Interface StrategyInterface + * @package Magento\Indexer + */ +interface StrategyInterface +{ + const IDX_SUFFIX = '_idx'; + + const TMP_SUFFIX = '_tmp'; + + /** + * Get IDX table usage flag + * + * @return bool + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getUseIdxTable(); + + /** + * Set IDX table usage flag + * + * @param bool $value + * + * @return $this + */ + public function setUseIdxTable($value = false); + + /** + * Prepare index table name + * + * @param string $tablePrefix + * + * @return string + */ + public function prepareTableName($tablePrefix); + + /** + * Returns target table name + * + * @param string $tablePrefix + * + * @return string + */ + public function getTableName($tablePrefix); +} diff --git a/app/code/Magento/Indexer/Model/Resource/AbstractResource.php b/app/code/Magento/Indexer/Model/Resource/AbstractResource.php index 9fa80dac9e76571bf9a4153cce3e255206499767..aeccf684e6a22fef89ab314648d073bb94e35286 100644 --- a/app/code/Magento/Indexer/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Indexer/Model/Resource/AbstractResource.php @@ -16,16 +16,28 @@ use Magento\Framework\DB\Select; abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\AbstractDb { - const IDX_SUFFIX = '_idx'; - - const TMP_SUFFIX = '_tmp'; + /** + * Constructor + * + * @var \Magento\Indexer\Model\Indexer\Table\StrategyInterface + */ + protected $tableStrategy; /** - * Flag that defines if need to use "_idx" index table suffix instead of "_tmp" + * Class constructor * - * @var bool + * @param \Magento\Framework\Model\Resource\Db\Context $context + * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy + * @param null $resourcePrefix */ - protected $_isNeedUseIdxTable = false; + public function __construct( + \Magento\Framework\Model\Resource\Db\Context $context, + \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, + $resourcePrefix = null + ) { + $this->tableStrategy = $tableStrategy; + parent::__construct($context, $resourcePrefix); + } /** * Reindex all @@ -34,7 +46,7 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs */ public function reindexAll() { - $this->useIdxTable(true); + $this->tableStrategy->setUseIdxTable(true); return $this; } @@ -56,14 +68,10 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs */ public function getIdxTable($table = null) { - $suffix = self::TMP_SUFFIX; - if ($this->_isNeedUseIdxTable) { - $suffix = self::IDX_SUFFIX; - } if ($table) { - return $table . $suffix; + return $this->tableStrategy->prepareTableName($table); } - return $this->getMainTable() . $suffix; + return $this->tableStrategy->prepareTableName($this->getMainTable()); } /** @@ -155,20 +163,6 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs return $this; } - /** - * Set or get what either "_idx" or "_tmp" suffixed temporary index table need to use - * - * @param bool $value - * @return bool - */ - public function useIdxTable($value = null) - { - if ($value !== null) { - $this->_isNeedUseIdxTable = (bool)$value; - } - return $this->_isNeedUseIdxTable; - } - /** * Clean up temporary index table * diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6aed194580dc6f9168d2f9bde635f315180daafe --- /dev/null +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php @@ -0,0 +1,94 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Indexer\Test\Unit\Model\Indexer\Table; + +/** + * Class StrategyTest + * @package Magento\Indexer\Test\Unit\Model\Indexer\Table + */ +class StrategyTest extends \PHPUnit_Framework_TestCase +{ + /** + * Strategy object + * + * @var \Magento\Indexer\Model\Indexer\Table\Strategy + */ + protected $_model; + + /** + * Resource mock + * + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_resourceMock; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->_resourceMock = $this->getMock( + '\Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->_model = new \Magento\Indexer\Model\Indexer\Table\Strategy( + $this->_resourceMock + ); + } + + /** + * Test use idx table switcher + * + * @return void + */ + public function testUseIdxTable() + { + $this->assertEquals(false, $this->_model->getUseIdxTable()); + $this->_model->setUseIdxTable(false); + $this->assertEquals(false, $this->_model->getUseIdxTable()); + $this->_model->setUseIdxTable(true); + $this->assertEquals(true, $this->_model->getUseIdxTable()); + $this->_model->setUseIdxTable(); + $this->assertEquals(false, $this->_model->getUseIdxTable()); + } + + /** + * Test table name preparation + * + * @return void + */ + public function testPrepareTableName() + { + $this->assertEquals('test_tmp', $this->_model->prepareTableName('test')); + $this->_model->setUseIdxTable(true); + $this->assertEquals('test_idx', $this->_model->prepareTableName('test')); + $this->_model->setUseIdxTable(false); + $this->assertEquals('test_tmp', $this->_model->prepareTableName('test')); + } + + /** + * Test table name getter + * + * @return void + */ + public function testGetTableName() + { + $prefix = 'pre_'; + $this->_resourceMock->expects($this->any())->method('getTableName')->will( + $this->returnCallback( + function ($tableName) use ($prefix) { + return $prefix . $tableName; + } + ) + ); + $this->assertEquals('pre_test_tmp', $this->_model->getTableName('test')); + $this->_model->setUseIdxTable(true); + $this->assertEquals('pre_test_idx', $this->_model->getTableName('test')); + } +} diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php index 29628de82f5459902a9996b0e47e4beeb179ac2b..90c5606b85da7ec8612250701c9adfbc9d075742 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php @@ -4,33 +4,41 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Indexer\Test\Unit\Model\Processor; class InvalidateCacheTest extends \PHPUnit_Framework_TestCase { /** + * Tested plugin + * * @var \Magento\Indexer\Model\Processor\InvalidateCache */ protected $plugin; /** + * Mock for context + * * @var \Magento\Indexer\Model\CacheContext|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; /** + * Subject mock + * * @var \Magento\Indexer\Model\ActionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $subjectMock; /** + * Event manager mock + * * @var \Magento\Framework\Event\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $eventManagerMock; /** + * Module manager mock + * * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManager; @@ -40,20 +48,21 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->subjectMock = $this->getMock('Magento\Indexer\Model\Processor', - [], [], '', false); - $this->contextMock = $this->getMock('Magento\Indexer\Model\CacheContext', - [], [], '', false); - $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', - [], [], '', false); - $this->moduleManager = $this->getMock('Magento\Framework\Module\Manager', - [], [], '', false); + $this->subjectMock = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false); + $this->contextMock = $this->getMock('Magento\Indexer\Model\CacheContext', [], [], '', false); + $this->eventManagerMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->moduleManager = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); $this->plugin = new \Magento\Indexer\Model\Processor\InvalidateCache( - $this->contextMock, $this->eventManagerMock, $this->moduleManager); + $this->contextMock, + $this->eventManagerMock, + $this->moduleManager + ); } /** * Test afterUpdateMview with enabled PageCache module + * + * @return void */ public function testAfterUpdateMviewPageCacheEnabled() { @@ -63,14 +72,17 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $this->eventManagerMock->expects($this->once()) ->method('dispatch') - ->with($this->equalTo('clean_cache_after_reindex'), - $this->equalTo(['object' => $this->contextMock])); - $actualResult = $this->plugin->afterUpdateMview($this->subjectMock); - $this->assertNull($actualResult); + ->with( + $this->equalTo('clean_cache_after_reindex'), + $this->equalTo(['object' => $this->contextMock]) + ); + $this->plugin->afterUpdateMview($this->subjectMock); } /** - * afterUpdateMview with disabled PageCache module + * Test afterUpdateMview with disabled PageCache module + * + * @return void */ public function testAfterUpdateMviewPageCacheDisabled() { @@ -80,7 +92,6 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)); $this->eventManagerMock->expects($this->never()) ->method('dispatch'); - $actualResult = $this->plugin->afterUpdateMview($this->subjectMock); - $this->assertNull($actualResult); + $this->plugin->afterUpdateMview($this->subjectMock); } } 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 79e058df703750c0242663308e62b9555296e379..07b7bf63f7c8ca71d7d146d0ad56e0b59ea624ec 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php @@ -17,6 +17,11 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase */ protected $_resourceMock; + /** + * @var \Magento\Indexer\Model\Indexer\Table\StrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_tableStrategyInterface; + protected function setUp() { @@ -24,10 +29,20 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $this->_tableStrategyInterface = $this->getMock( + 'Magento\Indexer\Model\Indexer\Table\StrategyInterface', + [], + [], + '', + false + ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = $objectManager->getConstructArguments( '\Magento\Indexer\Test\Unit\Model\Resource\AbstractResourceStub', - ['resource' => $this->_resourceMock] + [ + 'resource' => $this->_resourceMock, + 'tableStrategy' => $this->_tableStrategyInterface + ] ); $this->model = $objectManager->getObject( '\Magento\Indexer\Test\Unit\Model\Resource\AbstractResourceStub', @@ -37,18 +52,17 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase public function testReindexAll() { + $this->_tableStrategyInterface->expects($this->once()) + ->method('setUseIdxTable') + ->with(true); + $this->_tableStrategyInterface->expects($this->once()) + ->method('prepareTableName') + ->with('test') + ->will($this->returnValue('test_idx')); $this->model->reindexAll(); $this->assertEquals('test_idx', $this->model->getIdxTable('test')); } - public function testUseIdxTable() - { - $this->model->useIdxTable(true); - $this->assertEquals('test_idx', $this->model->getIdxTable('test')); - $this->model->useIdxTable(false); - $this->assertEquals('test_tmp', $this->model->getIdxTable('test')); - } - public function testClearTemporaryIndexTable() { $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 5334b4ad74bf65576c1ccec4ad8f4294e9dddf87..5c2d70fd3ba1f4706522b5534b358eed397bb3d7 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Indexer/etc/crontab.xml b/app/code/Magento/Indexer/etc/crontab.xml index 33e6a27040f939cca18a0ccf2418ffa0fa3ee5b7..2dd222c0e0166f7a4c5f1800e8655c83dccb0cec 100644 --- a/app/code/Magento/Indexer/etc/crontab.xml +++ b/app/code/Magento/Indexer/etc/crontab.xml @@ -6,7 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Cron/etc/crontab.xsd"> - <group id="index"> + <group id="default"> <job name="indexer_reindex_all_invalid" instance="Magento\Indexer\Model\Processor" method="reindexAllInvalid"> <schedule>* * * * *</schedule> </job> diff --git a/app/code/Magento/Indexer/etc/di.xml b/app/code/Magento/Indexer/etc/di.xml index 8c6730dffb5c959d732d78f590c366eae74ef1bb..d6c354590a60c3ab39544872c966aa98eb1f5572 100644 --- a/app/code/Magento/Indexer/etc/di.xml +++ b/app/code/Magento/Indexer/etc/di.xml @@ -10,6 +10,8 @@ <preference for="Magento\Framework\Mview\View\StateInterface" type="Magento\Indexer\Model\Mview\View\State" /> <preference for="Magento\Indexer\Model\ConfigInterface" type="Magento\Indexer\Model\Config" /> <preference for="Magento\Indexer\Model\IndexerInterface" type="Magento\Indexer\Model\Indexer" /> + <preference for="Magento\Indexer\Model\Indexer\Table\StrategyInterface" type="Magento\Indexer\Model\Indexer\Table\Strategy" /> + <type name="Magento\Indexer\Model\Indexer\Table\StrategyInterface" shared="false" /> <type name="Magento\Indexer\Model\Indexer"> <arguments> <argument name="view" xsi:type="object" shared="false">Magento\Framework\Mview\View</argument> diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index e7522cbdd35551484344ff6d2e89df0259344269..71e7696d8ef28184f8fd128d60231cac19b28ca4 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-user": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-user": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index bdc20c0270c5158053c633cfcfad014a842cbcb3..5fb0f54db609de19157dbbe5a22daf6d3025c950 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index 1e5b22c27320a7ab072789131a4b60f59b9dbdac..226458dacc1e2acfe398cfea0d658fb0ec2ab22e 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-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/MediaStorage/composer.json b/app/code/Magento/MediaStorage/composer.json index d6eb3484a3966987d8d3278506a3ba04abba6b52..da20bf9f3dc3d8790f4710a3027cbd22335b0d34 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Msrp/composer.json b/app/code/Magento/Msrp/composer.json index 264b8eb51dba8d26cd6487ab3a4c05374119152b..552af5d5da3518251046821ba504ab4608661fd3 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-beta13", - "magento/module-bundle": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-downloadable": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-grouped-product": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-bundle": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-downloadable": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-grouped-product": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 1d8a0325c2eb0998dc4e53af4125e2204ad25f50..3f6d9e22a139d0932d538424871afc49b49baa40 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-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 4c34f3419f10ad6f41717fd31d5b656d2d849ffb..3a42e4ac6e36ba5b352caffd24f13cf5e23c48d7 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -119,13 +119,15 @@ class Queue extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Newsletter\Model\ProblemFactory $problemFactory * @param \Magento\Newsletter\Model\Resource\Subscriber\CollectionFactory $subscriberCollectionFactory * @param \Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\Model\Context $context, - \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, + \Magento\Framework\View\DesignInterface $design, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Newsletter\Model\Template\Filter $templateFilter, @@ -134,9 +136,20 @@ class Queue extends \Magento\Email\Model\AbstractTemplate \Magento\Newsletter\Model\ProblemFactory $problemFactory, \Magento\Newsletter\Model\Resource\Subscriber\CollectionFactory $subscriberCollectionFactory, \Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $design, $registry, $appEmulation, $storeManager, $data); + parent::__construct( + $context, + $registry, + $design, + $appEmulation, + $storeManager, + $data, + $resource, + $resourceCollection + ); $this->_templateFilter = $templateFilter; $this->_date = $date; $this->_templateFactory = $templateFactory; diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 9f2dc723b155c0da2015d5cae3d906f5069ec660..9f439f7192713eb30dfff6dbc279b615cc53a6ff 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -106,8 +106,8 @@ class Template extends \Magento\Email\Model\AbstractTemplate */ public function __construct( \Magento\Framework\Model\Context $context, - \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, + \Magento\Framework\View\DesignInterface $design, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, @@ -117,7 +117,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\Filter\FilterManager $filterManager, array $data = [] ) { - parent::__construct($context, $design, $registry, $appEmulation, $storeManager, $data); + parent::__construct($context, $registry, $design, $appEmulation, $storeManager, $data); $this->_storeManager = $storeManager; $this->_request = $request; $this->_filter = $filter; diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0c97d3ef5ef8a0b28513411058c1604b81aa6bed --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Unit/Model/Plugin/CustomerPluginTest.php @@ -0,0 +1,94 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Newsletter\Test\Unit\Model\Plugin; + +class CustomerPluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Newsletter\Model\Plugin\CustomerPlugin + */ + protected $plugin; + + /** + * @var \Magento\Newsletter\Model\SubscriberFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $subscriberFactory; + + /** + * @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject + */ + private $subscriber; + + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + protected $objectManager; + + public function setUp() + { + $this->subscriberFactory = $this->getMockBuilder('\Magento\Newsletter\Model\SubscriberFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->subscriber = $this->getMockBuilder('\Magento\Newsletter\Model\Subscriber') + ->setMethods(['loadByEmail', 'getId', 'delete', 'updateSubscription']) + ->disableOriginalConstructor() + ->getMock(); + $this->subscriberFactory->expects($this->any())->method('create')->willReturn($this->subscriber); + + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->plugin = $this->objectManager->getObject( + 'Magento\Newsletter\Model\Plugin\CustomerPlugin', + [ + 'subscriberFactory' => $this->subscriberFactory + ] + ); + } + + public function testAfterSave() + { + $customerId = 1; + $subject = $this->getMock('\Magento\Customer\Api\CustomerRepositoryInterface'); + $customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); + $customer->expects($this->once())->method('getId')->willReturn($customerId); + $this->subscriber->expects($this->once())->method('updateSubscription')->with($customerId)->willReturnSelf(); + + $this->assertEquals($customer, $this->plugin->afterSave($subject, $customer)); + } + + public function testAroundDelete() + { + $deleteCustomer = function () { + return true; + }; + $subject = $this->getMock('\Magento\Customer\Api\CustomerRepositoryInterface'); + $customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); + $customer->expects($this->once())->method('getEmail')->willReturn('test@test.com'); + $this->subscriber->expects($this->once())->method('loadByEmail')->with('test@test.com')->willReturnSelf(); + $this->subscriber->expects($this->once())->method('getId')->willReturn(1); + $this->subscriber->expects($this->once())->method('delete')->willReturnSelf(); + + $this->assertEquals(true, $this->plugin->aroundDelete($subject, $deleteCustomer, $customer)); + } + + public function testAroundDeleteById() + { + $customerId = 1; + $deleteCustomerById = function () { + return true; + }; + $subject = $this->getMock('\Magento\Customer\Api\CustomerRepositoryInterface'); + $customer = $this->getMock('Magento\Customer\Api\Data\CustomerInterface'); + $subject->expects($this->once())->method('getById')->willReturn($customer); + $customer->expects($this->once())->method('getEmail')->willReturn('test@test.com'); + $this->subscriber->expects($this->once())->method('loadByEmail')->with('test@test.com')->willReturnSelf(); + $this->subscriber->expects($this->once())->method('getId')->willReturn(1); + $this->subscriber->expects($this->once())->method('delete')->willReturnSelf(); + + $this->assertEquals(true, $this->plugin->aroundDeleteById($subject, $deleteCustomerById, $customerId)); + } +} diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bb8ec3b719f54c143447aececfde24daccbcc5ce --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Unit/Model/QueueTest.php @@ -0,0 +1,205 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Newsletter\Test\Unit\Model; + +class QueueTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Newsletter\Model\Queue + */ + protected $queue; + + /** + * @var \Magento\Newsletter\Model\Template\Filter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $templateFilter; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $date; + + /** + * @var \Magento\Newsletter\Model\TemplateFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $templateFactory; + + /** + * @var \Magento\Newsletter\Model\ProblemFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $problemFactory; + + /** + * @var \Magento\Newsletter\Model\Resource\Subscriber\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subscribersCollection; + + /** + * @var \Magento\Newsletter\Model\Resource\Subscriber\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subscribersCollectionFactory; + + /** + * @var \Magento\Newsletter\Model\Queue\TransportBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $transportBuilder; + + /** + * @var \Magento\Newsletter\Model\Resource\Queue|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + protected $objectManager; + + public function setUp() + { + $this->templateFilter = $this->getMockBuilder('\Magento\Newsletter\Model\Template\Filter') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->date = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\DateTime') + ->disableOriginalConstructor() + ->getMock(); + $this->templateFactory = $this->getMockBuilder('\Magento\Newsletter\Model\TemplateFactory') + ->disableOriginalConstructor() + ->setMethods(['create', 'load']) + ->getMock(); + $this->problemFactory = $this->getMockBuilder('\Magento\Newsletter\Model\ProblemFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->transportBuilder = $this->getMockBuilder('\Magento\Newsletter\Model\Queue\TransportBuilder') + ->disableOriginalConstructor() + ->setMethods( + ['setTemplateData', 'setTemplateOptions', 'setTemplateVars', 'setFrom', 'addTo', 'getTransport'] + ) + ->getMock(); + $this->subscribersCollection = $this->getMockBuilder('\Magento\Newsletter\Model\Resource\Subscriber\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->resource = $this->getMockBuilder('\Magento\Newsletter\Model\Resource\Queue') + ->disableOriginalConstructor() + ->getMock(); + $this->subscribersCollectionFactory = $this->getMockBuilder( + '\Magento\Newsletter\Model\Resource\Subscriber\CollectionFactory' + ) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->subscribersCollectionFactory->expects($this->any())->method('create')->willReturn( + $this->subscribersCollection + ); + + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->queue = $this->objectManager->getObject( + '\Magento\Newsletter\Model\Queue', + [ + 'templateFilter' => $this->templateFilter, + 'date' => $this->date, + 'templateFactory' => $this->templateFactory, + 'problemFactory' => $this->problemFactory, + 'subscriberCollectionFactory' => $this->subscribersCollectionFactory, + 'transportBuilder' => $this->transportBuilder, + 'resource' => $this->resource + ] + ); + } + + public function testSendPerSubscriber1() + { + $this->queue->setQueueStatus(2); + $this->queue->setQueueStartAt(1); + + $this->assertEquals($this->queue, $this->queue->sendPerSubscriber()); + } + + public function testSendPerSubscriberZeroSize() + { + $this->queue->setQueueStatus(1); + $this->queue->setQueueStartAt(1); + $this->subscribersCollection->expects($this->once())->method('getQueueJoinedFlag')->willReturn(false); + $this->subscribersCollection->expects($this->once())->method('useQueue')->with($this->queue)->willReturnSelf(); + $this->subscribersCollection->expects($this->once())->method('getSize')->willReturn(0); + $this->date->expects($this->once())->method('gmtDate')->willReturn('any_date'); + + $this->assertEquals($this->queue, $this->queue->sendPerSubscriber()); + } + + public function testSendPerSubscriber2() + { + $this->queue->setQueueStatus(1); + $this->queue->setQueueStartAt(1); + $collection = $this->getMockBuilder('\Magento\Framework\Data\Collection') + ->disableOriginalConstructor() + ->setMethods(['getItems']) + ->getMock(); + $item = $this->getMockBuilder('\Magento\Newsletter\Model\Subscriber') + ->disableOriginalConstructor() + ->setMethods(['getStoreId', 'getSubscriberEmail', 'getSubscriberFullName', 'received']) + ->getMock(); + $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); + $this->subscribersCollection->expects($this->once())->method('getQueueJoinedFlag')->willReturn(false); + $this->subscribersCollection->expects($this->once())->method('useQueue')->with($this->queue)->willReturnSelf(); + $this->subscribersCollection->expects($this->once())->method('getSize')->willReturn(5); + $this->subscribersCollection->expects($this->once())->method('useOnlyUnsent')->willReturnSelf(); + $this->subscribersCollection->expects($this->once())->method('showCustomerInfo')->willReturnSelf(); + $this->subscribersCollection->expects($this->once())->method('setPageSize')->willReturnSelf(); + $this->subscribersCollection->expects($this->once())->method('setCurPage')->willReturnSelf(); + $this->subscribersCollection->expects($this->once())->method('load')->willReturn($collection); + $this->transportBuilder->expects($this->once())->method('setTemplateData')->willReturnSelf(); + $collection->expects($this->atLeastOnce())->method('getItems')->willReturn([$item]); + $item->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $item->expects($this->once())->method('getSubscriberEmail')->willReturn('email'); + $item->expects($this->once())->method('getSubscriberFullName')->willReturn('full_name'); + $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setTemplateVars')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setFrom')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('addTo')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport); + $item->expects($this->once())->method('received')->with($this->queue)->willReturnSelf(); + + $this->assertEquals($this->queue, $this->queue->sendPerSubscriber()); + } + + public function testGetDataForSave() + { + $result = [ + 'template_id' => 'id', + 'queue_status' => 'status', + 'queue_start_at' => 'start_at', + 'queue_finish_at' => 'finish_at' + ]; + $this->queue->setTemplateId('id'); + $this->queue->setQueueStatus('status'); + $this->queue->setQueueStartAt('start_at'); + $this->queue->setQueueFinishAt('finish_at'); + + $this->assertEquals($result, $this->queue->getDataForSave()); + } + + public function testGetTemplate() + { + $template = $this->getMockBuilder('\Magento\Newsletter\Model\Template') + ->disableOriginalConstructor() + ->getMock(); + $this->queue->setTemplateId(2); + $this->templateFactory->expects($this->once())->method('create')->willReturn($template); + $template->expects($this->once())->method('load')->with(2)->willReturnSelf(); + + $this->assertEquals($template, $this->queue->getTemplate()); + } + + public function testGetStores() + { + $stores = ['store']; + $this->resource->expects($this->once())->method('getStores')->willReturn($stores); + + $this->assertEquals($stores, $this->queue->getStores()); + } +} diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php index bd8380299a52ee06f8d95a9ddea229ae2649160e..90d5c2ca0a4886deac1ab31f7acf72a004ace884 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php @@ -100,7 +100,9 @@ class SubscriberTest extends \PHPUnit_Framework_TestCase [ 'loadByEmail', 'getIdFieldName', - 'save' + 'save', + 'loadByCustomerData', + 'received' ], [], '', @@ -134,7 +136,6 @@ class SubscriberTest extends \PHPUnit_Framework_TestCase 'name' => 'subscriber_name' ] ); - $this->resource->expects($this->any())->method('getIdFieldName')->willReturn('id_field'); $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); $this->customerSession->expects($this->any())->method('isLoggedIn')->willReturn(true); $customerDataModel = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); @@ -144,21 +145,193 @@ class SubscriberTest extends \PHPUnit_Framework_TestCase $this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel); $customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1); $customerDataModel->expects($this->any())->method('getId')->willReturn(1); - $this->transportBuilder->expects($this->any())->method('setTemplateIdentifier')->willReturnSelf(); - $this->transportBuilder->expects($this->any())->method('setTemplateOptions')->willReturnSelf(); - $this->transportBuilder->expects($this->any())->method('setTemplateVars')->willReturnSelf(); - $this->transportBuilder->expects($this->any())->method('setFrom')->willReturnSelf(); - $this->transportBuilder->expects($this->any())->method('addTo')->willReturnSelf(); - $storeModel = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false); - $this->scopeConfig->expects($this->any())->method('getValue')->willReturn('owner_email@magento.com'); - $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel); - $storeModel->expects($this->any())->method('getId')->willReturn(1); - $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); - $this->transportBuilder->expects($this->any())->method('getTransport')->willReturn($transport); - $transport->expects($this->any())->method('sendMessage')->willReturnSelf(); - $inlineTranslation = $this->getMock('Magento\Framework\Translate\Inline\StateInterface'); - $inlineTranslation->expects($this->any())->method('resume')->willReturnSelf(); + $this->sendEmailCheck(); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); + $this->assertEquals(1, $this->subscriber->subscribe($email)); } + + public function testSubscribeNotLoggedIn() + { + $email = 'subscriber_email@magento.com'; + $this->resource->expects($this->any())->method('loadByEmail')->willReturn( + [ + 'subscriber_status' => 3, + 'subscriber_email' => $email, + 'name' => 'subscriber_name' + ] + ); + $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); + $this->customerSession->expects($this->any())->method('isLoggedIn')->willReturn(false); + $customerDataModel = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); + $this->customerSession->expects($this->any())->method('getCustomerDataObject')->willReturn($customerDataModel); + $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1); + $customerDataModel->expects($this->any())->method('getEmail')->willReturn($email); + $this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel); + $customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1); + $customerDataModel->expects($this->any())->method('getId')->willReturn(1); + $this->sendEmailCheck(); + $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); + + $this->assertEquals(2, $this->subscriber->subscribe($email)); + } + + public function testUpdateSubscription() + { + $customerId = 1; + $customerDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + ->getMock(); + $this->customerRepository->expects($this->atLeastOnce()) + ->method('getById') + ->with($customerId)->willReturn($customerDataMock); + $this->resource->expects($this->atLeastOnce()) + ->method('loadByCustomerData') + ->with($customerDataMock) + ->willReturn( + [ + 'subscriber_id' => 1, + 'subscriber_status' => 1 + ] + ); + $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); + $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); + $this->customerAccountManagement->expects($this->once()) + ->method('getConfirmationStatus') + ->with($customerId) + ->willReturn('account_confirmation_required'); + $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); + + $this->assertEquals($this->subscriber, $this->subscriber->updateSubscription($customerId)); + } + + public function testUnsubscribeCustomerById() + { + $customerId = 1; + $customerDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + ->getMock(); + $this->customerRepository->expects($this->atLeastOnce()) + ->method('getById') + ->with($customerId)->willReturn($customerDataMock); + $this->resource->expects($this->atLeastOnce()) + ->method('loadByCustomerData') + ->with($customerDataMock) + ->willReturn( + [ + 'subscriber_id' => 1, + 'subscriber_status' => 1 + ] + ); + $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); + $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); + $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); + $this->sendEmailCheck(); + + $this->subscriber->unsubscribeCustomerById($customerId); + } + + public function testSubscribeCustomerById() + { + $customerId = 1; + $customerDataMock = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterface') + ->getMock(); + $this->customerRepository->expects($this->atLeastOnce()) + ->method('getById') + ->with($customerId)->willReturn($customerDataMock); + $this->resource->expects($this->atLeastOnce()) + ->method('loadByCustomerData') + ->with($customerDataMock) + ->willReturn( + [ + 'subscriber_id' => 1, + 'subscriber_status' => 3 + ] + ); + $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); + $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); + $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); + $this->sendEmailCheck(); + + $this->subscriber->subscribeCustomerById($customerId); + } + + public function testUnsubscribe() + { + $this->resource->expects($this->once())->method('save')->willReturnSelf(); + $this->sendEmailCheck(); + + $this->assertEquals($this->subscriber, $this->subscriber->unsubscribe()); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage This is an invalid subscription confirmation code. + */ + public function testUnsubscribeException() + { + $this->subscriber->setCode(111); + $this->subscriber->setCheckCode(222); + + $this->subscriber->unsubscribe(); + } + + public function testGetSubscriberFullName() + { + $this->subscriber->setCustomerFirstname('John'); + $this->subscriber->setCustomerLastname('Doe'); + + $this->assertEquals('John Doe', $this->subscriber->getSubscriberFullName()); + } + + public function testConfirm() + { + $code = 111; + $this->subscriber->setCode($code); + $this->resource->expects($this->once())->method('save')->willReturnSelf(); + + $this->assertTrue($this->subscriber->confirm($code)); + } + + public function testConfirmWrongCode() + { + $code = 111; + $this->subscriber->setCode(222); + + $this->assertFalse($this->subscriber->confirm($code)); + } + + public function testReceived() + { + $queue = $this->getMockBuilder('\Magento\Newsletter\Model\Queue') + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->once())->method('received')->with($this->subscriber, $queue)->willReturnSelf(); + + $this->assertEquals($this->subscriber, $this->subscriber->received($queue)); + } + + protected function sendEmailCheck() + { + $storeModel = $this->getMockBuilder('\Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface'); + $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); + $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setTemplateVars')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setFrom')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('addTo')->willReturnSelf(); + $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel); + $storeModel->expects($this->any())->method('getId')->willReturn(1); + $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport); + $transport->expects($this->once())->method('sendMessage')->willReturnSelf(); + $this->inlineTranslation->expects($this->once())->method('suspend')->willReturnSelf(); + $this->inlineTranslation->expects($this->once())->method('resume')->willReturnSelf(); + + return $this; + } } diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php index 1b599897715f903b48a95b6432f14c96a74f3f4f..0bbd428237b19edb86a68947a8964696d138baa9 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php @@ -65,8 +65,8 @@ class TemplateTest extends \PHPUnit_Framework_TestCase ['_init'], [ $context, - $design, $registry, + $design, $appEmulation, $storeManager, $request, diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 5e9806a6fab8fd93f56c0a0ccca0256ca1771bc6..1ac1fb8c9d929acbe852fb2c8c0fa93ee1e42409 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-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-email": "0.74.0-beta13", - "magento/module-cron": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-require-js": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-email": "0.74.0-beta14", + "magento/module-cron": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-require-js": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 90045a9378f6e5f6b38fe5824ccfb2deea5770b6..5118d798b7ee7a9f2a5c5f1291afd3a9f9ade93d 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 9e6c4caa47f24bf81041f76336168cdaf9256b15..5a4bc6de203315f49cc562f6c3561279bc5febe8 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-sales-rule": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-sales-rule": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index bc812b12e6d5c3b4ed3047b46623a6a0b2fb5f19..ce7896f50957edfc63dc32ca1c2b335c880bd0d9 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Payment/Block/Info.php b/app/code/Magento/Payment/Block/Info.php index d56f2c61fe3559e242c97aecc6bc23a704fe1dd6..94c8b8c998d938519c379f72769d496179fda838 100644 --- a/app/code/Magento/Payment/Block/Info.php +++ b/app/code/Magento/Payment/Block/Info.php @@ -15,7 +15,7 @@ class Info extends \Magento\Framework\View\Element\Template * * @var \Magento\Framework\Object */ - protected $_paymentSpecificInformation = null; + protected $_paymentSpecificInformation; /** * @var string @@ -152,10 +152,6 @@ class Info extends \Magento\Framework\View\Element\Template } elseif (is_array($transport)) { $transport = new \Magento\Framework\Object($transport); } - $this->_eventManager->dispatch( - 'payment_info_block_prepare_specific_information', - ['transport' => $transport, 'payment' => $this->getInfo(), 'block' => $this] - ); $this->_paymentSpecificInformation = $transport; } return $this->_paymentSpecificInformation; diff --git a/app/code/Magento/Payment/Block/Transparent/Form.php b/app/code/Magento/Payment/Block/Transparent/Form.php index 73df0c39c87d95c38a5336530d42802c9c913101..2ff21bae0872b75e9fd03ee53eab79b25dc6564f 100644 --- a/app/code/Magento/Payment/Block/Transparent/Form.php +++ b/app/code/Magento/Payment/Block/Transparent/Form.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Block\Transparent; use Magento\Framework\Exception\LocalizedException; +use Magento\Payment\Model\Method\Adapter; use Magento\Payment\Model\Method\TransparentInterface; use Magento\Checkout\Model\Session; use Magento\Payment\Model\Config; @@ -168,7 +169,11 @@ class Form extends \Magento\Payment\Block\Form\Cc */ public function getMethodConfigData($fieldName) { - return $this->getMethod()->getConfigInterface()->getValue($fieldName); + $method = $this->getMethod(); + if ($method instanceof TransparentInterface) { + return $method->getConfigInterface()->getValue($fieldName); + } + return $method->getConfigData($fieldName); } /** @@ -181,7 +186,7 @@ class Form extends \Magento\Payment\Block\Form\Cc { $method = parent::getMethod(); - if (!$method instanceof TransparentInterface) { + if (!$method instanceof TransparentInterface && !$method instanceof Adapter) { throw new LocalizedException( __('We cannot retrieve the transparent payment method model object.') ); diff --git a/app/code/Magento/Payment/Block/Transparent/Iframe.php b/app/code/Magento/Payment/Block/Transparent/Iframe.php index 3070173f92b36c0bae20d66aadce8981b7c322af..d93f0d076ab64d564bc28a946b7821a369f6b580 100644 --- a/app/code/Magento/Payment/Block/Transparent/Iframe.php +++ b/app/code/Magento/Payment/Block/Transparent/Iframe.php @@ -12,6 +12,8 @@ namespace Magento\Payment\Block\Transparent; */ class Iframe extends \Magento\Framework\View\Element\Template { + const REGISTRY_KEY = 'transparent_form_params'; + /** * Core registry * @@ -42,10 +44,8 @@ class Iframe extends \Magento\Framework\View\Element\Template */ protected function _prepareLayout() { - if ($this->hasRegistryKey()) { - $params = $this->coreRegistry->registry($this->getRegistryKey()); - $this->setParams($params); - } + $params = $this->coreRegistry->registry(self::REGISTRY_KEY); + $this->setParams($params); return parent::_prepareLayout(); } } diff --git a/app/code/Magento/Payment/Gateway/Command/CommandPool.php b/app/code/Magento/Payment/Gateway/Command/CommandPool.php index a6cafee447b83df75cc689ac349d57ed3c83bb8a..6b1014d5aa76d9fefb8a1efb80583147067f2853 100644 --- a/app/code/Magento/Payment/Gateway/Command/CommandPool.php +++ b/app/code/Magento/Payment/Gateway/Command/CommandPool.php @@ -8,21 +8,29 @@ namespace Magento\Payment\Gateway\Command; use Magento\Framework\ObjectManager\TMap; use Magento\Payment\Gateway\CommandInterface; use Magento\Framework\Exception\NotFoundException; +use Magento\Framework\ObjectManager\TMapFactory; class CommandPool implements CommandPoolInterface { /** - * @var CommandInterface[] + * @var CommandInterface[] | TMap */ private $commands; /** - * @param TMap $commands + * @param array $commands + * @param TMapFactory $tmapFactory */ public function __construct( - TMap $commands + array $commands, + TMapFactory $tmapFactory ) { - $this->commands = $commands; + $this->commands = $tmapFactory->create( + [ + 'array' => $commands, + 'type' => 'Magento\Payment\Gateway\CommandInterface' + ] + ); } /** diff --git a/app/code/Magento/Payment/Gateway/Command/GatewayCommand.php b/app/code/Magento/Payment/Gateway/Command/GatewayCommand.php index e2f5e25f75bad6c96dde6d0b2c2800e1f08af2f2..a6044462cded037192b2ca675ba06ce32e89549c 100644 --- a/app/code/Magento/Payment/Gateway/Command/GatewayCommand.php +++ b/app/code/Magento/Payment/Gateway/Command/GatewayCommand.php @@ -7,66 +7,83 @@ namespace Magento\Payment\Gateway\Command; use Magento\Payment\Gateway\CommandInterface; use Magento\Payment\Gateway\Http\ClientInterface; +use Magento\Payment\Gateway\Http\TransferFactoryInterface; use Magento\Payment\Gateway\Request; +use Magento\Payment\Gateway\Request\BuilderInterface; use Magento\Payment\Gateway\Response; +use Magento\Payment\Gateway\Response\HandlerInterface; +use Magento\Payment\Gateway\Validator\ValidatorInterface; class GatewayCommand implements CommandInterface { /** - * @var \Magento\Payment\Gateway\Request\BuilderInterface + * @var BuilderInterface */ private $requestBuilder; /** - * @var \Magento\Payment\Gateway\Http\TransferBuilderInterface + * @var TransferFactoryInterface */ - private $transferBuilder; + private $transferFactory; /** - * @var \Magento\Payment\Gateway\Http\ClientInterface + * @var ClientInterface */ - private $gateway; + private $client; /** - * @var \Magento\Payment\Gateway\Response\HandlerInterface + * @var HandlerInterface */ - private $responseHandler; + private $handler; /** - * @param \Magento\Payment\Gateway\Request\BuilderInterface $requestBuilder - * @param \Magento\Payment\Gateway\Http\TransferBuilderInterface $transferBuilder - * @param \Magento\Payment\Gateway\Http\ClientInterface $gateway - * @param \Magento\Payment\Gateway\Response\HandlerInterface $responseHandler + * @var ValidatorInterface + */ + private $validator; + + /** + * @param BuilderInterface $requestBuilder + * @param TransferFactoryInterface $transferFactory + * @param ClientInterface $client + * @param HandlerInterface $handler + * @param ValidatorInterface $validator */ public function __construct( - \Magento\Payment\Gateway\Request\BuilderInterface $requestBuilder, - \Magento\Payment\Gateway\Http\TransferBuilderInterface $transferBuilder, - ClientInterface $gateway, - \Magento\Payment\Gateway\Response\HandlerInterface $responseHandler + BuilderInterface $requestBuilder, + TransferFactoryInterface $transferFactory, + ClientInterface $client, + HandlerInterface $handler, + ValidatorInterface $validator ) { - $this->requestBuilder = $requestBuilder; - $this->transferBuilder = $transferBuilder; - $this->gateway = $gateway; - $this->responseHandler = $responseHandler; + $this->transferFactory = $transferFactory; + $this->client = $client; + $this->handler = $handler; + $this->validator = $validator; } /** * Executes command basing on business object * * @param array $commandSubject - * @return void + * @return null */ public function execute(array $commandSubject) { // @TODO implement exceptions catching - $transferO = $this->transferBuilder->build( + $transferO = $this->transferFactory->create( $this->requestBuilder->build($commandSubject) ); - $response = $this->gateway->placeRequest($transferO); + $response = $this->client->placeRequest($transferO); + + $result = $this->validator->validate(array_merge($commandSubject, ['response' => $response])); + if ($result !== null && !$result->isValid()) { + $commandSubject['payment']->getPayment()->setIsTransactionPending(true); + return; + } - $this->responseHandler->handle( + $this->handler->handle( $commandSubject, $response ); diff --git a/app/code/Magento/Payment/Gateway/Command/Result/ArrayResult.php b/app/code/Magento/Payment/Gateway/Command/Result/ArrayResult.php new file mode 100644 index 0000000000000000000000000000000000000000..fff6c1dc0125d4e62cc72640a3cd96d392b26292 --- /dev/null +++ b/app/code/Magento/Payment/Gateway/Command/Result/ArrayResult.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Gateway\Command\Result; + +use Magento\Payment\Gateway\Command\ResultInterface; + +class ArrayResult implements ResultInterface +{ + /** + * @var array + */ + private $array; + + /** + * @param array $array + */ + public function __construct(array $array = []) + { + $this->array = $array; + } + + /** + * Returns result interpretation + * + * @return array + */ + public function get() + { + return $this->array; + } +} diff --git a/app/code/Magento/Payment/Gateway/Command/ResultInterface.php b/app/code/Magento/Payment/Gateway/Command/ResultInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..bf26fc8e872516f7e6bc3913c52cf614f8d9d8ab --- /dev/null +++ b/app/code/Magento/Payment/Gateway/Command/ResultInterface.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Gateway\Command; + +interface ResultInterface +{ + /** + * Returns result interpretation + * + * @return mixed + */ + public function get(); +} diff --git a/app/code/Magento/Payment/Gateway/CommandInterface.php b/app/code/Magento/Payment/Gateway/CommandInterface.php index 1537c4d21a80da92d1de2956def17c5bed6815f5..44ef0ee10cf64a79646269e0fdd60a6d6ae3ef95 100644 --- a/app/code/Magento/Payment/Gateway/CommandInterface.php +++ b/app/code/Magento/Payment/Gateway/CommandInterface.php @@ -11,7 +11,7 @@ interface CommandInterface * Executes command basing on business object * * @param array $commandSubject - * @return void + * @return null|Command\ResultInterface */ public function execute(array $commandSubject); } diff --git a/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php b/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php index ec00f81b18046caea8c2c397384fd492bb8dbc4b..0364336a2ea5e42df84c190359218276bd2aa168 100644 --- a/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php +++ b/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Gateway\Config; use Magento\Framework\ObjectManager\TMap; +use Magento\Framework\ObjectManager\TMapFactory; class ValueHandlerPool implements \Magento\Payment\Gateway\Config\ValueHandlerPoolInterface { @@ -15,21 +16,28 @@ class ValueHandlerPool implements \Magento\Payment\Gateway\Config\ValueHandlerPo const DEFAULT_HANDLER = 'default'; /** - * @var ValueHandlerInterface[] + * @var ValueHandlerInterface[] | TMap */ private $handlers; /** - * @param TMap $handlers + * @param array $handlers + * @param TMapFactory $tmapFactory */ public function __construct( - TMap $handlers + array $handlers, + TMapFactory $tmapFactory ) { if (!isset($handlers[self::DEFAULT_HANDLER])) { throw new \LogicException('Default handler should be provided.'); } - $this->handlers = $handlers; + $this->handlers = $tmapFactory->create( + [ + 'array' => $handlers, + 'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + ] + ); } /** diff --git a/app/code/Magento/Payment/Gateway/Data/AddressAdapterInterface.php b/app/code/Magento/Payment/Gateway/Data/AddressAdapterInterface.php index aeb1f0432f4ccf4ad45752f7835b8182cbdf7b42..ef55a1a67384bbd4ecec2601d8c308fb72bce8c5 100644 --- a/app/code/Magento/Payment/Gateway/Data/AddressAdapterInterface.php +++ b/app/code/Magento/Payment/Gateway/Data/AddressAdapterInterface.php @@ -12,7 +12,7 @@ interface AddressAdapterInterface * * @return string */ - public function getRegion(); + public function getRegionCode(); /** * Get country id diff --git a/app/code/Magento/Payment/Gateway/Data/Order/AddressAdapter.php b/app/code/Magento/Payment/Gateway/Data/Order/AddressAdapter.php index 54f312ccb5afb19081456e15a1a96a48ad526385..b057d9118240bc923e7e1c00b5ddc64344101aab 100644 --- a/app/code/Magento/Payment/Gateway/Data/Order/AddressAdapter.php +++ b/app/code/Magento/Payment/Gateway/Data/Order/AddressAdapter.php @@ -28,9 +28,9 @@ class AddressAdapter implements AddressAdapterInterface * * @return string */ - public function getRegion() + public function getRegionCode() { - return $this->address->getRegion(); + return $this->address->getRegionCode(); } /** diff --git a/app/code/Magento/Payment/Gateway/Data/Order/OrderAdapter.php b/app/code/Magento/Payment/Gateway/Data/Order/OrderAdapter.php index 08ad153f611280c1709efe4660a42d9e02c10888..f01bee1d7c77ab2b4c695ea4f00229f165e29132 100644 --- a/app/code/Magento/Payment/Gateway/Data/Order/OrderAdapter.php +++ b/app/code/Magento/Payment/Gateway/Data/Order/OrderAdapter.php @@ -86,4 +86,24 @@ class OrderAdapter implements OrderAdapterInterface ['address' => $this->order->getShippingAddress()] ); } + + /** + * Returns order store id + * + * @return int + */ + public function getStoreId() + { + return $this->order->getStoreId(); + } + + /** + * Returns order id + * + * @return int + */ + public function getId() + { + return $this->order->getEntityId(); + } } diff --git a/app/code/Magento/Payment/Gateway/Data/OrderAdapterInterface.php b/app/code/Magento/Payment/Gateway/Data/OrderAdapterInterface.php index 60698aa7d943dc28d60a7555d1c4788621d9bf39..0d925d823a9906c6d1bedbe4f488338f33493d64 100644 --- a/app/code/Magento/Payment/Gateway/Data/OrderAdapterInterface.php +++ b/app/code/Magento/Payment/Gateway/Data/OrderAdapterInterface.php @@ -41,4 +41,18 @@ interface OrderAdapterInterface * @return AddressAdapterInterface */ public function getShippingAddress(); + + /** + * Returns order store id + * + * @return int + */ + public function getStoreId(); + + /** + * Returns order id + * + * @return int + */ + public function getId(); } diff --git a/app/code/Magento/Payment/Gateway/Data/Quote/AddressAdapter.php b/app/code/Magento/Payment/Gateway/Data/Quote/AddressAdapter.php index dd846efe7a702d073ff734dba7a3466d43cece60..b73f2bb7bcdf3c04ff07b8bcda6332b0f641b66a 100644 --- a/app/code/Magento/Payment/Gateway/Data/Quote/AddressAdapter.php +++ b/app/code/Magento/Payment/Gateway/Data/Quote/AddressAdapter.php @@ -28,9 +28,9 @@ class AddressAdapter implements AddressAdapterInterface * * @return string */ - public function getRegion() + public function getRegionCode() { - return $this->address->getRegion(); + return $this->address->getRegionCode(); } /** diff --git a/app/code/Magento/Payment/Gateway/Data/Quote/QuoteAdapter.php b/app/code/Magento/Payment/Gateway/Data/Quote/QuoteAdapter.php index b6ed86aa58522080817e7837695245fadde89875..43a6a9ded86e61c539b5f64dfbbd89de57bc1c94 100644 --- a/app/code/Magento/Payment/Gateway/Data/Quote/QuoteAdapter.php +++ b/app/code/Magento/Payment/Gateway/Data/Quote/QuoteAdapter.php @@ -86,4 +86,24 @@ class QuoteAdapter implements OrderAdapterInterface ['address' => $this->quote->getShippingAddress()] ); } + + /** + * Returns order store id + * + * @return int + */ + public function getStoreId() + { + return $this->quote->getStoreId(); + } + + /** + * Returns order id + * + * @return int + */ + public function getId() + { + return $this->quote->getId(); + } } diff --git a/app/code/Magento/Payment/Gateway/Http/Client/Zend.php b/app/code/Magento/Payment/Gateway/Http/Client/Zend.php index fb3b64434c605912f383c3fd77b4a9b91b6fc5b7..0ea8ffbc871b8e49261c641a5bb71e3669e830d2 100644 --- a/app/code/Magento/Payment/Gateway/Http/Client/Zend.php +++ b/app/code/Magento/Payment/Gateway/Http/Client/Zend.php @@ -8,6 +8,8 @@ namespace Magento\Payment\Gateway\Http\Client; use Magento\Framework\HTTP\ZendClientFactory; use Magento\Framework\HTTP\ZendClient; use Magento\Payment\Gateway\Http\ClientInterface; +use Magento\Payment\Gateway\Http\ConverterInterface; +use Magento\Payment\Model\Method\Logger; class Zend implements ClientInterface { @@ -17,20 +19,28 @@ class Zend implements ClientInterface private $clientFactory; /** - * @var \Magento\Payment\Gateway\Http\ConverterInterface + * @var ConverterInterface */ private $converter; + /** + * @var Logger + */ + private $logger; + /** * @param ZendClientFactory $clientFactory - * @param \Magento\Payment\Gateway\Http\ConverterInterface $converter + * @param ConverterInterface $converter + * @param Logger $logger */ public function __construct( ZendClientFactory $clientFactory, - \Magento\Payment\Gateway\Http\ConverterInterface $converter + ConverterInterface $converter, + Logger $logger ) { $this->clientFactory = $clientFactory; $this->converter = $converter; + $this->logger = $logger; } /** @@ -38,6 +48,10 @@ class Zend implements ClientInterface */ public function placeRequest(\Magento\Payment\Gateway\Http\TransferInterface $transferObject) { + $log = [ + 'request' => $transferObject->getBody() + ]; + $result = []; /** @var ZendClient $client */ $client = $this->clientFactory->create(); @@ -61,11 +75,17 @@ class Zend implements ClientInterface try { $response = $client->request(); - return $this->converter->convert($response->getBody()); + + $result = $this->converter->convert($response->getBody()); + $log['response'] = $result; } catch (\Zend_Http_Client_Exception $e) { throw new \Magento\Payment\Gateway\Http\ClientException(__($e->getMessage())); } catch (\Magento\Payment\Gateway\Http\ConverterException $e) { throw $e; + } finally { + $this->logger->debug($log); } + + return $result; } } diff --git a/app/code/Magento/Payment/Gateway/Http/Converter/HtmlFormConverter.php b/app/code/Magento/Payment/Gateway/Http/Converter/HtmlFormConverter.php new file mode 100644 index 0000000000000000000000000000000000000000..588a476bff9eeb0ebd66f37d7d3b9cce15a6a6e5 --- /dev/null +++ b/app/code/Magento/Payment/Gateway/Http/Converter/HtmlFormConverter.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Gateway\Http\Converter; + +use Magento\Payment\Gateway\Http\ConverterException; +use Magento\Payment\Gateway\Http\ConverterInterface; + +class HtmlFormConverter implements ConverterInterface +{ + /** + * Converts gateway response to ENV structure + * + * @param string $response + * @return array + * @throws ConverterException + */ + public function convert($response) + { + $document = new \DOMDocument(); + + libxml_use_internal_errors(true); + if (!$document->loadHTML($response)) { + throw new ConverterException(__('Wrong gateway response format.')); + } + libxml_use_internal_errors(false); + + $document->getElementsByTagName('input'); + + $convertedResponse = []; + /** @var \DOMNode $inputNode */ + foreach ($document->getElementsByTagName('input') as $inputNode) { + if (!$inputNode->attributes->getNamedItem('value') + || !$inputNode->attributes->getNamedItem('name') + ) { + continue; + } + $convertedResponse[$inputNode->attributes->getNamedItem('name')->nodeValue] + = $inputNode->attributes->getNamedItem('value')->nodeValue; + } + + return $convertedResponse; + } +} diff --git a/app/code/Magento/Payment/Gateway/Http/Transfer.php b/app/code/Magento/Payment/Gateway/Http/Transfer.php new file mode 100644 index 0000000000000000000000000000000000000000..6084f9f1c460b47b8f490388bd9ed6ebc091f976 --- /dev/null +++ b/app/code/Magento/Payment/Gateway/Http/Transfer.php @@ -0,0 +1,123 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Gateway\Http; + +class Transfer implements TransferInterface +{ + /** + * @var array + */ + private $clientConfig; + + /** + * @var array + */ + private $headers; + + /** + * @var string + */ + private $method; + + /** + * @var array + */ + private $body; + + /** + * @var string + */ + private $uri; + + /** + * @var bool + */ + private $encode; + + /** + * @param array $clientConfig + * @param array $headers + * @param array $body + * @param string $method + * @param string $uri + * @param bool $encode + */ + public function __construct( + array $clientConfig, + array $headers, + array $body, + $method, + $uri, + $encode = false + ) { + $this->clientConfig = $clientConfig; + $this->headers = $headers; + $this->method = $method; + $this->body = $body; + $this->uri = $uri; + $this->encode = $encode; + } + + /** + * Returns gateway client configuration + * + * @return array + */ + public function getClientConfig() + { + return $this->clientConfig; + } + + /** + * Returns method used to place request + * + * @return string|int + */ + public function getMethod() + { + return (string)$this->method; + } + + /** + * Returns headers + * + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Whether body should be encoded before place + * + * @return bool + */ + public function shouldEncode() + { + return (bool)$this->encode; + } + + /** + * Returns request body + * + * @return array + */ + public function getBody() + { + return $this->body; + } + + /** + * Returns URI + * + * @return string + */ + public function getUri() + { + return (string)$this->uri; + } +} diff --git a/app/code/Magento/Payment/Gateway/Http/TransferBuilderInterface.php b/app/code/Magento/Payment/Gateway/Http/TransferFactoryInterface.php similarity index 59% rename from app/code/Magento/Payment/Gateway/Http/TransferBuilderInterface.php rename to app/code/Magento/Payment/Gateway/Http/TransferFactoryInterface.php index b1a98abfa9af370c64c5e009ddda1185e917e3be..8a36ba9d1ca9186381ebd50fde4acc59edf9b83c 100644 --- a/app/code/Magento/Payment/Gateway/Http/TransferBuilderInterface.php +++ b/app/code/Magento/Payment/Gateway/Http/TransferFactoryInterface.php @@ -5,15 +5,13 @@ */ namespace Magento\Payment\Gateway\Http; -use Magento\Payment\Gateway\Http\TransferInterface; - -interface TransferBuilderInterface +interface TransferFactoryInterface { /** * Builds gateway transfer object * - * @param array $requestENV + * @param array $request * @return TransferInterface */ - public function build(array $requestENV); + public function create(array $request); } diff --git a/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php b/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php index 33e7df313156a02863e4c1db01d2ffeca9c35816..74395ff812d2513932228457cf5e40fcd14a1dc7 100644 --- a/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php +++ b/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php @@ -6,21 +6,29 @@ namespace Magento\Payment\Gateway\Request; use Magento\Framework\ObjectManager\TMap; +use Magento\Framework\ObjectManager\TMapFactory; class BuilderComposite implements BuilderInterface { /** - * @var BuilderInterface[] + * @var BuilderInterface[] | TMap */ private $builders; /** - * @param TMap $builders + * @param array $builders + * @param TMapFactory $tmapFactory */ public function __construct( - TMap $builders + array $builders, + TMapFactory $tmapFactory ) { - $this->builders = $builders; + $this->builders = $tmapFactory->create( + [ + 'array' => $builders, + 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + ] + ); } /** diff --git a/app/code/Magento/Payment/Gateway/Response/HandlerChain.php b/app/code/Magento/Payment/Gateway/Response/HandlerChain.php index 91205ccc844a35733ca07ff903f6390bcba3c332..1425514e7e3fb87054fdb09690d49d53c0b52a72 100644 --- a/app/code/Magento/Payment/Gateway/Response/HandlerChain.php +++ b/app/code/Magento/Payment/Gateway/Response/HandlerChain.php @@ -6,21 +6,29 @@ namespace Magento\Payment\Gateway\Response; use Magento\Framework\ObjectManager\TMap; +use Magento\Framework\ObjectManager\TMapFactory; class HandlerChain implements HandlerInterface { /** - * @var HandlerInterface[] + * @var HandlerInterface[] | TMap */ private $handlers; /** - * @param TMap $handlers + * @param array $handlers + * @param TMapFactory $tmapFactory */ public function __construct( - TMap $handlers + array $handlers, + TMapFactory $tmapFactory ) { - $this->handlers = $handlers; + $this->handlers = $tmapFactory->create( + [ + 'array' => $handlers, + 'type' => 'Magento\Payment\Gateway\Response\HandlerInterface' + ] + ); } /** diff --git a/app/code/Magento/Payment/Gateway/Validator/AbstractValidator.php b/app/code/Magento/Payment/Gateway/Validator/AbstractValidator.php new file mode 100644 index 0000000000000000000000000000000000000000..e82e0605445a367d1bbf528989c2081393f35c2c --- /dev/null +++ b/app/code/Magento/Payment/Gateway/Validator/AbstractValidator.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Gateway\Validator; + +abstract class AbstractValidator implements ValidatorInterface +{ + /** + * @var ResultInterfaceFactory + */ + private $resultInterfaceFactory; + + /** + * @param ResultInterfaceFactory $resultFactory + */ + public function __construct( + ResultInterfaceFactory $resultFactory + ) { + $this->resultInterfaceFactory = $resultFactory; + } + + /** + * Factory method + * + * @param bool $isValid + * @param array $fails + * @return ResultInterface + */ + protected function createResult($isValid, array $fails = []) + { + return $this->resultInterfaceFactory->create(['isValid' => (bool)$isValid, 'failsDescription' => $fails]); + } +} diff --git a/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php b/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php index 6ee690a2500ee6e520656acc67c5a138ed8a3783..05a476f9743c12a930052fe27c4dfcb057e54ae5 100644 --- a/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php +++ b/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php @@ -6,12 +6,13 @@ namespace Magento\Payment\Gateway\Validator; use Magento\Framework\ObjectManager\TMap; +use Magento\Framework\ObjectManager\TMapFactory; use Magento\Payment\Gateway\Validator\ResultInterfaceFactory; class ValidatorComposite implements ValidatorInterface { /** - * @var ValidatorInterface[] + * @var ValidatorInterface[] | TMap */ private $validators; @@ -22,13 +23,20 @@ class ValidatorComposite implements ValidatorInterface /** * @param ResultInterfaceFactory $resultFactory - * @param TMap $validators + * @param array $validators + * @param TMapFactory $tmapFactory */ public function __construct( ResultInterfaceFactory $resultFactory, - TMap $validators + array $validators, + TMapFactory $tmapFactory ) { - $this->validators = $validators; + $this->validators = $tmapFactory->create( + [ + 'array' => $validators, + 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ] + ); $this->resultFactory = $resultFactory; } diff --git a/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php b/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php index c2f2b347de8acff129afbc85f596a16788961754..e2b746ea7334f480ef5fa3a83358081cea3289db 100644 --- a/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php +++ b/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php @@ -7,21 +7,29 @@ namespace Magento\Payment\Gateway\Validator; use Magento\Framework\Exception\NotFoundException; use Magento\Framework\ObjectManager\TMap; +use Magento\Framework\ObjectManager\TMapFactory; class ValidatorPool implements \Magento\Payment\Gateway\Validator\ValidatorPoolInterface { /** - * @var ValidatorInterface[] + * @var ValidatorInterface[] | TMap */ private $validators; /** - * @param TMap $validators + * @param array $validators + * @param TMapFactory $tmapFactory */ public function __construct( - TMap $validators + array $validators, + TMapFactory $tmapFactory ) { - $this->validators = $validators; + $this->validators = $tmapFactory->create( + [ + 'array' => $validators, + 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ] + ); } /** diff --git a/app/code/Magento/Payment/Model/IframeConfigProvider.php b/app/code/Magento/Payment/Model/IframeConfigProvider.php index a3a48f64f6205766194ecf4a94c7253d81eee099..03520b7b908e8ea642922fe58a67d2da751c0a37 100644 --- a/app/code/Magento/Payment/Model/IframeConfigProvider.php +++ b/app/code/Magento/Payment/Model/IframeConfigProvider.php @@ -21,6 +21,11 @@ use Psr\Log\LoggerInterface; */ class IframeConfigProvider implements ConfigProviderInterface { + /** + * Default length of Cc year field + */ + const DEFAULT_YEAR_LENGTH = 2; + /** * @var Repository */ @@ -92,6 +97,7 @@ class IframeConfigProvider implements ConfigProviderInterface 'cgiUrl' => [$this->methodCode => $this->getCgiUrl()], 'placeOrderUrl' => [$this->methodCode => $this->getPlaceOrderUrl()], 'saveOrderUrl' => [$this->methodCode => $this->getSaveOrderUrl()], + 'expireYearLength' => [$this->methodCode => $this->getExpireDateYearLength()] ] ] ]; @@ -115,6 +121,16 @@ class IframeConfigProvider implements ConfigProviderInterface return $result; } + /** + * Returns Cc expire year length + * + * @return int + */ + protected function getExpireDateYearLength() + { + return (int)$this->getMethodConfigData('cc_year_length') ?: self::DEFAULT_YEAR_LENGTH; + } + /** * Get map of cc_code, cc_num, cc_expdate for gateway * Returns json formatted string diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index c9bc85c757d5c71b4c5b423637ce17d9a3456346..441547499d81b937367dc408fda83270171d32e4 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -586,6 +586,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function order(\Magento\Payment\Model\InfoInterface $payment, $amount) { @@ -603,6 +604,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount) { @@ -620,6 +622,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount) { @@ -638,6 +641,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) { @@ -653,6 +657,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @param \Magento\Framework\Object|InfoInterface $payment * @return $this * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function cancel(\Magento\Payment\Model\InfoInterface $payment) { @@ -666,6 +671,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function void(\Magento\Payment\Model\InfoInterface $payment) { @@ -692,6 +698,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return false * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function acceptPayment(InfoInterface $payment) { @@ -708,6 +715,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @return false * @throws \Magento\Framework\Exception\LocalizedException * @api + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function denyPayment(InfoInterface $payment) { @@ -833,7 +841,11 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl */ protected function _debug($debugData) { - $this->logger->debug($debugData, $this->getDebugReplacePrivateDataKeys(), $this->getDebugFlag()); + $this->logger->debug( + $debugData, + $this->getDebugReplacePrivateDataKeys(), + $this->getDebugFlag() + ); } /** diff --git a/app/code/Magento/Payment/Model/Method/Logger.php b/app/code/Magento/Payment/Model/Method/Logger.php index 107de086bb90d5ed63e45850d082f67700fbc19f..7e7331b77df73d9f87624d733167eed0b9cdff08 100644 --- a/app/code/Magento/Payment/Model/Method/Logger.php +++ b/app/code/Magento/Payment/Model/Method/Logger.php @@ -15,38 +15,73 @@ use Psr\Log\LoggerInterface; class Logger { const DEBUG_KEYS_MASK = '****'; + /** * @var LoggerInterface */ protected $logger; + /** + * @var \Magento\Payment\Gateway\ConfigInterface + */ + private $config; + /** * @param LoggerInterface $logger + * @param \Magento\Payment\Gateway\ConfigInterface $config */ - public function __construct(LoggerInterface $logger) - { + public function __construct( + LoggerInterface $logger, + \Magento\Payment\Gateway\ConfigInterface $config = null + ) { $this->logger = $logger; + $this->config = $config; } /** * Logs payment related information used for debug * * @param array $debugData - * @param array $debugReplaceKeys - * @param bool $debugFlag + * @param array|null $debugReplaceKeys + * @param bool|null $debugFlag * @return void */ - public function debug(array $debugData, array $debugReplaceKeys, $debugFlag) + public function debug(array $debugData, array $debugReplaceKeys = null, $debugFlag = null) { - if ($debugFlag == true && !empty($debugData) && !empty($debugReplaceKeys)) { - $debugData = $this->filterDebugData( - $debugData, - $debugReplaceKeys - ); + $debugReplaceKeys = $debugReplaceKeys !== null ? $debugReplaceKeys : $this->getDebugReplaceFields(); + $debugFlag = $debugFlag !== null ? $debugFlag : $this->isDebugOn(); + if ($debugFlag === true && !empty($debugData) && !empty($debugReplaceKeys)) { + $debugData = $this->filterDebugData( + $debugData, + $debugReplaceKeys + ); $this->logger->debug(var_export($debugData, true)); } } + /** + * Returns configured keys to be replaced with mask + * + * @return array + */ + private function getDebugReplaceFields() + { + if ($this->config->getValue('debugReplaceKeys')) { + return explode(',', $this->config->getValue('debugReplaceKeys')); + } + return []; + } + + /** + * Whether debug is enabled in configuration + * + * @return bool + */ + private function isDebugOn() + { + return (bool)$this->config->getValue('debug'); + } + /** * Recursive filter data by private conventions * diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php index e39384caf7849e52bef212c734d5f88f76aed083..92394d8bb330ed66ed9fb6dc98f49666fb725155 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php @@ -13,9 +13,23 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase { $commandI = $this->getMockBuilder('Magento\Payment\Gateway\CommandInterface') ->getMockForAbstractClass(); + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => ['Magento\Payment\Gateway\CommandInterface'], + 'type' => 'Magento\Payment\Gateway\CommandInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('offsetExists') ->with('command') @@ -25,7 +39,7 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase ->with('command') ->willReturn($commandI); - $pool = new CommandPool($tMap); + $pool = new CommandPool(['Magento\Payment\Gateway\CommandInterface'], $tMapFactory); static::assertSame($commandI, $pool->get('command')); } @@ -33,15 +47,30 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase public function testGetException() { $this->setExpectedException('Magento\Framework\Exception\NotFoundException'); + + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [], + 'type' => 'Magento\Payment\Gateway\CommandInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('offsetExists') ->with('command') ->willReturn(false); - $pool = new CommandPool($tMap); + $pool = new CommandPool([], $tMapFactory); $pool->get('command'); } } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php index 849138ac08114dc69b17ba59f76aa98115080a03..9872e20250bbe2d34c5375f22cbac5916e69cf3a 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Command/GatewayCommandTest.php @@ -16,36 +16,44 @@ class GatewayCommandTest extends \PHPUnit_Framework_TestCase protected $requestBuilderMock; /** - * @var \Magento\Payment\Gateway\Http\TransferBuilderInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Payment\Gateway\Http\TransferFactoryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $transferBuilderMock; + protected $transferFactoryMock; /** * @var \Magento\Payment\Gateway\Http\ClientInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $gatewayMock; + protected $clientMock; /** * @var \Magento\Payment\Gateway\Response\HandlerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $responseHandlerMock; + /** + * @var \Magento\Payment\Gateway\Validator\ValidatorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + protected function setUp() { $this->requestBuilderMock = $this->getMockBuilder('Magento\Payment\Gateway\Request\BuilderInterface') ->getMockForAbstractClass(); - $this->transferBuilderMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\TransferBuilderInterface') + $this->transferFactoryMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\TransferFactoryInterface') ->getMockForAbstractClass(); - $this->gatewayMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\ClientInterface') + $this->clientMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\ClientInterface') ->getMockForAbstractClass(); $this->responseHandlerMock = $this->getMockBuilder('Magento\Payment\Gateway\Response\HandlerInterface') ->getMockForAbstractClass(); + $this->validatorMock = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ValidatorInterface') + ->getMockForAbstractClass(); $this->model = new \Magento\Payment\Gateway\Command\GatewayCommand( $this->requestBuilderMock, - $this->transferBuilderMock, - $this->gatewayMock, - $this->responseHandlerMock + $this->transferFactoryMock, + $this->clientMock, + $this->responseHandlerMock, + $this->validatorMock ); } @@ -54,26 +62,35 @@ class GatewayCommandTest extends \PHPUnit_Framework_TestCase $commandSubject = ['authorize']; $request = ['request_field1' => 'request_value1', 'request_field2' => 'request_value2']; $response = ['response_field1' => 'response_value1']; + $validationResult = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ResultInterface') + ->getMockForAbstractClass(); $transferO = $this->getMockBuilder('Magento\Payment\Gateway\Http\TransferInterface') ->getMockForAbstractClass(); - $this->requestBuilderMock->expects($this->once()) + $this->requestBuilderMock->expects(static::once()) ->method('build') ->with($commandSubject) ->willReturn($request); - $this->transferBuilderMock->expects($this->once()) - ->method('build') + $this->transferFactoryMock->expects(static::once()) + ->method('create') ->with($request) ->willReturn($transferO); - $this->gatewayMock->expects($this->once()) + $this->clientMock->expects(static::once()) ->method('placeRequest') ->with($transferO) ->willReturn($response); + $this->validatorMock->expects(static::once()) + ->method('validate') + ->with(array_merge($commandSubject, ['response' =>$response])) + ->willReturn($validationResult); + $validationResult->expects(static::once()) + ->method('isValid') + ->willReturn(true); - $this->responseHandlerMock->expects($this->once()) + $this->responseHandlerMock->expects(static::once()) ->method('handle') ->with($commandSubject, $response); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php index a10523f6496ce70ff9247ac11b89e7edf23d8101..266128b42f6f9ee21b26c83e5e3caf0187163998 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php @@ -12,14 +12,14 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase public function testConstructorException() { $this->setExpectedException('LogicException'); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') ->disableOriginalConstructor() + ->setMethods(['create']) ->getMock(); - $tMap->expects(static::once()) - ->method('offsetExists') - ->with(ValueHandlerPool::DEFAULT_HANDLER) - ->willReturn(false); - new ValueHandlerPool($tMap); + + $tMapFactory->expects(static::never()) + ->method('create'); + new ValueHandlerPool([], $tMapFactory); } public function testGet() @@ -30,10 +30,27 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase $someValueHandler = $this->getMockBuilder('Magento\Payment\Gateway\Config\ValueHandlerInterface') ->disableOriginalConstructor() ->getMockForAbstractClass(); + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); - $tMap->expects(static::exactly(4)) + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [ + ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', + 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + ], + 'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + ] + ) + ->willReturn($tMap); + $tMap->expects(static::exactly(3)) ->method('offsetExists') ->willReturnMap( [ @@ -50,7 +67,13 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase ] ); - $pool = new ValueHandlerPool($tMap); + $pool = new ValueHandlerPool( + [ + ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', + 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + ], + $tMapFactory + ); static::assertSame($someValueHandler, $pool->get('some_value')); static::assertSame($defaultHandler, $pool->get(ValueHandlerPool::DEFAULT_HANDLER)); static::assertSame($defaultHandler, $pool->get('no_custom_logic_required')); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php index a31a859d54194ff9093018fef6c0d34d10fb199d..fc8ea141c1abe6641fd41caf6ea62cf74b90d200 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Order/AddressAdapterTest.php @@ -32,8 +32,8 @@ class AddressAdapterTest extends \PHPUnit_Framework_TestCase public function testGetRegion() { $expected = 'California'; - $this->orderAddressMock->expects($this->once())->method('getRegion')->willReturn($expected); - $this->assertEquals($expected, $this->model->getRegion()); + $this->orderAddressMock->expects($this->once())->method('getRegionCode')->willReturn($expected); + $this->assertEquals($expected, $this->model->getRegionCode()); } public function testGetCountryId() diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php index 5674f0eba1c82adf6c6e812ee4079d2953625e58..84ad8947b35ec0c74b9fda544c7d1d7a2016a636 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Data/Quote/AddressAdapterTest.php @@ -32,8 +32,8 @@ class AddressAdapterTest extends \PHPUnit_Framework_TestCase public function testGetRegion() { $expected = 'California'; - $this->quoteAddressMock->expects($this->once())->method('getRegion')->willReturn($expected); - $this->assertEquals($expected, $this->model->getRegion()); + $this->quoteAddressMock->expects($this->once())->method('getRegionCode')->willReturn($expected); + $this->assertEquals($expected, $this->model->getRegionCode()); } public function testGetCountryId() diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php index ec6e6a3e04af5b6d5ceae94cc7bd46edad4d25b0..43f2a400ccd77100161afbd5596ddf4fdbc7b8b1 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Client/ZendTest.php @@ -39,6 +39,11 @@ class ZendTest extends \PHPUnit_Framework_TestCase */ protected $transferObjectMock; + /** + * @var \Magento\Payment\Model\Method\Logger|\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + protected function setUp() { $this->converterMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\ConverterInterface') @@ -53,10 +58,14 @@ class ZendTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $this->loggerMock = $this->getMockBuilder('Magento\Payment\Model\Method\Logger') + ->disableOriginalConstructor() + ->getMock(); + $this->transferObjectMock = $this->getMockBuilder('Magento\Payment\Gateway\Http\TransferInterface') ->getMockForAbstractClass(); - $this->model = new Zend($this->zendClientFactoryMock, $this->converterMock); + $this->model = new Zend($this->zendClientFactoryMock, $this->converterMock, $this->loggerMock); } public function testPlaceRequest() @@ -136,7 +145,7 @@ class ZendTest extends \PHPUnit_Framework_TestCase $this->transferObjectMock->expects($this->once())->method('getClientConfig')->willReturn($config); $this->transferObjectMock->expects($this->atLeastOnce())->method('getMethod')->willReturn($method); $this->transferObjectMock->expects($this->once())->method('getHeaders')->willReturn($headers); - $this->transferObjectMock->expects($this->once())->method('getBody')->willReturn($body); + $this->transferObjectMock->expects($this->atLeastOnce())->method('getBody')->willReturn($body); $this->transferObjectMock->expects($this->once())->method('shouldEncode')->willReturn($shouldEncode); $this->transferObjectMock->expects($this->once())->method('getUri')->willReturn($uri); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Http/Converter/HtmlFormConverterTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Converter/HtmlFormConverterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8f2792fe4b92bddc5b59b1320c52858c294193b9 --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Http/Converter/HtmlFormConverterTest.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Test\Unit\Gateway\Http\Converter; + +use Magento\Payment\Gateway\Http\Converter\HtmlFormConverter; + +class HtmlFormConverterTest extends \PHPUnit_Framework_TestCase +{ + public function testConvert() + { + $expectedResult = [ + 'parameter1' => 'val1', + 'parameter2' => 'val2', + 'parameter3' => 'val3' + ]; + + $converter = new HtmlFormConverter(); + static::assertEquals($expectedResult, $converter->convert($this->getValidFormHtml())); + } + + public function testConvertNotValidHtml() + { + $converter = new HtmlFormConverter(); + $converter->convert('Not html. Really not.'); + } + + /** + * Returns valid form HTML + * + * @return string + */ + private function getValidFormHtml() + { + return ' + <!DOCTYPE HTML> + <html> + <head> + <meta charset="utf-8"> + <title>Title</title> + </head> + <body> + + <form action="some"> + <p><input type="radio" name="parameter1" value="val1">val1<Br> + <input type="radio" name="parameter2" value="val2">val2<Br> + <input type="radio" name="parameter3" value="val3">val3</p> + <p><input type="submit"></p> + </form> + + </body> + </html> + '; + } +} diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Http/TransferTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Http/TransferTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bdecd39bc83feffd20bcb00f45cc62115cb3622c --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Http/TransferTest.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Test\Unit\Gateway\Http; + +use Magento\Payment\Gateway\Http\Transfer; + +class TransferTest extends \PHPUnit_Framework_TestCase +{ + public function testIO() + { + $clientConfig = ['config']; + $headers = ['Header']; + $body = ['data', 'data2']; + $method = 'POST'; + $uri = 'https://gateway.com'; + $encode = false; + + $transfer = new Transfer( + $clientConfig, + $headers, + $body, + $method, + $uri, + $encode + ); + + static::assertSame($clientConfig, $transfer->getClientConfig()); + static::assertSame($headers, $transfer->getHeaders()); + static::assertSame($body, $transfer->getBody()); + static::assertSame($method, $transfer->getMethod()); + static::assertSame($uri, $transfer->getUri()); + static::assertSame($encode, $transfer->shouldEncode()); + } +} diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php index 39d9339d2d93402eee7865cd31b946dfd1097ac3..e1e5ea547456a76f23629322b483718b5cf98e61 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php @@ -11,13 +11,28 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase { public function testBuildEmpty() { + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [], + 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('getIterator') ->willReturn(new \ArrayIterator([])); - $builder = new BuilderComposite($tMap); + + $builder = new BuilderComposite([], $tMapFactory); static::assertEquals([], $builder->build([])); } @@ -27,12 +42,18 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase 'user' => 'Mrs G. Crump', 'url' => 'https://url.in', 'amount' => 10.00, - 'currecy' => 'pound', + 'currency' => 'pound', 'address' => '46 Egernon Crescent', 'item' => 'gas cooker', 'quantity' => 1 ]; - + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') + ->disableOriginalConstructor() + ->getMock(); $customerBuilder = $this->getMockBuilder('Magento\Payment\Gateway\Request\BuilderInterface') ->getMockForAbstractClass(); $productBuilder = $this->getMockBuilder('Magento\Payment\Gateway\Request\BuilderInterface') @@ -53,7 +74,7 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase ->willReturn( [ 'amount' => 10.00, - 'currecy' => 'pound', + 'currency' => 'pound', 'item' => 'gas cooker', 'quantity' => 1 ] @@ -66,14 +87,31 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase ] ); - $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') - ->disableOriginalConstructor() - ->getMock(); + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [ + 'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface', + 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', + 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' + ], + 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('getIterator') ->willReturn(new \ArrayIterator([$customerBuilder, $productBuilder, $magentoBuilder])); - $builder = new BuilderComposite($tMap); + $builder = new BuilderComposite( + [ + 'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface', + 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', + 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' + ], + $tMapFactory + ); static::assertEquals($expectedRequest, $builder->build([])); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php index 716fe3246ae1d8fa17f6d051e1babd42ddf2779e..c65a826a2624d79adff61fac919ce47385fac6ac 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php @@ -15,10 +15,26 @@ class HandlerChainTest extends \PHPUnit_Framework_TestCase ->getMockForAbstractClass(); $handler2 = $this->getMockBuilder('Magento\Payment\Gateway\Response\HandlerInterface') ->getMockForAbstractClass(); - + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [ + 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', + 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' + ], + 'type' => 'Magento\Payment\Gateway\Response\HandlerInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('getIterator') ->willReturn(new \ArrayIterator([$handler1, $handler2])); @@ -32,7 +48,13 @@ class HandlerChainTest extends \PHPUnit_Framework_TestCase ->method('handle') ->with($handlingSubject, $response); - $chain = new HandlerChain($tMap); + $chain = new HandlerChain( + [ + 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', + 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' + ], + $tMapFactory + ); $chain->handle($handlingSubject, $response); } } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php index 9150e83f0e7363cee65f589cbb8980728f7ac580..8528b65ac6cecf91bd5603009334a0b47f216137 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php @@ -16,10 +16,26 @@ class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase ->getMockForAbstractClass(); $validator2 = $this->getMockBuilder('Magento\Payment\Gateway\Validator\ValidatorInterface') ->getMockForAbstractClass(); - + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [ + 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', + 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ], + 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('getIterator') ->willReturn(new \ArrayIterator([$validator1, $validator2])); @@ -64,7 +80,14 @@ class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase ->willReturn($compositeResult); - $validatorComposite = new ValidatorComposite($resultFactory, $tMap); + $validatorComposite = new ValidatorComposite( + $resultFactory, + [ + 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', + 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ], + $tMapFactory + ); static::assertSame($compositeResult, $validatorComposite->validate($validationSubject)); } } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php index c48aca93d6e370462cce2ce0824c5d3927baef56..becc387fab2d91b86cc6ba3b13954c8c0c29ae05 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php @@ -16,6 +16,20 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], + 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('offsetExists') ->with('validator') @@ -25,7 +39,10 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase ->with('validator') ->willReturn($commandI); - $pool = new ValidatorPool($tMap); + $pool = new ValidatorPool( + ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], + $tMapFactory + ); static::assertSame($commandI, $pool->get('validator')); } @@ -33,15 +50,30 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase public function testGetException() { $this->setExpectedException('Magento\Framework\Exception\NotFoundException'); + + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $tMap = $this->getMockBuilder('Magento\Framework\ObjectManager\TMap') ->disableOriginalConstructor() ->getMock(); + + $tMapFactory->expects(static::once()) + ->method('create') + ->with( + [ + 'array' => [], + 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + ] + ) + ->willReturn($tMap); $tMap->expects(static::once()) ->method('offsetExists') ->with('validator') ->willReturn(false); - $pool = new ValidatorPool($tMap); + $pool = new ValidatorPool([], $tMapFactory); $pool->get('validator'); } } diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 87f3a9ef1cd080f2b0da3e1e42532f71dc39d4b4..b78f45d789049bbd5d2a03a892e688dbd0d40535 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Payment/etc/payment.xml b/app/code/Magento/Payment/etc/payment.xml index b034e1695e0641056899daeaddb112e4bc47c454..5560a70f11b325ea8d12a85ec5fd2582b29593f1 100644 --- a/app/code/Magento/Payment/etc/payment.xml +++ b/app/code/Magento/Payment/etc/payment.xml @@ -32,5 +32,17 @@ <type id="OT" order="1000"> <label>Other</label> </type> + <type id="DN" order="60"> + <label>Diners</label> + </type> + <type id="JC" order="70"> + <label>JCB</label> + </type> + <type id="MI" order="80"> + <label>Maestro International</label> + </type> + <type id="MD" order="100"> + <label>Maestro Domestic</label> + </type> </credit_cards> </payment> diff --git a/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml b/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml index e9632aa0f89155238a8a659b660687a2bc4ce743..c6a429a0fbe08f624c53f03d7998879281dfde27 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml @@ -22,6 +22,7 @@ $code = $block->getMethodCode(); "cardFieldsMap":<?php echo $block->getCardFieldsMap() ?>, "orderSaveUrl":"<?php echo $block->getOrderUrl() ?>", "cgiUrl":"<?php echo $block->getCgiUrl() ?>", + "expireYearLength":"<?php echo $block->getMethodConfigData('cc_year_length') ?>", "nativeAction":"<?php echo $block->getUrl('*/*/save', ['_secure' => $block->getRequest()->isSecure()]) ?>" }, "validation":[]}' style="display:none;"> diff --git a/app/code/Magento/Payment/view/adminhtml/web/transparent.js b/app/code/Magento/Payment/view/adminhtml/web/transparent.js index 1317880d7f062c08ebe1c1fee96be951796b1a53..7edbb30c6318ffd45339c6b55b3b612067f76b62 100644 --- a/app/code/Magento/Payment/view/adminhtml/web/transparent.js +++ b/app/code/Magento/Payment/view/adminhtml/web/transparent.js @@ -23,7 +23,8 @@ define([ controller: null, gateway: null, dateDelim: null, - cardFieldsMap: null + cardFieldsMap: null, + expireYearLength: 2 }, _create: function() { @@ -52,6 +53,9 @@ define([ */ _orderSave: function() { var postData = "form_key="+FORM_KEY; + postData += '&cc_type=' + this.element.find( + '[data-container="' + this.options.gateway + '-cc-type"]' + ).val(); $.ajax({ url: this.options.orderSaveUrl, type: 'post', @@ -135,8 +139,8 @@ define([ this.element.find('[data-container="' + this.options.gateway + '-cc-month"]').val() , 10 ); - if (year.length > 2) { - year = year.substring(2); + if (year.length > this.options.expireYearLength) { + year = year.substring(year.length - this.options.expireYearLength); } if (month < 10) { month = '0' + month; 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 index a5a78d731cfeac57b02fc28ff488534ea733a1cd..5349dab7b4d93202a4dec1f9924de97d0c564645 100644 --- 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 @@ -39,6 +39,9 @@ define( }, originalPlaceOrder: function(parent) { return parent.placeOrder.bind(parent); + }, + getExpireYearLength: function(parent) { + return window.checkoutConfig.payment.iframe.expireYearLength[this.getCode()]; } }); } 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 index cd9c3342c733f9cd2f4cf3e656b533ccb7b5e655..df5212f51e03f9a2b54332ca117c38d7abb0d5ba 100644 --- 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 @@ -14,7 +14,8 @@ 'cgiUrl': getCgiUrl(), 'dateDelim': getDateDelim(), 'cardFieldsMap': getCardFieldsMap(), - 'nativeAction': getSaveOrderUrl() + 'nativeAction': getSaveOrderUrl(), + 'expireYearLength': getExpireYearLength() }, 'validation':[]}"> <!-- ko with: getCcFormView() --> <!-- ko template: getTemplate() --><!-- /ko --> diff --git a/app/code/Magento/Payment/view/frontend/web/transparent.js b/app/code/Magento/Payment/view/frontend/web/transparent.js index 570772d6d430c67d6dcd4ea10325fade6d3407b0..6394cf38fee739a4667b1845efc4e11f4582b913 100644 --- a/app/code/Magento/Payment/view/frontend/web/transparent.js +++ b/app/code/Magento/Payment/view/frontend/web/transparent.js @@ -28,7 +28,8 @@ define([ controller: null, gateway: null, dateDelim: null, - cardFieldsMap: null + cardFieldsMap: null, + expireYearLength: 2 }, _create: function() { @@ -60,6 +61,10 @@ define([ postData += '&' + $(this.options.reviewAgreementForm).serialize(); } postData += '&controller=' + this.options.controller; + postData += '&cc_type=' + this.element.find( + '[data-container="' + this.options.gateway + '-cc-type"]' + ).val(); + $.ajax({ url: this.options.orderSaveUrl, type: 'post', @@ -140,9 +145,10 @@ define([ this.element.find('[data-container="' + this.options.gateway + '-cc-month"]').val(), 10 ); - if (year.length > 2) { - year = year.substring(2); + if (year.length > this.options.expireYearLength) { + year = year.substring(year.length - this.options.expireYearLength); } + if (month < 10) { month = '0' + month; } diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index 379f16a66b2f4879c1c315c5a33c6d93cd69f64b..b81c38561e3dfc1e24c9565dec1988e79ff43715 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-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-cron": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-cron": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 3e993546d08a901e3e7f7feda86c18e19e2cfd7e..715f9607506075b3e7fd70a2f1f691c63f78f3f5 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Quote/Api/Data/CartInterface.php b/app/code/Magento/Quote/Api/Data/CartInterface.php index 64eb62f72a2a7590ecd9decc93d7fdeae5033576..a663618a0b81fba68dca3b123ee9f0b43466e243 100644 --- a/app/code/Magento/Quote/Api/Data/CartInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartInterface.php @@ -54,6 +54,8 @@ interface CartInterface extends \Magento\Framework\Api\ExtensibleDataInterface const KEY_CUSTOMER_TAX_CLASS_ID = 'customer_tax_class_id'; + const KEY_STORE_ID = 'store_id'; + /**#@-*/ /** @@ -350,6 +352,21 @@ interface CartInterface extends \Magento\Framework\Api\ExtensibleDataInterface */ public function setCustomerTaxClassId($customerTaxClassId); + /** + * Get store identifier + * + * @return int + */ + public function getStoreId(); + + /** + * Sets store identifier + * + * @param int $storeId + * @return $this + */ + public function setStoreId($storeId); + /** * Retrieve existing extension attributes object or create a new one. * diff --git a/app/code/Magento/Quote/Model/BillingAddressManagement.php b/app/code/Magento/Quote/Model/BillingAddressManagement.php index cad5a3b9c42d1ff5755bb34795be8c8fc1b176c9..c710b56797f9008902381457c7f9719967e805ea 100644 --- a/app/code/Magento/Quote/Model/BillingAddressManagement.php +++ b/app/code/Magento/Quote/Model/BillingAddressManagement.php @@ -67,6 +67,7 @@ class BillingAddressManagement implements BillingAddressManagementInterface 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; @@ -87,6 +88,8 @@ class BillingAddressManagement implements BillingAddressManagementInterface $shippingAddress = $quote->getShippingAddress()->importCustomerAddressData($addressData); $shippingAddress->setSaveInAddressBook($saveInAddressBook); } + } elseif ($quote->getCustomerId()) { + $address->setEmail($quote->getCustomerEmail()); } $address->setSaveInAddressBook($saveInAddressBook); $quote->setBillingAddress($address); diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index 95fa91f6c6c5c29de29ac69cdb491cacef11ee76..2dd5c4ca3add051bb7c518b939e8a1011e098a10 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -28,7 +28,6 @@ use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface; * sales_quote_delete_before * sales_quote_delete_after * - * @method Quote setStoreId(int $value) * @method int getIsMultiShipping() * @method Quote setIsMultiShipping(int $value) * @method float getStoreToBaseRate() @@ -687,16 +686,23 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C //@codeCoverageIgnoreEnd /** - * Get quote store identifier - * - * @return int + * {@inheritdoc} */ public function getStoreId() { if (!$this->hasStoreId()) { return $this->_storeManager->getStore()->getId(); } - return $this->_getData('store_id'); + return (int)$this->_getData(self::KEY_STORE_ID); + } + + /** + * {@inheritdoc} + */ + public function setStoreId($storeId) + { + $this->setData(self::KEY_STORE_ID, (int)$storeId); + return $this; } /** diff --git a/app/code/Magento/Quote/Model/Quote/Payment.php b/app/code/Magento/Quote/Model/Quote/Payment.php index bb98b0d85ca3ac9d216eddcfac9a52f661249c4b..04f583d1c25b950c9cc5bc24b65cdaca9ee08233 100644 --- a/app/code/Magento/Quote/Model/Quote/Payment.php +++ b/app/code/Magento/Quote/Model/Quote/Payment.php @@ -5,6 +5,8 @@ */ namespace Magento\Quote\Model\Quote; +use Magento\Payment\Model\Method\AbstractMethod; + /** * Quote payment information * @@ -209,7 +211,7 @@ class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\ public function getOrderPlaceRedirectUrl() { $method = $this->getMethodInstance(); - if ($method) { + if ($method && $method instanceof AbstractMethod) { return $method->getOrderPlaceRedirectUrl(); } return ''; diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php index d6ed68479310ca4dd21af16ca2d43da91b66adb6..07f4f61eb198bc59cf00df9c77b34a404ffc35c2 100644 --- a/app/code/Magento/Quote/Model/ShippingAddressManagement.php +++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php @@ -89,6 +89,8 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface if ($customerAddressId) { $addressData = $this->addressRepository->getById($customerAddressId); $address = $quote->getShippingAddress()->importCustomerAddressData($addressData); + } elseif ($quote->getCustomerId()) { + $address->setEmail($quote->getCustomerEmail()); } $address->setSameAsBilling($sameAsBilling); $address->setSaveInAddressBook($saveInAddressBook); diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php index 872cfa989fbdaf24a559265014aa37c6f650de5b..04e919863d29a21a350fd731ccecfe4ed0db00ed 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php @@ -133,7 +133,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('load') @@ -150,7 +150,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('load') @@ -169,7 +169,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->once()) ->method('setSharedStoreIds') ->with($sharedStoreIds) @@ -191,7 +191,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('loadByCustomer') @@ -213,7 +213,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('load') @@ -235,7 +235,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('load') @@ -253,7 +253,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('load') @@ -273,7 +273,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->once()) ->method('setSharedStoreIds') ->with($sharedStoreIds) @@ -296,7 +296,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock); + $this->storeMock->expects($this->once())->method('getId')->willReturn(1); $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); $this->quoteMock->expects($this->once()) ->method('loadByCustomer') diff --git a/app/code/Magento/Quote/composer.json b/app/code/Magento/Quote/composer.json index f58331308612ac84cf4b8e0e7a42328671b2450e..05d09f86f706c1689b7d04bf1f05527d584c2ff2 100644 --- a/app/code/Magento/Quote/composer.json +++ b/app/code/Magento/Quote/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-catalog-rule": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-sales-sequence": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-catalog-rule": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-sales-sequence": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php index 7c18123b5fa881d59ad91ce148ca94d2ed168e22..f9fe3f7290440886646b29df65165e0aa76bc81c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Filter; /** @@ -42,6 +40,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param string $fieldId * @param bool $visibility * + * @codeCoverageIgnore * @return void */ public function setFieldVisibility($fieldId, $visibility) @@ -95,6 +94,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param string $key * @param string $value * @return $this + * @codeCoverageIgnore */ public function addReportTypeOption($key, $value) { @@ -113,7 +113,13 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create( - ['data' => ['id' => 'filter_form', 'action' => $actionUrl, 'method' => 'get']] + [ + 'data' => [ + 'id' => 'filter_form', + 'action' => $actionUrl, + 'method' => 'get' + ] + ] ); $htmlIdPrefix = 'sales_report_'; @@ -127,7 +133,11 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $fieldset->addField( 'report_type', 'select', - ['name' => 'report_type', 'options' => $this->_reportTypeOptions, 'label' => __('Match Period To')] + [ + 'name' => 'report_type', + 'options' => $this->_reportTypeOptions, + 'label' => __('Match Period To') + ] ); $fieldset->addField( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php index 9fe1fa27a2c481ff73d35930f66aec1e5ea298e6..463339d2949ad37ca67bdb46c17ea109bb77ddb5 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml; /** @@ -81,7 +79,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid { $filter = $this->getParam($this->getVarNameFilter(), null); - if (is_null($filter)) { + if (null === $filter) { $filter = $this->_defaultFilter; } @@ -154,7 +152,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Get allowed stores * - * @return array + * @return array|\int[] */ protected function _getAllowedStoreIds() { @@ -205,7 +203,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * Set visibility of store switcher * * @param bool $visible - * + * @codeCoverageIgnore * @return void */ public function setStoreSwitcherVisibility($visible = true) @@ -215,6 +213,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return visibility of store switcher + * @codeCoverageIgnore * * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) @@ -226,6 +225,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return store switcher html + * @codeCoverageIgnore * * @return string */ @@ -238,8 +238,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * Set visibility of date filter * * @param bool $visible - * * @return void + * @codeCoverageIgnore */ public function setDateFilterVisibility($visible = true) { @@ -248,6 +248,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return visibility of date filter + * @codeCoverageIgnore * * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) @@ -259,6 +260,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return date filter html + * @codeCoverageIgnore * * @return string */ @@ -289,6 +291,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return refresh button html + * @codeCoverageIgnore * * @return string */ @@ -302,8 +305,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * * @param string $name * @param string $value - * * @return void + * @codeCoverageIgnore */ public function setFilter($name, $value) { @@ -331,8 +334,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * Set sub-report rows count * * @param int $size - * * @return void + * @codeCoverageIgnore */ public function setSubReportSize($size) { @@ -341,6 +344,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return sub-report rows count + * @codeCoverageIgnore * * @return int */ @@ -353,6 +357,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * Retrieve errors * * @return array + * @codeCoverageIgnore */ public function getErrors() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php index 68b0b78bbbd23ea397af64e076ece23c9972025a..39813ec48946af6e05b0aae0d7fdc8ed516e2a65 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php @@ -71,6 +71,8 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended } /** + * Pseudo constructor + * * @return void */ protected function _construct() @@ -86,6 +88,10 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended } /** + * Get resource collection name + * + * @codeCoverageIgnore + * * @return string */ public function getResourceCollectionName() @@ -339,9 +345,11 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * @param array $storeIds + * StoreIds setter * + * @param array $storeIds * @return $this + * @codeCoverageIgnore */ public function setStoreIds($storeIds) { @@ -396,6 +404,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended * @param \Magento\Framework\Object $filterData * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @codeCoverageIgnore */ protected function _addCustomFilter($collection, $filterData) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php index ac9cf8c700bd7efc13558d6fb0161388dd2de4e3..30555dbca8d2b14a12cff014d8e3da1b667a6591 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; /** @@ -24,15 +22,15 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Curren public function render(\Magento\Framework\Object $row) { $data = $row->getData($this->getColumn()->getIndex()); - $currency_code = $this->_getCurrencyCode($row); + $currencyCode = $this->_getCurrencyCode($row); - if (!$currency_code) { + if (!$currencyCode) { return $data; } $data = floatval($data) * $this->_getRate($row); $data = sprintf("%f", $data); - $data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data); + $data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data); return $data; } } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php index 023f4f4bac729ed0fb6e44b7ffc123a595464b1a..0c635887cf0bc156ba384355eacf96de09ab76cd 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php @@ -28,6 +28,7 @@ class Shopcart extends \Magento\Backend\Block\Widget\Grid\Extended /** * StoreIds setter + * @codeCoverageIgnore * * @param array $storeIds * @return $this diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product.php b/app/code/Magento/Reports/Block/Adminhtml/Product.php index 9c5cad9fc76f8398a9cef6677f51183ee0d94e9d..4adc6dccbc09aa166b571c6e73e39ace1ed60187 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product.php @@ -13,7 +13,7 @@ namespace Magento\Reports\Block\Adminhtml; class Product extends \Magento\Backend\Block\Widget\Grid\Container { /** - * @return void + * {@inheritdoc} */ protected function _construct() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php index d872439b7f8e6417d2ea613f868105c0764a20fb..32a25599702e9d312ac79160b5d0d5b8f38199ca 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Bestsellers extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Bestsellers extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php index d6820a811970fded00679f36d5ad6564ccae7e36..bedef6d74acceb8be7e61ef3d045faf17f1c98be 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php @@ -14,12 +14,15 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Bestsellers; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -28,7 +31,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} + * @codeCoverageIgnore */ public function getResourceCollectionName() { @@ -36,7 +40,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php index c14f1c248b15bdbd2c3ee8a859d9a3fe32c41c6d..cfd20f5e3a468e5948e746da801ddc2b8291db3d 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Coupons extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template file + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Coupons extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php index c04265b1c531f9c8eaef861a81eacdd8998afc84..cf79f4c06682831286c114354b47d1943008b5ed 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php @@ -14,12 +14,15 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Coupons; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -29,7 +32,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { @@ -41,7 +44,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareColumns() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php index b18faf62ef5530eefda4516a5de9410c0277468a..30b6fccb13435e396ce06d6383768b301f0f399c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php @@ -13,6 +13,8 @@ use Magento\Framework\Locale\Bundle\DataBundle; class Date extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Date { /** + * Constructor + * * @param \Magento\Backend\Block\Context $context * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php index 3b6cf45846551dae90daad88e9d1b02f3e186793..e6de75fb9545e9723b5a02f1e87ee9f4cc434259 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Invoiced extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template file + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Invoiced extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php index 414c2e775872a1e9a36795e820c9b417533c1416..854520bafad351539f350b4f1c9369db8fdd0372 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Invoiced; /** @@ -17,12 +15,15 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Invoiced; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY condition + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -31,18 +32,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'created_at_invoice' ? 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Invoiced' : 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Order'; + return ($this->getFilterData()->getData('report_type')) == 'created_at_invoice' + ? 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Invoiced' + : 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Order'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php index 6ff26a3822b8a7f76f37ff4a046314317f538db0..c48dee92771a07839ef2e352350d0ed9a52f8446 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Refunded extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template file + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Refunded extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php index e5f68a315f74013a51de8df19dc74cfbc996efb5..c3964e9675cd7f4b67807df54e548cef34028d13 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Refunded; /** @@ -17,12 +15,15 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Refunded; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -31,18 +32,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'created_at_refunded' ? 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Refunded' : 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Order'; + return $this->getFilterData()->getData('report_type') == 'created_at_refunded' + ? 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Refunded' + : 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Order'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php index 6c6ca70730a2111e637426a159365a973a5be8e3..ad43f74e52646da9445d0d8a2c12500f3b761f8f 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Sales extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template file + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Sales extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php index 012e170b2c269dac90cdd6b43d1461edf4aa4ee4..6f7b99bb8941fe4cef1547a952e9e00583bfb9c0 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Sales; /** @@ -17,12 +15,15 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Sales; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -31,18 +32,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'updated_at_order' ? 'Magento\Sales\Model\Resource\Report\Order\Updatedat\Collection' : 'Magento\Sales\Model\Resource\Report\Order\Collection'; + return $this->getFilterData()->getData('report_type') == 'updated_at_order' + ? 'Magento\Sales\Model\Resource\Report\Order\Updatedat\Collection' + : 'Magento\Sales\Model\Resource\Report\Order\Collection'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} + * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareColumns() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php index 0499c0ee07af14dbf113e5a4fc6aa388bdb4f04e..e72406788d3ec9a30fe366c536e7d68d80fb222d 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Shipping extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template file + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Shipping extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php index ee594aaa3447565990652114cee7ba498b1f3011..28d8bbe6b196fb55963f61797c95a09962960e50 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Shipping; /** @@ -17,12 +15,15 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Shipping; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * Group by criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -32,18 +33,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'created_at_shipment' ? 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Shipment' : 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Order'; + return $this->getFilterData()->getData('report_type') == 'created_at_shipment' + ? 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Shipment' + : 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Order'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php index 767760eabb655e8849f345c7db16503ce145432e..ed27f1616518c78751c902e7433f2c8a35b86511 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php @@ -13,12 +13,14 @@ namespace Magento\Reports\Block\Adminhtml\Sales; class Tax extends \Magento\Backend\Block\Widget\Grid\Container { /** + * Template file + * * @var string */ protected $_template = 'report/grid/container.phtml'; /** - * @return void + * {@inheritdoc} */ protected function _construct() { @@ -35,6 +37,8 @@ class Tax extends \Magento\Backend\Block\Widget\Grid\Container } /** + * Get filter URL + * * @return string */ public function getFilterUrl() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php index 48c3a647299b4b3cc76dde1dd63ed36a0e05f7a2..7196f1ff332533630ba0241383ffc6cd6a12e030 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml\Sales\Tax; /** @@ -17,16 +15,22 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Tax; class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** + * GROUP BY criteria + * * @var string */ protected $_columnGroupBy = 'period'; /** + * Config factory + * * @var \Magento\Sales\Model\Order\ConfigFactory */ protected $_configFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory @@ -49,7 +53,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return void + * {@inheritdoc} + * @codeCoverageIgnore */ protected function _construct() { @@ -59,18 +64,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * @return string + * {@inheritdoc} */ public function getResourceCollectionName() { - return $this->getFilterData()->getData( - 'report_type' - ) == - 'updated_at_order' ? 'Magento\Tax\Model\Resource\Report\Updatedat\Collection' : 'Magento\Tax\Model\Resource\Report\Collection'; + return $this->getFilterData()->getData('report_type') == 'updated_at_order' + ? 'Magento\Tax\Model\Resource\Report\Updatedat\Collection' + : 'Magento\Tax\Model\Resource\Report\Collection'; } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php index 690c98b4d692559de2d645c23623801f0ebe4705..df114f5e653e6b121874ab9aad21a71174abcb43 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Adminhtml; /** @@ -16,36 +14,8 @@ namespace Magento\Reports\Block\Adminhtml; class Wishlist extends \Magento\Backend\Block\Template { /** - * @var int - */ - public $wishlists_count; - - /** - * @var int - */ - public $items_bought; - - /** - * @var int - */ - public $shared_count; - - /** - * @var int - */ - public $referrals_count; - - /** - * @var int - */ - public $conversions_count; - - /** - * @var int - */ - public $customer_with_wishlist; - - /** + * Template file + * * @var string */ protected $_template = 'report/wishlist.phtml'; @@ -58,6 +28,8 @@ class Wishlist extends \Magento\Backend\Block\Template protected $_wishlistFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\Resource\Wishlist\CollectionFactory $wishlistFactory * @param array $data @@ -72,9 +44,9 @@ class Wishlist extends \Magento\Backend\Block\Template } /** - * @return $this + * {@inheritdoc} */ - public function _beforeToHtml() + protected function _beforeToHtml() { $this->setChild( 'grid', diff --git a/app/code/Magento/Reports/Block/Product/AbstractProduct.php b/app/code/Magento/Reports/Block/Product/AbstractProduct.php index dfe51eea66fed23301c4f8d4a0d9bdb6945e4d69..cf420b4d3cebeddc38077c1f3619ac4ae5fcf403 100644 --- a/app/code/Magento/Reports/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Reports/Block/Product/AbstractProduct.php @@ -81,11 +81,11 @@ abstract class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractPr } /** - * Retrieve Product Index model instance + * Public method for retrieve Product Index model * * @return \Magento\Reports\Model\Product\Index\AbstractIndex */ - protected function _getModel() + public function getModel() { try { $model = $this->_indexFactory->get($this->_indexType); @@ -96,16 +96,6 @@ abstract class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractPr return $model; } - /** - * Public method for retrieve Product Index model - * - * @return \Magento\Reports\Model\Product\Index\AbstractIndex - */ - public function getModel() - { - return $this->_getModel(); - } - /** * Retrieve Index Product Collection * @@ -116,14 +106,14 @@ abstract class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractPr if ($this->_collection === null) { $attributes = $this->_catalogConfig->getProductAttributes(); - $this->_collection = $this->_getModel()->getCollection()->addAttributeToSelect($attributes); + $this->_collection = $this->getModel()->getCollection()->addAttributeToSelect($attributes); if ($this->getCustomerId()) { $this->_collection->setCustomerId($this->getCustomerId()); } $this->_collection->excludeProductIds( - $this->_getModel()->getExcludeProductIds() + $this->getModel()->getExcludeProductIds() )->addUrlRewrite()->setPageSize( $this->getPageSize() )->setCurPage( @@ -152,7 +142,7 @@ abstract class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractPr */ public function getCount() { - if (!$this->_getModel()->getCount()) { + if (!$this->getModel()->getCount()) { return 0; } return $this->getItemsCollection()->count(); diff --git a/app/code/Magento/Reports/Block/Product/Compared.php b/app/code/Magento/Reports/Block/Product/Compared.php index 6693d0053ea87edac053ff4e54bb3ada3de04152..67e3d641b829a4c8add0ba1df7fa85749c9f79f7 100644 --- a/app/code/Magento/Reports/Block/Product/Compared.php +++ b/app/code/Magento/Reports/Block/Product/Compared.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Product; /** @@ -15,6 +13,9 @@ namespace Magento\Reports\Block\Product; */ class Compared extends \Magento\Reports\Block\Product\AbstractProduct { + /** + * Config path for compared products count + */ const XML_PATH_RECENTLY_COMPARED_COUNT = 'catalog/recently_products/compared_count'; /** @@ -34,7 +35,10 @@ class Compared extends \Magento\Reports\Block\Product\AbstractProduct if ($this->hasData('page_size')) { return $this->getData('page_size'); } - return $this->_scopeConfig->getValue(self::XML_PATH_RECENTLY_COMPARED_COUNT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->_scopeConfig->getValue( + self::XML_PATH_RECENTLY_COMPARED_COUNT, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Reports/Block/Product/Viewed.php b/app/code/Magento/Reports/Block/Product/Viewed.php index 947c90c89505ce4e8957ff7870c13862da31f526..9a689ec5a6da59c758e9b85e01125a27f897089e 100644 --- a/app/code/Magento/Reports/Block/Product/Viewed.php +++ b/app/code/Magento/Reports/Block/Product/Viewed.php @@ -4,17 +4,20 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Block\Product; +use \Magento\Framework\Object\IdentityInterface; + /** * Reports Recently Viewed Products Block * * @author Magento Core Team <core@magentocommerce.com> */ -class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \Magento\Framework\Object\IdentityInterface +class Viewed extends AbstractProduct implements IdentityInterface { + /** + * Config path to recently viewed product count + */ const XML_PATH_RECENTLY_VIEWED_COUNT = 'catalog/recently_products/viewed_count'; /** @@ -34,7 +37,10 @@ class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \ if ($this->hasData('page_size')) { return $this->getData('page_size'); } - return $this->_scopeConfig->getValue(self::XML_PATH_RECENTLY_VIEWED_COUNT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->_scopeConfig->getValue( + self::XML_PATH_RECENTLY_VIEWED_COUNT, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Reports/Helper/Data.php b/app/code/Magento/Reports/Helper/Data.php index 50856d3b37cde36d9b1066dcc9aa5d608a004b9b..c33b0791a559ec899c8477972f803320245df473 100644 --- a/app/code/Magento/Reports/Helper/Data.php +++ b/app/code/Magento/Reports/Helper/Data.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Reports data helper */ @@ -23,16 +21,22 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper const REPORT_PERIOD_TYPE_YEAR = 'year'; /** + * Item factory + * * @var \Magento\Reports\Model\ItemFactory */ protected $_itemFactory; /** + * Constructor + * * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Reports\Model\ItemFactory $itemFactory */ - public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Reports\Model\ItemFactory $itemFactory) - { + public function __construct( + \Magento\Framework\App\Helper\Context $context, + \Magento\Reports\Model\ItemFactory $itemFactory + ) { parent::__construct($context); $this->_itemFactory = $itemFactory; } @@ -55,7 +59,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $dateStart = new \DateTime($from); $dateEnd = new \DateTime($to); - while ($dateStart->diff($dateEnd)->invert = 0) { + while ($dateStart->diff($dateEnd)->invert == 0) { switch ($period) { case self::REPORT_PERIOD_TYPE_DAY: $intervals[] = $dateStart->format('Y-m-d'); diff --git a/app/code/Magento/Reports/Model/Flag.php b/app/code/Magento/Reports/Model/Flag.php index d289a0ce35412498b963fb7ce3e3059591fcf7f5..3782a655f24862cbf5dee4291ed8ab0832a9fa3e 100644 --- a/app/code/Magento/Reports/Model/Flag.php +++ b/app/code/Magento/Reports/Model/Flag.php @@ -30,6 +30,7 @@ class Flag extends \Magento\Framework\Flag /** * Setter for flag code + * @codeCoverageIgnore * * @param string $code * @return $this diff --git a/app/code/Magento/Reports/Model/Grouped/Collection.php b/app/code/Magento/Reports/Model/Grouped/Collection.php index 6f8e9d561dad6cd65a5ea80b76e2a15465c1f50f..3f00e36c1a7a7ec4d78f975baaa33bd3bc3f747d 100644 --- a/app/code/Magento/Reports/Model/Grouped/Collection.php +++ b/app/code/Magento/Reports/Model/Grouped/Collection.php @@ -25,6 +25,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Set column to group by + * @codeCoverageIgnore * * @param string $column * @return $this @@ -61,6 +62,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Setter for resource collection + * @codeCoverageIgnore * * @param DbCollection $collection * @return $this diff --git a/app/code/Magento/Reports/Model/Item.php b/app/code/Magento/Reports/Model/Item.php index ecc9c805e91722136affdff251c4123ca873613c..01a60c397c5eab8bc83b6345979e1f982601ee9b 100644 --- a/app/code/Magento/Reports/Model/Item.php +++ b/app/code/Magento/Reports/Model/Item.php @@ -19,6 +19,7 @@ class Item extends \Magento\Framework\Object /** * Set is empty indicator + * @codeCoverageIgnore * * @param bool $flag * @return $this @@ -31,6 +32,7 @@ class Item extends \Magento\Framework\Object /** * Get is empty indicator + * @codeCoverageIgnore * * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) @@ -49,6 +51,7 @@ class Item extends \Magento\Framework\Object /** * Get children + * @codeCoverageIgnore * * @return array */ @@ -59,6 +62,7 @@ class Item extends \Magento\Framework\Object /** * Set children + * @codeCoverageIgnore * * @param array $children * @return $this diff --git a/app/code/Magento/Reports/Model/Resource/Event/Collection.php b/app/code/Magento/Reports/Model/Resource/Event/Collection.php index 7a515823998ef5c5787fbd9fdb1fd72f4f30ee00..94124028fdb3716c430e6c44bfdf3497786988b0 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Collection.php @@ -32,6 +32,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Add store ids filter + * @codeCoverageIgnore * * @param array $storeIds * @return $this diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 60b24016381f63220ffc29feabe48525f12be626..07c2e2aa8c4a76d1d262f38904d52b00ea622f99 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Model\Resource\Order; use Magento\Framework\DB\Select; @@ -40,26 +38,36 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected $_scopeConfig; /** + * Store manager instance + * * @var \Magento\Store\Model\StoreManagerInterface */ protected $_storeManager; /** + * Locale date instance + * * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $_localeDate; /** + * Order config instance + * * @var \Magento\Sales\Model\Order\Config */ protected $_orderConfig; /** + * Reports order factory + * * @var \Magento\Sales\Model\Resource\Report\OrderFactory */ protected $_reportOrderFactory; /** + * Constructor + * * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy @@ -128,6 +136,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Retrieve is live flag for rep * * @return bool + * @codeCoverageIgnore */ public function isLive() { @@ -162,7 +171,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ protected function _getSalesAmountExpression() { - if (is_null($this->_salesAmountExpression)) { + if (null === $this->_salesAmountExpression) { $adapter = $this->getConnection(); $expressionTransferObject = new \Magento\Framework\Object( [ @@ -257,8 +266,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Prepare report summary from aggregated data * * @param string $range - * @param mixed $customStart - * @param mixed $customEnd + * @param string|null $customStart + * @param string|null $customEnd * @return $this */ protected function _prepareSummaryAggregated($range, $customStart, $customEnd) @@ -271,13 +280,13 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection $rangePeriod = $this->_getRangeExpressionForAttribute($range, 'main_table.period'); $tableName = $this->getConnection()->quoteIdentifier('main_table.period'); - $rangePeriod2 = str_replace($tableName, "MIN({$tableName})", $rangePeriod); + $rangePeriodAggregateStmt = str_replace($tableName, "MIN({$tableName})", $rangePeriod); $this->getSelect()->columns( [ 'revenue' => 'SUM(main_table.total_revenue_amount)', 'quantity' => 'SUM(main_table.orders_count)', - 'range' => $rangePeriod2, + 'range' => $rangePeriodAggregateStmt, ] )->order( 'range' @@ -349,8 +358,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * * @param string $range * @param string $attribute - * @param mixed $from - * @param mixed $to + * @param string|null $from + * @param string|null $to * @return string */ protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null) @@ -665,7 +674,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Set store filter collection * - * @param array $storeIds + * @param int[] $storeIds * @return $this */ public function setStoreIds($storeIds) @@ -778,16 +787,15 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ public function addSumAvgTotals($storeId = 0) { - $adapter = $this->getConnection(); - $baseSubtotalRefunded = $adapter->getIfNullSql('main_table.base_subtotal_refunded', 0); - $baseSubtotalCanceled = $adapter->getIfNullSql('main_table.base_subtotal_canceled', 0); - $baseDiscountCanceled = $adapter->getIfNullSql('main_table.base_discount_canceled', 0); - /** * calculate average and total amount */ - $expr = $storeId == - 0 ? "(main_table.base_subtotal -\n {$baseSubtotalRefunded} - {$baseSubtotalCanceled} - ABS(main_table.base_discount_amount) -\n {$baseDiscountCanceled}) * main_table.base_to_global_rate" : "main_table.base_subtotal - {$baseSubtotalCanceled} - {$baseSubtotalRefunded} -\n ABS(main_table.base_discount_amount) - {$baseDiscountCanceled}"; + $expr = $this->getTotalsExpression( + $storeId, + $this->getConnection()->getIfNullSql('main_table.base_subtotal_refunded', 0), + $this->getConnection()->getIfNullSql('main_table.base_subtotal_canceled', 0), + $this->getConnection()->getIfNullSql('main_table.base_discount_canceled', 0) + ); $this->getSelect()->columns( ['orders_avg_amount' => "AVG({$expr})"] @@ -798,6 +806,28 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection return $this; } + /** + * Get SQL expression for totals + * + * @param int $storeId + * @param string $baseSubtotalRefunded + * @param string $baseSubtotalCanceled + * @param string $baseDiscountCanceled + * @return string + */ + protected function getTotalsExpression( + $storeId, + $baseSubtotalRefunded, + $baseSubtotalCanceled, + $baseDiscountCanceled + ) { + $template = ($storeId != 0) + ? 'main_table.base_subtotal - %2$s - %1$s - ABS(main_table.base_discount_amount) - %3$s' + : '(main_table.base_subtotal - %1$s - %2$s - ABS(main_table.base_discount_amount) - %3$s) ' + . ' * main_table.base_to_global_rate'; + return sprintf($template, $baseSubtotalRefunded, $baseSubtotalCanceled, $baseDiscountCanceled); + } + /** * Sort order by total amount * @@ -869,6 +899,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Initialize initial fields to select * * @return $this + * @codeCoverageIgnore */ protected function _initInitialFieldsToSelect() { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index 3eb9ac629a26e8fdcd075618a98ea3c26357ce1a..7df4b5dc4d9d0bc3616cb6221d4609ad158f8f40 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -147,8 +147,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Set Type for COUNT SQL Select + * @codeCoverageIgnore * - * @codeCoverageIgnoreStart * @param int $type * @return $this */ @@ -160,6 +160,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Set product entity id + * @codeCoverageIgnore * * @param string $entityId * @return $this @@ -172,6 +173,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Get product entity id + * @codeCoverageIgnore * * @return int */ @@ -182,6 +184,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Set product entity table name + * @codeCoverageIgnore * * @param string $value * @return $this @@ -194,6 +197,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Get product entity table name + * @codeCoverageIgnore * * @return string */ @@ -204,6 +208,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Get product attribute set id + * @codeCoverageIgnore * * @return int */ @@ -214,6 +219,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Set product attribute set id + * @codeCoverageIgnore * * @param int $value * @return $this @@ -223,7 +229,6 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $this->_productEntityAttributeSetId = $value; return $this; } - //@codeCoverageIgnoreEnd /** * Join fields diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php index 52d72406cb130d56d6a11e75ed1d68e139268287..45b1c2c5e9d51e3bbb6a0633c821187f731434df 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Model\Resource\Product\Index; /** @@ -14,16 +12,22 @@ namespace Magento\Reports\Model\Resource\Product\Index; abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** + * DateItime instance + * * @var \Magento\Framework\Stdlib\DateTime */ protected $dateTime; /** + * Reports helper + * * @var \Magento\Reports\Model\Resource\Helper */ protected $_resourceHelper; /** + * Constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Magento\Reports\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -55,7 +59,9 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra return $this; } $adapter = $this->_getWriteAdapter(); - $select = $adapter->select()->from($this->getMainTable())->where('visitor_id = ?', $object->getVisitorId()); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('visitor_id = ?', $object->getVisitorId()); $rowSet = $select->query()->fetchAll(); foreach ($rowSet as $row) { @@ -76,7 +82,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra if ($idx) { /** - * If we are here it means that we have two rows: one with known customer, but second just visitor is set + * If we are here it means that we have two rows: one with known customer and second with guest visitor * One row should be updated with customer_id, second should be deleted */ $adapter->delete($this->getMainTable(), ['index_id = ?' => $row['index_id']]); @@ -192,7 +198,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra * Add information about product ids to visitor/customer * * @param \Magento\Framework\Object|\Magento\Reports\Model\Product\Index\AbstractIndex $object - * @param array $productIds + * @param int[] $productIds * @return $this */ public function registerIds(\Magento\Framework\Object $object, $productIds) diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php index b172b4e053c274e51f42417e56f381343b2abb9d..77ea700b2cc00c843a8df396649870d0e9009b67 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php @@ -179,6 +179,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc /** * Set customer id, that will be used in 'whereCondition' + * @codeCoverageIgnore * * @param int $id * @return $this diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php index 0ad3ffd330f063475affcd8cb56e36a9e5b4b7b8..93a22cf0011189fb11b3306525879f4f7b4685a1 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php @@ -17,6 +17,7 @@ class Viewed extends \Magento\Reports\Model\Resource\Product\Index\AbstractIndex * Initialize connection and main resource table * * @return void + * @codeCoverageIgnore */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php index 84a6d7d6a25efac94bd4ff2f7f3935a5c2ee70c1..777d13232b2a349e64b58ff63cd0b382012232a6 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Model\Resource\Report; /** @@ -22,21 +20,29 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr protected $_flag = null; /** + * Logger instance + * * @var \Psr\Log\LoggerInterface */ protected $_logger; /** + * Locale date instance + * * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $_localeDate; /** + * Reports flag factory + * * @var \Magento\Reports\Model\FlagFactory */ protected $_reportsFlagFactory; /** + * Constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -179,7 +185,7 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr * @param string $whereColumn * @param null|string|\DateTime $from * @param null|string|\DateTime $to - * @param array $additionalWhere + * @param [][] $additionalWhere * @param string $alias * @return \Magento\Framework\DB\Select */ @@ -281,12 +287,12 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr * * @param string $table * @param string $relatedTable - * @param array $joinCondition + * @param [] $joinCondition * @param string $column * @param string $whereColumn * @param string|null $from * @param string|null $to - * @param array $additionalWhere + * @param [][] $additionalWhere * @param string $alias * @param string $relatedAlias * @return \Magento\Framework\DB\Select @@ -353,7 +359,7 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr /** * Retrieve query for attribute with timezone conversion * - * @param string|array $table + * @param string|[] $table * @param string $column * @param null|mixed $from * @param null|mixed $to diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection.php index 2de5f389f25247113bbb141ddfc84486d8ab7bd6..abc6db15ad0380ba97d6d0efc337961c4b775f65 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection.php @@ -96,6 +96,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Set period + * @codeCoverageIgnore * * @param int $period * @return $this @@ -108,6 +109,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Set interval + * @codeCoverageIgnore * * @param \DateTime $fromDate * @param \DateTime $toDate @@ -260,6 +262,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Set store ids + * @codeCoverageIgnore * * @param array $storeIds * @return $this @@ -272,6 +275,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Get store ids + * @codeCoverageIgnore * * @return array */ @@ -292,6 +296,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Set page size + * @codeCoverageIgnore * * @param int $size * @return $this @@ -304,6 +309,7 @@ class Collection extends \Magento\Framework\Data\Collection /** * Get page size + * @codeCoverageIgnore * * @return int */ diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php index 234d520b32b126a6641fb8288b09c2e990fe19de..4575ec6394c844f38d4d871042095f612de90e9e 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php @@ -64,6 +64,7 @@ class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection /** * Set array of columns that should be aggregated + * @codeCoverageIgnore * * @param array $columns * @return $this @@ -76,6 +77,7 @@ class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection /** * Retrieve array of columns that should be aggregated + * @codeCoverageIgnore * * @return array */ @@ -86,6 +88,7 @@ class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection /** * Set date range + * @codeCoverageIgnore * * @param mixed $from * @param mixed $to @@ -100,6 +103,7 @@ class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection /** * Set period + * @codeCoverageIgnore * * @param string $period * @return $this @@ -218,6 +222,7 @@ class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection /** * Setter for isSubTotals + * @codeCoverageIgnore * * @param bool $flag * @return $this 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 56e658e56db51f51339f45c7d28785fe9281dd62..432ebc9b5d432e6f4653e1789e280a6a0a595c4f 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Most viewed product report aggregate resource model * @@ -31,16 +29,22 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport const AGGREGATION_YEARLY = 'report_viewed_product_aggregated_yearly'; /** + * Product resource instance + * * @var \Magento\Catalog\Model\Resource\Product */ protected $_productResource; /** + * Resource helper instance + * * @var \Magento\Reports\Model\Resource\Helper */ protected $_resourceHelper; /** + * Constructor + * * @param \Magento\Framework\Model\Resource\Db\Context $context * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate diff --git a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php index 797b20da8555176e603785c511672062d90830ac..ab98d411ca05510003c9c9e4fc1cf7e8e2d7bfa7 100644 --- a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php @@ -60,6 +60,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Set wishlist table name + * @codeCoverageIgnore * * @param string $value * @return $this @@ -72,6 +73,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Retrieve wishlist table name + * @codeCoverageIgnore * * @return string */ diff --git a/app/code/Magento/Reports/Setup/InstallData.php b/app/code/Magento/Reports/Setup/InstallData.php index 071ed7c29645029f880b7af63cb0950259590f98..fef292ffb21a02c04131a4a1cd209555951f1496 100644 --- a/app/code/Magento/Reports/Setup/InstallData.php +++ b/app/code/Magento/Reports/Setup/InstallData.php @@ -7,8 +7,6 @@ namespace Magento\Reports\Setup; -// @codingStandardsIgnoreFile - use Magento\Cms\Model\PageFactory; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; @@ -82,11 +80,13 @@ class InstallData implements \Magento\Framework\Setup\InstallDataInterface $cms = $this->pageFactory->create(); $cms->load('home', 'identifier'); + // @codingStandardsIgnoreStart $reportLayoutUpdate = '<!-- <referenceContainer name="right"> <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.viewed</argument></action> <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.compared</argument></action> </referenceContainer>-->'; + // @codingStandardsIgnoreEnd /* * Merge and save old layout update data with report layout data diff --git a/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php b/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..81eb87c4cac8a1532b08a48e109af0a6c42327fd --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Helper/DataTest.php @@ -0,0 +1,147 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Helper; + +use Magento\Reports\Helper\Data; + +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Helper\Data + */ + protected $data; + + /** + * @var \Magento\Framework\App\Helper\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Reports\Model\ItemFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemFactoryMock; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->itemFactoryMock = $this->getMockBuilder('Magento\Reports\Model\ItemFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->data = new Data( + $this->contextMock, + $this->itemFactoryMock + ); + } + + /** + * @param string $from + * @param string $to + * @param string $period + * @param array $results + * @dataProvider intervalsDataProvider + * @return void + */ + public function testGetIntervals($from, $to, $period, $results) + { + $this->assertEquals($this->data->getIntervals($from, $to, $period), $results); + } + + /** + * @param string $from + * @param string $to + * @param string $period + * @param array $results + * @dataProvider intervalsDataProvider + * @return void + */ + public function testPrepareIntervalsCollection($from, $to, $period, $results) + { + $collection = $this->getMockBuilder('Magento\Framework\Data\Collection') + ->disableOriginalConstructor() + ->setMethods(['addItem']) + ->getMock(); + + $item = $this->getMockBuilder('Magento\Reports\Model\Item') + ->disableOriginalConstructor() + ->setMethods(['setPeriod', 'setIsEmpty']) + ->getMock(); + + $this->itemFactoryMock->expects($this->exactly(count($results))) + ->method('create') + ->willReturn($item); + $item->expects($this->exactly(count($results))) + ->method('setIsEmpty'); + $collection->expects($this->exactly(count($results))) + ->method('addItem'); + + foreach ($results as $key => $result) { + $item->expects($this->at($key + $key)) + ->method('setPeriod') + ->with($result); + } + + $this->data->prepareIntervalsCollection($collection, $from, $to, $period); + } + + /** + * @return array + */ + public function intervalsDataProvider() + { + return [ + [ + 'from' => '2000-01-15 10:00:00', + 'to' => '2000-01-15 11:00:00', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_DAY, + 'results' => ['2000-01-15'] + ], + [ + 'from' => '2000-01-15 10:00:00', + 'to' => '2000-01-17 10:00:00', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_MONTH, + 'results' => ['2000-01'] + ], + [ + 'from' => '2000-01-15 10:00:00', + 'to' => '2000-02-15 10:00:00', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_YEAR, + 'results' => ['2000'] + ], + [ + 'from' => '2000-01-15 10:00:00', + 'to' => '2000-01-16 11:00:00', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_DAY, + 'results' => ['2000-01-15', '2000-01-16'] + ], + [ + 'from' => '2000-01-15 10:00:00', + 'to' => '2000-02-17 10:00:00', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_MONTH, + 'results' => ['2000-01', '2000-02'] + ], + [ + 'from' => '2000-01-15 10:00:00', + 'to' => '2003-02-15 10:00:00', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_YEAR, + 'results' => ['2000', '2001', '2002', '2003'] + ], + [ + 'from' => '', + 'to' => '', + 'period' => \Magento\Reports\Helper\Data::REPORT_PERIOD_TYPE_YEAR, + 'results' => [] + ] + ]; + } +} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php b/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php index ba4dc5396b30df834f76dba8b40183af149af079..7e53522ac6680d17587318727bf538a6bebbdd0e 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php @@ -47,6 +47,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase */ protected $productCompModelMock; + /** + * @var \Magento\Reports\Model\Product\Index\ViewedFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productIndexFactoryMock; + + /** + * {@inheritDoc} + */ public function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -56,13 +64,13 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->customerVisitorMock = $this->getMockBuilder('Magento\Customer\Model\Visitor') ->disableOriginalConstructor()->getMock(); - $productIndexFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ViewedFactory') + $this->productIndexFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ViewedFactory') ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->productIndexMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Viewed') ->disableOriginalConstructor()->getMock(); - $productIndexFactoryMock->expects($this->any()) + $this->productIndexFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->productIndexMock); @@ -84,20 +92,25 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $storeManager->expects($this->any()) ->method('getStore') ->willReturn($this->storeMock); - $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') + + $this->productCompModelMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') ->disableOriginalConstructor() - ->setMethods(['create']) ->getMock(); - $this->productCompModelMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + + $this->productCompFactoryMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\ComparedFactory') ->disableOriginalConstructor() + ->setMethods(['create']) ->getMock(); + $this->productCompFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->productCompModelMock); $this->observer = $objectManager->getObject( 'Magento\Reports\Model\Event\Observer', [ 'customerSession' => $this->customerSessionMock, 'customerVisitor' => $this->customerVisitorMock, - 'productIndxFactory' => $productIndexFactoryMock, + 'productIndxFactory' => $this->productIndexFactoryMock, 'productCompFactory' => $this->productCompFactoryMock, 'storeManager' => $storeManager, 'event' => $reportEventFactory @@ -105,6 +118,9 @@ class ObserverTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testCatalogProductViewCustomer() { $productId = 5; @@ -123,17 +139,10 @@ class ObserverTest extends \PHPUnit_Framework_TestCase 'store_id' => $storeId, ]; - $this->storeMock->expects($this->any()) - ->method('getId') - ->willReturn($storeId); - - $this->customerSessionMock->expects($this->any()) - ->method('isLoggedIn') - ->willReturn(true); + $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId); - $this->customerSessionMock->expects($this->any()) - ->method('getCustomerId') - ->willReturn($customerId); + $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn(true); + $this->customerSessionMock->expects($this->any())->method('getCustomerId')->willReturn($customerId); $this->prepareProductIndexMock($expectedViewedData); $this->prepareReportEventModel($expectedEventData); @@ -141,6 +150,9 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->observer->catalogProductView($eventObserver); } + /** + * @return void + */ public function testCatalogProductViewVisitor() { $productId = 6; @@ -159,17 +171,11 @@ class ObserverTest extends \PHPUnit_Framework_TestCase 'store_id' => $storeId, ]; - $this->storeMock->expects($this->any()) - ->method('getId') - ->willReturn($storeId); + $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId); - $this->customerSessionMock->expects($this->any()) - ->method('isLoggedIn') - ->willReturn(false); + $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn(false); - $this->customerVisitorMock->expects($this->any()) - ->method('getId') - ->willReturn($visitorId); + $this->customerVisitorMock->expects($this->any())->method('getId')->willReturn($visitorId); $this->prepareProductIndexMock($expectedViewedData); $this->prepareReportEventModel($expectedEventData); @@ -182,6 +188,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase * @param string $userKey * @param int $userId * @dataProvider catalogProductCompareAddProductDataProvider + * @return void */ public function testCatalogProductCompareAddProduct($isLoggedIn, $userKey, $userId) { @@ -193,31 +200,84 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $userKey => $userId ]; $observerMock = $this->getObserverMock($productId); - $this->customerSessionMock->expects($this->any()) - ->method('isLoggedIn') - ->willReturn($isLoggedIn); - $this->customerSessionMock->expects($this->any()) - ->method('getCustomerId') - ->willReturn($customerId); - $this->customerVisitorMock->expects($this->any()) - ->method('getId') - ->willReturn($visitorId); - $this->productCompFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($this->productCompModelMock); - $this->productCompModelMock->expects($this->any()) - ->method('setData') - ->with($viewData) - ->willReturnSelf(); - $this->productCompModelMock->expects($this->any()) - ->method('save') - ->willReturnSelf(); - $this->productCompModelMock->expects($this->any()) - ->method('calculate') - ->willReturnSelf(); + + $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn($isLoggedIn); + $this->customerSessionMock->expects($this->any())->method('getCustomerId')->willReturn($customerId); + + $this->customerVisitorMock->expects($this->any())->method('getId')->willReturn($visitorId); + + $this->productCompModelMock->expects($this->any())->method('setData')->with($viewData)->willReturnSelf(); + $this->productCompModelMock->expects($this->any())->method('save')->willReturnSelf(); + $this->productCompModelMock->expects($this->any())->method('calculate')->willReturnSelf(); + $this->assertEquals($this->observer, $this->observer->catalogProductCompareAddProduct($observerMock)); } + /** + * @return void + */ + public function testCustomerLoginLoggedInTrue() + { + $customerId = 222; + $visitorId = 333; + $observerMock = $this->getObserverMock(111); + + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true); + $this->customerSessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); + + $this->customerVisitorMock->expects($this->once())->method('getId')->willReturn($visitorId); + + $this->reportEventMock->expects($this->once())->method('updateCustomerType')->with($visitorId, $customerId); + + $this->productCompModelMock->expects($this->once())->method('updateCustomerFromVisitor')->willReturnSelf(); + $this->productCompModelMock->expects($this->once())->method('calculate')->willReturnSelf(); + + $this->productIndexMock->expects($this->once())->method('updateCustomerFromVisitor')->willReturnSelf(); + $this->productIndexMock->expects($this->once())->method('calculate')->willReturnSelf(); + + $this->assertEquals($this->observer, $this->observer->customerLogin($observerMock)); + } + + /** + * @return void + */ + public function testCustomerLoginLoggedInFalse() + { + $observerMock = $this->getObserverMock(111); + + $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false); + $this->customerSessionMock->expects($this->never())->method('getCustomerId'); + + $this->customerVisitorMock->expects($this->never())->method('getId'); + + $this->productCompModelMock->expects($this->never())->method('updateCustomerFromVisitor')->willReturnSelf(); + $this->productCompModelMock->expects($this->never())->method('calculate')->willReturnSelf(); + + $this->productIndexMock->expects($this->never())->method('updateCustomerFromVisitor')->willReturnSelf(); + $this->productIndexMock->expects($this->never())->method('calculate')->willReturnSelf(); + + $this->assertEquals($this->observer, $this->observer->customerLogin($observerMock)); + } + + /** + * @return void + */ + public function testCustomerLogout() + { + $observerMock = $this->getObserverMock(111); + + $this->productCompModelMock->expects($this->once())->method('purgeVisitorByCustomer')->willReturnSelf(); + $this->productCompModelMock->expects($this->once())->method('calculate')->willReturnSelf(); + + $this->productIndexMock->expects($this->once())->method('purgeVisitorByCustomer')->willReturnSelf(); + $this->productIndexMock->expects($this->once())->method('calculate')->willReturnSelf(); + + $this->assertEquals($this->observer, $this->observer->customerLogout($observerMock)); + } + + /** + * @return array + */ public function catalogProductCompareAddProductDataProvider() { return [ @@ -260,14 +320,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase */ protected function prepareReportEventModel($expectedEventData) { - $this->reportEventMock->expects($this->any()) - ->method('setData') - ->with($expectedEventData) - ->willReturnSelf(); - - $this->reportEventMock->expects($this->any()) - ->method('save') - ->willReturnSelf(); + $this->reportEventMock->expects($this->any())->method('setData')->with($expectedEventData)->willReturnSelf(); + $this->reportEventMock->expects($this->any())->method('save')->willReturnSelf(); } /** @@ -276,22 +330,21 @@ class ObserverTest extends \PHPUnit_Framework_TestCase */ protected function getObserverMock($productId) { - $eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer')->disableOriginalConstructor() + $eventObserverMock = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() ->getMock(); - $eventMock = $this->getMockBuilder('Magento\Framework\Event')->disableOriginalConstructor() + $eventMock = $this->getMockBuilder('Magento\Framework\Event') + ->disableOriginalConstructor() ->setMethods(['getProduct'])->getMock(); - $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() ->getMock(); - $productMock->expects($this->any()) - ->method('getId') - ->willReturn($productId); - $eventMock->expects($this->any()) - ->method('getProduct') - ->willReturn($productMock); - $eventObserverMock->expects($this->any()) - ->method('getEvent') - ->willReturn($eventMock); + $productMock->expects($this->any())->method('getId')->willReturn($productId); + + $eventMock->expects($this->any())->method('getProduct')->willReturn($productMock); + + $eventObserverMock->expects($this->any())->method('getEvent')->willReturn($eventMock); return $eventObserverMock; } diff --git a/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php b/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php index a6585041528a549b1d69b10135614c1270f44937..f9ee6d86285e0aad348824a00a26ae17f2e42e7f 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Plugin/LogTest.php @@ -3,82 +3,84 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Reports\Test\Unit\Model\Plugin; +use Magento\Reports\Model\Plugin\Log; + class LogTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Reports\Model\Plugin\Log */ - protected $model; + protected $log; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Reports\Model\Event|\PHPUnit_Framework_MockObject_MockObject */ - protected $reportEventMock; + protected $eventMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Reports\Model\Product\Index\Compared|\PHPUnit_Framework_MockObject_MockObject */ - protected $cmpProductIdxMock; + protected $comparedMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Reports\Model\Product\Index\Viewed|\PHPUnit_Framework_MockObject_MockObject */ - protected $viewProductIdxMock; + protected $viewedMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Log\Model\Resource\Log|\PHPUnit_Framework_MockObject_MockObject */ protected $logResourceMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Log\Model\Resource\Log|\PHPUnit_Framework_MockObject_MockObject */ protected $subjectMock; + /** + * {@inheritDoc} + */ protected function setUp() { - $this->reportEventMock = $this->getMock('Magento\Reports\Model\Event', [], [], '', false); - $this->cmpProductIdxMock = $this->getMock( - 'Magento\Reports\Model\Product\Index\Compared', - [], - [], - '', - false - ); - $this->viewProductIdxMock = $this->getMock( - 'Magento\Reports\Model\Product\Index\Viewed', - [], - [], - '', - false - ); + $this->eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + ->disableOriginalConstructor() + ->getMock(); + $this->comparedMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Compared') + ->disableOriginalConstructor() + ->getMock(); + $this->viewedMock = $this->getMockBuilder('Magento\Reports\Model\Product\Index\Viewed') + ->disableOriginalConstructor() + ->getMock(); - $this->logResourceMock = $this->getMock('Magento\Log\Model\Resource\Log', [], [], '', false); + $this->logResourceMock = $this->getMockBuilder('Magento\Log\Model\Resource\Log') + ->disableOriginalConstructor() + ->getMock(); + $this->subjectMock = $this->getMockBuilder('Magento\Log\Model\Resource\Log') + ->disableOriginalConstructor() + ->getMock(); - $this->subjectMock = $this->getMock('Magento\Log\Model\Resource\Log', [], [], '', false); - $this->model = new \Magento\Reports\Model\Plugin\Log( - $this->reportEventMock, - $this->cmpProductIdxMock, - $this->viewProductIdxMock + $this->log = new Log( + $this->eventMock, + $this->comparedMock, + $this->viewedMock ); } /** - * @covers \Magento\Reports\Model\Plugin\Log::afterClean + * @return void */ public function testAfterClean() { - $this->reportEventMock->expects($this->once())->method('clean'); - - $this->cmpProductIdxMock->expects($this->once())->method('clean'); - - $this->viewProductIdxMock->expects($this->once())->method('clean'); + $this->eventMock->expects($this->once())->method('clean'); + $this->comparedMock->expects($this->once())->method('clean'); + $this->viewedMock->expects($this->once())->method('clean'); $this->assertEquals( $this->logResourceMock, - $this->model->afterClean($this->subjectMock, $this->logResourceMock) + $this->log->afterClean($this->subjectMock, $this->logResourceMock) ); } } diff --git a/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php b/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7a2a7213a6b7899f7f89fd47a04bb66fb31539ea --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/Product/Index/ComparedTest.php @@ -0,0 +1,149 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Model\Product\Index; + +use Magento\Reports\Model\Product\Index\Compared; + +class ComparedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Model\Product\Index\Compared + */ + protected $compared; + + /** + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \Magento\Customer\Model\Visitor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $visitorMock; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\Session\Generic|\PHPUnit_Framework_MockObject_MockObject + */ + protected $genericMock; + + /** + * @var \Magento\Catalog\Model\Product\Visibility|\PHPUnit_Framework_MockObject_MockObject + */ + protected $visibilityMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTimeMock; + + /** + * @var \Magento\Catalog\Helper\Product\Compare|\PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogProductHelperMock; + + /** + * @var \Magento\Framework\Model\Resource\AbstractResource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * @var \Magento\Framework\Data\Collection\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dbMock; + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->getMock(); + $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->getMock(); + $this->visitorMock = $this->getMockBuilder('Magento\Customer\Model\Visitor') + ->disableOriginalConstructor() + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->getMock(); + $this->genericMock = $this->getMockBuilder('Magento\Framework\Session\Generic') + ->disableOriginalConstructor() + ->getMock(); + $this->visibilityMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Visibility') + ->disableOriginalConstructor() + ->getMock(); + $this->dateTimeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime') + ->getMock(); + $this->catalogProductHelperMock = $this->getMockBuilder('Magento\Catalog\Helper\Product\Compare') + ->disableOriginalConstructor() + ->getMock(); + + $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\Resource\AbstractResource') + ->disableOriginalConstructor() + ->setMethods(['getIdFieldName', '_construct', '_getReadAdapter', '_getWriteAdapter']) + ->getMock(); + $this->dbMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + ->disableOriginalConstructor() + ->getMock(); + + $this->compared = new Compared( + $this->contextMock, + $this->registryMock, + $this->storeManagerMock, + $this->visitorMock, + $this->sessionMock, + $this->genericMock, + $this->visibilityMock, + $this->dateTimeMock, + $this->catalogProductHelperMock, + $this->resourceMock, + $this->dbMock + ); + } + + /** + * @return void + */ + public function testGetExcludeProductIds() + { + $collection = $this->getMockBuilder('Magento\Catalog\Model\Resource\Product\Compare\Item\Collection') + ->disableOriginalConstructor() + ->setMethods(['getEntityId']) + ->getMock(); + $collection->expects($this->once())->method('getEntityId')->willReturn(1); + + $product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $product->expects($this->once())->method('getId')->willReturn(2); + + $this->catalogProductHelperMock->expects($this->once())->method('hasItems')->willReturn(true); + $this->catalogProductHelperMock->expects($this->once())->method('getItemCollection')->willReturn([$collection]); + + $this->registryMock->expects($this->any())->method('registry')->willReturn($product); + + $this->assertEquals([1, 2], $this->compared->getExcludeProductIds()); + } +} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Event/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Event/CollectionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2191830c60ffd3ebdad30f105190cc31f9aa2b7f --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Event/CollectionTest.php @@ -0,0 +1,161 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Model\Resource\Event; + +use Magento\Reports\Model\Resource\Event\Collection; + +class CollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Model\Resource\Event\Collection + */ + protected $collection; + + /** + * @var \Magento\Framework\Data\Collection\EntityFactoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityFactoryMock; + + /** + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fetchStrategyMock; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $managerMock; + + /** + * @var \Magento\Framework\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * @var \Zend_Db_Adapter_Abstract|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dbMock; + + /** + * @var \Zend_Db_Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactoryInterface') + ->getMock(); + $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + ->getMock(); + $this->fetchStrategyMock = $this->getMockBuilder('Magento\Framework\Data\Collection\Db\FetchStrategyInterface') + ->getMock(); + $this->managerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->getMock(); + + $this->selectMock = $this->getMockBuilder('Zend_Db_Select') + ->setMethods(['where', 'from']) + ->disableOriginalConstructor() + ->getMock(); + $this->selectMock->expects($this->any()) + ->method('from') + ->willReturnSelf(); + $this->selectMock->expects($this->any()) + ->method('where') + ->willReturnSelf(); + + $this->dbMock = $this->getMockBuilder('Zend_Db_Adapter_Abstract') + ->disableOriginalConstructor() + ->getMock(); + $this->dbMock->expects($this->any()) + ->method('select') + ->willReturn($this->selectMock); + + $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\AbstractDb') + ->disableOriginalConstructor() + ->setMethods(['getReadConnection', 'getCurrentStoreIds', '_construct', 'getMainTable', 'getTable']) + ->getMock(); + $this->resourceMock->expects($this->any()) + ->method('getReadConnection') + ->willReturn($this->dbMock); + + $this->collection = new Collection( + $this->entityFactoryMock, + $this->loggerMock, + $this->fetchStrategyMock, + $this->managerMock, + null, + $this->resourceMock + ); + } + + /** + * @param mixed $ignoreData + * @param 'string' $ignoreSql + * @dataProvider ignoresDataProvider + * @return void + */ + public function testAddStoreFilter($ignoreData, $ignoreSql) + { + $typeId = 1; + $subjectId =2; + $subtype = 3; + $limit = 0; + $stores = [1, 2]; + + $this->resourceMock + ->expects($this->once()) + ->method('getCurrentStoreIds') + ->willReturn($stores); + $this->selectMock + ->expects($this->at(0)) + ->method('where') + ->with('event_type_id = ?', $typeId); + $this->selectMock + ->expects($this->at(1)) + ->method('where') + ->with('subject_id = ?', $subjectId); + $this->selectMock + ->expects($this->at(2)) + ->method('where') + ->with('subtype = ?', $subtype); + $this->selectMock + ->expects($this->at(3)) + ->method('where') + ->with('store_id IN(?)', $stores); + $this->selectMock + ->expects($this->at(4)) + ->method('where') + ->with($ignoreSql, $ignoreData); + + $this->collection->addRecentlyFiler($typeId, $subjectId, $subtype, $ignoreData, $limit); + } + + /** + * @return array + */ + public function ignoresDataProvider() + { + return [ + [ + 'ignoreData' => 1, + 'ignoreSql' => 'object_id <> ?' + ], + [ + 'ignoreData' => [1], + 'ignoreSql' => 'object_id NOT IN(?)' + ] + ]; + } +} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/EventTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/EventTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5d1dc3bbcea0733b49ccf35ba68ae9f3d948581a --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/EventTest.php @@ -0,0 +1,248 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Model\Resource; + +use Magento\Reports\Model\Resource\Event; + +class EventTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Model\Resource\Event + */ + protected $event; + + /** + * @var \Magento\Framework\Model\Resource\Db\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connectionMock; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->getMock(); + + $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->getMock(); + + $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + + $this->storeManagerMock + ->expects($this->any()) + ->method('getStore') + ->willReturn($this->storeMock); + + $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->getMock(); + + $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->getMock(); + $this->resourceMock + ->expects($this->any()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->contextMock + ->expects($this->any()) + ->method('getResources') + ->willReturn($this->resourceMock); + + $this->event = new Event( + $this->contextMock, + $this->scopeConfigMock, + $this->storeManagerMock + ); + } + + /** + * @return void + */ + public function testUpdateCustomerTypeWithoutType() + { + $eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + ->disableOriginalConstructor() + ->getMock(); + $this->connectionMock + ->expects($this->never()) + ->method('update'); + + $this->event->updateCustomerType($eventMock, 1, 1); + + } + + /** + * @return void + */ + public function testUpdateCustomerTypeWithType() + { + $eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + ->disableOriginalConstructor() + ->getMock(); + $this->connectionMock + ->expects($this->once()) + ->method('update'); + + $this->event->updateCustomerType($eventMock, 1, 1, ['type']); + + } + + /** + * @return void + */ + public function testApplyLogToCollection() + { + $derivedSelect = 'SELECT * FROM table'; + $idFieldName = 'IdFieldName'; + + $collectionSelectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + ->disableOriginalConstructor() + ->setMethods(['joinInner', 'order']) + ->getMock(); + $collectionSelectMock + ->expects($this->once()) + ->method('joinInner') + ->with( + ['evt' => new \Zend_Db_Expr("({$derivedSelect})")], + "{$idFieldName} = evt.object_id", + [] + ) + ->willReturnSelf(); + $collectionSelectMock + ->expects($this->once()) + ->method('order') + ->willReturnSelf(); + + $collectionMock = $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') + ->disableOriginalConstructor() + ->getMock(); + $collectionMock + ->expects($this->once()) + ->method('getResource') + ->willReturnSelf(); + $collectionMock + ->expects($this->once()) + ->method('getIdFieldName') + ->willReturn($idFieldName); + $collectionMock + ->expects($this->any()) + ->method('getSelect') + ->willReturn($collectionSelectMock); + + $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + ->disableOriginalConstructor() + ->setMethods(['from', 'where', 'group', 'joinInner', '__toString']) + ->getMock(); + $selectMock + ->expects($this->once()) + ->method('from') + ->willReturnSelf(); + $selectMock + ->expects($this->any()) + ->method('where') + ->willReturnSelf(); + $selectMock + ->expects($this->once()) + ->method('group') + ->willReturnSelf(); + $selectMock + ->expects($this->any()) + ->method('__toString') + ->willReturn($derivedSelect); + + $this->connectionMock + ->expects($this->once()) + ->method('select') + ->willReturn($selectMock); + + $this->storeMock + ->expects($this->any()) + ->method('getId') + ->willReturn(1); + + $this->event->applyLogToCollection($collectionMock, 1, 1, 1); + } + + /** + * @return void + */ + public function testClean() + { + $eventMock = $this->getMockBuilder('Magento\Reports\Model\Event') + ->disableOriginalConstructor() + ->getMock(); + + $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + ->disableOriginalConstructor() + ->setMethods(['select', 'from', 'joinLeft', 'where', 'limit', 'fetchCol']) + ->getMock(); + + $this->connectionMock + ->expects($this->at(3)) + ->method('fetchCol') + ->willReturn(1); + $this->connectionMock + ->expects($this->once()) + ->method('delete'); + $this->connectionMock + ->expects($this->any()) + ->method('select') + ->willReturn($selectMock); + + $selectMock + ->expects($this->exactly(2)) + ->method('from') + ->willReturnSelf(); + $selectMock + ->expects($this->exactly(2)) + ->method('joinLeft') + ->willReturnSelf(); + $selectMock + ->expects($this->any()) + ->method('where') + ->willReturnSelf(); + $selectMock + ->expects($this->exactly(2)) + ->method('limit') + ->willReturnSelf(); + + $this->event->clean($eventMock); + } +} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/HelperTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/HelperTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b000c4ad43ab230bf9b648241354cb3cd60b65d3 --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/HelperTest.php @@ -0,0 +1,122 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Model\Resource; + +use Magento\Reports\Model\Resource\Helper; + +class HelperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Model\Resource\Helper + */ + protected $helper; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connectionMock; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->getMock(); + + $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->getMock(); + + $this->resourceMock + ->expects($this->any()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->helper = new Helper( + $this->resourceMock + ); + } + + /** + * @return void + */ + public function testMergeVisitorProductIndex() + { + $mainTable = 'mainTable'; + $data = ['dataKey' => 'dataValue']; + $matchFields = ['matchField']; + + $this->connectionMock + ->expects($this->once()) + ->method('insertOnDuplicate') + ->with($mainTable, $data, array_keys($data)); + + $this->helper->mergeVisitorProductIndex($mainTable, $data, $matchFields); + } + + /** + * @param string $type + * @param array $result + * @dataProvider typesDataProvider + * @return void + */ + public function testUpdateReportRatingPos($type, $result) + { + $mainTable = 'mainTable'; + $column = 'column'; + $aggregationTable = 'aggregationTable'; + + $selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + ->disableOriginalConstructor() + ->getMock(); + $selectMock + ->expects($this->any()) + ->method('from') + ->willReturnSelf(); + $selectMock + ->expects($this->once()) + ->method('group') + ->willReturnSelf(); + $selectMock + ->expects($this->once()) + ->method('order') + ->willReturnSelf(); + $selectMock + ->expects($this->once()) + ->method('insertFromSelect') + ->with($aggregationTable, $result) + ->willReturnSelf(); + + $this->connectionMock + ->expects($this->any()) + ->method('select') + ->willReturn($selectMock); + + $this->helper->updateReportRatingPos($this->connectionMock, $type, $column, $mainTable, $aggregationTable); + } + + /** + * @return array + */ + public function typesDataProvider() + { + $mResult = ['period', 'store_id', 'product_id', 'product_name', 'product_price', 'column', 'rating_pos']; + $dResult = ['period', 'store_id', 'product_id', 'product_name', 'product_price', 'id', 'column', 'rating_pos']; + return [ + ['type' => 'year', 'result' => $mResult], + ['type' => 'month', 'result' => $mResult], + ['type' => 'day', 'result' => $dResult], + ['type' => null, 'result' => $mResult] + ]; + } +} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Order/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Order/CollectionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..22a6bb1be49c2719d81af2339c7feef95295a195 --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Order/CollectionTest.php @@ -0,0 +1,509 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Model\Resource\Order; + +use Magento\Reports\Model\Resource\Order\Collection; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class CollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Model\Resource\Order\Collection + */ + protected $collection; + + /** + * @var \Magento\Framework\Data\Collection\EntityFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityFactoryMock; + + /** + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fetchStrategyMock; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $managerMock; + + /** + * @var \Magento\Sales\Model\Resource\EntitySnapshot|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entitySnapshotMock; + + /** + * @var \Magento\Framework\DB\Helper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $timezoneMock; + + /** + * @var \Magento\Sales\Model\Order\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\OrderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactoryMock; + + /** + * @var \Zend_Db_Adapter_Abstract|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dbMock; + + /** + * @var \Zend_Db_Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Magento\Framework\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + ->getMock(); + $this->fetchStrategyMock = $this->getMockBuilder('Magento\Framework\Data\Collection\Db\FetchStrategyInterface') + ->getMock(); + $this->managerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->getMock(); + $this->entitySnapshotMock = $this->getMockBuilder('Magento\Sales\Model\Resource\EntitySnapshot') + ->disableOriginalConstructor() + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\Framework\DB\Helper') + ->disableOriginalConstructor() + ->getMock(); + $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->getMock(); + $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->getMock(); + $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->getMock(); + $this->configMock = $this->getMockBuilder('Magento\Sales\Model\Order\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\OrderFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->selectMock = $this->getMockBuilder('Zend_Db_Select') + ->disableOriginalConstructor() + ->getMock(); + $this->selectMock + ->expects($this->any()) + ->method('columns') + ->willReturnSelf(); + $this->selectMock + ->expects($this->any()) + ->method('where') + ->willReturnSelf(); + $this->selectMock + ->expects($this->any()) + ->method('order') + ->willReturnSelf(); + $this->selectMock + ->expects($this->any()) + ->method('group') + ->willReturnSelf(); + $this->selectMock + ->expects($this->any()) + ->method('getPart') + ->willReturn([]); + + $this->dbMock = $this->getMockForAbstractClass( + 'Zend_Db_Adapter_Abstract', + [], + '', + false, + true, + true, + ['select', 'getIfNullSql', 'getDateFormatSql', 'prepareSqlCondition', 'getCheckSql'] + ); + $this->dbMock + ->expects($this->any()) + ->method('select') + ->willReturn($this->selectMock); + + $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\AbstractDb') + ->disableOriginalConstructor() + ->getMock(); + $this->resourceMock + ->expects($this->once()) + ->method('getReadConnection') + ->willReturn($this->dbMock); + + $this->collection = new Collection( + $this->entityFactoryMock, + $this->loggerMock, + $this->fetchStrategyMock, + $this->managerMock, + $this->entitySnapshotMock, + $this->helperMock, + $this->scopeConfigMock, + $this->storeManagerMock, + $this->timezoneMock, + $this->configMock, + $this->orderFactoryMock, + null, + $this->resourceMock + ); + } + + /** + * @return void + */ + public function testCheckIsLive() + { + $range = ''; + $this->scopeConfigMock + ->expects($this->once()) + ->method('getValue') + ->with( + 'sales/dashboard/use_aggregated_data', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + $this->collection->checkIsLive($range); + } + + /** + * @param int $useAggregatedData + * @param string $mainTable + * @param int $isFilter + * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getIfNullSqlResult + * @dataProvider useAggregatedDataDataProvider + * @return void + */ + public function testPrepareSummary($useAggregatedData, $mainTable, $isFilter, $getIfNullSqlResult) + { + $range = ''; + $customStart = 1; + $customEnd = 10; + + $this->scopeConfigMock + ->expects($this->once()) + ->method('getValue') + ->with( + 'sales/dashboard/use_aggregated_data', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->willReturn($useAggregatedData); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Order') + ->disableOriginalConstructor() + ->getMock(); + + $this->orderFactoryMock + ->expects($this->any()) + ->method('create') + ->willReturn($orderMock); + + $this->resourceMock + ->expects($this->at(0)) + ->method('getTable') + ->with($mainTable); + + $this->dbMock + ->expects($getIfNullSqlResult) + ->method('getIfNullSql'); + + $this->collection->prepareSummary($range, $customStart, $customEnd, $isFilter); + } + + /** + * @param int $range + * @param string $customStart + * @param string $customEnd + * @param string $expectedInterval + * @dataProvider firstPartDateRangeDataProvider + * @return void + */ + public function testGetDateRangeFirstPart($range, $customStart, $customEnd, $expectedInterval) + { + $result = $this->collection->getDateRange($range, $customStart, $customEnd); + $interval = $result['to']->diff($result['from']); + $intervalResult = $interval->format('%y %m %d %h:%i:%s'); + $this->assertEquals($expectedInterval, $intervalResult); + } + + /** + * @param int $range + * @param string $customStart + * @param string $customEnd + * @param string $config + * @dataProvider secondPartDateRangeDataProvider + * @return void + */ + public function testGetDateRangeSecondPart($range, $customStart, $customEnd, $config) + { + $this->scopeConfigMock + ->expects($this->once()) + ->method('getValue') + ->with( + $config, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->willReturn(1); + + $result = $this->collection->getDateRange($range, $customStart, $customEnd); + $this->assertEquals(3, count($result)); + } + + /** + * @return void + */ + public function testGetDateRangeWithReturnObject() + { + $this->assertEquals(2, count($this->collection->getDateRange('7d', '', '', true))); + $this->assertEquals(3, count($this->collection->getDateRange('7d', '', '', false))); + } + + /** + * @return void + */ + public function testAddItemCountExpr() + { + $this->selectMock + ->expects($this->once()) + ->method('columns') + ->with(['items_count' => 'total_item_count'], 'main_table'); + $this->collection->addItemCountExpr(); + } + + /** + * @param int $isFilter + * @param int $useAggregatedData + * @param string $mainTable + * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getIfNullSqlResult + * @dataProvider totalsDataProvider + * @return void + */ + public function testCalculateTotals($isFilter, $useAggregatedData, $mainTable, $getIfNullSqlResult) + { + $this->scopeConfigMock + ->expects($this->once()) + ->method('getValue') + ->with( + 'sales/dashboard/use_aggregated_data', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->willReturn($useAggregatedData); + + $this->resourceMock + ->expects($this->at(0)) + ->method('getTable') + ->with($mainTable); + + $this->dbMock + ->expects($getIfNullSqlResult) + ->method('getIfNullSql'); + + $this->collection->checkIsLive(''); + $this->collection->calculateTotals($isFilter); + } + + /** + * @param int $isFilter + * @param string $useAggregatedData + * @param string $mainTable + * @dataProvider salesDataProvider + * @return void + */ + public function testCalculateSales($isFilter, $useAggregatedData, $mainTable) + { + $this->scopeConfigMock + ->expects($this->once()) + ->method('getValue') + ->with( + 'sales/dashboard/use_aggregated_data', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->willReturn($useAggregatedData); + + $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + + $this->storeManagerMock + ->expects($this->any()) + ->method('getStore') + ->willReturn($storeMock); + + $this->resourceMock + ->expects($this->at(0)) + ->method('getTable') + ->with($mainTable); + + $this->collection->calculateSales($isFilter); + } + + /** + * @return void + */ + public function testSetDateRange() + { + $fromDate = '1'; + $toDate = '2'; + + $this->dbMock + ->expects($this->at(0)) + ->method('prepareSqlCondition') + ->with('"created_at"', ['from' => $fromDate, 'to' => $toDate]); + + $this->collection->setDateRange($fromDate, $toDate); + } + + /** + * @param array $storeIds + * @param array $parameters + * @dataProvider storesDataProvider + * @return void + */ + public function testSetStoreIds($storeIds, $parameters) + { + $this->dbMock + ->expects($this->any()) + ->method('getIfNullSql') + ->willReturn('text'); + + $this->selectMock + ->expects($this->once()) + ->method('columns') + ->with($parameters) + ->willReturnSelf(); + + $this->collection->setStoreIds($storeIds); + } + + /** + * @return array + */ + public function useAggregatedDataDataProvider() + { + return [ + [1, 'sales_order_aggregated_created', 0, $this->never()], + [0, 'sales_order', 0, $this->exactly(7)], + [0, 'sales_order', 1, $this->exactly(6)] + ]; + } + + /** + * @return array + */ + public function firstPartDateRangeDataProvider() + { + return [ + ['', '', '', '0 0 0 23:59:59'], + ['24h', '', '', '0 0 1 0:0:0'], + ['7d', '', '', '0 0 6 23:59:59'] + ]; + } + + /** + * @return array + */ + public function secondPartDateRangeDataProvider() + { + return [ + ['1m', 1, 10, 'reports/dashboard/mtd_start'], + ['1y', 1, 10, 'reports/dashboard/ytd_start'], + ['2y', 1, 10, 'reports/dashboard/ytd_start'] + ]; + } + + /** + * @return array + */ + public function totalsDataProvider() + { + return [ + [1, 1, 'sales_order_aggregated_created', $this->never()], + [0, 1, 'sales_order_aggregated_created', $this->never()], + [1, 0, 'sales_order', $this->exactly(10)], + [0, 0, 'sales_order', $this->exactly(11)] + ]; + } + + /** + * @return array + */ + public function salesDataProvider() + { + return [ + [1, 1, 'sales_order_aggregated_created'], + [0, 1, 'sales_order_aggregated_created'], + [1, 0, 'sales_order'], + [0, 0, 'sales_order'] + ]; + } + + /** + * @return array + */ + public function storesDataProvider() + { + $firstReturn = [ + 'subtotal' => 'SUM(main_table.base_subtotal * main_table.base_to_global_rate)', + 'tax' => 'SUM(main_table.base_tax_amount * main_table.base_to_global_rate)', + 'shipping' => 'SUM(main_table.base_shipping_amount * main_table.base_to_global_rate)', + 'discount' => 'SUM(main_table.base_discount_amount * main_table.base_to_global_rate)', + 'total' => 'SUM(main_table.base_grand_total * main_table.base_to_global_rate)', + 'invoiced' => 'SUM(main_table.base_total_paid * main_table.base_to_global_rate)', + 'refunded' => 'SUM(main_table.base_total_refunded * main_table.base_to_global_rate)', + 'profit' => 'SUM(text * main_table.base_to_global_rate) + SUM(text * main_table.base_to_global_rate) '. + '- SUM(text * main_table.base_to_global_rate) - SUM(text * main_table.base_to_global_rate) '. + '- SUM(text * main_table.base_to_global_rate)', + ]; + + $secondReturn = [ + 'subtotal' => 'SUM(main_table.base_subtotal)', + 'tax' => 'SUM(main_table.base_tax_amount)', + 'shipping' => 'SUM(main_table.base_shipping_amount)', + 'discount' => 'SUM(main_table.base_discount_amount)', + 'total' => 'SUM(main_table.base_grand_total)', + 'invoiced' => 'SUM(main_table.base_total_paid)', + 'refunded' => 'SUM(main_table.base_total_refunded)', + 'profit' => 'SUM(text) + SUM(text) - SUM(text) - SUM(text) - SUM(text)', + ]; + + return [ + [[], $firstReturn], + [[1], $secondReturn] + ]; + } +} diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php index 96ad13c9b21868aa019927b72cee62eba019797b..ed5075a8bf70b7e4aeeb28e4e5eec0e08af3d08f 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Collection/AbstractCollectionTest.php @@ -4,16 +4,16 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Reports\Test\Unit\Model\Resource\Report\Collection; class AbstractCollectionTest extends \PHPUnit_Framework_TestCase { /** - * @var AbstractCollection + * Tested collection + * + * @var \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection */ - protected $_model; + protected $collection; protected function setUp() { @@ -29,7 +29,7 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase ->getMockForAbstractClass(); $resource->method('getReadConnection')->willReturn($connection); - $this->_model = new \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection( + $this->collection = new \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection( $entityFactory, $logger, $fetchStrategy, @@ -41,15 +41,15 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase public function testIsSubtotalsGetDefault() { - $this->assertFalse($this->_model->isSubTotals()); + $this->assertFalse($this->collection->isSubTotals()); } public function testSetIsSubtotals() { - $this->_model->setIsSubTotals(true); - $this->assertTrue($this->_model->isSubTotals()); + $this->collection->setIsSubTotals(true); + $this->assertTrue($this->collection->isSubTotals()); - $this->_model->setIsSubTotals(false); - $this->assertFalse($this->_model->isSubTotals()); + $this->collection->setIsSubTotals(false); + $this->assertFalse($this->collection->isSubTotals()); } } diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/CollectionTest.php index c1e8adeeee7d3c16a6bb8984939699ef12c1ef48..ca08b3b21761a51c314c60a315f89e1dc5d359e2 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/CollectionTest.php @@ -3,32 +3,196 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Reports\Test\Unit\Model\Resource\Report; +use Magento\Reports\Model\Resource\Report\Collection; + class CollectionTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Reports\Model\Resource\Report\Collection */ - protected $_model; + protected $collection; + /** + * @var \Magento\Framework\Data\Collection\EntityFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityFactoryMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $timezoneMock; + + /** + * @var \Magento\Reports\Model\Resource\Report\Collection\Factory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $factoryMock; + + /** + * {@inheritDoc} + */ protected function setUp() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_model = $helper->getObject('Magento\Reports\Model\Resource\Report\Collection'); + $this->entityFactoryMock = $this->getMockBuilder('Magento\Framework\Data\Collection\EntityFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->getMock(); + $this->factoryMock = $this->getMockBuilder('Magento\Reports\Model\Resource\Report\Collection\Factory') + ->disableOriginalConstructor() + ->getMock(); + + $this->timezoneMock + ->expects($this->any()) + ->method('formatDateTime') + ->will($this->returnCallback([$this, 'formatDateTime'])); + + $this->collection = new Collection( + $this->entityFactoryMock, + $this->timezoneMock, + $this->factoryMock + ); } - public function testGetIntervalsWithoutSpecifiedPeriod() + /** + * @return void + */ + public function testGetPeriods() { - $startDate = new \DateTime('-3 day'); - $endDate = new \DateTime('+3 day'); - $this->_model->setInterval($startDate, $endDate); + $expectedArray = ['day' => 'Day', 'month' => 'Month', 'year' => 'Year']; + $this->assertEquals($expectedArray, $this->collection->getPeriods()); + } - $this->assertEquals(0, $this->_model->getSize()); + /** + * @return void + */ + public function testGetStoreIds() + { + $storeIds = [1]; + $this->assertEquals(null, $this->collection->getStoreIds()); + $this->collection->setStoreIds($storeIds); + $this->assertEquals($storeIds, $this->collection->getStoreIds()); } - public function testGetIntervalsWithoutSpecifiedInterval() + /** + * @param string $period + * @param \DateTime $fromDate + * @param \DateTime $toDate + * @param int $size + * @dataProvider intervalsDataProvider + * @return void + */ + public function testGetSize($period, $fromDate, $toDate, $size) { - $this->assertEquals(0, $this->_model->getSize()); + $this->collection->setPeriod($period); + $this->collection->setInterval($fromDate, $toDate); + $this->assertEquals($size, $this->collection->getSize()); + } + + /** + * @return void + */ + public function testGetPageSize() + { + $pageSize = 1; + $this->assertEquals(null, $this->collection->getPageSize()); + $this->collection->setPageSize($pageSize); + $this->assertEquals($pageSize, $this->collection->getPageSize()); + } + + /** + * @param string $period + * @param \DateTime $fromDate + * @param \DateTime $toDate + * @param int $size + * @dataProvider intervalsDataProvider + * @return void + */ + public function testGetReports($period, $fromDate, $toDate, $size) + { + $this->collection->setPeriod($period); + $this->collection->setInterval($fromDate, $toDate); + $reports = $this->collection->getReports(); + foreach ($reports as $report) { + $this->assertInstanceOf('\Magento\Framework\Object', $report); + $reportData = $report->getData(); + $this->assertTrue(empty($reportData['children'])); + $this->assertTrue($reportData['is_empty']); + } + $this->assertEquals($size, count($reports)); + } + + /** + * @return void + */ + public function testLoadData() + { + $this->assertInstanceOf('\Magento\Reports\Model\Resource\Report\Collection', $this->collection->loadData()); + } + + /** + * @return array + */ + public function intervalsDataProvider() + { + return [ + [ + '_period' => 'day', + '_from' => new \DateTime('-3 day'), + '_to' => new \DateTime('+3 day'), + 'size' => 7 + ], + [ + '_period' => 'month', + '_from' => new \DateTime('2015-01-15 11:11:11'), + '_to' => new \DateTime('2015-01-25 11:11:11'), + 'size' => 1 + ], + [ + '_period' => 'month', + '_from' => new \DateTime('2015-01-15 11:11:11'), + '_to' => new \DateTime('2015-02-25 11:11:11'), + 'size' => 2 + ], + [ + '_period' => 'year', + '_from' => new \DateTime('2015-01-15 11:11:11'), + '_to' => new \DateTime('2015-01-25 11:11:11'), + 'size' => 1 + ], + [ + '_period' => 'year', + '_from' => new \DateTime('2014-01-15 11:11:11'), + '_to' => new \DateTime('2015-01-25 11:11:11'), + 'size' => 2 + ], + [ + '_period' => null, + '_from' => new \DateTime('-3 day'), + '_to' => new \DateTime('+3 day'), + 'size' => 0 + ] + ]; + } + + /** + * @return string + */ + public function formatDateTime() + { + $args = func_get_args(); + + $dateStart = $args[0]; + + $formatter = new \IntlDateFormatter( + "en_US", + \IntlDateFormatter::SHORT, + \IntlDateFormatter::SHORT, + 'America/Los_Angeles' + ); + + return $formatter->format($dateStart); } } diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Product/ViewedTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Product/ViewedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b22e4f2bf044939cb3db933093d341afbf6318ac --- /dev/null +++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Product/ViewedTest.php @@ -0,0 +1,286 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Reports\Test\Unit\Model\Resource\Report\Product; + +use Magento\Reports\Model\Resource\Report\Product\Viewed; + +/** + * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ViewedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Model\Resource\Report\Product\Viewed + */ + protected $viewed; + + /** + * @var \Magento\Framework\Model\Resource\Db\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $timezoneMock; + + /** + * @var \Magento\Reports\Model\FlagFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $flagFactoryMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTimeMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\Timezone\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * @var \Magento\Catalog\Model\Resource\Product|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \Magento\Reports\Model\Resource\Helper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connectionMock; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $zendDbMock; + + /** + * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attributeMock; + + /** + * @var \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\PHPUnit_Framework_MockObject_MockObject + */ + protected $backendMock; + + /** + * @var \Magento\Reports\Model\Flag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $flagMock; + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @return void + */ + protected function setUp() + { + $this->zendDbMock = $this->getMockBuilder('Zend_Db_Statement_Interface')->getMock(); + $this->zendDbMock->expects($this->any())->method('fetchColumn')->willReturn([]); + + $this->selectMock = $this->getMockBuilder('Magento\Framework\DB\Select') + ->disableOriginalConstructor() + ->setMethods( + [ + 'from', + 'where', + 'joinInner', + 'joinLeft', + 'having', + 'useStraightJoin', + 'insertFromSelect', + '__toString' + ] + ) + ->getMock(); + $this->selectMock->expects($this->any())->method('from')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('where')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('joinInner')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('joinLeft')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('having')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('useStraightJoin')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('insertFromSelect')->willReturnSelf(); + $this->selectMock->expects($this->any())->method('__toString')->willReturn('string'); + + $this->connectionMock = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface')->getMock(); + $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock); + $this->connectionMock->expects($this->any())->method('query')->willReturn($this->zendDbMock); + + $this->resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->getMock(); + $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); + $this->resourceMock->expects($this->any())->method('getTableName')->will( + $this->returnCallback( + function ($arg) { + return $arg; + } + ) + ); + + $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Resource\Db\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock); + + $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + + $dateTime = $this->getMockBuilder('DateTime')->getMock(); + + $this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')->getMock(); + $this->timezoneMock->expects($this->any())->method('scopeDate')->willReturn($dateTime); + + $this->dateTimeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime')->getMock(); + + $this->flagMock = $this->getMockBuilder('Magento\Reports\Model\Flag') + ->disableOriginalConstructor() + ->setMethods(['setReportFlagCode', 'unsetData', 'loadSelf', 'setFlagData', 'setLastUpdate', 'save']) + ->getMock(); + + $this->flagFactoryMock = $this->getMockBuilder('Magento\Reports\Model\FlagFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->flagFactoryMock->expects($this->any())->method('create')->willReturn($this->flagMock); + + $this->validatorMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Timezone\Validator') + ->disableOriginalConstructor() + ->getMock(); + + $this->backendMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') + ->disableOriginalConstructor() + ->getMock(); + $this->attributeMock->expects($this->any())->method('getBackend')->willReturn($this->backendMock); + + $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Resource\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->productMock->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock); + + $this->helperMock = $this->getMockBuilder('Magento\Reports\Model\Resource\Helper') + ->disableOriginalConstructor() + ->getMock(); + + $this->viewed = new Viewed( + $this->contextMock, + $this->loggerMock, + $this->timezoneMock, + $this->flagFactoryMock, + $this->dateTimeMock, + $this->validatorMock, + $this->productMock, + $this->helperMock + ); + } + + /** + * @param mixed $from + * @param mixed $to + * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $truncateCount + * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $deleteCount + * @dataProvider intervalsDataProvider + * @return void + */ + public function testAggregate($from, $to, $truncateCount, $deleteCount) + { + $this->connectionMock->expects($truncateCount)->method('truncateTable'); + $this->connectionMock->expects($deleteCount)->method('delete'); + + $this->helperMock + ->expects($this->at(0)) + ->method('updateReportRatingPos') + ->with( + $this->connectionMock, + 'day', + 'views_num', + 'report_viewed_product_aggregated_daily', + 'report_viewed_product_aggregated_daily' + ) + ->willReturnSelf(); + $this->helperMock + ->expects($this->at(1)) + ->method('updateReportRatingPos') + ->with( + $this->connectionMock, + 'month', + 'views_num', + 'report_viewed_product_aggregated_daily', + 'report_viewed_product_aggregated_monthly' + ) + ->willReturnSelf(); + $this->helperMock + ->expects($this->at(2)) + ->method('updateReportRatingPos') + ->with( + $this->connectionMock, + 'year', + 'views_num', + 'report_viewed_product_aggregated_daily', + 'report_viewed_product_aggregated_yearly' + ) + ->willReturnSelf(); + + $this->flagMock->expects($this->once())->method('unsetData')->willReturnSelf(); + $this->flagMock->expects($this->once())->method('loadSelf')->willReturnSelf(); + $this->flagMock->expects($this->never())->method('setFlagData')->willReturnSelf(); + $this->flagMock->expects($this->once())->method('setLastUpdate')->willReturnSelf(); + $this->flagMock->expects($this->once())->method('save')->willReturnSelf(); + $this->flagMock + ->expects($this->once()) + ->method('setReportFlagCode') + ->with(\Magento\Reports\Model\Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE) + ->willReturnSelf(); + + $this->viewed->aggregate($from, $to); + } + + /** + * @return array + */ + public function intervalsDataProvider() + { + return [ + [ + 'from' => new \DateTime('+3 day'), + 'to' => new \DateTime('-3 day'), + 'truncateCount' => $this->never(), + 'deleteCount' => $this->once() + ], + [ + 'from' => null, + 'to' => null, + 'truncateCount' => $this->once(), + 'deleteCount' => $this->never() + ] + ]; + } +} diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 099550f07e1ea5ec1812cf7466c1f75732a52e60..89ac5cea8d624dd0d8c836196cda54c80b9daa21 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-log": "0.74.0-beta13", - "magento/module-wishlist": "0.74.0-beta13", - "magento/module-review": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-downloadable": "0.74.0-beta13", - "magento/module-sales-rule": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-log": "0.74.0-beta14", + "magento/module-wishlist": "0.74.0-beta14", + "magento/module-review": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-downloadable": "0.74.0-beta14", + "magento/module-sales-rule": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index c921a04022f146ff8fe438985fd98d93ef9c3fbe..f36ff58438ce0c1b827ee011308bdf0710623bf6 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-beta13", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php index 63405dde14c7588458537f1d9ee4f47a5e38dc8b..82e5fd6abc996310802fd5871bbbff62cbcbfdab 100644 --- a/app/code/Magento/Review/Model/Review.php +++ b/app/code/Magento/Review/Model/Review.php @@ -6,6 +6,7 @@ namespace Magento\Review\Model; use Magento\Catalog\Model\Product; +use Magento\Framework\Object\IdentityInterface; use Magento\Review\Model\Resource\Review\Product\Collection as ProductCollection; use Magento\Review\Model\Resource\Review\Status\Collection as StatusCollection; @@ -21,7 +22,7 @@ use Magento\Review\Model\Resource\Review\Status\Collection as StatusCollection; * @method \Magento\Review\Model\Review setStatusId(int $value) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Review extends \Magento\Framework\Model\AbstractModel +class Review extends \Magento\Framework\Model\AbstractModel implements IdentityInterface { /** * Event prefix for observer @@ -359,4 +360,18 @@ class Review extends \Magento\Framework\Model\AbstractModel { return $this->getResource()->getEntityIdByCode($entityCode); } + + /** + * Return unique ID(s) for each object in system + * + * @return array + */ + public function getIdentities() + { + $tags = []; + if ($this->isApproved() && $this->getEntityPkValue()) { + $tags[] = Product::CACHE_TAG . '_' . $this->getEntityPkValue(); + } + return $tags; + } } diff --git a/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php b/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php index e96842c2cc28601dd771445269d924f42cd51d01..4be052abd03baebb2d5125ab1662c30f99acd5bc 100644 --- a/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php +++ b/app/code/Magento/Review/Test/Unit/Model/ReviewTest.php @@ -6,6 +6,7 @@ namespace Magento\Review\Test\Unit\Model; +use \Magento\Catalog\Model\Product; use \Magento\Review\Model\Review; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; @@ -270,4 +271,15 @@ class ReviewTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($result)); $this->assertSame($result, $this->review->getEntityIdByCode($entityCode)); } + + public function testGetIdentities() + { + $this->review->setStatusId(Review::STATUS_PENDING); + $this->assertEmpty($this->review->getIdentities()); + + $productId = 1; + $this->review->setEntityPkValue($productId); + $this->review->setStatusId(Review::STATUS_APPROVED); + $this->assertEquals([Product::CACHE_TAG . '_' . $productId], $this->review->getIdentities()); + } } diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index 45201df67e97c0cfec3850649adf2b8fdcfbfa74..b8bb07beb0f6fc1ba9a59a47a57b2329e504a074 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-newsletter": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-newsletter": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.74.0-beta13" + "magento/module-cookie": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Review/view/frontend/layout/review_product_listajax.xml b/app/code/Magento/Review/view/frontend/layout/review_product_listajax.xml index 3af29a203ff8ff030ae04b5fa2dc651de88f9a5b..0f950489f8aae9dc1c8c8405a6c1c7a5adbf076a 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_product_listajax.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_product_listajax.xml @@ -7,7 +7,7 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd"> <container name="root"> - <block class="Magento\Review\Block\Product\View\ListView" name="product.info.product_additional_data" as="product_additional_data" template="product/view/list.phtml"/> + <block class="Magento\Review\Block\Product\View\ListView" name="product.info.product_additional_data" as="product_additional_data" template="product/view/list.phtml" /> <block class="Magento\Theme\Block\Html\Pager" name="product_review_list.toolbar"> <arguments> <argument name="show_per_page" xsi:type="boolean">false</argument> diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 9e085b9677094ac04fb063a23147c319500255be..ca4231a1f2e5bd6127a2792c31677aca56da011a 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Rule/Model/AbstractModel.php b/app/code/Magento/Rule/Model/AbstractModel.php index 8aedb81590ed17eb55dc379c90a3058160af320a..ce15aad634bed7a86551a2b483fc8039e2edb679 100644 --- a/app/code/Magento/Rule/Model/AbstractModel.php +++ b/app/code/Magento/Rule/Model/AbstractModel.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Abstract Rule entity data model */ @@ -63,16 +61,22 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel abstract public function getActionsInstance(); /** + * Form factory + * * @var \Magento\Framework\Data\FormFactory */ protected $_formFactory; /** + * Timezone instance + * * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $_localeDate; /** + * Constructor + * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Data\FormFactory $formFactory @@ -233,7 +237,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel */ protected function _resetConditions($conditions = null) { - if (is_null($conditions)) { + if (null === $conditions) { $conditions = $this->getConditionsInstance(); } $conditions->setRule($this)->setId('1')->setPrefix('conditions'); @@ -250,7 +254,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel */ protected function _resetActions($actions = null) { - if (is_null($actions)) { + if (null === $actions) { $actions = $this->getActionsInstance(); } $actions->setRule($this)->setId('1')->setPrefix('actions'); @@ -390,6 +394,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel * Check availability to delete rule * * @return bool + * @codeCoverageIgnore */ public function isDeleteable() { @@ -401,6 +406,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel * * @param bool $value * @return $this + * @codeCoverageIgnore */ public function setIsDeleteable($value) { @@ -412,6 +418,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel * Check if rule is readonly * * @return bool + * @codeCoverageIgnore */ public function isReadonly() { @@ -423,6 +430,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel * * @param bool $value * @return $this + * @codeCoverageIgnore */ public function setIsReadonly($value) { diff --git a/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php b/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php index 32d0b012c88418f6e18656975357f3d17a9461f1..7c628927f6c15426dba5042fa02316cb428864bd 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Rule\Test\Unit\Model\Condition\Product; use ReflectionMethod; @@ -14,24 +12,30 @@ use ReflectionProperty; class AbstractProductTest extends \PHPUnit_Framework_TestCase { /** - * @var AbstractProduct|\PHPUnit_Framework_MockObject_MockObject + * Tested condition + * + * @var \Magento\Rule\Model\Condition\Product\AbstractProduct|\PHPUnit_Framework_MockObject_MockObject */ protected $_condition; /** + * Framework object + * * @var \Magento\Framework\Object|\PHPUnit_Framework_MockObject_MockObject */ protected $_object; /** + * Reflection for Magento\Rule\Model\Condition\Product\AbstractProduct::$_entityAttributeValues + * * @var \ReflectionProperty - * 'Magento\Rule\Model\Condition\Product\AbstractProduct::_entityAttributeValues' */ protected $_entityAttributeValuesProperty; /** + * Reflection for Magento\Rule\Model\Condition\Product\AbstractProduct::$_config + * * @var \ReflectionProperty - * 'Magento\Rule\Model\Condition\Product\AbstractProduct::_config' */ protected $_configProperty; @@ -159,8 +163,10 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase $this->_condition, $this->getMock('Magento\Eav\Model\Config', [], [], '', false) ); - $this->_entityAttributeValuesProperty->setValue($this->_condition, - $this->getMock('Magento\Eav\Model\Config', [], [], '', false)); + $this->_entityAttributeValuesProperty->setValue( + $this->_condition, + $this->getMock('Magento\Eav\Model\Config', [], [], '', false) + ); $attribute = new \Magento\Framework\Object(); $attribute->setBackendType('datetime'); @@ -306,7 +312,7 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); $attrObjectSourceMock - ->expects(is_null($expectedAttrObjSourceAllOptionsParam) ? $this->never() : $this->once()) + ->expects((null === $expectedAttrObjSourceAllOptionsParam) ? $this->never() : $this->once()) ->method('getAllOptions') ->with($expectedAttrObjSourceAllOptionsParam) ->willReturn($attrObjectSourceAllOptionsValue); @@ -317,7 +323,7 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase ->getMock(); $attributeObjectMock->method('usesSource')->willReturn(true); $attributeObjectMock - ->expects(is_null($attributeObjectFrontendInput) ? $this->never() : $this->once()) + ->expects((null === $attributeObjectFrontendInput) ? $this->never() : $this->once()) ->method('getFrontendInput') ->willReturn($attributeObjectFrontendInput); $attributeObjectMock->method('getSource')->willReturn($attrObjectSourceMock); @@ -345,12 +351,14 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase $attrSetCollectionValueMock->method('setEntityTypeFilter')->will($this->returnSelf()); $attrSetCollectionValueMock->method('load')->will($this->returnSelf()); $attrSetCollectionValueMock - ->expects(is_null($attrSetCollectionOptionsArray) ? $this->never() : $this->once()) + ->expects((null === $attrSetCollectionOptionsArray) ? $this->never() : $this->once()) ->method('toOptionArray') ->willReturn($attrSetCollectionOptionsArray); - $attrSetCollectionProperty = - new ReflectionProperty('Magento\Rule\Model\Condition\Product\AbstractProduct', '_attrSetCollection'); + $attrSetCollectionProperty = new ReflectionProperty( + 'Magento\Rule\Model\Condition\Product\AbstractProduct', + '_attrSetCollection' + ); $attrSetCollectionProperty->setAccessible(true); $attrSetCollectionProperty->setValue($this->_condition, $attrSetCollectionValueMock); @@ -366,6 +374,8 @@ class AbstractProductTest extends \PHPUnit_Framework_TestCase } /** + * Data provider for prepare value options + * * @return array * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index d6e66b999c893133d222d72c447801d2b2bff85e..5d0a656ebc0bb6db836a97268ddecc99906ad595 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-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php index dfd663234daec616b0e77161aed4f89ae858bd5f..3b319b82613c61da32995e744fc8210ded8670a2 100644 --- a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php @@ -35,6 +35,10 @@ interface OrderAddressInterface extends \Magento\Framework\Api\ExtensibleDataInt * Region ID. */ const REGION_ID = 'region_id'; + /** + * Region code. + */ + const KEY_REGION_CODE = 'region_code'; /* * Customer ID. */ @@ -247,6 +251,13 @@ interface OrderAddressInterface extends \Magento\Framework\Api\ExtensibleDataInt */ public function getRegion(); + /** + * Gets the region code for the order address + * + * @return string|null Region code. + */ + public function getRegionCode(); + /** * Gets the region ID for the order address. * @@ -494,6 +505,14 @@ interface OrderAddressInterface extends \Magento\Framework\Api\ExtensibleDataInt */ public function setVatRequestId($id); + /** + * Set region code + * + * @param string $regionCode + * @return $this + */ + public function setRegionCode($regionCode); + /** * Sets the VAT request date for the order address. * diff --git a/app/code/Magento/Sales/Model/Order/Address.php b/app/code/Magento/Sales/Model/Order/Address.php index 9486d6e0fb34b74714d5e102c6d1bb1a289c48ab..2ffcb048799e6f7b5f7456487e4cc20cff95d922 100644 --- a/app/code/Magento/Sales/Model/Order/Address.php +++ b/app/code/Magento/Sales/Model/Order/Address.php @@ -702,6 +702,14 @@ class Address extends AbstractModel implements OrderAddressInterface, AddressMod return $this->setData(OrderAddressInterface::VAT_REQUEST_ID, $id); } + /** + * {@inheritdoc} + */ + public function setRegionCode($regionCode) + { + return $this->setData(OrderAddressInterface::KEY_REGION_CODE, $regionCode); + } + /** * {@inheritdoc} */ diff --git a/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php b/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php index 37c29c2be223a85d35eb22fa196c757480c062ed..b4f0e627cebf03296c4ce22b62758b0a0e40cd9e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php @@ -38,20 +38,6 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $objectManagerMock->expects($this->once()) - ->method('get') - ->with('Magento\Email\Model\Resource\Template') - ->will($this->returnValue($objectManagerHelper->getObject('Magento\Email\Model\Resource\Template'))); - - try { - $this->objectManagerBackup = \Magento\Framework\App\ObjectManager::getInstance(); - } catch (\RuntimeException $e) { - $this->objectManagerBackup = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER) - ->create($_SERVER); - } - \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); - $this->template = $objectManagerHelper->getObject( 'Magento\Sales\Model\Email\Template', [ @@ -60,12 +46,6 @@ class TemplateTest extends \PHPUnit_Framework_TestCase ); } - protected function tearDown() - { - parent::tearDown(); - \Magento\Framework\App\ObjectManager::setInstance($this->objectManagerBackup); - } - public function testIncludeTemplate() { $this->mockViewFilesystem->expects($this->once()) diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index 7f07de89e05f1b012a4d782d2828f7f86dd127eb..e9850b28b5ebbefd68476b14a55a1ea6f8bb63af 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-sales-rule": "0.74.0-beta13", - "magento/module-sales-sequence": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-gift-message": "0.74.0-beta13", - "magento/module-reports": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-wishlist": "0.74.0-beta13", - "magento/module-email": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-sales-rule": "0.74.0-beta14", + "magento/module-sales-sequence": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-gift-message": "0.74.0-beta14", + "magento/module-reports": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-wishlist": "0.74.0-beta14", + "magento/module-email": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/edit/message.js b/app/code/Magento/Sales/view/adminhtml/web/order/edit/message.js index 5479b72127223e2f0b98730a965e94a97c845f9d..13511e83106674b301a992ca6a360e69c6c2b7b2 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/edit/message.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/edit/message.js @@ -7,7 +7,7 @@ define([ "jquery", "jquery/ui", - 'Magento_Ui/js/dialog/dialog', + 'Magento_Ui/js/modal/modal', "mage/translate" ], function($){ "use strict"; @@ -15,7 +15,7 @@ define([ options: { url: null, message: null, - dialog: null + modal: null }, /** @@ -26,10 +26,10 @@ define([ }, /** - * Show dialog + * Show modal */ showDialog: function() { - this.options.dialog.html(this.options.message).trigger('openDialog'); + this.options.dialog.html(this.options.message).modal('openModal'); }, /** @@ -40,11 +40,24 @@ define([ }, /** - * Prepare dialog + * Prepare modal * @protected */ _prepareDialog: function() { - this.options.dialog = $('<div class="ui-dialog-content ui-widget-content"></div>').dialog(); + var self = this; + + this.options.dialog = $('<div class="ui-dialog-content ui-widget-content"></div>').modal({ + type: 'popup', + modalClass: 'edit-order-popup', + title: $.mage.__('Edit Order'), + buttons: [{ + text: $.mage.__('Ok'), + 'class': 'action-primary', + click: function(){ + self.redirect(); + } + }] + }); } }); diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 73ca3c6e1d876da3377b77cc31d0a0a61b398a5a..e842b73e7b207cacc55274b6f11cb78df5d008ab 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-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-rule": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/module-reports": "0.74.0-beta13", - "magento/module-catalog-rule": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-rule": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/module-reports": "0.74.0-beta14", + "magento/module-catalog-rule": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/SalesSequence/composer.json b/app/code/Magento/SalesSequence/composer.json index 15ce9855deb2e50bac1d6261380f653585182cfc..825a8e16713a027df4ea0dd1da8d58e2af16c7ea 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-beta13", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Search/composer.json b/app/code/Magento/Search/composer.json index d0eea2c18d8d8791e84e4b2b396f714ccedd2388..98e1ce97eda1a03ced7574846f0a8d0d3efc2722 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog-search": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-reports": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog-search": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-reports": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/SendFriend/composer.json b/app/code/Magento/SendFriend/composer.json index f8e2a4f687541841f0942de6a0805271b6dac339..b6712222a0c651e7a30e4186b029c40789fd30ae 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 1960a285405d0b1fb9159a8cbb6905f4b27b57e8..26e8e039f88d70c2292afe9ffeae4601a4f1ea4a 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-contact": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-payment": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-contact": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-payment": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-fedex": "0.74.0-beta13", - "magento/module-ups": "0.74.0-beta13" + "magento/module-fedex": "0.74.0-beta14", + "magento/module-ups": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 7c7137e8db82477d6c3ded19a28dd6969b68fc42..6e9cd7ca7d1d8f9a280952fcccdd76c9b45a844c 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-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog-url-rewrite": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog-url-rewrite": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index e8a224d7a443669cfe35054a4ebb9af15f6138fe..3bb80c7c21ec85900b2c9c7ec5b15ce3a6c99176 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-beta13", - "magento/module-ui": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-directory": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 3ef7c5e73fc4cd09ad9f1ff4cca1b0b5f56ed1d6..b2d4d6faad79318556340971f6dd6d832e89af6c 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-config": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-reports": "0.74.0-beta13", - "magento/module-page-cache": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-config": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-reports": "0.74.0-beta14", + "magento/module-page-cache": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json index 0cebf5d7d3360dba867fee97e90b3a9d2336ad91..2642b8587938955bd7b651a9485560794002064f 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-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-tax": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 7e2129cc460bb0145f4cf7dacf63bb226e4bb049..9fbb0bd754d2cc08791507e25ca35d5d013776d9 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-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-widget": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/module-media-storage": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-require-js": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-widget": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/module-media-storage": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-require-js": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-translation": "0.74.0-beta13" + "magento/module-translation": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index 05ce2874e8b195cefb7355cb2208a5ca59b6208d..7de19b36d8a93d4c6640246a5098e529c27e1860 100644 --- a/app/code/Magento/Translation/composer.json +++ b/app/code/Magento/Translation/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-backend": "0.74.0-beta13", - "magento/module-developer": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-backend": "0.74.0-beta14", + "magento/module-developer": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Ui/Component/Bookmark.php b/app/code/Magento/Ui/Component/Bookmark.php index cbb66e064806e28cfc15de7e9dcba59448b2d13c..7c8d54889f13ae6a1028dc2d61e6544f5ba464f1 100644 --- a/app/code/Magento/Ui/Component/Bookmark.php +++ b/app/code/Magento/Ui/Component/Bookmark.php @@ -75,12 +75,17 @@ class Bookmark extends AbstractComponent $bookmarks = $this->bookmarkManagement->loadByNamespace($namespace); /** @var \Magento\Ui\Api\Data\BookmarkInterface $bookmark */ foreach ($bookmarks->getItems() as $bookmark) { - $config['activeIndex'] = ($bookmark->isCurrent() ? $bookmark->getIdentifier() : 'default'); + $activeIndex = ($bookmark->isCurrent() ? $bookmark->getIdentifier() : false); + if ($bookmark->getIdentifier() == 'current') { $config['current'] = $bookmark->getConfig(); } else { $config['views'][$bookmark->getIdentifier()] = $bookmark->getConfig(); } + + if ($activeIndex !== false) { + $config['activeIndex'] = $activeIndex; + } } } diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php index f959e11ae83c85cf64e9e9502279005e44c2b738..2128543535b2b0d6823d60046ef60c21001913ce 100644 --- a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php +++ b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php @@ -23,6 +23,10 @@ class Save extends AbstractAction */ const CURRENT_IDENTIFIER = 'current'; + const ACTIVE_IDENTIFIER = 'activeIndex'; + + const VIEWS_IDENTIFIER = 'views'; + /** * @var BookmarkRepositoryInterface */ @@ -75,30 +79,37 @@ class Save extends AbstractAction { $bookmark = $this->bookmarkFactory->create(); $data = $this->_request->getParam('data'); - if (isset($data['views'])) { - foreach ($data['views'] as $identifier => $data) { - $updateBookmark = $this->checkBookmark($identifier); - if ($updateBookmark !== false) { - $bookmark = $updateBookmark; - } + $action = key($data); + switch($action) { + case self::ACTIVE_IDENTIFIER: + $this->updateCurrentBookmark($data[$action]); + break; + case self::CURRENT_IDENTIFIER: $this->updateBookmark( $bookmark, - $identifier, - (isset($data['label']) ? $data['label'] : ''), - $data + $action, + $bookmark->getTitle(), + $data[$action] ); - } - } else { - $identifier = isset($data['activeIndex']) - ? $data['activeIndex'] - : (isset($data[self::CURRENT_IDENTIFIER]) ? self::CURRENT_IDENTIFIER : ''); - $updateBookmark = $this->checkBookmark($identifier); - if ($updateBookmark !== false) { - $bookmark = $updateBookmark; - } - $this->updateBookmark($bookmark, $identifier, '', $data[$identifier]); + break; + + case self::VIEWS_IDENTIFIER: + foreach ($data[$action] as $identifier => $data) { + $this->updateBookmark( + $bookmark, + $identifier, + isset($data['label']) ? $data['label'] : '', + $data + ); + $this->updateCurrentBookmark($identifier); + } + + break; + + default: + throw new \LogicException(__('Unsupported bookmark action.')); } } @@ -114,20 +125,35 @@ class Save extends AbstractAction protected function updateBookmark(BookmarkInterface $bookmark, $identifier, $title, array $config = []) { $this->filterVars($config); + + $updateBookmark = $this->checkBookmark($identifier); + if ($updateBookmark !== false) { + $bookmark = $updateBookmark; + } + $bookmark->setUserId($this->userContext->getUserId()) ->setNamespace($this->_request->getParam('namespace')) ->setIdentifier($identifier) ->setTitle($title) - ->setConfig($config) - ->setCurrent($identifier !== self::CURRENT_IDENTIFIER); + ->setConfig($config); $this->bookmarkRepository->save($bookmark); + } + /** + * Update current bookmark + * + * @param string $identifier + * @return void + */ + protected function updateCurrentBookmark($identifier) + { $bookmarks = $this->bookmarkManagement->loadByNamespace($this->_request->getParam('namespace')); foreach ($bookmarks->getItems() as $bookmark) { if ($bookmark->getIdentifier() == $identifier) { - continue; + $bookmark->setCurrent(true); + } else { + $bookmark->setCurrent(false); } - $bookmark->setCurrent(false); $this->bookmarkRepository->save($bookmark); } } diff --git a/app/code/Magento/Ui/composer.json b/app/code/Magento/Ui/composer.json index edb3157e7aab2160a922d9f80b68fe3674e946ed..35d8c625925fde44598e7b8524c3e574d51f309e 100644 --- a/app/code/Magento/Ui/composer.json +++ b/app/code/Magento/Ui/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js b/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js index 882fd49f464af70702a9db2372a988a9462ab35c..4a0ceedf00035b14483671a2ec5caece43324907 100644 --- a/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js +++ b/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js @@ -122,6 +122,10 @@ define([ delete node.type; delete node.config; + if (children) { + node.initChildCount = _.size(children); + } + if (node.isTemplate) { node.isTemplate = false; diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js b/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js index 84ea34f88934be1e8bc349a149482e3f297b49ee..14ba3ef49693ef7615b5d9052a94a2e60dbed5d2 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/abstract.js @@ -47,8 +47,7 @@ define([ _.bindAll(this, 'reset'); this._super(); - - this.initialValue = this.getInititalValue(); + this.initialValue = this.getInitialValue(); this.value(this.initialValue); @@ -97,7 +96,7 @@ define([ * * @returns {*} Elements' value. */ - getInititalValue: function () { + getInitialValue: function () { var values = [this.value(), this.default], value; diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/boolean.js b/app/code/Magento/Ui/view/base/web/js/form/element/boolean.js index 4782c853d210b11696c71f31d8d855a8e64eb4b0..efe82b0a13a1c4ee16cb71b7581e77ee41393fc8 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/boolean.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/boolean.js @@ -13,7 +13,7 @@ define([ * * @return {Boolean} */ - getInititalValue: function () { + getInitialValue: function () { return !!+this._super(); }, diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/date.js b/app/code/Magento/Ui/view/base/web/js/form/element/date.js index 140f063a315d00b0dd47a5c144503eb28c75b9cd..08f28b0c63722c92fb0e3b9cc580b1eaa1c3d107 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/date.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/date.js @@ -26,7 +26,7 @@ define([ * * @returns {String} */ - getInititalValue: function () { + getInitialValue: function () { var value = this._super(); if (value) { diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js index a6dc9e3b3afe600527a5b0fd470b05547b955789..6e7b2ac69a4ff61d6617faf2d0226084660890d5 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js @@ -20,7 +20,7 @@ define([ * * @returns {Number|String} */ - getInititalValue: function () { + getInitialValue: function () { var value = this._super(); return _.isString(value) ? value.split(',') : value; diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/select.js b/app/code/Magento/Ui/view/base/web/js/form/element/select.js index 3034df1e2c67ad8154be1caa055fd97e0a45bbf2..225a6a3250d350bb55b90b4caeb5f8abc1ae9fa8 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/select.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/select.js @@ -14,9 +14,9 @@ define([ var inputNode = { parent: '${ $.$data.parentName }', type: 'form.input', - name: '<%= $data.index %>_input', - dataScope: '<%= $data.customEntry %>', - customScope: '<%= $data.customScope %>', + name: '${ $.$data.index }_input', + dataScope: '${ $.$data.customEntry }', + customScope: '${ $.$data.customScope }', sortOrder: { after: '${ $.$data.name }' }, @@ -157,6 +157,7 @@ define([ initFilter: function () { var filter = this.filterBy; + this.filter(this.default, filter.field); this.setLinks({ filter: filter.target }, 'imports'); @@ -181,7 +182,7 @@ define([ * * @returns {Number|String} */ - getInititalValue: function () { + getInitialValue: function () { var value = this._super(); if (value !== '') { diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js index 33a095e64e806024affa49638b9fe8bb40566e79..e0b7525f007128ec86e7409519c1df011081aa63 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js @@ -4,24 +4,282 @@ */ define([ 'underscore', - './column' -], function (_, Column) { + 'mageUtils', + 'uiRegistry', + './column', + 'Magento_Ui/js/modal/confirm' +], function (_, utils, registry, Column, confirm) { 'use strict'; return Column.extend({ defaults: { - headerTmpl: 'ui/grid/columns/actions', - bodyTmpl: 'ui/grid/cells/actions' + bodyTmpl: 'ui/grid/cells/actions', + actions: [], + rows: [], + templates: { + actions: {} + }, + rowsProvider: '${ $.parentName }', + imports: { + rows: '${ $.rowsProvider }:rows' + }, + listens: { + rows: 'updateActions' + } }, - getDisplayed: function (actions) { - actions = _.filter(actions, function (action) { - return !('hidden' in action) || !action.hidden; + /** + * Initializes observable properties. + * + * @returns {ActionsColumn} Chainable. + */ + initObservable: function () { + this._super() + .observe('actions opened'); + + return this; + }, + + /** + * Returns specific action of a specified row + * or all action objects associated with it. + * + * @param {Number} rowIndex - Index of a row. + * @param {String} [actionIndex] - Action identifier. + * @returns {Array|Object} + */ + getAction: function (rowIndex, actionIndex) { + var rowActions = this.actions()[rowIndex]; + + return rowActions && actionIndex ? + rowActions[actionIndex] : + rowActions; + }, + + /** + * Returns visible actions for a specified row. + * + * @param {Number} rowIndex - Index of a row. + * @returns {Array} Visible actions. + */ + getVisibleActions: function (rowIndex) { + var rowActions = this.getAction(rowIndex); + + return _.filter(rowActions, this.isActionVisible, this); + }, + + /** + * Adds new action. If action with a specfied identifier + * already exists, than the original will be overrided. + * + * @param {String} index - Actions' identifier. + * @param {Object} action - Actions' data. + * @returns {ActionsColumn} Chainable. + */ + addAction: function (index, action) { + var actionTmpls = this.templates.actions; + + actionTmpls[index] = action; + + this.updateActions(); + + return this; + }, + + /** + * Recreates actions for each row. + * + * @returns {ActionsColumn} Chainable. + */ + updateActions: function () { + var rows = this.rows, + actions = rows.map(this._formatActions, this); + + this.actions(actions); + + return this; + }, + + /** + * Processes actions, setting additional information to them and + * evaluating ther properties as a string templates. + * + * @private + * @param {Object} row - Row object. + * @param {Number} rowIndex - Index of a row. + * @returns {Array} + */ + _formatActions: function (row, rowIndex) { + var rowActions = row[this.index] || {}, + recordId = row[this.indexField], + customActions = this.templates.actions; + + /** + * Actions iterator. + */ + function iterate(action, index) { + action = utils.extend({ + index: index, + rowIndex: rowIndex, + recordId: recordId + }, action); + + return utils.template(action, row, true); + } + + rowActions = _.mapObject(rowActions, iterate); + customActions = _.map(customActions, iterate); + + customActions.forEach(function (action) { + rowActions[action.index] = action; + }); + + return rowActions; + }, + + /** + * Applies specified action. + * + * @param {String} actionIndex - Actions' identifier. + * @param {Number} rowIndex - Index of a row. + * @returns {ActionsColumn} Chainable. + */ + applyAction: function (actionIndex, rowIndex) { + var action = this.getAction(rowIndex, actionIndex), + callback; + + if (!action.href && !action.callback) { + return this; + } + + callback = this._getCallback(action); + + action.confirm ? + this._confirm(action, callback) : + callback(); + + return this; + }, + + /** + * Creates action callback based on its' data. If action doesn't spicify + * a callback function than the default one will be used. + * + * @private + * @param {Object} action - Actions' object. + * @returns {Function} Callback function. + */ + _getCallback: function (action) { + var args = [action.index, action.recordId, action], + callback = action.callback; + + if (utils.isObject(callback)) { + args.unshift(callback.target); + + callback = registry.async(callback.provider); + } else if (typeof callback != 'function') { + callback = this.defaultCallback.bind(this); + } + + return function () { + callback.apply(null, args); + }; + }, + + /** + * Default action callback. Redirects to + * the specified in actions' data url. + * + * @param {String} actionIndex - Actions' identifier. + * @param {(Number|String)} recordId - Id of the record accociated + * with a specfied action. + * @param {Object} action - Actions' data. + */ + defaultCallback: function (actionIndex, recordId, action) { + window.location.href = action.href; + }, + + /** + * Shows actions' confirmation window. + * + * @param {Object} action - Actions' data. + * @param {Function} callback - Callback that will be + * invoked if action is confirmed. + */ + _confirm: function (action, callback) { + var confirmData = action.confirm; + + confirm({ + title: confirmData.title, + content: confirmData.message, + actions: { + confirm: callback + } }); + }, + + /** + * Checks if row has only one visible action. + * + * @param {Number} rowIndex - Row index. + * @returns {Boolean} + */ + isSingle: function (rowIndex) { + return this.getVisibleActions(rowIndex).length === 1; + }, + + /** + * Checks if row has more than one visible action. + * + * @param {Number} rowIndex - Row index. + * @returns {Boolean} + */ + isMultiple: function (rowIndex) { + return this.getVisibleActions(rowIndex).length > 1; + }, + + /** + * Checks if action should be displayed. + * + * @param {Object} action - Action object. + * @returns {Boolean} + */ + isActionVisible: function (action) { + return action.hidden !== true; + }, + + /** + * Opens or closes specific actions list. + * + * @param {Number} rowIndex - Index of a row, + * where actions are displayed. + * @returns {ActionsColumn} Chainable. + */ + toggleList: function (rowIndex) { + var state = false; + + if (rowIndex !== this.opened()) { + state = rowIndex; + } + + this.opened(state); + + return this; + }, - this.displayed = actions; + /** + * Closes actions list. + * + * @param {Number} rowIndex - Index of a row, + * where actions are displayed. + * @returns {ActionsColumn} + */ + closeList: function (rowIndex) { + if (this.opened() === rowIndex) { + this.opened(false); + } - return actions; + return this; } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js index f0d3202c7f6822eb2c97aa3f89499f18a7048c32..1eb359826b1cff89f423be340531dd34d52c8157 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/column.js @@ -13,37 +13,111 @@ define([ defaults: { headerTmpl: 'ui/grid/columns/text', bodyTmpl: 'ui/grid/cells/text', - sortable: false, + sortable: true, + sorting: false, visible: true, + draggable: true, links: { - visible: '${ $.storageConfig.path }.visible' + visible: '${ $.storageConfig.path }.visible', + sorting: '${ $.storageConfig.path }.sorting' + }, + imports: { + exportSorting: 'sorting' + }, + listens: { + '${ $.provider }:params.sorting.field': 'onSortChange' + }, + modules: { + source: '${ $.provider }' } }, + /** + * Initializes observable properties. + * + * @returns {Column} Chainable. + */ initObservable: function () { this._super() - .observe('visible'); + .observe('visible dragging dragover sorting'); return this; }, - applyState: function (property, state) { - var storage = this.storage(), - namespace = this.storageConfig.root + '.' + property, - data, - value; + /** + * Applies specified stored state of a column or one of its' properties. + * + * @param {String} state - Defines what state should be used: saved or default. + * @param {String} [property] - Defines what columns' property should be applied. + * If not specfied, than all collumns stored properties will be used. + * @returns {Column} Chainable. + */ + applyState: function (state, property) { + var namespace = this.storageConfig.root; - if (state === 'default') { - data = storage.getDefault(); - } else if (state === 'last') { - data = storage.getSaved(); + if (property) { + namespace += '.' + property; } - value = utils.nested(data, namespace); + this.storage('applyState', state, namespace); - if (!_.isUndefined(value)) { - this.set(property, value); + return this; + }, + + /** + * Sets columns' sorting. If column is currently sorted, + * than its' direction will be toggled. + * + * @param {*} [enable=true] - If false, than sorting will + * be removed from a column. + * @returns {Column} Chainable. + */ + sort: function (enable) { + var direction; + + if (!this.sortable) { + return this; + } + + enable = enable !== false ? true : false; + + direction = enable ? + this.sorting() ? + this.toggleDirection() : + 'asc' : + false; + + this.sorting(direction); + + return this; + }, + + /** + * Exports sorting data to the dataProvider if + * sorting of a column is enabled. + * + * @param {(String|Boolean)} sorting - Columns' sorting state. + */ + exportSorting: function (sorting) { + if (!sorting) { + return; } + + this.source('set', 'params.sorting', { + field: this.index, + direction: sorting + }); + }, + + /** + * Toggles sorting direcction. + * + * @returns {String} New direction. + */ + toggleDirection: function () { + return this.sorting() === 'asc' ? + 'desc' : + 'asc'; }, getClickUrl: function (row) { @@ -61,16 +135,43 @@ define([ window.location.href = url; }, + /** + * Ment to preprocess data associated with a current columns' field. + * + * @param {*} data - Data to be preprocessed. + * @returns {String} + */ getLabel: function (data) { return data; }, + /** + * Returns path to the columns' header template. + * + * @returns {String} + */ getHeader: function () { return this.headerTmpl; }, + /** + * Returns path to the columns' body template. + * + * @returns {String} + */ getBody: function () { return this.bodyTmpl; + }, + + /** + * Listener of the providers' sorting state changes. + * + * @param {Srting} field - Field by which current sorting is performed. + */ + onSortChange: function (field) { + if (field !== this.index) { + this.sort(false); + } } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js index 3393c0094a8e8853a5a95b18de6e4805a92ac723..90ace7d79af6ad4eb96d1c0bceb5140ccdc7afe1 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js @@ -5,23 +5,40 @@ define([ 'mageUtils', 'moment', - './sortable' -], function (utils, moment, Sortable) { + './column' +], function (utils, moment, Column) { 'use strict'; - return Sortable.extend({ + return Column.extend({ defaults: { dateFormat: 'MMM D, YYYY h:mm:ss A' }, + /** + * Initializes components' static properties. + * + * @returns {DateColumn} Chainable. + */ initProperties: function () { this.dateFormat = utils.normalizeDate(this.dateFormat); return this._super(); }, - getLabel: function (data) { - return moment(data).isValid() ? moment(data).format(this.dateFormat) : ''; + /** + * Formats incoming date based on the 'dateFormat' property. + * + * @param {String} date - Date to be formatted. + * @returns {String} Formatted date. + */ + getLabel: function (date) { + date = moment(date); + + date = date.isValid() ? + date.format(this.dateFormat) : + ''; + + return date; } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js index e6b33d1e62854e72ea6d8ed311317140cf4ad11b..7ced03bfba9256fd0fa18591e4042f2018339d53 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js @@ -13,13 +13,13 @@ define([ defaults: { headerTmpl: 'ui/grid/columns/multiselect', bodyTmpl: 'ui/grid/cells/multiselect', + sortable: false, menuVisible: false, excludeMode: false, allSelected: false, indetermine: false, selected: [], excluded: [], - ns: '${ $.provider }:params', actions: [{ value: 'selectAll', label: $t('Select all') @@ -40,13 +40,9 @@ define([ }, listens: { - '${ $.ns }.filters': 'deselectAll', + '${ $.provider }:params.filters': 'deselectAll', selected: 'onSelectedChange', rows: 'onRowsChange' - }, - - modules: { - source: '${ $.provider }' } }, @@ -87,7 +83,10 @@ define([ }, /** - * Selects all grid records, even those that are not visible on the page. + * Selects all grid records, even those that + * are not visible on the page. + * + * @returns {Multiselect} Chainable. */ selectAll: function () { this.excludeMode(true); @@ -100,44 +99,54 @@ define([ /** * Deselects all grid records. + * + * @returns {Multiselect} Chainable. */ deselectAll: function () { this.excludeMode(false); this.clearExcluded() - .deselectPage(); - this.selected.removeAll(); + .selected.removeAll(); return this; }, /** * Selects or deselects all records. + * + * @returns {Multiselect} Chainable. */ toggleSelectAll: function () { - return this.allSelected() ? - this.deselectAll() : - this.selectAll(); + this.allSelected() ? + this.deselectAll() : + this.selectAll(); + + return this; }, /** * Selects all records on the current page. + * + * @returns {Multiselect} Chainable. */ selectPage: function () { - this.selected( - _.union(this.selected(), this.getIds()) - ); + var selected = _.union(this.selected(), this.getIds()); + + this.selected(selected); return this; }, /** * Deselects all records on the current page. + * + * @returns {Multiselect} Chainable. */ deselectPage: function () { - var currentPageIds = this.getIds(); + var pageIds = this.getIds(); + this.selected.remove(function (value) { - return currentPageIds.indexOf(value) !== -1; + return !!~pageIds.indexOf(value); }); return this; @@ -209,18 +218,17 @@ define([ }, /** - * Exports selections to the data provider. + * Returns selections data. + * + * @returns {Object} */ - exportSelections: function () { - var data = {}, - type; - - type = this.excludeMode() ? 'excluded' : 'selected'; - - data[type] = this[type](); - data.total = this.totalSelected(); - - this.source('set', 'config.multiselect', data); + getSelections: function () { + return { + excluded: this.excluded(), + selected: this.selected(), + total: this.totalSelected(), + excludeMode: this.excludeMode() + }; }, /** @@ -231,27 +239,27 @@ define([ */ isActionRelevant: function (actionId) { var pageIds = this.getIds().length, - multiplePages = pageIds < this.totalRecords(); + multiplePages = pageIds < this.totalRecords(), + result = true; switch (actionId) { case 'selectPage': - - return multiplePages && !this.isPageSelected(true); + result = multiplePages && !this.isPageSelected(true); + break; case 'deselectPage': - - return multiplePages && this.isPageSelected(); + result = multiplePages && this.isPageSelected(); + break; case 'selectAll': - - return !this.allSelected(); + result = !this.allSelected(); + break; case 'deselectAll': - - return this.totalSelected() > 0; + result = this.totalSelected() > 0; } - return true; + return result; }, /** @@ -286,6 +294,8 @@ define([ /** * Updates values of the 'allSelected' * and 'indetermine' properties. + * + * @returns {Multiselect} Chainable. */ updateState: function () { var selected = this.selected().length, @@ -309,15 +319,14 @@ define([ }, /** - * Callback method to handle change of the selected items. + * Callback method to handle changes of selected items. * - * @param {Array} selected - List of the currently selected items. + * @param {Array} selected - An array of currently selected items. */ onSelectedChange: function (selected) { this.updateExcluded(selected) .countSelected() - .updateState() - .exportSelections(); + .updateState(); }, /** @@ -325,12 +334,12 @@ define([ * based on "selectMode" property. */ onRowsChange: function () { - var newSelected; + var newSelections; if (this.excludeMode()) { - newSelected = _.union(this.getIds(true), this.selected()); + newSelections = _.union(this.getIds(true), this.selected()); - this.selected(newSelected); + this.selected(newSelections); } } }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js index 54185ef6617aa82740e0bb7f76f1650798361f93..46cbff1cf1dfd610ea5a3cd016304493cf880fde 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js @@ -3,21 +3,30 @@ * See COPYING.txt for license details. */ define([ - './sortable' -], function (Sortable) { + './column' +], function (Column) { 'use strict'; - return Sortable.extend({ - getLabel: function (data) { + return Column.extend({ + /** + * Retrieves label associated with a provided value. + * + * @param {(String|Number)} value - Value of the option. + * @returns {String} + */ + getLabel: function (value) { var options = this.options || [], label = ''; - data = data || ''; + value = value || ''; + + /*eslint-disable eqeqeq*/ options.some(function (item) { label = item.label; - return item.value == data; + return item.value == value; }); + /*eslint-enable eqeqeq*/ return label; } diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/sortable.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/sortable.js deleted file mode 100644 index d54971607c37b33ce3a56455d7b7f8bb18aef05b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/sortable.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - './column' -], function (Column) { - 'use strict'; - - return Column.extend({ - defaults: { - sortable: true, - sorting: false, - classes: { - 'asc': '_ascend', - 'desc': '_descend' - }, - links: { - sorting: '${ $.storageConfig.path }.sorting' - }, - imports: { - setSortClass: 'sorting', - push: 'sorting' - }, - listens: { - '${ $.provider }:params.sorting.field': 'onSortChange' - }, - modules: { - source: '${ $.provider }' - } - }, - - initObservable: function () { - this._super() - .observe('sorting sortClass'); - - return this; - }, - - sort: function (enabled) { - var direction; - - direction = enabled !== false ? - this.sorting() ? - this.toggleDirection() : - 'asc' : - false; - - this.sorting(direction); - }, - - push: function (sorting) { - if (!sorting) { - return; - } - - this.source('set', 'params.sorting', { - field: this.index, - direction: sorting - }); - }, - - toggleDirection: function () { - return this.sorting() === 'asc' ? - 'desc' : - 'asc'; - }, - - setSortClass: function (sorting) { - var sortClass = this.classes[sorting] || ''; - - this.sortClass(sortClass); - }, - - onSortChange: function (field) { - if (field !== this.index) { - this.sort(false); - } - } - }); -}); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js index 78a115f2498a3068ca02baa8e07922013a91424a..286fe4307408feeaf678c3e778af0adf6a539edb 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js @@ -12,6 +12,22 @@ define([ ], function (_, utils, registry, Storage, Collapsible, layout) { 'use strict'; + /** + * Removes 'current' namespace from a 'path' string. + * + * @param {String} path + * @returns {String} Path without namespace. + */ + function removeStateNs(path) { + path = typeof path == 'string' ? path.split('.') : ''; + + if (path[0] === 'current') { + path.shift(); + } + + return path.join('.'); + } + return Collapsible.extend({ defaults: { template: 'ui/grid/controls/bookmarks/bookmarks', @@ -29,7 +45,7 @@ define([ }, newView: { label: 'New View', - index: '${ Date.now() }', + index: '_${ Date.now() }', editing: true, isNew: true } @@ -59,8 +75,8 @@ define([ */ initialize: function () { utils.limit(this, 'saveSate', 2000); - utils.limit(this, 'checkChanges', 200); utils.limit(this, '_defaultPolyfill', 1000); + utils.limit(this, 'checkChanges', 50); this._super() .initViews(); @@ -223,7 +239,9 @@ define([ */ applyView: function (view) { if (typeof view === 'string') { - view = this.elems.findWhere({index: view}); + view = this.elems.findWhere({ + index: view + }); } view.active(true); @@ -234,6 +252,34 @@ define([ return this; }, + /** + * Applies specified views' data on a current data object. + * + * @param {String} state - Defines what state shultd be used: default or saved. + * @param {String} [path] - Path to the property whose value + * will be inserted to a current data object. + * @returns {Bookmarks} Chainable. + */ + applyState: function (state, path) { + var view, + value; + + view = state === 'default' ? + this.defaultView : + this.activeView(); + + path = removeStateNs(path); + value = view.getData(path); + + if (!_.isUndefined(value)) { + path = path ? 'current.' + path : 'current'; + + this.set(path, value); + } + + return this; + }, + /** * Saves current data state. * @@ -260,24 +306,6 @@ define([ return this; }, - /** - * Retrieves last saved data of a current view. - * - * @returns {Object} - */ - getSaved: function () { - return this.activeView().getData(); - }, - - /** - * Retrieves default data. - * - * @returns {Object} - */ - getDefault: function () { - return this.defaultView.getData(); - }, - /** * Defines default data if it wasn't gathered previously. * Assumes that if theres is no views available, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js index b42fedfe78dd725567fbb7ed3f7f48b196533af5..afd5d4276de442947da6755cf208f191268226d3 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js @@ -58,12 +58,19 @@ define([ }, /** - * Retrieves current data. + * Retrieves copied views' data. * - * @returns {Object} + * @param {String} [path] - Path to the specific property. + * @returns {*} */ - getData: function () { - return utils.copy(this.data.items); + getData: function (path) { + var data = this.data.items; + + if (path) { + data = utils.nested(data, path); + } + + return utils.copy(data); }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js index f48a86abab1c2937c1a0076137fa7539fc41f2ca..765e437334285090378e1db15d8ac33753da9ab8 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js @@ -3,10 +3,11 @@ * See COPYING.txt for license details. */ define([ + 'underscore', 'mageUtils', 'mage/translate', 'Magento_Ui/js/lib/collapsible' -], function (utils, $t, Collapsible) { +], function (_, utils, $t, Collapsible) { 'use strict'; return Collapsible.extend({ @@ -15,32 +16,59 @@ define([ minVisible: 1, maxVisible: 30, viewportSize: 18, + columnsData: { + container: 'elems' + }, + imports: { + addColumns: '${ $.columnsData.provider }:${ $.columnsData.container }' + }, templates: { headerMsg: $t('${ $.visible } out of ${ $.total } visible') } }, /** - * Action Reset + * Resets columns visibility to theirs default state. + * + * @returns {Columns} Chainable. */ reset: function () { - this.elems.each('applyState', 'visible', 'default'); + this.elems.each('applyState', 'default', 'visible'); return this; }, /** - * Action Cancel + * Applies last saved state of columns visibility. + * + * @returns {Columns} Chainable. */ cancel: function () { - this.elems.each('applyState', 'visible', 'last'); + this.elems.each('applyState', 'saved', 'visible'); return this; }, /** - * Helper, which helps to stop resizing. - * viewportSize limits number of elements. + * Adds columns whose visibility can be controlled to the component. + * + * @param {Array} columns - Elements array that will be added to component. + * @returns {Columns} Chainable. + */ + addColumns: function (columns) { + columns = _.where(columns, { + controlVisibility: true + }); + + this.insertChild(columns); + + return this; + }, + + /** + * Defines whether child elements array length + * is greater than the 'viewportSize' property. + * * @returns {Boolean} */ hasOverflow: function () { @@ -51,6 +79,7 @@ define([ * Helper, checks * - if less than one item choosen * - if more then viewportMaxSize choosen + * * @param {Object} elem * @returns {Boolean} */ @@ -63,7 +92,8 @@ define([ }, /** - * Helper, returns number of visible checkboxes + * Counts number of visible columns. + * * @returns {Number} */ countVisible: function () { @@ -72,8 +102,7 @@ define([ /** * Compile header message from headerMessage setting. - * Expects Underscore template format - * @param {String} text - underscore-format template + * * @returns {String} */ getHeaderMessage: function () { diff --git a/app/code/Magento/Ui/view/base/web/js/grid/dnd.js b/app/code/Magento/Ui/view/base/web/js/grid/dnd.js new file mode 100644 index 0000000000000000000000000000000000000000..d1eb5ee827c40825b4f7df3620bb7215d4e21b68 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/grid/dnd.js @@ -0,0 +1,473 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'ko', + 'jquery', + 'underscore', + 'Magento_Ui/js/lib/class' +], function (ko, $, _, Class) { + 'use strict'; + + var isTouchDevice = typeof document.ontouchstart !== 'undefined', + transformProp; + + /** + * Defines supported css 'transform' property. + * + * @returns {String|Undefined} + */ + transformProp = (function () { + var style = document.body.style, + base = 'Transform', + vendors = ['webkit', 'moz', 'ms', 'o'], + vi = vendors.length, + property; + + if (typeof style.transform != 'undefined') { + return 'transform'; + } + + while (vi--) { + property = vendors[vi] + base; + + if (typeof style[property] != 'undefined') { + return property; + } + } + })(); + + /** + * Returns first touch data if it's available. + * + * @param {(MouseEvent|TouchEvent)} e - Event object. + * @returns {Object} + */ + function getTouch(e) { + return e.touches ? e.touches[0] : e; + } + + /** + * Moves specified DOM element to the x and y coordinates. + * + * @param {HTMLElement} elem - Element to be relocated. + * @param {Number} x - X coordinate. + * @param {Number} y - Y coordinate. + */ + function locate(elem, x, y) { + var value = 'translate(' + x + 'px,' + y + 'px)'; + + elem.style[transformProp] = value; + } + + /*eslint-disable no-extra-parens*/ + /** + * Checks if specified coordinate is inside of the provided area. + * + * @param {Number} x - X coordinate. + * @param {Number} y - Y coordinate. + * @param {Object} area - Object which represents area. + * @returns {Boolean} + */ + function isInside(x, y, area) { + return ( + area && + x >= area.left && x <= area.right && + y >= area.top && y <= area.bottom + ); + } + /*eslint-enable no-extra-parens*/ + + /** + * Calculates distance between two points. + * + * @param {Number} x1 - X coordinate of a first point. + * @param {Number} y1 - Y coordinate of a first point. + * @param {Number} x2 - X coordinate of a second point. + * @param {Number} y2 - Y coordinate of a second point. + * @returns {Number} Distance between points. + */ + function distance(x1, y1, x2, y2) { + var dx = x2 - x1, + dy = y2 - y1; + + dx *= dx; + dy *= dy; + + return Math.sqrt(dx + dy); + } + + /** + * Returns viewModel associated with a provided DOM element. + * + * @param {HTMLElement} elem + * @returns {Object|Array} + */ + function getModel(elem) { + return ko.contextFor(elem).$data; + } + + return Class.extend({ + defaults: { + noSelectClass: '_no-select', + hiddenClass: '_hidden', + fixedX: false, + fixedY: true, + minDistance: 2, + columns: [] + }, + + /** + * Initializes Dnd component. + * + * @returns {Dnd} Chainable. + */ + initialize: function () { + _.bindAll(this, 'onMouseMove', 'onMouseUp', 'onMouseDown'); + + this.$body = $('body'); + + this._super() + .initListeners(); + + return this; + }, + + /** + * Binds necessary events listeners. + * + * @returns {Dnd} Chainbale. + */ + initListeners: function () { + var addListener = document.addEventListener; + + if (isTouchDevice) { + addListener('touchmove', this.onMouseMove, false); + addListener('touchend', this.onMouseUp, false); + addListener('touchleave', this.onMouseUp, false); + } else { + addListener('mousemove', this.onMouseMove, false); + addListener('mouseup', this.onMouseUp, false); + } + + return this; + }, + + /** + * Sets specified column as a draggable element. + * + * @param {HTMLTableHeaderCellElement} column - Columns header element. + * @returns {Dnd} Chainable. + */ + addColumn: function (column) { + this.columns.push(column); + + isTouchDevice ? + column.addEventListener('touchstart', this.onMouseDown, false) : + column.addEventListener('mousedown', this.onMouseDown, false); + + return this; + }, + + /** + * Defines specified table element as a main container. + * + * @param {HTMLTableElement} table + * @returns {Dnd} Chainable. + */ + setTable: function (table) { + this.table = table; + + return this; + }, + + /** + * Defines specified table element as a draggable table. + * Only this element will be moved across the screen. + * + * @param {HTMLTableElement} dragTable + * @returns {Dnd} Chainable. + */ + setDragTable: function (dragTable) { + this.dragTable = dragTable; + + return this; + }, + + /** + * Calculates coordinates of draggable elements. + * + * @returns {Dnd} Chainbale. + */ + _cacheCoords: function () { + var container = this.table.getBoundingClientRect(), + bodyRect = document.body.getBoundingClientRect(), + grabbed = this.grabbed, + dragElem = grabbed.elem, + cells = _.toArray(dragElem.parentNode.cells), + rect; + + this.coords = this.columns.map(function (column) { + var data; + + rect = column.getBoundingClientRect(); + + data = { + index: cells.indexOf(column), + target: column, + orig: rect, + left: rect.left - bodyRect.left, + right: rect.right - bodyRect.left, + top: rect.top - bodyRect.top, + bottom: container.bottom - bodyRect.top + }; + + if (column === dragElem) { + this.dragArea = data; + + grabbed.shiftX = rect.left - grabbed.x; + grabbed.shiftY = rect.top - grabbed.y; + } + + return data; + }, this); + + return this; + }, + + /** + * Coppies dimensions of a grabbed column + * to a draggable grid. + * + * @param {HTMLTableHeaderCellElement} elem - Grabbed column. + * @returns {Dnd} Chainable. + */ + _copyDimensions: function (elem) { + var dragTable = this.dragTable, + dragBody = dragTable.tBodies[0], + dragTrs = dragBody ? dragBody.children : [], + origTrs = _.toArray(this.table.tBodies[0].children), + columnIndex = _.toArray(elem.parentNode.cells).indexOf(elem), + origTd, + dragTr; + + dragTable.style.width = elem.offsetWidth + 'px'; + dragTable.tHead.firstElementChild.cells[0].style.height = elem.offsetHeight + 'px'; + + origTrs.forEach(function (origTr, rowIndex) { + origTd = origTr.cells[columnIndex]; + dragTr = dragTrs[rowIndex]; + + if (origTd && dragTr) { + dragTr.cells[0].style.height = origTd.offsetHeight + 'px'; + } + }); + + return this; + }, + + /** + * Matches provided coordinates to available areas. + * + * @param {Number} x - X coordinate of a mouse pointer. + * @param {Number} y - Y coordinate of a mouse pointer. + * @returns {Object|Undefined} Matched area. + */ + _getDropArea: function (x, y) { + return _.find(this.coords, function (area) { + return isInside(x, y, area); + }); + }, + + /** + * Updates state of hovered areas. + * + * @param {Number} x - X coordinate of a mouse pointer. + * @param {Number} y - Y coordinate of a mouse pointer. + */ + _updateAreas: function (x, y) { + var leavedArea = this.dropArea, + area = this.dropArea = this._getDropArea(x, y); + + if (leavedArea) { + this.dragleave(leavedArea); + } + + if (area && area.target !== this.dragArea.target) { + this.dragenter(area); + } + }, + + /** + * Grab action handler. + * + * @param {Number} x - X coordinate of a grabbed point. + * @param {Number} y - Y coordinate of a grabbed point. + * @param {HTMLElement} elem - Grabbed elemenet. + */ + grab: function (x, y, elem) { + this.initDrag = true; + this.grabbed = { + x: x, + y: y, + elem: elem + }; + + this.$body.addClass(this.noSelectClass); + }, + + /** + * Dragstart action handler. + * + * @param {HTMLTableHeaderCellElement} elem - Element which is dragging. + */ + dragstart: function (elem) { + this.initDrag = false; + this.dropArea = false; + this.dragging = true; + + getModel(elem).dragging(true); + + this._cacheCoords() + ._copyDimensions(elem); + + $(this.dragTable).removeClass(this.hiddenClass); + }, + + /** + * Drag action handler. Locates draggable + * grid at a specified coordinates. + * + * @param {Number} x - X coordinate. + * @param {Number} y - Y coordinate. + */ + drag: function (x, y) { + var grabbed = this.grabbed, + dragArea = this.dragArea, + posX = x + grabbed.shiftX, + posY = y + grabbed.shiftY; + + if (this.fixedX) { + x = dragArea.left; + posX = dragArea.orig.left; + } + + if (this.fixedY) { + y = dragArea.top; + posY = dragArea.orig.top; + } + + locate(this.dragTable, posX, posY); + + if (!isInside(x, y, this.dropArea)) { + this._updateAreas(x, y); + } + }, + + /** + * Dragenter action handler. + * + * @param {Object} dropArea + */ + dragenter: function (dropArea) { + var direction = this.dragArea.index < dropArea.index ? + 'left' : + 'right'; + + getModel(dropArea.target).dragover(direction); + }, + + /** + * Dragleave action handler. + * + * @param {Object} dropArea + */ + dragleave: function (dropArea) { + getModel(dropArea.target).dragover(false); + }, + + /** + * Dragend action handler. + * + * @param {Object} dragArea + */ + dragend: function (dragArea) { + var dropArea = this.dropArea, + dragElem = dragArea.target; + + this.dragging = false; + + $(this.dragTable).addClass(this.hiddenClass); + + getModel(dragElem).dragging(false); + + if (dropArea && dropArea.target !== dragElem) { + this.drop(dropArea, dragArea); + } + }, + + /** + * Drop action handler. + * + * @param {Object} dropArea + * @param {Object} dragArea + */ + drop: function (dropArea, dragArea) { + var dropModel = getModel(dropArea.target), + dragModel = getModel(dragArea.target); + + getModel(this.table).insertChild(dragModel, dropModel); + dropModel.dragover(false); + }, + + /** + * Documents' 'mousemove' event handler. + * + * @param {(MouseEvent|TouchEvent)} e - Event object. + */ + onMouseMove: function (e) { + var grab = this.grabbed, + touch = getTouch(e), + x = touch.pageX, + y = touch.pageY; + + if (this.initDrag || this.dragging) { + e.preventDefault(); + } + + if (this.initDrag && distance(x, y, grab.x, grab.y) >= this.minDistance) { + this.dragstart(grab.elem); + } + + if (this.dragging) { + this.drag(x, y); + } + }, + + /** + * Documents' 'mouseup' event handler. + */ + onMouseUp: function () { + if (this.initDrag || this.dragging) { + this.initDrag = false; + this.$body.removeClass(this.noSelectClass); + } + + if (this.dragging) { + this.dragend(this.dragArea); + } + }, + + /** + * Columns' 'mousedown' event handler. + * + * @param {(MouseEvent|TouchEvent)} e - Event object. + */ + onMouseDown: function (e) { + var touch = getTouch(e); + + this.grab(touch.pageX, touch.pageY, e.currentTarget); + } + }); +}); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js index bcd26c0f6fa5ed3f641f455747094a401641a5fd..558e6629a166b5e47676af7513415add275e54c6 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js @@ -5,8 +5,9 @@ define([ 'underscore', 'mageUtils', + 'Magento_Ui/js/core/renderer/layout', 'Magento_Ui/js/lib/collapsible' -], function (_, utils, Collapsible) { +], function (_, utils, layout, Collapsible) { 'use strict'; function extractPreview(elem) { @@ -39,15 +40,15 @@ define([ filters: { placeholder: true }, - listens: { - active: 'extractPreviews', - applied: 'cancel extractActive' - }, links: { applied: '${ $.storageConfig.path }' }, exports: { applied: '${ $.provider }:params.filters' + }, + listens: { + active: 'updatePreviews', + applied: 'cancel extractActive' } }, @@ -57,6 +58,8 @@ define([ * @returns {Filters} Chainable. */ initialize: function () { + this._processedColumns = {}; + this._super() .cancel() .extractActive(); @@ -182,12 +185,12 @@ define([ }, /** - * Extract previews of a specified filters. + * Updates previews of a specified filters. * * @param {Array} filters - Filters to be processed. * @returns {Filters} Chainable. */ - extractPreviews: function (filters) { + updatePreviews: function (filters) { var previews = filters.map(extractPreview); this.previews(_.compact(previews)); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/listing.js b/app/code/Magento/Ui/view/base/web/js/grid/listing.js index fd7d70f9f7fd13f62fb111a70eacc1957655017b..299560ba2bfe5eaa6a4e06319e7388135e6ee941 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/listing.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/listing.js @@ -3,23 +3,54 @@ * See COPYING.txt for license details. */ define([ + 'underscore', 'uiComponent', - 'Magento_Ui/js/lib/spinner' -], function (Component, loader) { + 'Magento_Ui/js/lib/spinner', + 'Magento_Ui/js/core/renderer/layout' +], function (_, Component, loader, layout) { 'use strict'; return Component.extend({ defaults: { template: 'ui/grid/listing', + positions: false, + storageConfig: { + positions: '${ $.storageConfig.path }.positions' + }, + dndConfig: { + name: '${ $.name }_dnd', + component: 'Magento_Ui/js/grid/dnd', + containerTmpl: 'ui/grid/dnd/listing', + enabled: true + }, imports: { rows: '${ $.provider }:data.items' }, listens: { + elems: 'setPositions', '${ $.provider }:reload': 'showLoader', '${ $.provider }:reloaded': 'hideLoader' + }, + modules: { + dnd: '${ $.dndConfig.name }' } }, + /** + * Initializes Listing component. + * + * @returns {Listing} Chainable. + */ + initialize: function () { + this._super(); + + if (this.dndConfig.enabled) { + this.initDnd(); + } + + return this; + }, + /** * Initializes observable properties. * @@ -32,6 +63,90 @@ define([ return this; }, + /** + * Creates drag&drop widget instance. + * + * @returns {Listing} Chainable. + */ + initDnd: function () { + layout([this.dndConfig]); + + return this; + }, + + /** + * Called when another element was added to current component. + * + * @returns {Listing} Chainable. + */ + initElement: function () { + var currentCount = this.elems().length, + totalCount = this.initChildCount; + + if (totalCount === currentCount) { + this.initPositions(); + } + + return this._super(); + }, + + /** + * Defines initial order of child elements. + * + * @returns {Listing} Chainable. + */ + initPositions: function () { + var link = { + positions: this.storageConfig.positions + }; + + this.on('positions', this.applyPositions.bind(this)); + + this.setLinks(link, 'imports') + .setLinks(link, 'exports'); + + return this; + }, + + /** + * Updates current state of child positions. + * + * @returns {Listing} Chainable. + */ + setPositions: function () { + var positions = {}; + + this.elems.each(function (elem, index) { + positions[elem.index] = index; + }); + + this.set('positions', positions); + + return this; + }, + + /** + * Reseorts child elements array according to provided positions. + * + * @param {Object} positions - Object where key represents child + * index and value is its' position. + * @returns {Listing} Chainable. + */ + applyPositions: function (positions) { + var sorting; + + sorting = this.elems.map(function (elem) { + return { + elem: elem, + position: positions[elem.index] + }; + }); + + this.insertChild(sorting); + + return this; + }, + /** * Hides loader. */ diff --git a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js index 35c792feaba23e40c19c68f2609171c798983297..21e86a6d640b2f43aab310774f09ce31d69583de 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js @@ -4,37 +4,178 @@ */ define([ 'underscore', + 'uiRegistry', 'mageUtils', - 'Magento_Ui/js/lib/collapsible' -], function (_, utils, Collapsible) { + 'Magento_Ui/js/lib/collapsible', + 'Magento_Ui/js/modal/confirm', + 'Magento_Ui/js/modal/alert', + 'mage/translate' +], function (_, registry, utils, Collapsible, confirm, alert, $t) { 'use strict'; return Collapsible.extend({ defaults: { template: 'ui/grid/actions', - noItems: 'You haven\'t selected any items!' + selectProvider: '', + actions: [], + noItemsMsg: $t('You haven\'t selected any items!'), + modules: { + selections: '${ $.selectProvider }' + } }, - applyAction: function (action) { - var proceed = true, - selections = this.source.get('config.multiselect'); + /** + * Initializes observable properties. + * + * @returns {Massactions} Chainable. + */ + initObservable: function () { + this._super() + .observe('actions'); + + return this; + }, - if (!selections || !selections.total) { - proceed = false; + /** + * Applies specified action. + * + * @param {String} actionIndex - Actions' identifier. + * @returns {Massactions} Chainable. + */ + applyAction: function (actionIndex) { + var data = this.getSelections(), + action, + callback; - alert(this.noItems); - } + if (!data.total) { + alert({ + content: this.noItemsMsg + }); - if (proceed && action.confirm) { - proceed = window.confirm(action.confirm); + return this; } - if (proceed) { - utils.submit({ - url: action.url, - data: selections + action = this.getAction(actionIndex), + callback = this._getCallback(action, data); + + action.confirm ? + this._confirm(action, callback) : + callback(); + + return this; + }, + + /** + * Retrieves selections data from the selections provider. + * + * @returns {Object|Undefined} + */ + getSelections: function () { + var provider = this.selections(), + selections = provider && provider.getSelections(); + + return selections; + }, + + /** + * Retrieves action object associated with a specified index. + * + * @param {String} actionIndex - Actions' identifier. + * @returns {Object} Action object. + */ + getAction: function (actionIndex) { + return _.findWhere(this.actions(), { + type: actionIndex + }); + }, + + /** + * Adds new action. If action with a specfied identifier + * already exists, than the original one will be overrided. + * + * @param {Object} action - Action object. + * @returns {Massactions} Chainable. + */ + addAction: function (action) { + var actions = this.actions(), + index = _.findIdnex(actions, { + type: action.type }); + + ~index ? + actions[index] = action : + actions.push(action); + + this.actions(actions); + + return this; + }, + + /** + * Creates action callback based on its' data. If action doesn't spicify + * a callback function than the default one will be used. + * + * @private + * @param {Object} action - Actions' object. + * @param {Object} selections - Selections data. + * @returns {Function} Callback function. + */ + _getCallback: function (action, selections) { + var callback = action.callback, + args = [action, selections]; + + if (utils.isObject(callback)) { + args.unshift(callback.target); + + callback = registry.async(callback.provider); + } else if (typeof callback != 'function') { + callback = this.defaultCallback.bind(this); } + + return function () { + callback.apply(null, args); + }; + }, + + /** + * Default action callback. Sends selections data + * via POST request. + * + * @param {Object} data - Selections data. + * @param {Object} action - Action data. + */ + defaultCallback: function (data, action) { + var selections = {}; + + if (data.excludeMode) { + selections.excluded = data.excluded; + } else { + selections.selected = data.selected; + } + + utils.submit({ + url: action.url, + data: selections + }); + }, + + /** + * Shows actions' confirmation window. + * + * @param {Object} action - Actions' data. + * @param {Function} callback - Callback that will be + * invoked if action is confirmed. + */ + _confirm: function (action, callback) { + var confirmData = action.confirm; + + confirm({ + title: confirmData.title, + content: confirmData.message, + actions: { + confirm: callback + } + }); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/paging.js b/app/code/Magento/Ui/view/base/web/js/grid/paging.js index e04597379afa39323ca1a5700b7d5a14e06017c9..0fd512c3ffc48a3e3b840dbb2d8ef29d2ef0d829 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/paging.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/paging.js @@ -23,9 +23,10 @@ define([ template: 'ui/grid/paging', pageSize: 20, current: 1, + selectProvider: '', imports: { - totalSelected: '${ $.provider }:config.multiselect.total', + totalSelected: '${ $.selectProvider }:totalSelected', totalRecords: '${ $.provider }:data.totalRecords' }, diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/links.js b/app/code/Magento/Ui/view/base/web/js/lib/component/links.js index 94df6c5d22c3cecb1d53de18eca10c00c01e89b5..deecc3fa9a14acdaf5f59b073a7d0b067c90c7be 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/links.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/component/links.js @@ -81,22 +81,19 @@ define([ } function setLinked(map, data) { - var hasLink, - match; - + var match; + if (!map) { return; } - hasLink = map.some(function (item) { - match = item; - - return !item.linked && - item.target === data.target && - item.property === data.property; + match = _.findWhere(map, { + linked: false, + target: data.target, + property: data.property }); - if (hasLink) { + if (match) { match.linked = data; data.linked = match; } @@ -106,6 +103,8 @@ define([ var direction = data.direction, map = maps[direction]; + data.linked = false; + (map[property] = map[property] || []).push(data); direction = direction === 'imports' ? 'exports' : 'imports'; @@ -165,7 +164,7 @@ define([ }); }); }); - + return this; }, diff --git a/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js b/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js index cc82f645030e071a202ae68fca9ccb282ac27de6..a91b3cd38b611151d50068a2c41fc94a818e4085 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/component/manip.js @@ -10,45 +10,17 @@ define([ ], function (ko, _, utils, registry) { 'use strict'; - function getIndex(container, target) { - var result; - - container.some(function (item, index) { - result = index; - - return item && (item.name === target || item === target); - }); - - return result; - } - function compact(container) { return container.filter(utils.isObject); } - function reserve(container, elem, position) { - var offset = position, - target; - - if (_.isObject(position)) { - target = position.after || position.before; - offset = getIndex(container, target); - - if (position.after) { - ++offset; - } - } - - offset = utils.formatOffset(container, offset); - - container[offset] ? - container.splice(offset, 0, elem) : - container[offset] = elem; - - return offset; - } - return { + /** + * Retrieves requested region. + * Creates region if it was not created yet + * + * @returns {ObservableArray}. + */ getRegion: function (name) { var regions = this.regions = this.regions || {}; @@ -59,23 +31,65 @@ define([ return regions[name]; }, + /** + * Replaces specified regions' data with a provided one. + * Creates region if it was not created yet. + * + * @param {Array} items - New regions' data. + * @param {String} name - Name of the region. + * @returns {Component} Chainable. + */ updateRegion: function (items, name) { var region = this.getRegion(name); region(items); + + return this; }, /** * Requests specified components to insert * them into 'elems' array starting from provided position. * - * @param {String} elem - Name of the component to insert. + * @param {String} elems - Name of the component to insert. * @param {Number} [position=-1] - Position at which to insert elements. * @returns {Component} Chainable. */ - insertChild: function (elem, position) { - reserve(this._elems, elem, position); - registry.get(elem, this._insert); + insertChild: function (elems, position) { + var container = this._elems, + update = false, + newItems = [], + newItem; + + if (Array.isArray(elems)) { + newItems = elems.map(function (item) { + newItem = item.elem ? + utils.insert(item.elem, container, item.position) : + utils.insert(item, container, position); + + return newItem; + }); + } else { + newItems.push(utils.insert(elems, container, position)); + } + + newItems.forEach(function (item) { + if (!item) { + return; + } + + if (item === true) { + update = true; + } else { + _.isString(item) ? + registry.get(item, this._insert) : + this._insert(item); + } + }, this); + + if (update) { + this._update(); + } return this; }, diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js new file mode 100644 index 0000000000000000000000000000000000000000..2297f2d5cf1764d0198b791ec6011f3b2debf2b8 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js @@ -0,0 +1,22 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'ko' +], function (ko) { + 'use strict'; + + ko.bindingHandlers.afterRender = { + /** + * Binding init callback. + */ + init: function (element, valueAccessor, allBindings, viewModel) { + var callback = valueAccessor(); + + if (typeof callback === 'function') { + callback(element, viewModel); + } + } + }; +}); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js b/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js index a8bb4a15077772cc66f78d7f85a00f1e94383161..2758b3f8c2391b60ff9fefa818279fc9af09a295 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js @@ -14,11 +14,11 @@ define([ './bind/optgroup', './bind/fadeVisible', './bind/mage-init', + './bind/after-render', './extender/observable_array' -], function(ko, templateEngine) { +], function (ko, templateEngine) { 'use strict'; ko.setTemplateEngine(templateEngine); ko.applyBindings(); - }); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js index adf6b9176b4004d6d55c52cffe1fc2398cb13207..4bf6b21f686f8365c90515b2919c108b5fda2d8d 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js @@ -7,23 +7,23 @@ define([ 'underscore', './storage', './events' -], function(utils, _, Storage, Events) { +], function (utils, _, Storage, Events) { 'use strict'; - function async(name, registry, method) { + function async(name, registry, method) { var args = _.toArray(arguments).slice(3); if (_.isString(method)) { registry.get(name, function (component) { - component[method].apply(component, args); + component[method].apply(component, args); }); } else if (_.isFunction(method)) { - registry.get(name, method); + registry.get(name, method); } else if (!args.length) { return registry.get(name); } - } - + } + function Registry() { this.storage = new Storage(); this.events = new Events(this.storage); @@ -35,9 +35,9 @@ define([ /** * Retrieves data from registry. * - * @params {(String|Array)} elems - + * @param {(String|Array)} elems - * An array of elements' names or a string of names divided by spaces. - * @params {Function} [callback] - + * @param {Function} [callback] - * Callback function that will be triggered * when all of the elements are registered. * @returns {Array|*|Undefined} @@ -45,7 +45,7 @@ define([ * or an element itself if only is requested. * If callback function is specified then returns 'undefined'. */ - get: function(elems, callback) { + get: function (elems, callback) { var records; elems = utils.stringToArray(elems) || []; @@ -64,8 +64,8 @@ define([ /** * Sets data to registry. * - * @params {String} elems - Elements' name. - * @params {*} value - Value that will be assigned to the element. + * @param {String} elem - Elements' name. + * @param {*} value - Value that will be assigned to the element. * @returns {registry} Chainable. */ set: function (elem, value) { @@ -77,7 +77,7 @@ define([ /** * Removes specified elements from a storage. - * @params {(String|Array)} elems - + * @param {(String|Array)} elems - * An array of elements' names or a string of names divided by spaces. * @returns {registry} Chainable. */ @@ -92,7 +92,7 @@ define([ /** * Checks whether specified elements has been registered. * - * @params {(String|Array)} elems - + * @param {(String|Array)} elems - * An array of elements' names or a string of names divided by spaces. * @returns {Boolean} */ diff --git a/app/code/Magento/Ui/view/base/web/js/modal/alert.js b/app/code/Magento/Ui/view/base/web/js/modal/alert.js new file mode 100644 index 0000000000000000000000000000000000000000..33be3c8041dea6c2f0586124bc3f1e8120020cef --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/modal/alert.js @@ -0,0 +1,40 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'underscore', + 'jquery/ui', + 'Magento_Ui/js/modal/confirm', + 'mage/translate' +], function ($, _) { + 'use strict'; + + $.widget('mage.alert', $.mage.confirm, { + options: { + modalClass: 'confirm', + title: $.mage.__('Attention'), + actions: { + always: function () {} + }, + buttons: [{ + text: $.mage.__('OK'), + class: 'action-secondary', + click: function () { + this.closeModal(true); + } + }] + }, + closeModal: function () { + this.options.actions.always(); + this.element.bind('confirmclosed', _.bind(this._remove, this)); + + return this._super(); + } + }); + + return function (config) { + return $('<div></div>').html(config.content).alert(config); + }; +}); diff --git a/app/code/Magento/Ui/view/base/web/js/modal/confirm.js b/app/code/Magento/Ui/view/base/web/js/modal/confirm.js new file mode 100644 index 0000000000000000000000000000000000000000..7bad2023b649b18edeaf710780d8cf0e73a5f6b9 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/modal/confirm.js @@ -0,0 +1,66 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'underscore', + 'jquery/ui', + 'Magento_Ui/js/modal/modal', + 'mage/translate' +], function ($, _) { + 'use strict'; + + $.widget('mage.confirm', $.mage.modal, { + options: { + modalClass: 'confirm', + title: '', + actions: { + always: function(){}, + confirm: function(){}, + cancel: function(){} + }, + buttons: [{ + text: $.mage.__('Cancel'), + class: 'action-tertiary', + click: function(){ + this.closeModal(); + } + }, { + text: $.mage.__('OK'), + class: 'action-secondary', + click: function() { + this.closeModal(true); + } + }] + }, + _create: function() { + this._super(); + this.modal.find(this.options.modalCloseBtn).off().on('click', _.bind(this.closeModal, this, false)); + this.openModal(); + }, + _remove: function() { + this.modal.remove(); + }, + openModal: function() { + return this._super(); + }, + closeModal: function(result) { + result = result || false; + + if (result) { + this.options.actions.confirm(); + } else { + this.options.actions.cancel(); + } + this.options.actions.always(); + this.element.bind('confirmclosed', _.bind(this._remove, this)); + + return this._super(); + } + }); + + return function (config) { + return $('<div></div>').html(config.content).confirm(config); + }; +}); diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modalToggle.js b/app/code/Magento/Ui/view/base/web/js/modal/modalToggle.js new file mode 100644 index 0000000000000000000000000000000000000000..65714ef029cf6ba25199057fc8b64ab03515b01f --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/modal/modalToggle.js @@ -0,0 +1,28 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'Magento_Ui/js/modal/modal' +], function($){ + 'use strict'; + + return function(config, el) { + var widget = $(config.content).modal(config); + + $(el).on(config.toggleEvent, function() { + var state = widget.data('mage-modal').options.isOpen; + + if (state) { + widget.modal('closeModal'); + } else { + widget.modal('openModal'); + } + + return false; + }); + + return widget; + }; +}); \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/actions.html b/app/code/Magento/Ui/view/base/web/templates/grid/actions.html index 685936aa8430382b59ff1b065c74e244aadcd24a..89bf5ba4061d17358994f8a2c3cf9d8158d90d51 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/actions.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/actions.html @@ -18,8 +18,8 @@ <ul class="action-menu" data-bind="css: {'_active': opened}, - foreach: {data: actions, as: 'action'}"> - <li data-bind="click: $parent.applyAction.bind($parent, action)"> + foreach: actions"> + <li data-bind="click: $parent.applyAction.bind($parent, type)"> <span class="action-menu-item" data-bind="text: label"></span> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html index 67f195377c669e5ba824a8be13603c69fa2aa0bf..85fba7ed0c6c2d5c725486bd30bf69b65c4ea213 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/actions.html @@ -6,25 +6,47 @@ --> <td data-bind="visible: visible" class="data-grid-actions-cell"> - <!-- ko if: getDisplayed(row[field.index]).length > 1 --> - <div class="action-select-wrap _active"> - <button class="action-select"> + <!-- ko if: isSingle($parentContext.$index()) --> + <!-- ko foreach: getVisibleActions($parentContext.$index()) --> + <a + class="action-menu-item" + data-bind=" + attr: { + href: $data.href + }, + click: $parent.applyAction.bind($parent, index, rowIndex), + text: $data.label"></a> + <!-- /ko --> + <!-- /ko --> + + <!-- ko if: isMultiple($parentContext.$index()) --> + <div + class="action-select-wrap" + data-bind=" + css : { + '_active' : opened() === $parentContext.$index() + }, + outerClick: closeList.bind($data, $parentContext.$index())"> + <button class="action-select" data-bind="click: toggleList.bind($data, $parentContext.$index())"> <span data-bind="text: $t('Select')"></span> </button> - <ul class="action-menu _active"> + <ul + class="action-menu" + data-bind=" + css: {'_active': opened() === $parentContext.$index()}"> + <!-- ko foreach: getVisibleActions($parentContext.$index()) --> <li> <a class="action-menu-item" - data-bind="attr: {href: displayed[0].href}, - text: displayed[0].label"></a> + data-bind=" + attr: { + href: $data.href + }, + click: $parent.applyAction.bind($parent, index, rowIndex), + text: $data.label"></a> </li> + <!-- /ko --> </ul> </div> <!-- /ko --> - <!-- ko ifnot: getDisplayed(row[field.index]).length > 1 --> - <a - class="action-menu-item" - data-bind="attr: {href: displayed[0].href}, - text: displayed[0].label"></a> - <!-- /ko --> </td> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html index 27d6bfcf6216b5a5d6ace4d652e681814b99bcaf..166a4f1f9b7e9a7d25b6a973f95e462019e9234e 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/html.html @@ -5,7 +5,9 @@ */ --> <td - data-bind="visible: visible, - click: isClickable(row) ? redirect.bind($data, getClickUrl(row)) : false, - html: getLabel(row[field.index])" + data-bind=" + visible: visible, + css: { _dragging: dragging }, + click: isClickable(row) ? redirect.bind($data, getClickUrl(row)) : false, + html: getLabel(row[field.index])" data-action="grid-row-edit"></td> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html index 81e6b2c5bc3706a042daf1f6e2b3725e84b681c4..c11acd1f36ecea301095cea6258c9b1a65c781e7 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/multiselect.html @@ -10,9 +10,12 @@ <input class="admin__control-checkbox" type="checkbox" - data-bind="checked: selected, - value: row[indexField], - attr: {id: 'check' + row[indexField]}"> + data-bind=" + checked: selected, + value: row[indexField], + attr: { + id: 'check' + row[indexField] + }"> <label data-bind="attr: {for: 'check' + row[indexField]}"></label> </label> </td> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html b/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html index 257b4b0585d45aec84541ae338780047e16e3852..09ecafbdfbab9bf193a52b0f28063a79693ba68d 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/cells/text.html @@ -4,8 +4,10 @@ * See COPYING.txt for license details. */ --> -<td - data-bind="visible: visible, - click: isClickable(row) ? redirect.bind($data, getClickUrl(row)) : false, - text: getLabel(row[field.index])" +<td + data-bind=" + visible: visible, + css: { _dragging: dragging }, + click: isClickable(row) ? redirect.bind($data, getClickUrl(row)) : false, + text: getLabel(row[field.index])" data-action="grid-row-edit"></td> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/columns/actions.html b/app/code/Magento/Ui/view/base/web/templates/grid/columns/actions.html deleted file mode 100644 index 5d3aaa53d9bafc964ba9515d5fa6cb900de9c594..0000000000000000000000000000000000000000 --- a/app/code/Magento/Ui/view/base/web/templates/grid/columns/actions.html +++ /dev/null @@ -1,10 +0,0 @@ -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<th class="data-grid-th data-grid-actions-cell" data-bind="visible: visible"> - <span data-bind="text: label"></span> -</th> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html b/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html index dc7b883659adb7cc690246acbc840cc12520ef6d..41207503828c1221929d6b0eb96914dcd45b5b00 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/columns/text.html @@ -4,17 +4,21 @@ * See COPYING.txt for license details. */ --> - -<!-- ko if: sortable --> - <th - class="data-grid-th _sortable" - data-bind="css: sortClass, click: sort, visible: visible"> - <span data-bind="text: label"></span> - </th> -<!-- /ko --> - -<!-- ko ifnot: sortable --> - <th class="data-grid-th" data-bind="visible: visible"> - <span data-bind="text: label"></span> - </th> -<!-- /ko --> +<th + class="data-grid-th" + data-bind=" + afterRender: draggable && $parent.dndConfig.enabled ? + (function (elem) { $parent.dnd('addColumn', elem); }) : + false, + css: { + '_sortable': sortable, + '_draggable': draggable, + '_ascend': sorting() === 'asc', + '_descend': sorting() === 'desc', + '_dragover-left': dragover() === 'right', + '_dragover-right': dragover() === 'left' + }, + click: sort, + visible: visible"> + <span data-bind="text: label"></span> +</th> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/dnd/listing.html b/app/code/Magento/Ui/view/base/web/templates/grid/dnd/listing.html new file mode 100644 index 0000000000000000000000000000000000000000..38b622cdef6cfe21bfe25e9176b2ff90c8fe1a8b --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/templates/grid/dnd/listing.html @@ -0,0 +1,42 @@ + +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<table + class="data-grid _dragging-copy _hidden" + data-bind=" + afterRender: function (elem) { dnd('setDragTable', elem); } + "> + <thead data-part="head"> + <tr data-part="head.row"> + <!-- ko foreach: elems --> + <!-- ko if: dragging --> + <!-- ko template: getHeader() --><!-- /ko --> + <!-- /ko --> + <!-- /ko --> + </tr> + </thead> + <tbody data-part="body"> + <!-- ko if: hasData() --> + <!-- ko foreach: { data: rows, as: 'row' } --> + <tr data-part="body.row"> + <!-- ko foreach: { data: $parent.elems, as: 'field' } --> + <!-- ko if: dragging --> + <!-- ko template: getBody() --><!-- /ko --> + <!-- /ko --> + <!-- /ko --> + </tr> + <!-- /ko --> + <!-- /ko --> + + <!-- ko ifnot: hasData() --> + <tr class="data-grid-tr-no-data"> + <td data-bind="attr: { colspan: getColspan() }, + text: $t('We couldn\'t find any records.')"></td> + </tr> + <!-- /ko --> + </tbody> +</table> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/listing.html b/app/code/Magento/Ui/view/base/web/templates/grid/listing.html index c3de27d5c7e52f97647170b06fc6a3b1e8b67162..118136c29fd86c65a84adf1fc1b4cd676c67f2fc 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/listing.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/listing.html @@ -4,15 +4,20 @@ * See COPYING.txt for license details. */ --> - <div class="admin__data-grid-wrap"> - <table class="data-grid"> + <table + class="data-grid" + data-bind=" + afterRender: dndConfig.enabled ? + function (elem) { dnd('setTable', elem); } : + false, + css: { + 'data-grid-draggable': dndConfig.enabled + }"> <thead data-part="head"> <tr data-part="head.row"> <!-- ko foreach: elems --> - <!-- ko if: visible --> - <!-- ko template: getHeader() --><!-- /ko --> - <!-- /ko --> + <!-- ko template: getHeader() --><!-- /ko --> <!-- /ko --> </tr> </thead> @@ -21,9 +26,7 @@ <!-- ko foreach: { data: rows, as: 'row' } --> <tr data-part="body.row"> <!-- ko foreach: { data: $parent.elems, as: 'field' } --> - <!-- ko if: visible --> - <!-- ko template: getBody() --><!-- /ko --> - <!-- /ko --> + <!-- ko template: getBody() --><!-- /ko --> <!-- /ko --> </tr> <!-- /ko --> @@ -37,4 +40,7 @@ <!-- /ko --> </tbody> </table> + <!-- ko if: dndConfig.enabled --> + <!-- ko template: dndConfig.containerTmpl --><!-- /ko --> + <!-- /ko --> </div> \ No newline at end of file diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 29ec2510c07e79abb5e21f664e90c98db3554609..871fbcdc12c1d2a6a3055ac20e0b5370575a5489 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index 91f18fbea4728a982a17dca4cd56a0ac9f5ab88e..24a2772e11a3c6bf97a534c2fa44c09e672e3d6d 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog-url-rewrite": "0.74.0-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-cms-url-rewrite": "0.74.0-beta13", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog-url-rewrite": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-cms-url-rewrite": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index 82c4b5609f4d62e0499e75a6a4f4147da21ebdf6..b16f88f04a4c5b9cec2efb70b688923490d10226 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-integration": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-integration": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index 625a904edd642d843d9d02ec910e2616a242dd5f..59b75138b5be4d8cb021390eec32bc8747c00f8e 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-shipping": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-config": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-shipping": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-config": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Variable/composer.json b/app/code/Magento/Variable/composer.json index b61f8fe802c68ffa61e53966cb117e1f439a4436..58eb8dbd4b6c0be1e41c82dd72972cde940dfe8c 100644 --- a/app/code/Magento/Variable/composer.json +++ b/app/code/Magento/Variable/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0|~5.6.0", - "magento/module-backend": "0.74.0-beta13", - "magento/module-email": "0.74.0-beta13", - "magento/module-store": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-backend": "0.74.0-beta14", + "magento/module-email": "0.74.0-beta14", + "magento/module-store": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Version/composer.json b/app/code/Magento/Version/composer.json index 4a3025af599865f283ba05b22341148d4412162e..07feda54cfd8fcfa810c79f28b9775b8abd4951b 100644 --- a/app/code/Magento/Version/composer.json +++ b/app/code/Magento/Version/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 94d5b769e85526178ded1e4a57d0488acccca8b6..7c018de1b3b051d135d1fe69741e44a94185723c 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-authorization": "0.74.0-beta13", - "magento/module-integration": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-authorization": "0.74.0-beta14", + "magento/module-integration": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-user": "0.74.0-beta13" + "magento/module-user": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index ba0a615bab17ec2d4cd8221715dd418b87785220..7102e797d034a46b70b9724af86c42669e9a8d1b 100644 --- a/app/code/Magento/Weee/composer.json +++ b/app/code/Magento/Weee/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-store": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-tax": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-directory": "0.74.0-beta13", - "magento/module-eav": "0.74.0-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-quote": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-tax": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-directory": "0.74.0-beta14", + "magento/module-eav": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-quote": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index cfecd20e99f1b7ad876322a228f0868b448e1c05..53ed15c7b6fb5644a930350c0ef7825766161645 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-beta13", - "magento/module-cms": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-variable": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-cms": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-variable": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 703058cbf5f90410d1631d2d9dedda1ad6c026f4..31d183b64bb0ae5cafd1f548adcc4c776cf12132 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-beta13", - "magento/module-customer": "0.74.0-beta13", - "magento/module-catalog": "0.74.0-beta13", - "magento/module-checkout": "0.74.0-beta13", - "magento/module-theme": "0.74.0-beta13", - "magento/module-catalog-inventory": "0.74.0-beta13", - "magento/module-rss": "0.74.0-beta13", - "magento/module-backend": "0.74.0-beta13", - "magento/module-sales": "0.74.0-beta13", - "magento/module-grouped-product": "0.74.0-beta13", - "magento/framework": "0.74.0-beta13", - "magento/module-ui": "0.74.0-beta13", + "magento/module-store": "0.74.0-beta14", + "magento/module-customer": "0.74.0-beta14", + "magento/module-catalog": "0.74.0-beta14", + "magento/module-checkout": "0.74.0-beta14", + "magento/module-theme": "0.74.0-beta14", + "magento/module-catalog-inventory": "0.74.0-beta14", + "magento/module-rss": "0.74.0-beta14", + "magento/module-backend": "0.74.0-beta14", + "magento/module-sales": "0.74.0-beta14", + "magento/module-grouped-product": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", + "magento/module-ui": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-configurable-product": "0.74.0-beta13", - "magento/module-downloadable": "0.74.0-beta13", - "magento/module-bundle": "0.74.0-beta13", - "magento/module-cookie": "0.74.0-beta13" + "magento/module-configurable-product": "0.74.0-beta14", + "magento/module-downloadable": "0.74.0-beta14", + "magento/module-bundle": "0.74.0-beta14", + "magento/module-cookie": "0.74.0-beta14" }, "type": "magento2-module", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/header/actions-group/_search.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/header/actions-group/_search.less index 27524d7d4d0854693596871cd21c5d8f05dd84b8..ff4c338c62faa30c58cd734cf4e1f0025fe74444 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/header/actions-group/_search.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/header/actions-group/_search.less @@ -95,6 +95,9 @@ display: block; font-size: @font-size__s; padding: @search-global-input__padding-top @search-global-input__padding-side @search-global-input__padding-bottom; + &._active { + background-color: @color-blue-clear-sky; + } } .title { display: block; 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 d3ef739a9435a77614ee1bcf3a302cfd274cc7ef..a243bf34f061e922823d54c49ac504676092250b 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 @@ -48,6 +48,10 @@ @data-grid-row-parent-marker__size: 1rem; +@data-grid-td__dragging__opacity: 95%; +@data-grid-dragging-copy__border-color: @color-blue-pure; +@data-grid-dragging-copy__border: 1px solid @data-grid-dragging-copy__border-color; + // .admin__data-grid-outer-wrap { @@ -106,6 +110,9 @@ &:nth-child(even) { td { background-color: @data-grid-td__even__background-color; + &._dragging { + background-color: fade(@data-grid-td__even__background-color, @data-grid-td__dragging__opacity); + } } } &.data-grid-tr-no-data { @@ -154,7 +161,21 @@ &:last-child { border-right-style: @data-grid-td__border-outer-style; } + &._dragging { + color: fade(@table__color, @data-grid-td__dragging__opacity); + background-color: fade(@data-grid-td__odd__background-color, @data-grid-td__dragging__opacity); + a { + color: fade(@link__color, @data-grid-td__dragging__opacity); + &:hover { + color: fade(@link__hover__color, @data-grid-td__dragging__opacity); + } + } + } + // Action select data grid styles (can be action-select-secondary in future) + .action-select-wrap { + position: static; + } .action-select { .link-pattern(); background-color: transparent; @@ -168,6 +189,9 @@ } &:after { border-color: @link__color transparent transparent transparent; + margin: .6rem 0 0 .7rem; + right: auto; + top: auto; } &:before { display: none; @@ -175,6 +199,8 @@ } .action-menu { left: auto; + right: auto; + top: auto; z-index: 1; } } @@ -189,11 +215,22 @@ &:first-child { border-left-color: @data-grid-th__border-color; } + &._dragover-left { + box-shadow: inset 3px 0 0px 0px @color-white; + } + &._dragover-right { + box-shadow: inset -3px 0 0px 0px @color-white; + } } .data-grid-th { color: @data-grid-th__color; padding: @data-grid-th__padding-vertical @data-grid-th__padding-horizontal; vertical-align: middle; + &._draggable { + cursor: -webkit-grab; + cursor: -moz-grab; + cursor: grab; + } &._sortable { background-clip: padding-box; // Fix for border overlay in Firefox cursor: pointer; @@ -281,6 +318,45 @@ } } } + // Draggable columns + &._hidden { + display: none; + } + &.data-grid-draggable { + background-color: @color-black; + } + &._dragging-copy { + background-color: @color-white; + box-shadow: @component__box-shadow__base; + left: 0; + opacity: .95; + position: fixed; + top: 0; + z-index: @overlay__z-index; + .data-grid-th { + border: @data-grid-dragging-copy__border; + border-bottom: none; + } + .data-grid-th, + .data-grid-th._sortable { + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + cursor: grabbing; + } + tbody { + tr { + &:last-child { + td { + border-bottom: @data-grid-dragging-copy__border; + } + } + } + td { + border-left: @data-grid-dragging-copy__border; + border-right: @data-grid-dragging-copy__border; + } + } + } } // Ascend & Descend sort marker @@ -349,4 +425,4 @@ &._col-xs { width: 1%; } -} +} \ No newline at end of file diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 58fbb8be56c6018d058fc9797820f32babab0f07..a635d2f6368d6f8d066d468efc7a6056820e06e4 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-beta13", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" 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 7562f5de527b2a29ee016193b59c95d76b0912d2..ef23f9abd3aba56beb7a5f80218731c402d0081e 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_classes.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_classes.less @@ -19,3 +19,11 @@ .a-center { // ToDo UI: should be renamed to ._text-center text-align: center; } + +// No select +._no-select { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index ed12dd50070e3732d4d1dad3ae1035b8452d9dc4..e715b5304c3a39ca06f52c98c37a438a68cf839d 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-beta13", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/frontend/Magento/blank/etc/view.xml b/app/design/frontend/Magento/blank/etc/view.xml index 84c78279b3c69c5cc89b48d2502827025907ffb4..b9864e298b7df1afb47615252bd2c93f392ea34b 100644 --- a/app/design/frontend/Magento/blank/etc/view.xml +++ b/app/design/frontend/Magento/blank/etc/view.xml @@ -185,6 +185,14 @@ <var name="product_stock_alert_email_product_image:width">76</var> <var name="product_stock_alert_email_product_image:ratio">1</var> <var name="product_stock_alert_email_product_image:height">76</var> + + <var name="swatch_image:width">30</var> + <var name="swatch_image:ratio">0.8</var> + <var name="swatch_image:height">20</var> + + <var name="swatch_thumb:width">110</var> + <var name="swatch_thumb:ratio">0.8</var> + <var name="swatch_thumb:height">90</var> </vars> <vars module="Magento_Bundle"> <var name="product_summary_image_size">58</var> <!-- New Product image size used for summary block--> diff --git a/app/design/frontend/Magento/luma/composer.json b/app/design/frontend/Magento/luma/composer.json index 84cbda7b1c907d6bc7262137162476f6a1d94ca3..011484f9abf79fb35ffa25a064e3debc221029ee 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-beta13", - "magento/framework": "0.74.0-beta13", + "magento/theme-frontend-blank": "0.74.0-beta14", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/app/design/frontend/Magento/luma/etc/view.xml b/app/design/frontend/Magento/luma/etc/view.xml index a72c461ffa06f0e1a028a7c0f8e0394855755904..1d3fb18268ee0270dd432198b7940546d3987516 100644 --- a/app/design/frontend/Magento/luma/etc/view.xml +++ b/app/design/frontend/Magento/luma/etc/view.xml @@ -190,6 +190,14 @@ <var name="product_stock_alert_email_product_image:width">76</var> <var name="product_stock_alert_email_product_image:ratio">1</var> <var name="product_stock_alert_email_product_image:height">76</var> + + <var name="swatch_image:width">30</var> + <var name="swatch_image:ratio">0.8</var> + <var name="swatch_image:height">20</var> + + <var name="swatch_thumb:width">110</var> + <var name="swatch_thumb:ratio">0.8</var> + <var name="swatch_thumb:height">90</var> </vars> <vars module="Magento_Bundle"> <var name="product_summary_image_size">58</var> <!-- New Product image size used for summary block--> diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index 8792a746870334173328153bee80077157349745..752d5584e51535511fc382bd1edfad901affa4fd 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "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 12f592f50bc7f6772183dc3e44a42ecb65fbfb05..4feb2ced23f3e909170d222c43410ff08edc5cd7 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "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 eec09e8483fbe8846f06947d7d8fef60d284d0d0..c2a70d39babadc84b11b03652e750d590ffd15fa 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "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 7ff13b7e8f3aa58340613fe97806ecfcc1b174aa..b6c40d9c8fa9be5d193c4f81534ab9cf0bebdd89 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "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 af92cc0e22f2de55041a7b8d0f6973cfa7244e09..c905b708215fd32745c8c1313fca3649c31f4c7c 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "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 ea475dfb76206af0453c1d37586d71107d2ea7bb..4f80afff03c0adbfab31185741fdb201c6391b50 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "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 fe43b44fcdc7f9e7a3f2b31fa64b08e5bee94b3b..63c14d0af900801962fcaa32f179cf375fa451f9 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "magento/framework": "0.74.0-beta13", + "magento/framework": "0.74.0-beta14", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 94549cfd2878cbc97c0476f54c7a7f2d4f1b093f..2fca4d005a36670877caf6253c70e0bb38e92a90 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-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/composer.lock b/composer.lock index 77a18945169153ccdfd51d970fdd2255c499d42b..4e3421ad6e05957d87c2807e67fe0152cbf10bac 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "daa84b5d3ea8eabcd1bb1f33c07e08dd", + "hash": "32f26595c37e07bb66613d23424788e0", "packages": [ { "name": "composer/composer", @@ -49,7 +49,7 @@ "Composer": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -261,7 +261,7 @@ "ZF1", "framework" ], - "time": "2015-06-02 08:04:41" + "time": "2015-02-06 17:25:45" }, { "name": "monolog/monolog", @@ -567,7 +567,7 @@ "Symfony\\Component\\Finder\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -616,7 +616,7 @@ "Symfony\\Component\\Process\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -684,12 +684,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-code.git", - "reference": "0ed94f842ba60cdc900c46a61bdbd7ac95a3e140" + "reference": "cfd5951ff4348e4430850560416c7ddb755f95d3" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-code/zipball/0ed94f842ba60cdc900c46a61bdbd7ac95a3e140", - "reference": "0ed94f842ba60cdc900c46a61bdbd7ac95a3e140", + "reference": "cfd5951ff4348e4430850560416c7ddb755f95d3", "shasum": "" }, "require": { @@ -698,9 +698,6 @@ }, "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": { @@ -716,7 +713,7 @@ }, "autoload": { "psr-4": { - "Zend\\Code\\": "src/" + "Zend\\Code\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -724,12 +721,12 @@ "BSD-3-Clause" ], "description": "provides facilities to generate arbitrary code using an object oriented interface", - "homepage": "https://github.com/zendframework/zend-code", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "code", "zf2" ], - "time": "2015-03-31 15:39:14" + "time": "2015-04-01 17:59:08" }, { "name": "zendframework/zend-config", @@ -737,12 +734,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-config.git", - "reference": "95f3a4b3fa85d49e6f060183122de4596fa6d29d" + "reference": "8682fe4e2923b383bb6472fc84b5796a07589163" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-config/zipball/95f3a4b3fa85d49e6f060183122de4596fa6d29d", - "reference": "95f3a4b3fa85d49e6f060183122de4596fa6d29d", + "reference": "8682fe4e2923b383bb6472fc84b5796a07589163", "shasum": "" }, "require": { @@ -750,9 +747,6 @@ "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", @@ -773,7 +767,7 @@ }, "autoload": { "psr-4": { - "Zend\\Config\\": "src/" + "Zend\\Config\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -781,12 +775,12 @@ "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/zend-config", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "config", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 17:59:31" }, { "name": "zendframework/zend-console", @@ -794,23 +788,18 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-console.git", - "reference": "54823d9ba6f8ce39046384ee5a043b5b3d5f56d7" + "reference": "94ab6663b07e19f20b3319ecf317bd72b6a72dca" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-console/zipball/54823d9ba6f8ce39046384ee5a043b5b3d5f56d7", - "reference": "54823d9ba6f8ce39046384ee5a043b5b3d5f56d7", + "reference": "94ab6663b07e19f20b3319ecf317bd72b6a72dca", "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" @@ -824,19 +813,19 @@ }, "autoload": { "psr-4": { - "Zend\\Console\\": "src/" + "Zend\\Console\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-console", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "console", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 17:59:48" }, { "name": "zendframework/zend-di", @@ -844,12 +833,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-di.git", - "reference": "b9f8de081adecf71a003a569e9ba76c0a4c00bf2" + "reference": "0811f2a67ad0b50dfb8d602ed67cde0b82249190" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-di/zipball/b9f8de081adecf71a003a569e9ba76c0a4c00bf2", - "reference": "b9f8de081adecf71a003a569e9ba76c0a4c00bf2", + "reference": "0811f2a67ad0b50dfb8d602ed67cde0b82249190", "shasum": "" }, "require": { @@ -858,9 +847,6 @@ "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": { @@ -875,19 +861,19 @@ }, "autoload": { "psr-4": { - "Zend\\Di\\": "src/" + "Zend\\Di\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-di", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "di", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:01:30" }, { "name": "zendframework/zend-escaper", @@ -895,22 +881,17 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-escaper.git", - "reference": "15e5769e4fcdb4bf07ebd76500810e7070e23a97" + "reference": "65b3328627362b0be1d5e9067bc846511d1fbc96" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/15e5769e4fcdb4bf07ebd76500810e7070e23a97", - "reference": "15e5769e4fcdb4bf07ebd76500810e7070e23a97", + "reference": "65b3328627362b0be1d5e9067bc846511d1fbc96", "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": { @@ -920,19 +901,19 @@ }, "autoload": { "psr-4": { - "Zend\\Escaper\\": "src/" + "Zend\\Escaper\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-escaper", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "escaper", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:02:07" }, { "name": "zendframework/zend-eventmanager", @@ -940,23 +921,18 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-eventmanager.git", - "reference": "58d21c95c7005a527262fd536499195f104e83f9" + "reference": "38df5b567d4ff4d22144745c503ba0502d0d5695" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/58d21c95c7005a527262fd536499195f104e83f9", - "reference": "58d21c95c7005a527262fd536499195f104e83f9", + "reference": "38df5b567d4ff4d22144745c503ba0502d0d5695", "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": { @@ -966,19 +942,19 @@ }, "autoload": { "psr-4": { - "Zend\\EventManager\\": "src/" + "Zend\\EventManager\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-event-manager", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "eventmanager", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:05:26" }, { "name": "zendframework/zend-filter", @@ -986,12 +962,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-filter.git", - "reference": "6d8aed2da81b62a04747346c4370562cdbe34595" + "reference": "b13741a88553351fc52472de529b57b580b8f6f1" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/6d8aed2da81b62a04747346c4370562cdbe34595", - "reference": "6d8aed2da81b62a04747346c4370562cdbe34595", + "reference": "b13741a88553351fc52472de529b57b580b8f6f1", "shasum": "" }, "require": { @@ -999,9 +975,6 @@ "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" @@ -1021,7 +994,7 @@ }, "autoload": { "psr-4": { - "Zend\\Filter\\": "src/" + "Zend\\Filter\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1029,12 +1002,12 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed data filters", - "homepage": "https://github.com/zendframework/zend-filter", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "filter", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:25" }, { "name": "zendframework/zend-form", @@ -1042,12 +1015,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-form.git", - "reference": "bca0db55718355d25c2c10fdd41a83561f1c94b3" + "reference": "09f5bd46ffbf783df22281898e2175b291bd43a3" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-form/zipball/bca0db55718355d25c2c10fdd41a83561f1c94b3", - "reference": "bca0db55718355d25c2c10fdd41a83561f1c94b3", + "reference": "09f5bd46ffbf783df22281898e2175b291bd43a3", "shasum": "" }, "require": { @@ -1056,9 +1029,6 @@ "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", @@ -1089,19 +1059,19 @@ }, "autoload": { "psr-4": { - "Zend\\Form\\": "src/" + "Zend\\Form\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-form", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "form", "zf2" ], - "time": "2015-03-28 20:29:18" + "time": "2015-04-01 18:09:25" }, { "name": "zendframework/zend-http", @@ -1109,12 +1079,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-http.git", - "reference": "9c6047a0bdb3094d3ea07a215ff929cc47de4deb" + "reference": "ee6220609845b32d1b2873c9ac694aef56d508f5" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-http/zipball/9c6047a0bdb3094d3ea07a215ff929cc47de4deb", - "reference": "9c6047a0bdb3094d3ea07a215ff929cc47de4deb", + "reference": "ee6220609845b32d1b2873c9ac694aef56d508f5", "shasum": "" }, "require": { @@ -1124,11 +1094,6 @@ "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": { @@ -1138,7 +1103,7 @@ }, "autoload": { "psr-4": { - "Zend\\Http\\": "src/" + "Zend\\Http\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1146,12 +1111,12 @@ "BSD-3-Clause" ], "description": "provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests", - "homepage": "https://github.com/zendframework/zend-http", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "http", "zf2" ], - "time": "2015-03-27 15:46:30" + "time": "2015-04-01 18:09:25" }, { "name": "zendframework/zend-i18n", @@ -1159,12 +1124,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-i18n.git", - "reference": "9aebc5287373a802540d75fe5508417f866c2e52" + "reference": "33051775d9a8c341fe3b77d1f3daa0e921e2f4bd" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-i18n/zipball/9aebc5287373a802540d75fe5508417f866c2e52", - "reference": "9aebc5287373a802540d75fe5508417f866c2e52", + "reference": "33051775d9a8c341fe3b77d1f3daa0e921e2f4bd", "shasum": "" }, "require": { @@ -1172,9 +1137,6 @@ "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", @@ -1203,19 +1165,19 @@ }, "autoload": { "psr-4": { - "Zend\\I18n\\": "src/" + "Zend\\I18n\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-i18n", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "i18n", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:26" }, { "name": "zendframework/zend-inputfilter", @@ -1223,12 +1185,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-inputfilter.git", - "reference": "4b1398f3635fae3cc5e873c5bb067274f3d10a93" + "reference": "16856fec61f285e41e5492235220a4dec06ab90f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/4b1398f3635fae3cc5e873c5bb067274f3d10a93", - "reference": "4b1398f3635fae3cc5e873c5bb067274f3d10a93", + "reference": "16856fec61f285e41e5492235220a4dec06ab90f", "shasum": "" }, "require": { @@ -1238,9 +1200,6 @@ "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": { @@ -1255,19 +1214,19 @@ }, "autoload": { "psr-4": { - "Zend\\InputFilter\\": "src/" + "Zend\\InputFilter\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-input-filter", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "inputfilter", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:09:26" }, { "name": "zendframework/zend-json", @@ -1275,12 +1234,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-json.git", - "reference": "2d845e151c1b9a237cf1899ac31e17fb10bd1e3f" + "reference": "76aeb27e4baf39799e5ca3cf6f2fdd6748ee930c" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-json/zipball/2d845e151c1b9a237cf1899ac31e17fb10bd1e3f", - "reference": "2d845e151c1b9a237cf1899ac31e17fb10bd1e3f", + "reference": "76aeb27e4baf39799e5ca3cf6f2fdd6748ee930c", "shasum": "" }, "require": { @@ -1288,9 +1247,6 @@ "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" }, @@ -1308,7 +1264,7 @@ }, "autoload": { "psr-4": { - "Zend\\Json\\": "src/" + "Zend\\Json\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1316,12 +1272,12 @@ "BSD-3-Clause" ], "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", - "homepage": "https://github.com/zendframework/zend-json", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "json", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:26" }, { "name": "zendframework/zend-loader", @@ -1329,22 +1285,17 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-loader.git", - "reference": "65de2c7a56f8eee633c6bf1cfab73e45648880d4" + "reference": "6868b8a0c346f17fb97724c3a63aa2cbf6b94865" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-loader/zipball/65de2c7a56f8eee633c6bf1cfab73e45648880d4", - "reference": "65de2c7a56f8eee633c6bf1cfab73e45648880d4", + "reference": "6868b8a0c346f17fb97724c3a63aa2cbf6b94865", "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": { @@ -1354,19 +1305,19 @@ }, "autoload": { "psr-4": { - "Zend\\Loader\\": "src/" + "Zend\\Loader\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-loader", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "loader", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:09:26" }, { "name": "zendframework/zend-log", @@ -1374,12 +1325,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-log.git", - "reference": "002e3c810cad7e31e51c9895e9e3cb6fbd312cdd" + "reference": "2d5d20fd45470506bdaff727c46dc25fe953146e" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-log/zipball/002e3c810cad7e31e51c9895e9e3cb6fbd312cdd", - "reference": "002e3c810cad7e31e51c9895e9e3cb6fbd312cdd", + "reference": "2d5d20fd45470506bdaff727c46dc25fe953146e", "shasum": "" }, "require": { @@ -1388,9 +1339,6 @@ "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", @@ -1414,7 +1362,7 @@ }, "autoload": { "psr-4": { - "Zend\\Log\\": "src/" + "Zend\\Log\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1422,13 +1370,13 @@ "BSD-3-Clause" ], "description": "component for general purpose logging", - "homepage": "https://github.com/zendframework/zend-log", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "log", "logging", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:26" }, { "name": "zendframework/zend-math", @@ -1436,22 +1384,17 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-math.git", - "reference": "f41fe4acfd809c14f2a802d1aa45dec8fcd2cc73" + "reference": "634123f83ca90b6613f132d0d100e6b5e9890a29" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-math/zipball/f41fe4acfd809c14f2a802d1aa45dec8fcd2cc73", - "reference": "f41fe4acfd809c14f2a802d1aa45dec8fcd2cc73", + "reference": "634123f83ca90b6613f132d0d100e6b5e9890a29", "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", @@ -1467,19 +1410,19 @@ }, "autoload": { "psr-4": { - "Zend\\Math\\": "src/" + "Zend\\Math\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-math", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "math", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:09:27" }, { "name": "zendframework/zend-modulemanager", @@ -1487,12 +1430,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-modulemanager.git", - "reference": "af7ae3cd29a1efb73cc66ae1081e606039d5c20f" + "reference": "cbe16b0eafe734a062ed0182381e64b9c953dccf" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/af7ae3cd29a1efb73cc66ae1081e606039d5c20f", - "reference": "af7ae3cd29a1efb73cc66ae1081e606039d5c20f", + "reference": "cbe16b0eafe734a062ed0182381e64b9c953dccf", "shasum": "" }, "require": { @@ -1501,9 +1444,6 @@ "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", @@ -1525,19 +1465,19 @@ }, "autoload": { "psr-4": { - "Zend\\ModuleManager\\": "src/" + "Zend\\ModuleManager\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-module-manager", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "modulemanager", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:09:27" }, { "name": "zendframework/zend-mvc", @@ -1545,12 +1485,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-mvc.git", - "reference": "0b4a4a829b30be510a3f215c4ff00c703ee8b431" + "reference": "bfff0f5f9e4d925ee13b8c159c9d6ae7e0db5412" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-mvc/zipball/0b4a4a829b30be510a3f215c4ff00c703ee8b431", - "reference": "0b4a4a829b30be510a3f215c4ff00c703ee8b431", + "reference": "bfff0f5f9e4d925ee13b8c159c9d6ae7e0db5412", "shasum": "" }, "require": { @@ -1561,9 +1501,6 @@ "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", @@ -1612,19 +1549,19 @@ }, "autoload": { "psr-4": { - "Zend\\Mvc\\": "src/" + "Zend\\Mvc\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-mvc", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "mvc", "zf2" ], - "time": "2015-03-26 18:55:14" + "time": "2015-04-01 18:09:27" }, { "name": "zendframework/zend-serializer", @@ -1632,12 +1569,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-serializer.git", - "reference": "3c531789a9882a5deb721356a7bd2642b65d4b09" + "reference": "a46960854d6326f0036d98c9abc7a79e36e25928" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-serializer/zipball/3c531789a9882a5deb721356a7bd2642b65d4b09", - "reference": "3c531789a9882a5deb721356a7bd2642b65d4b09", + "reference": "a46960854d6326f0036d98c9abc7a79e36e25928", "shasum": "" }, "require": { @@ -1647,9 +1584,6 @@ "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": { @@ -1664,7 +1598,7 @@ }, "autoload": { "psr-4": { - "Zend\\Serializer\\": "src/" + "Zend\\Serializer\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1672,12 +1606,12 @@ "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/zend-serializer", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "serializer", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:28" }, { "name": "zendframework/zend-server", @@ -1685,12 +1619,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-server.git", - "reference": "d11ff0bd529d202022823d4accf5983cbd50fc49" + "reference": "fc73c34490908ba143af3c57c7e166b40c4b9f8e" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-server/zipball/d11ff0bd529d202022823d4accf5983cbd50fc49", - "reference": "d11ff0bd529d202022823d4accf5983cbd50fc49", + "reference": "fc73c34490908ba143af3c57c7e166b40c4b9f8e", "shasum": "" }, "require": { @@ -1698,11 +1632,6 @@ "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": { @@ -1712,19 +1641,19 @@ }, "autoload": { "psr-4": { - "Zend\\Server\\": "src/" + "Zend\\Server\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-server", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "server", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:28" }, { "name": "zendframework/zend-servicemanager", @@ -1732,21 +1661,18 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-servicemanager.git", - "reference": "57cf99fa5ac08c05a135a8d0d676c52a5e450083" + "reference": "d3c27c708a148a30608f313a5b7a61a531bd9cb9" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/57cf99fa5ac08c05a135a8d0d676c52a5e450083", - "reference": "57cf99fa5ac08c05a135a8d0d676c52a5e450083", + "reference": "d3c27c708a148a30608f313a5b7a61a531bd9cb9", "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": { @@ -1762,19 +1688,19 @@ }, "autoload": { "psr-4": { - "Zend\\ServiceManager\\": "src/" + "Zend\\ServiceManager\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-service-manager", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "servicemanager", "zf2" ], - "time": "2015-03-23 18:29:14" + "time": "2015-04-01 18:09:28" }, { "name": "zendframework/zend-soap", @@ -1782,12 +1708,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-soap.git", - "reference": "a599463aba97ce247faf3fb443e3c7858b46449b" + "reference": "e42b900798ea95a9063fa4922da976d8b3a8ab6f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-soap/zipball/a599463aba97ce247faf3fb443e3c7858b46449b", - "reference": "a599463aba97ce247faf3fb443e3c7858b46449b", + "reference": "e42b900798ea95a9063fa4922da976d8b3a8ab6f", "shasum": "" }, "require": { @@ -1797,9 +1723,6 @@ "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": { @@ -1814,19 +1737,19 @@ }, "autoload": { "psr-4": { - "Zend\\Soap\\": "src/" + "Zend\\Soap\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-soap", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "soap", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:29" }, { "name": "zendframework/zend-stdlib", @@ -1834,21 +1757,18 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "cf05c5ba75606e47ffee91cedc72778da46f74c3" + "reference": "eab586f4c18af3fa63c977611939f1f4a3cf1030" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cf05c5ba75606e47ffee91cedc72778da46f74c3", - "reference": "cf05c5ba75606e47ffee91cedc72778da46f74c3", + "reference": "eab586f4c18af3fa63c977611939f1f4a3cf1030", "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", @@ -1869,19 +1789,19 @@ }, "autoload": { "psr-4": { - "Zend\\Stdlib\\": "src/" + "Zend\\Stdlib\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-stdlib", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "stdlib", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:29" }, { "name": "zendframework/zend-text", @@ -1889,12 +1809,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-text.git", - "reference": "d962ea25647b20527f3ca34ae225bbc885dabfc7" + "reference": "35f519e20e575a331c2ee554e5a555a59ce4b9e2" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-text/zipball/d962ea25647b20527f3ca34ae225bbc885dabfc7", - "reference": "d962ea25647b20527f3ca34ae225bbc885dabfc7", + "reference": "35f519e20e575a331c2ee554e5a555a59ce4b9e2", "shasum": "" }, "require": { @@ -1902,11 +1822,6 @@ "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": { @@ -1916,19 +1831,19 @@ }, "autoload": { "psr-4": { - "Zend\\Text\\": "src/" + "Zend\\Text\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-text", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "text", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:29" }, { "name": "zendframework/zend-uri", @@ -1936,12 +1851,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-uri.git", - "reference": "bd9e625639415376f6a82551c73328448d7bc7d1" + "reference": "53f5b162b293f80de8b951eece8e08be83c4fe16" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-uri/zipball/bd9e625639415376f6a82551c73328448d7bc7d1", - "reference": "bd9e625639415376f6a82551c73328448d7bc7d1", + "reference": "53f5b162b293f80de8b951eece8e08be83c4fe16", "shasum": "" }, "require": { @@ -1949,11 +1864,6 @@ "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": { @@ -1963,7 +1873,7 @@ }, "autoload": { "psr-4": { - "Zend\\Uri\\": "src/" + "Zend\\Uri\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -1971,12 +1881,12 @@ "BSD-3-Clause" ], "description": "a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)", - "homepage": "https://github.com/zendframework/zend-uri", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "uri", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:29" }, { "name": "zendframework/zend-validator", @@ -1984,12 +1894,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-validator.git", - "reference": "45fac2545a0f2eb66d71cb7966feee481e7c475f" + "reference": "eb678d20256f120a72ca27276bbb2875841701ab" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/45fac2545a0f2eb66d71cb7966feee481e7c475f", - "reference": "45fac2545a0f2eb66d71cb7966feee481e7c475f", + "reference": "eb678d20256f120a72ca27276bbb2875841701ab", "shasum": "" }, "require": { @@ -1997,9 +1907,6 @@ "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", @@ -2027,7 +1934,7 @@ }, "autoload": { "psr-4": { - "Zend\\Validator\\": "src/" + "Zend\\Validator\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2035,12 +1942,12 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed validators", - "homepage": "https://github.com/zendframework/zend-validator", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "validator", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:30" }, { "name": "zendframework/zend-view", @@ -2048,12 +1955,12 @@ "source": { "type": "git", "url": "https://github.com/zendframework/zend-view.git", - "reference": "37beb1ad46e530f627b4b6c3716efd728e976ba9" + "reference": "e119b4b5f082af58a96eb206e782b62c193227bf" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zendframework/zend-view/zipball/37beb1ad46e530f627b4b6c3716efd728e976ba9", - "reference": "37beb1ad46e530f627b4b6c3716efd728e976ba9", + "reference": "e119b4b5f082af58a96eb206e782b62c193227bf", "shasum": "" }, "require": { @@ -2063,9 +1970,6 @@ "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", @@ -2104,7 +2008,7 @@ }, "autoload": { "psr-4": { - "Zend\\View\\": "src/" + "Zend\\View\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2112,12 +2016,12 @@ "BSD-3-Clause" ], "description": "provides a system of helpers, output filters, and variable escaping", - "homepage": "https://github.com/zendframework/zend-view", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "view", "zf2" ], - "time": "2015-03-25 20:55:48" + "time": "2015-04-01 18:09:30" } ], "packages-dev": [ @@ -2789,7 +2693,7 @@ "src/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -3288,7 +3192,7 @@ "Symfony\\Component\\Config\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3348,7 +3252,7 @@ "Symfony\\Component\\DependencyInjection\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3406,7 +3310,7 @@ "Symfony\\Component\\EventDispatcher\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3455,7 +3359,7 @@ "Symfony\\Component\\Filesystem\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3504,7 +3408,7 @@ "Symfony\\Component\\Stopwatch\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -3553,7 +3457,7 @@ "Symfony\\Component\\Yaml\\": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], diff --git a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php index f8ef77f8e297b3bdf6a41c501c70adb40d31db99..0f49b8bef0ae3f56dfff91db4c9ae8cc25f371c4 100644 --- a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php @@ -29,7 +29,12 @@ class StockItemTest extends WebapiAbstract /** * Resource path */ - const RESOURCE_PATH = '/V1/stockItems'; + const RESOURCE_GET_PATH = '/V1/stockItems'; + + /** + * Resource path + */ + const RESOURCE_PUT_PATH = '/V1/products/:productSku/stockItems/:itemId'; /** @var \Magento\Catalog\Model\Resource\Product\Collection */ protected $productCollection; @@ -73,7 +78,7 @@ class StockItemTest extends WebapiAbstract $productSku = 'simple1'; $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . "/$productSku", + 'resourcePath' => self::RESOURCE_GET_PATH . "/$productSku", 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, ], 'soap' => [ @@ -100,9 +105,13 @@ class StockItemTest extends WebapiAbstract { $stockItemOld = $this->getStockItemBySku($fixtureData); $productSku = 'simple1'; + $itemId = $stockItemOld['item_id']; + + $resourcePath = str_replace([':productSku', ':itemId'], [$productSku, $itemId], self::RESOURCE_PUT_PATH); + $serviceInfo = [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . "/$productSku", + 'resourcePath' => $resourcePath, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], 'soap' => [ 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 4cc58bed391e49689102645eebd393e1288265a6..bf42f3fba147321bb4b4cc34be562638f04c8d79 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/BillingAddressManagementTest.php @@ -103,7 +103,7 @@ class BillingAddressManagementTest extends WebapiAbstract $addressData = [ 'firstname' => 'John', 'lastname' => 'Smith', - 'email' => 'cat@dog.com', + 'email' => '', 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', @@ -134,6 +134,7 @@ class BillingAddressManagementTest extends WebapiAbstract $this->assertContains($streetLine, $quote->getBillingAddress()->getStreet()); } unset($addressData['street']); + unset($addressData['email']); $this->assertEquals('billing', $savedData['address_type']); //check the rest of fields foreach ($addressData as $key => $value) { @@ -226,7 +227,6 @@ class BillingAddressManagementTest extends WebapiAbstract $addressData = [ 'firstname' => 'John', 'lastname' => 'Smith', - 'email' => 'cat@dog.com', 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', 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 cbf99b7f9922c70d8da68086d89c5dec51e8f017..554b6728a02a6885a1cef6359a266dc3a3b1e5de 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestBillingAddressManagementTest.php @@ -112,7 +112,7 @@ class GuestBillingAddressManagementTest extends WebapiAbstract $addressData = [ 'firstname' => 'John', 'lastname' => 'Smith', - 'email' => 'cat@dog.com', + 'email' => '', 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', @@ -143,6 +143,7 @@ class GuestBillingAddressManagementTest extends WebapiAbstract $this->assertContains($streetLine, $quote->getBillingAddress()->getStreet()); } unset($addressData['street']); + unset($addressData['email']); $this->assertEquals('billing', $savedData['address_type']); //check the rest of fields foreach ($addressData as $key => $value) { diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php index 2e01c93f13a3f3acc9225ea2ff1a7b3d238ec2cb..6ac15b22292da1603e0c56f1f49f99bbab2c5509 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php @@ -153,7 +153,7 @@ class GuestShippingAddressManagementTest extends WebapiAbstract $addressData = [ 'firstname' => 'John', 'lastname' => 'Smith', - 'email' => 'cat@dog.com', + 'email' => '', 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', @@ -183,6 +183,7 @@ class GuestShippingAddressManagementTest extends WebapiAbstract //custom checks for street, region and address_type $this->assertEquals($addressData['street'], $quote->getShippingAddress()->getStreet()); unset($addressData['street']); + unset($addressData['email']); $this->assertEquals('shipping', $savedData['address_type']); //check the rest of fields 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 b789a1d4031906e8982c85f4700df15c65236b45..a15ea0d24fbc85d7e741e329dc266fe4cc5a8b18 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php @@ -128,7 +128,7 @@ class ShippingAddressManagementTest extends WebapiAbstract $addressData = [ 'firstname' => 'John', 'lastname' => 'Smith', - 'email' => 'cat@dog.com', + 'email' => '', 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', @@ -158,6 +158,7 @@ class ShippingAddressManagementTest extends WebapiAbstract //custom checks for street, region and address_type $this->assertEquals($addressData['street'], $quote->getShippingAddress()->getStreet()); unset($addressData['street']); + unset($addressData['email']); $this->assertEquals('shipping', $savedData['address_type']); //check the rest of fields @@ -306,7 +307,6 @@ class ShippingAddressManagementTest extends WebapiAbstract $addressData = [ 'firstname' => 'John', 'lastname' => 'Smith', - 'email' => 'cat@dog.com', 'company' => 'eBay Inc', 'street' => ['Typical Street', 'Tiny House 18'], 'city' => 'Big City', diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index 8ce924bd190d77c558cedd1ff4a7f04b83af3df5..ca4b3bc7f79e43c04109d7162163832f89340ec8 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc26", + "magento/mtf": "1.0.0-rc27", "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/Client/Element/GlobalsearchElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/GlobalsearchElement.php index e1bcbd54580d6daa2bd2eac1a39657b8dd7c8f24..50307147313fa52285d237b6637cb22244f546a6 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/GlobalsearchElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/GlobalsearchElement.php @@ -14,11 +14,6 @@ use Magento\Mtf\Client\ElementInterface; */ class GlobalsearchElement extends SimpleElement { - /** - * "Backspace" key code. - */ - const BACKSPACE = "\xEE\x80\x83"; - /** * Search icon selector. * @@ -63,43 +58,14 @@ class GlobalsearchElement extends SimpleElement public function setValue($value) { $this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); - $this->waitInitElement(); - if (!$this->find($this->searchInput)->isVisible()) { $this->find($this->searchIcon)->click(); } - $this->selectWindow(); - $this->clear(); - $this->find($this->searchInput)->setValue($value); - $this->selectWindow(); - + $this->find($this->searchInput)->keys(str_split($value)); $this->waitResult(); } - /** - * Clear value of element. - * - * @return void - */ - protected function clear() - { - $element = $this->find($this->searchInput); - while ('' != $element->getValue()) { - $element->setValue([self::BACKSPACE]); - } - } - - /** - * Select to last window. - * - * @return void - */ - protected function selectWindow() - { - $this->driver->selectWindow(); - } - /** * Wait init search suggest container. * @@ -130,12 +96,7 @@ class GlobalsearchElement extends SimpleElement $this->driver->waitUntil( function () use ($browser, $selector) { - if ($browser->find($selector)->isVisible()) { - return true; - } else { - $browser->selectWindow(); - return null; - } + return $browser->find($selector)->isVisible() ? true : null; } ); } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form/Group.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form/Group.php index 0d3244802c70260eedce3ed996df9856c77a3057..09123d09767bf838415192989cd1f5f06732360b 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form/Group.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form/Group.php @@ -9,7 +9,7 @@ namespace Magento\Backend\Test\Block\System\Config\Form; use Magento\Mtf\Client\Locator; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; /** * Class Group diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Form.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Form.php deleted file mode 100644 index d57bd1aa4d78f8f9829b08857a27611793b1d462..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Form.php +++ /dev/null @@ -1,199 +0,0 @@ -<?php -/** - * @api - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Backend\Test\Block\Widget; - -use Magento\Mtf\Block\Form as FormInstance; -use Magento\Mtf\Client\Locator; -use Magento\Mtf\Factory\Factory; -use Magento\Mtf\Fixture\FixtureInterface; - -/** - * Class Form - * Is used to represent any form on the page - * - * @SuppressWarnings(PHPMD.NumberOfChildren) - */ -class Form extends FormInstance -{ - /** - * 'Save' button - * - * @var string - */ - protected $saveButton = '#save'; - - /** - * 'Save And Continue Edit' button - * - * @var string - */ - protected $saveAndContinueButton = '#save_and_continue'; - - /** - * 'Save And Continue Edit' button - * - * @var string - */ - protected $saveAndContinueEditButton = '#save_and_continue_edit'; - - /** - * Back button - * - * @var string - */ - protected $backButton = '#back'; - - /** - * Reset button - * - * @var string - */ - protected $resetButton = '#reset'; - - /** - * 'Delete' button - * - * @var string - */ - protected $deleteButton = '#delete-button-button'; - - /** - * Backend abstract block - * - * @var string - */ - protected $templateBlock = './ancestor::body'; - - /** - * Selector of element to wait for. If set by child will wait for element after action - * - * @var string - */ - protected $waitForSelector; - - /** - * Locator type of waitForSelector - * - * @var Locator - */ - protected $waitForSelectorType = Locator::SELECTOR_CSS; - - /** - * Wait for should be for visibility or not? - * - * @var boolean - */ - protected $waitForSelectorVisible = true; - - /** - * Update the root form - * - * @param FixtureInterface $fixture - * @return Form - */ - public function update(FixtureInterface $fixture) - { - $this->fill($fixture); - return $this; - } - - /** - * Get backend abstract block - * - * @return \Magento\Backend\Test\Block\Template - */ - protected function getTemplateBlock() - { - return Factory::getBlockFactory()->getMagentoBackendTemplate( - $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH) - ); - } - - /** - * Save the form - * - * @param FixtureInterface $fixture - * @return Form - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function save(FixtureInterface $fixture = null) - { - $this->_rootElement->find($this->saveButton, Locator::SELECTOR_CSS)->click(); - $this->waitForElement(); - return $this; - } - - /** - * Method that waits for the configured selector using class attributes. - */ - protected function waitForElement() - { - if (!empty($this->waitForSelector)) { - if ($this->waitForSelectorVisible) { - $this->getTemplateBlock()->waitForElementVisible($this->waitForSelector, $this->waitForSelectorType); - } else { - $this->getTemplateBlock()->waitForElementNotVisible($this->waitForSelector, $this->waitForSelectorType); - } - } - } - - /** - * Back action - * - * @return Form - */ - public function back() - { - $this->_rootElement->find($this->backButton, Locator::SELECTOR_CSS)->click(); - return $this; - } - - /** - * Reset the form - * - * @return Form - */ - public function reset() - { - $this->_rootElement->find($this->resetButton, Locator::SELECTOR_CSS)->click(); - return $this; - } - - /** - * Delete current form item - * - * @param FixtureInterface $fixture - * @return Form - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function delete(FixtureInterface $fixture = null) - { - $this->_rootElement->find($this->deleteButton, Locator::SELECTOR_CSS)->click(); - return $this; - } - - /** - * Click save and continue button on form - */ - public function clickSaveAndContinue() - { - $this->_rootElement->find($this->saveAndContinueButton, Locator::SELECTOR_CSS)->click(); - return $this; - } - - /** - * Click save and continue button on form - */ - public function clickSaveAndContinueEdit() - { - $this->_rootElement->find($this->saveAndContinueEditButton, Locator::SELECTOR_CSS)->click(); - return $this; - } -} 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 b11db4365fa2d253ebf571ea4495200274fc74d6..b104c3230510c08d70f30d1d17d49be50cebd18d 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 @@ -7,6 +7,7 @@ namespace Magento\Backend\Test\Block\Widget; use Magento\Mtf\Block\BlockFactory; +use Magento\Mtf\Block\Form; use Magento\Mtf\Block\Mapper; use Magento\Mtf\Client\Locator; use Magento\Mtf\Client\ElementInterface; @@ -87,8 +88,7 @@ class FormTabs extends Form foreach ($tabs as $tabName => $tabFields) { $tab = $this->getTab($tabName); $this->openTab($tabName); - $tab->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context); - $this->updateUnassignedFields($tab); + $tab->fillFormTab($tabFields, $context); } if (!empty($this->unassignedFields)) { $this->fillMissedFields($tabs); @@ -97,34 +97,25 @@ class FormTabs extends Form return $this; } - /** - * Update array with fields which aren't assigned to any tab - * - * @param Tab $tab - */ - protected function updateUnassignedFields(Tab $tab) - { - $this->unassignedFields = array_diff_key( - $this->unassignedFields, - array_intersect_key($this->unassignedFields, $tab->setFields) - ); - } - /** * Fill fields which weren't found on filled tabs * - * @param array $tabs * @throws \Exception - * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ - protected function fillMissedFields(array $tabs) + protected function fillMissedFields() { - foreach (array_diff_key($this->tabs, $tabs) as $tabName => $tabData) { + foreach ($this->tabs as $tabName => $tabData) { $tab = $this->getTab($tabName); - if ($this->openTab($tabName)) { - $tab->fillFormTab($this->unassignedFields, $this->_rootElement); - $this->updateUnassignedFields($tab); + if ($this->openTab($tabName) && $this->isTabVisible($tabName)) { + $mapping = $tab->dataMapping($this->unassignedFields); + foreach ($mapping as $fieldName => $data) { + $element = $tab->_rootElement->find($data['selector'], $data['strategy'], $data['input']); + if ($element->isVisible()) { + $element->setValue($data['value']); + unset($this->unassignedFields[$fieldName]); + } + } if (empty($this->unassignedFields)) { break; } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.php b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9624a9398b6ac7c7bb2f25f47b49bfde089978f5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Backend\Test\TestCase; + +use Magento\Backend\Test\Fixture\GlobalSearch; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Create customer + * 2. Create two simple products + * 3. Create order with one of created simple product + * + * Steps: + * 1. Login to backend + * 2. Click on Search button on the top of page + * 3. Fill in data according dataSet + * 4. Perform assertions + * + * @group Search_Core_(MX) + * @ZephyrId MAGETWO-28457 + */ +class GlobalSearchEntityTest extends Injectable +{ + /* tags */ + const MVP = 'no'; + const DOMAIN = 'MX'; + /* end tags */ + + /** + * Backend Dashboard page. + * + * @var Dashboard + */ + protected $dashboard; + + /** + * Preparing pages for test. + * + * @param Dashboard $dashboard + * @return void + */ + public function __inject(Dashboard $dashboard) + { + $this->dashboard = $dashboard; + } + + /** + * Run Global Search Entity Test. + * + * @param GlobalSearch $search + * @return void + */ + public function test(GlobalSearch $search) + { + //Steps: + $this->dashboard->open(); + $this->dashboard->getAdminPanelHeader()->search($search->getQuery()); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..7adcf2b0241bad21f32708ea1416b7a9afcf5128 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Backend\Test\TestCase\GlobalSearchEntityTest"> + <variation name="GlobalSearchEntityTestVariation2"> + <data name="description" xsi:type="string">search with 2 sign return no results</data> + <data name="search/data/query" xsi:type="string">:)</data> + <constraint name="Magento\Backend\Test\Constraint\AssertGlobalSearchNoRecordsFound" /> + </variation> + <variation name="GlobalSearchEntityTestVariation3"> + <data name="description" xsi:type="string">search product by sku</data> + <data name="search/data/query" xsi:type="string">orderInjectable::default::product::sku</data> + <constraint name="Magento\Backend\Test\Constraint\AssertGlobalSearchProductName" /> + </variation> + <variation name="GlobalSearchEntityTestVariation4"> + <data name="description" xsi:type="string">search existed customer</data> + <data name="search/data/query" xsi:type="string">customer::johndoe_unique::lastname</data> + <constraint name="Magento\Backend\Test\Constraint\AssertGlobalSearchCustomerName" /> + </variation> + <variation name="GlobalSearchEntityTestVariation5"> + <data name="description" xsi:type="string">search order (by order id)</data> + <data name="search/data/query" xsi:type="string">orderInjectable::default::id</data> + <constraint name="Magento\Backend\Test\Constraint\AssertGlobalSearchOrderId" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/NavigateMenuTest.php b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/NavigateMenuTest.php index b8d486de23c5b4006f491a3f1fad1532a2a0f928..2e4509a1e66eab3cb43acfd0a9f0407c7bf50ffc 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/NavigateMenuTest.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/NavigateMenuTest.php @@ -13,7 +13,7 @@ use Magento\Backend\Test\Page\Adminhtml\Dashboard; * Steps: * 1. Log in to backend. * 2. Navigate throught menu to the page. - * 6. Perform asserts. + * 3. Perform asserts. * * @ZephyrId MAGETWO-34874 */ diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php index 308ebbe82565e481275b3940ca1f3bece6a11cae..dcb74539acd16a4e77972e99f68f331d328bfc1b 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php @@ -9,8 +9,7 @@ namespace Magento\Bundle\Test\Constraint; use Magento\Catalog\Test\Constraint\AssertProductCustomOptionsOnProductPage; /** - * Class AssertProductCustomOptionsOnBundleProductPage - * Assertion that commodity options are displayed correctly on bundle product page + * Assertion that commodity options are displayed correctly on bundle product page. */ class AssertProductCustomOptionsOnBundleProductPage extends AssertProductCustomOptionsOnProductPage { diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php index 3c62ea1c4eac77055ad478c6b28de567657631cf..156e24f75aa75a93d7ca1fb19c39fd69c5888508 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php @@ -32,7 +32,7 @@ class AssertTierPriceOnBundleProductPage extends AssertProductTierPriceOnProduct * * @var int */ - protected $priceFormat = 4; + protected $priceFormat = 0; /** * Assertion that tier prices are displayed correctly diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php index a30b316e1e8901d96241ba11f3a7547a5f4b184e..c4f0aee1ebebec8092b22ef6e821825495669879 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php @@ -139,13 +139,13 @@ class Price implements FixtureInterface 'price_to' => '120.00', ], 'fixed-115' => [ - 'price_from' => '115.00', - 'price_to' => '120.00', + 'price_from' => '317.00', + 'price_to' => '362.00', 'cart_price' => '317.00', ], - 'fixed-159' => [ - 'price_from' => '115.00', - 'price_to' => '120.00', + 'fixed-110' => [ + 'price_from' => '159.00', + 'price_to' => '164.00', 'cart_price' => '159.00', ], 'fixed-756' => [ diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml index 2fddc12693d45cf68779b2f75cabcb6b492b47cc..597a6d7f735a93b8a301a9aaff642a95606c0af0 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml @@ -6,10 +6,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogProductView" area="Product" mca="catalog/product/view"> - <block name="viewBlock"> - <render name="bundle" class="Magento\Bundle\Test\Block\Catalog\Product\View"/> - </block> - <block name="bundleViewBlock" class="Magento\Bundle\Test\Block\Catalog\Product\View" locator="#maincontent" strategy="css selector"/> - </page> + <page name="CatalogProductView" area="Product" mca="catalog/product/view"> + <block name="viewBlock"> + <render name="bundle" class="Magento\Bundle\Test\Block\Catalog\Product\View" /> + </block> + <block name="bundleViewBlock" class="Magento\Bundle\Test\Block\Catalog\Product\View" locator="#maincontent" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml index 51d270f4d41e0230b4b54570806b8faa5e0080f3..ad5b9bfa0c055caf84c363a3dcc9067689628cc6 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml @@ -228,7 +228,6 @@ <constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceType" /> </variation> <variation name="CreateBundleProductEntityTestVariation10"> - <data name="tag" xsi:type="string">to_maintain:yes</data> <data name="description" xsi:type="string">Create dynamic bundle</data> <data name="product/data/url_key" xsi:type="string">bundle-product-%isolation%</data> <data name="product/data/name" xsi:type="string">Bundle Dynamic %isolation%</data> @@ -272,7 +271,7 @@ <data name="product/data/sku" xsi:type="string">sku_bundle_fixed_%isolation%</data> <data name="product/data/price_type" xsi:type="string">Fixed</data> <data name="product/data/price/value" xsi:type="string">110</data> - <data name="product/data/price/preset" xsi:type="string">fixed-159</data> + <data name="product/data/price/preset" xsi:type="string">fixed-110</data> <data name="product/data/bundle_selections/preset" xsi:type="string">second</data> <data name="product/data/bundle_selections/products" xsi:type="string">catalogProductSimple::product_100_dollar,catalogProductSimple::product_40_dollar</data> <data name="product/data/checkout_data/preset" xsi:type="string">with_custom_options_2</data> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main/EditForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main/EditForm.xml index 887e1983789462f31d40ec9c2846931bb225abd8..ab116cdecc2f5118629b781c8985557529e882a4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main/EditForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main/EditForm.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<mapping strict="0"> +<mapping strict="1"> <fields> <attribute_set_name /> </fields> 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 39e76e2c98eec4d2d018e8048116199a27c683b7..bd1b633deedd32b670b10b1adf4faae4c2a87e58 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 @@ -7,7 +7,7 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action; use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Element\SimpleElement; /** @@ -25,6 +25,7 @@ class Attribute extends Form public function fill(FixtureInterface $fixture, SimpleElement $element = null) { $data = $fixture->getData(); + $fields = []; foreach ($data as $name => $dataValue) { $fields['toggle_' . $name] = 'Yes'; $fields[$name] = $dataValue; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/NewCategoryIds.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/NewCategoryIds.php index c1baad740ef47f6564c703afddebd6d11d772b35..5c44c611d8da52a7080edabd5699d5b5c0582af2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/NewCategoryIds.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/NewCategoryIds.php @@ -7,7 +7,7 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails; use Magento\Catalog\Test\Fixture\Category; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; /** * Create new category. diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInGrid.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInGrid.php index edc00d8db75fe91c060c124232eadf815fc4c115..bb1e7cc32bbd8dbecc5bdfe2e8764e3c71a071ae 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInGrid.php @@ -11,7 +11,6 @@ use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\Fixture\FixtureInterface; /** - * Class AssertProductInGrid * Assert that product is present in products grid. */ class AssertProductInGrid extends AbstractConstraint @@ -63,7 +62,7 @@ class AssertProductInGrid extends AbstractConstraint } /** - * Get product type + * Get product type. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml index 1e99a0752d4e407a6dfac02c519cf83d9f6ded54..1a38dd8158cd63cd9553ba8cde4daaa7e3c76eed 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml @@ -111,13 +111,13 @@ <field name="is_wysiwyg_enabled" is_required=""> <default_value xsi:type="number">0</default_value> </field> - <field name="is_used_for_promo_rules" is_required=""> + <field name="is_used_for_promo_rules" is_required="" group="frontend-properties"> <default_value xsi:type="number">0</default_value> </field> <field name="search_weight" is_required=""> <default_value xsi:type="string">1</default_value> </field> - <field name="options" is_required="" source="Magento\Catalog\Test\Fixture\CatalogProductAttribute\Options"> + <field name="options" is_required="" group="properties" source="Magento\Catalog\Test\Fixture\CatalogProductAttribute\Options"> <default_value xsi:type="null"/> </field> <field name="default_value_text" group="advanced-properties"/> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php index 692126a34d1d3f0f8fd0599d228924a9d48b5807..531996bb5b186be6347180c6b1a70ffef8809370 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php @@ -90,7 +90,7 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface if ($fixture->hasData('options')) { $optionsData = $fixture->getData()['options']; - foreach ($matches[1] as $key => $optionId) { + foreach (array_unique($matches[1]) as $key => $optionId) { $optionsData[$key]['id'] = $optionId; } $resultData['options'] = $optionsData; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml index cc82e98b336dbdd13b1088b90762f29d081f212f..2e2903a0cf35267fb62eb27cec89bee8c831baef 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductVirtual.xml @@ -36,6 +36,23 @@ </field> </dataset> + <dataset name="required_fields"> + <field name="url_key" xsi:type="string">virtual-product%isolation%</field> + <field name="name" xsi:type="string">Virtual product %isolation%</field> + <field name="sku" xsi:type="string">sku_virtual_product_%isolation%</field> + <field name="is_virtual" xsi:type="string">Yes</field> + <field name="price" xsi:type="array"> + <item name="value" xsi:type="string">10</item> + <item name="preset" xsi:type="string">-</item> + </field> + <field name="tax_class_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">taxable_goods</item> + </field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + </dataset> + <dataset name="required_fields_with_category"> <field name="url_key" xsi:type="string">virtual-product%isolation%</field> <field name="name" xsi:type="string">Virtual product %isolation%</field> 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 e84f0409dada6c372eead7ef608a6adb8544f588..364854e6870bbf6a8b9aa15989b7ccececcb7cbc 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 @@ -257,7 +257,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> </variation> <variation name="CreateSimpleProductEntityTestVariation15"> - <data name="tag" xsi:type="string">to_maintain:yes</data> <data name="description" xsi:type="string">Create product with tax class and group price</data> <data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data> <data name="product/data/name" xsi:type="string">Simple Product %isolation%</data> @@ -317,7 +316,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductTierPriceOnProductPage" /> </variation> <variation name="CreateSimpleProductEntityTestVariation18"> - <data name="issue" xsi:type="string">Bug: MAGETWO-35342</data> <data name="description" xsi:type="string">Create product wit suite of custom options</data> <data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data> <data name="product/data/name" xsi:type="string">Simple Product %isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php index 6c297ef596e1f08f89d4d4f578e4945d1a67caa9..1cdff9dbf0ed156e55ea0d5bbc657f7628f7e02d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php @@ -30,7 +30,6 @@ class ProductTypeSwitchingOnCreationTest extends Injectable /* tags */ const MVP = 'yes'; const DOMAIN = 'MX'; - const TO_MAINTAIN = 'yes'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml index af77d4f6fd3d4ea47bad0a0bb3cf512ada4ab3f1..d4850eed96207c39e7d3a43265eab36300c2bcf9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml @@ -27,13 +27,13 @@ </variation> <variation name="ProductTypeSwitchingOnCreationTestVariation3"> <data name="createProduct" xsi:type="string">configurable</data> - <data name="product" xsi:type="string">catalogProductSimple::default</data> + <data name="product" xsi:type="string">catalogProductSimple::product_without_category</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> <variation name="ProductTypeSwitchingOnCreationTestVariation4"> <data name="createProduct" xsi:type="string">configurable</data> - <data name="product" xsi:type="string">catalogProductVirtual::default</data> + <data name="product" xsi:type="string">catalogProductVirtual::required_fields</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.xml index d477c119f14ec5c992f4f9285a47c94bac67effc..8d1fc4b9e09c4fe2d44ffc29021fa079d9a88191 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Catalog\Test\TestCase\Product\ProductTypeSwitchingOnUpdateTest"> <variation name="ProductTypeSwitchingOnUpdateTestVariation1"> - <data name="tag" xsi:type="string">stable:no</data> <data name="productOrigin" xsi:type="string">catalogProductSimple::default</data> <data name="product" xsi:type="string">configurableProduct::default</data> <data name="actionName" xsi:type="string">-</data> @@ -28,17 +27,15 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> <variation name="ProductTypeSwitchingOnUpdateTestVariation3"> - <data name="tag" xsi:type="string">stable:no</data> <data name="productOrigin" xsi:type="string">configurableProduct::default</data> - <data name="product" xsi:type="string">catalogProductSimple::default</data> + <data name="product" xsi:type="string">catalogProductSimple::product_without_category</data> <data name="actionName" xsi:type="string">deleteAttributes</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> <variation name="ProductTypeSwitchingOnUpdateTestVariation4"> - <data name="tag" xsi:type="string">stable:no</data> <data name="productOrigin" xsi:type="string">configurableProduct::default</data> - <data name="product" xsi:type="string">catalogProductVirtual::default</data> + <data name="product" xsi:type="string">catalogProductVirtual::required_fields</data> <data name="actionName" xsi:type="string">deleteAttributes</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> @@ -51,7 +48,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> <variation name="ProductTypeSwitchingOnUpdateTestVariation6"> - <data name="tag" xsi:type="string">stable:no</data> <data name="productOrigin" xsi:type="string">catalogProductVirtual::default</data> <data name="product" xsi:type="string">configurableProduct::not_virtual_for_type_switching</data> <data name="actionName" xsi:type="string">-</data> @@ -82,7 +78,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> <variation name="ProductTypeSwitchingOnUpdateTestVariation9"> - <data name="tag" xsi:type="string">stable:no</data> <data name="productOrigin" xsi:type="string">downloadableProduct::default</data> <data name="product" xsi:type="string">configurableProduct::not_virtual_for_type_switching</data> <data name="actionName" xsi:type="string">-</data> 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 73e20318e00350a5fc21cc5089a833cdc7469cd1..4dde51eae09a370f540fa8e3b2e9970d40c19dc6 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 @@ -70,7 +70,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSearchableBySku" /> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> </variation> <variation name="UpdateSimpleProductEntityTestVariation5"> <data name="description" xsi:type="string">Update stock to Out of Stock</data> @@ -104,7 +103,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductIsNotDisplayingOnFrontend" /> </variation> <variation name="UpdateSimpleProductEntityTestVariation7"> - <data name="tag" xsi:type="string">stable:no</data> <data name="description" xsi:type="string">Update category</data> <data name="initialProduct/dataSet" xsi:type="string">product_with_category</data> <data name="product/data/category_ids/presets" xsi:type="string">default</data> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml index 0346cc1467f5ee7cf386c0d0f304c5bef9625a62..d6607d67fd40b773f4af4c01f0f6dad154b31237 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml @@ -15,11 +15,8 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">999</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/category_ids/presets" xsi:type="string">default_subcategory</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="product/data/tier_price/preset" xsi:type="string">MAGETWO-23002</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -38,18 +35,13 @@ <data name="product/data/tax_class_id/dataSet" xsi:type="string">taxable_goods</data> <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">999</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/category_ids/presets" xsi:type="string">-</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> <data name="product/data/special_price" xsi:type="string">45</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog, Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" /> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> @@ -64,17 +56,13 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">999</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/category_ids/presets" xsi:type="string">default_subcategory</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="product/data/tier_price/preset" xsi:type="string">MAGETWO-23002</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog, Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" /> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductOutOfStock" /> @@ -86,14 +74,8 @@ <data name="product/data/sku" xsi:type="string">virtual_sku_%isolation%</data> <data name="product/data/price/value" xsi:type="string">99.99</data> <data name="product/data/tax_class_id/dataSet" xsi:type="string">taxable_goods</data> - <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">-</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/category_ids/presets" xsi:type="string">-</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -108,14 +90,8 @@ <data name="product/data/sku" xsi:type="string">virtual_sku_%isolation%</data> <data name="product/data/price/value" xsi:type="string">5.00</data> <data name="product/data/tax_class_id/dataSet" xsi:type="string">None</data> - <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">-</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/category_ids/presets" xsi:type="string">-</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -134,10 +110,8 @@ <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/category_ids/presets" xsi:type="string">default_subcategory</data> <data name="product/data/group_price/preset" xsi:type="string">MAGETWO-23055</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="product/data/tier_price/preset" xsi:type="string">MAGETWO-23002</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog, Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -154,14 +128,10 @@ <data name="product/data/sku" xsi:type="string">virtual_sku_%isolation%</data> <data name="product/data/price/value" xsi:type="string">99.99</data> <data name="product/data/tax_class_id/dataSet" xsi:type="string">None</data> - <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">-</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/category_ids/presets" xsi:type="string">default_subcategory</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> <data name="product/data/special_price" xsi:type="string">45</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog, Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -176,14 +146,9 @@ <data name="product/data/sku" xsi:type="string">virtual_sku_%isolation%</data> <data name="product/data/price/value" xsi:type="string">5.00</data> <data name="product/data/tax_class_id/dataSet" xsi:type="string">taxable_goods</data> - <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">-</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/category_ids/presets" xsi:type="string">-</data> <data name="product/data/group_price/preset" xsi:type="string">MAGETWO-23055</data> - <data name="product/data/special_price" xsi:type="string">-</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -201,9 +166,6 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">999</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/category_ids/presets" xsi:type="string">default_subcategory</data> - <data name="product/data/group_price/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> <data name="product/data/custom_options/preset" xsi:type="string">options-suite</data> <data name="product/data/visibility" xsi:type="string">Search</data> @@ -221,14 +183,9 @@ <data name="product/data/sku" xsi:type="string">virtual_sku_%isolation%</data> <data name="product/data/price/value" xsi:type="string">99.99</data> <data name="product/data/tax_class_id/dataSet" xsi:type="string">taxable_goods</data> - <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">-</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/category_ids/presets" xsi:type="string">-</data> <data name="product/data/group_price/preset" xsi:type="string">MAGETWO-23055</data> - <data name="product/data/special_price" xsi:type="string">-</data> - <data name="product/data/tier_price/preset" xsi:type="string">-</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog, Search</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -247,19 +204,15 @@ <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/category_ids/presets" xsi:type="string">default_subcategory</data> <data name="product/data/group_price/preset" xsi:type="string">MAGETWO-23055</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="product/data/tier_price/preset" xsi:type="string">MAGETWO-23002</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/visibility" xsi:type="string">Catalog</data> <data name="product/data/url_key" xsi:type="string">virtual-product-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSpecialPriceOnProductPage" /> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductGroupedPriceOnProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductTierPriceOnProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" /> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateAttributeSetEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateAttributeSetEntityTest.xml index 93ba98c55dd97d03970e3d0ea2d951f3886c634b..320e99b58a4df53b9a155bad31d53748404b84d5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateAttributeSetEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateAttributeSetEntityTest.xml @@ -6,14 +6,14 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Catalog\Test\TestCase\ProductAttribute\CreateAttributeSetEntityTest"> - <variation name="CreateAttributeSetEntityTestVariation1"> - <data name="attributeSet/data/attribute_set_name" xsi:type="string">ProductTemplate%isolation%</data> - <data name="attributeSet/data/skeleton_set/dataSet" xsi:type="string">default</data> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateSuccessSaveMessage"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateForm"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateInGrid"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateOnProductForm"/> - </variation> - </testCase> + <testCase name="Magento\Catalog\Test\TestCase\ProductAttribute\CreateAttributeSetEntityTest"> + <variation name="CreateAttributeSetEntityTestVariation1"> + <data name="attributeSet/data/attribute_set_name" xsi:type="string">ProductTemplate%isolation%</data> + <data name="attributeSet/data/skeleton_set/dataSet" xsi:type="string">default</data> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateSuccessSaveMessage" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateForm" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateInGrid" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateOnProductForm" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateAttributeSetTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateAttributeSetTest.xml index f569a5dbbd81d73b74ad961f2d3941e5f78b86f8..7597b2416ba022c4ba0a68073835d2af87313ada 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateAttributeSetTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateAttributeSetTest.xml @@ -6,17 +6,17 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Catalog\Test\TestCase\ProductAttribute\UpdateAttributeSetTest"> - <variation name="UpdateAttributeSetTestVariation1"> - <data name="attributeSet/data/attribute_set_name" xsi:type="string">ProductTemplateEdit1%isolation%</data> - <data name="attributeSet/data/group" xsi:type="string">Custom-group%isolation%</data> - <data name="attributeSetOriginal/dataSet" xsi:type="string">custom_attribute_set</data> - <data name="productAttributeOriginal/dataSet" xsi:type="string">attribute_type_text_field</data> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateSuccessSaveMessage"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateForm"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateInGrid"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateOnProductForm"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateGroupOnProductForm"/> - </variation> - </testCase> + <testCase name="Magento\Catalog\Test\TestCase\ProductAttribute\UpdateAttributeSetTest"> + <variation name="UpdateAttributeSetTestVariation1"> + <data name="attributeSet/data/attribute_set_name" xsi:type="string">ProductTemplateEdit1%isolation%</data> + <data name="attributeSet/data/group" xsi:type="string">Custom-group%isolation%</data> + <data name="attributeSetOriginal/dataSet" xsi:type="string">custom_attribute_set</data> + <data name="productAttributeOriginal/dataSet" xsi:type="string">attribute_type_text_field</data> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateSuccessSaveMessage" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateForm" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateInGrid" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateOnProductForm" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductTemplateGroupOnProductForm" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml index de42ea1eca4ef4ad387c7315f103b0cb0aa75ff0..0e74dfb542a73f312a319c9aef11e02d330176da 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml @@ -6,58 +6,48 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Catalog\Test\TestCase\ProductAttribute\UpdateProductAttributeEntityTest"> - <variation name="UpdateProductAttributeEntityTestVariation1"> - <data name="productTemplate/dataSet" xsi:type="string">custom_attribute_set</data> - <data name="productAttributeOriginal/dataSet" xsi:type="string">attribute_type_text_field</data> - <data name="attribute/data/frontend_label" xsi:type="string">Text_Field_%isolation%</data> - <data name="attribute/data/frontend_input" xsi:type="string">-</data> - <data name="attribute/data/options/preset" xsi:type="string">-</data> - <data name="attribute/data/is_required" xsi:type="string">Yes</data> - <data name="attribute/data/attribute_code" xsi:type="string">-</data> - <data name="attribute/data/is_global" xsi:type="string">Global</data> - <data name="attribute/data/default_value_text" xsi:type="string">attribute_edited%isolation%</data> - <data name="attribute/data/is_unique" xsi:type="string">Yes</data> - <data name="attribute/data/manage_frontend_label" xsi:type="string">-</data> - <data name="attribute/data/is_searchable" xsi:type="string">Yes</data> - <data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data> - <data name="attribute/data/is_comparable" xsi:type="string">Yes</data> - <data name="attribute/data/is_filterable" xsi:type="string">-</data> - <data name="attribute/data/is_filterable_in_search" xsi:type="string">-</data> - <data name="attribute/data/is_used_for_promo_rules" xsi:type="string">Yes</data> - <data name="attribute/data/is_html_allowed_on_front" xsi:type="string">Yes</data> - <data name="attribute/data/is_visible_on_front" xsi:type="string">Yes</data> - <data name="attribute/data/used_in_product_listing" xsi:type="string">Yes</data> - <data name="attribute/data/used_for_sort_by" xsi:type="string">Yes</data> - <data name="isRequired" xsi:type="string">Yes</data> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeSaveMessage"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm"/> - </variation> - <variation name="UpdateProductAttributeEntityTestVariation2"> - <data name="productTemplate/dataSet" xsi:type="string">custom_attribute_set</data> - <data name="productAttributeOriginal/dataSet" xsi:type="string">attribute_type_dropdown</data> - <data name="attribute/data/frontend_label" xsi:type="string">Dropdown_%isolation%</data> - <data name="attribute/data/frontend_input" xsi:type="string">-</data> - <data name="attribute/data/options/preset" xsi:type="string">default</data> - <data name="attribute/data/is_required" xsi:type="string">Yes</data> - <data name="attribute/data/attribute_code" xsi:type="string">-</data> - <data name="attribute/data/is_global" xsi:type="string">Global</data> - <data name="attribute/data/default_value_text" xsi:type="string">-</data> - <data name="attribute/data/is_unique" xsi:type="string">Yes</data> - <data name="attribute/data/manage_frontend_label" xsi:type="string">-</data> - <data name="attribute/data/is_searchable" xsi:type="string">Yes</data> - <data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data> - <data name="attribute/data/is_comparable" xsi:type="string">Yes</data> - <data name="attribute/data/is_filterable" xsi:type="string">Filterable (with results)</data> - <data name="attribute/data/is_filterable_in_search" xsi:type="string">Yes</data> - <data name="attribute/data/is_used_for_promo_rules" xsi:type="string">No</data> - <data name="attribute/data/is_html_allowed_on_front" xsi:type="string">Yes</data> - <data name="attribute/data/is_visible_on_front" xsi:type="string">Yes</data> - <data name="attribute/data/used_in_product_listing" xsi:type="string">Yes</data> - <data name="attribute/data/used_for_sort_by" xsi:type="string">Yes</data> - <data name="isRequired" xsi:type="string">Yes</data> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeSaveMessage"/> - <constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm"/> - </variation> - </testCase> + <testCase name="Magento\Catalog\Test\TestCase\ProductAttribute\UpdateProductAttributeEntityTest"> + <variation name="UpdateProductAttributeEntityTestVariation1"> + <data name="productTemplate/dataSet" xsi:type="string">custom_attribute_set</data> + <data name="productAttributeOriginal/dataSet" xsi:type="string">attribute_type_text_field</data> + <data name="attribute/data/frontend_label" xsi:type="string">Text_Field_%isolation%</data> + <data name="attribute/data/is_required" xsi:type="string">Yes</data> + <data name="attribute/data/is_global" xsi:type="string">Global</data> + <data name="attribute/data/default_value_text" xsi:type="string">attribute_edited%isolation%</data> + <data name="attribute/data/is_unique" xsi:type="string">Yes</data> + <data name="attribute/data/is_searchable" xsi:type="string">Yes</data> + <data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data> + <data name="attribute/data/is_comparable" xsi:type="string">Yes</data> + <data name="attribute/data/is_used_for_promo_rules" xsi:type="string">Yes</data> + <data name="attribute/data/is_html_allowed_on_front" xsi:type="string">Yes</data> + <data name="attribute/data/is_visible_on_front" xsi:type="string">Yes</data> + <data name="attribute/data/used_in_product_listing" xsi:type="string">Yes</data> + <data name="attribute/data/used_for_sort_by" xsi:type="string">Yes</data> + <data name="isRequired" xsi:type="string">Yes</data> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeSaveMessage" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" /> + </variation> + <variation name="UpdateProductAttributeEntityTestVariation2"> + <data name="productTemplate/dataSet" xsi:type="string">custom_attribute_set</data> + <data name="productAttributeOriginal/dataSet" xsi:type="string">attribute_type_dropdown</data> + <data name="attribute/data/frontend_label" xsi:type="string">Dropdown_%isolation%</data> + <data name="attribute/data/options/preset" xsi:type="string">default</data> + <data name="attribute/data/is_required" xsi:type="string">Yes</data> + <data name="attribute/data/is_global" xsi:type="string">Global</data> + <data name="attribute/data/is_unique" xsi:type="string">Yes</data> + <data name="attribute/data/is_searchable" xsi:type="string">Yes</data> + <data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data> + <data name="attribute/data/is_comparable" xsi:type="string">Yes</data> + <data name="attribute/data/is_filterable" xsi:type="string">Filterable (with results)</data> + <data name="attribute/data/is_filterable_in_search" xsi:type="string">Yes</data> + <data name="attribute/data/is_used_for_promo_rules" xsi:type="string">No</data> + <data name="attribute/data/is_html_allowed_on_front" xsi:type="string">Yes</data> + <data name="attribute/data/is_visible_on_front" xsi:type="string">Yes</data> + <data name="attribute/data/used_in_product_listing" xsi:type="string">Yes</data> + <data name="attribute/data/used_for_sort_by" xsi:type="string">Yes</data> + <data name="isRequired" xsi:type="string">Yes</data> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeSaveMessage" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Adminhtml/Edit/SearchTermForm.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Adminhtml/Edit/SearchTermForm.php index c3c576a8b7d4cff2100653d3aa4a62b1d7912130..25ca938dde09070eefb4cc191d65d1a75e5d1f79 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Adminhtml/Edit/SearchTermForm.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Adminhtml/Edit/SearchTermForm.php @@ -6,11 +6,10 @@ namespace Magento\CatalogSearch\Test\Block\Adminhtml\Edit; -use Magento\Backend\Test\Block\Widget\Form as WidgetForm; +use Magento\Mtf\Block\Form as WidgetForm; /** - * Class Form - * Form for search term + * Form for search term. */ class SearchTermForm extends WidgetForm { diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.php index 5581bb47ea913a86cb7ba2a4bfaaddffdfe69bb8..c52774c67d3d912b1dd8813e9aacd7a61d89dd57 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.php @@ -11,55 +11,61 @@ use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Locator; /** - * Class Shipping - * Cart shipping block + * Cart shipping block. */ class Shipping extends Form { /** - * Form wrapper selector + * Form wrapper selector. * * @var string */ protected $formWrapper = '.content'; /** - * Open shipping form selector + * Open shipping form selector. * * @var string */ protected $openForm = '.title'; /** - * Get quote selector + * Get quote selector. * * @var string */ protected $getQuote = '.action.quote'; /** - * Update total selector + * Update total selector. * * @var string */ protected $updateTotalSelector = '.action.update'; /** - * Selector to access the shipping carrier method + * Selector to access the shipping carrier method. * * @var string */ protected $shippingMethod = '//span[text()="%s"]/following::*//*[contains(text(), "%s")]'; /** - * From with shipping available shipping methods + * From with shipping available shipping methods. * * @var string */ protected $shippingMethodForm = '#co-shipping-method-form'; /** - * Open estimate shipping and tax form + * Fields that are used in estimation shipping form. + * + * @var array + */ + protected $estimationFields = ['country_id', 'region_id', 'region', 'postcode']; + + /** + * Open estimate shipping and tax form. * * @return void */ @@ -71,7 +77,7 @@ class Shipping extends Form } /** - * Click Get quote button + * Click Get quote button. * * @return void */ @@ -81,7 +87,7 @@ class Shipping extends Form } /** - * Select shipping method + * Select shipping method. * * @param array $shipping * @return void @@ -97,7 +103,7 @@ class Shipping extends Form } /** - * Fill shipping and tax form + * Fill shipping and tax form. * * @param Address $address * @return void @@ -105,12 +111,14 @@ class Shipping extends Form public function fillEstimateShippingAndTax(Address $address) { $this->openEstimateShippingAndTax(); - $this->fill($address); + $data = $address->getData(); + $mapping = $this->dataMapping(array_intersect_key($data, array_flip($this->estimationFields))); + $this->_fill($mapping, $this->_rootElement); $this->clickGetQuote(); } /** - * Determines if the specified shipping carrier/method is visible on the cart + * Determines if the specified shipping carrier/method is visible on the cart. * * @param $carrier * @param $method 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 f4df8ae791b970291e26684656e2199df91d1445..dcc945eaafd750c6d4fcb282c791c3f611e0e8a1 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 @@ -48,8 +48,6 @@ class Billing extends Form $isShippingAddress = false ) { if ($billingAddress) { - //@TODO: MAGETWO-34756 - sleep(5); $this->fill($billingAddress); } if ($isShippingAddress) { 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 4188aef15cd0565a483f3a08e31fdaf7156cd429..53402d17d2a4654409dd5a2b7d6937ad7c58422f 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,8 +6,8 @@ namespace Magento\Cms\Test\Block\Adminhtml\Page; -use Magento\Ui\Test\Block\Adminhtml\DataGrid; use Magento\Mtf\Client\Locator; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; /** * Backend Data Grid for managing "CMS Page" entities. @@ -66,8 +66,8 @@ class Grid extends DataGrid * * @var string */ - protected $previewCmsPage = '.action-menu-item'; - + protected $previewCmsPage = ".//a[contains(@class, 'action-menu-item') and text() = '%s']"; + /** * Search item and open it on Frontend. * @@ -77,10 +77,12 @@ class Grid extends DataGrid */ public function searchAndPreview(array $filter) { + $itemName = 'Preview'; $this->search($filter); $rowItem = $this->_rootElement->find($this->rowItem); if ($rowItem->isVisible()) { - $rowItem->find($this->previewCmsPage)->click(); + $rowItem->find('.action-select')->click(); + $rowItem->find(sprintf($this->previewCmsPage, $itemName), Locator::SELECTOR_XPATH)->click(); } else { throw new \Exception('Searched item was not found.'); } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsBlockEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsBlockEntityTest.xml index 2e1583ed1df208668de87b8fc5a3e62edd4b4628..a6fb5bb04526031f8a9e828ea496e769bde0590b 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsBlockEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsBlockEntityTest.xml @@ -18,7 +18,6 @@ <constraint name="Magento\Cms\Test\Constraint\AssertCmsBlockOnCategoryPage" /> </variation> <variation name="CreateCmsBlockEntityTestVariation2"> - <data name="issue" xsi:type="string">Bug: MAGETWO-35059</data> <data name="cmsBlock/data/title" xsi:type="string">block_%isolation%</data> <data name="cmsBlock/data/identifier" xsi:type="string">identifier_%isolation%</data> <data name="cmsBlock/data/stores/dataSet/option_0" xsi:type="string">default</data> 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 60e0ea23b8526546d7ef2dca4f1d92a7c870c99b..7c1cddceb98ec3c10a9706921d161ae55629fec8 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 @@ -9,6 +9,7 @@ namespace Magento\Cms\Test\TestCase; use Magento\Cms\Test\Fixture\CmsPage as CmsPageFixture; use Magento\Cms\Test\Page\Adminhtml\CmsPageIndex; use Magento\Cms\Test\Page\Adminhtml\CmsPageNew; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestCase\Injectable; /** @@ -29,7 +30,6 @@ class CreateCmsPageEntityTest extends Injectable const MVP = 'yes'; const DOMAIN = 'PS'; const TEST_TYPE = 'acceptance_test'; - const TO_MAINTAIN = 'yes'; /* end tags */ /** @@ -46,33 +46,46 @@ class CreateCmsPageEntityTest extends Injectable */ protected $cmsPageNew; + /** + * Fixture factory. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + /** * Inject pages. * * @param CmsPageIndex $cmsIndex * @param CmsPageNew $cmsPageNew + * @param FixtureFactory $fixtureFactory * @return void */ - public function __inject(CmsPageIndex $cmsIndex, CmsPageNew $cmsPageNew) + public function __inject(CmsPageIndex $cmsIndex, CmsPageNew $cmsPageNew, FixtureFactory $fixtureFactory) { $this->cmsIndex = $cmsIndex; $this->cmsPageNew = $cmsPageNew; + $this->fixtureFactory = $fixtureFactory; } /** * Creating Cms page. * - * @param CmsPageFixture $cms - * @return void + * @param array $data + * @param string $fixtureType + * @return array */ - public function test(CmsPageFixture $cms) + public function test(array $data, $fixtureType) { // Steps + $cms = $this->fixtureFactory->createByCode($fixtureType, ['data' => $data]); $this->cmsIndex->open(); $this->cmsIndex->getPageActionsBlock()->addNew(); //TODO: remove cms page new refresh after resolve issue with static js files publication (MAGETWO-37898) $this->cmsPageNew->open(); $this->cmsPageNew->getPageForm()->fill($cms); $this->cmsPageNew->getPageMainActions()->save(); + + return ['cms' => $cms]; } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml index 21c9773ef8a4518f1ebdd6c466585dd4d2749fd2..a549ca390d66817d3c7a2c64590aaa833bd1ed8a 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml @@ -9,10 +9,11 @@ <testCase name="Magento\Cms\Test\TestCase\CreateCmsPageEntityTest"> <variation name="CreateCmsPageEntityTestVariation1"> <data name="description" xsi:type="string">MAGETWO-12399: Create CMS Content Page</data> - <data name="cms/data/title" xsi:type="string">NewCmsPage%isolation%</data> - <data name="cms/data/identifier" xsi:type="string">identifier-%isolation%</data> - <data name="cms/data/store_id" xsi:type="string">All Store Views</data> - <data name="cms/data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> + <data name="fixtureType" xsi:type="string">cmsPage</data> + <data name="data/title" xsi:type="string">NewCmsPage%isolation%</data> + <data name="data/identifier" xsi:type="string">identifier-%isolation%</data> + <data name="data/store_id" xsi:type="string">All Store Views</data> + <data name="data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> <data name="tag" xsi:type="string">test_type:acceptance_test</data> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageInGrid" /> @@ -20,20 +21,21 @@ </variation> <variation name="CreateCmsPageEntityTestVariation2"> <data name="description" xsi:type="string">Create page for default store view</data> - <data name="cms/data/title" xsi:type="string">NewCmsPage%isolation%</data> - <data name="cms/data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> - <data name="cms/data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> + <data name="fixtureType" xsi:type="string">cmsPage</data> + <data name="data/title" xsi:type="string">NewCmsPage%isolation%</data> + <data name="data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageForm" /> </variation> <variation name="CreateCmsPageEntityTestVariation3"> - <data name="issue" xsi:type="string">Bug: MAGETWO-34858</data> <data name="description" xsi:type="string">Create page with widget and system variable</data> - <data name="cms/data/title" xsi:type="string">NewCmsPage%isolation%</data> - <data name="cms/data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> - <data name="cms/data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> - <data name="cms/data/content/widget/preset" xsi:type="string">default</data> - <data name="cms/data/content/variable" xsi:type="string">General Contact Name</data> + <data name="fixtureType" xsi:type="string">cmsPage</data> + <data name="data/title" xsi:type="string">NewCmsPage%isolation%</data> + <data name="data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> + <data name="data/content/widget/preset" xsi:type="string">default</data> + <data name="data/content/variable" xsi:type="string">General Contact Name</data> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageForm" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageInGrid" /> @@ -41,10 +43,11 @@ </variation> <variation name="CreateCmsPageEntityTestVariation4"> <data name="description" xsi:type="string">Create disabled page</data> - <data name="cms/data/title" xsi:type="string">NewCmsPage%isolation%</data> - <data name="cms/data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> - <data name="cms/data/is_active" xsi:type="string">Disabled</data> - <data name="cms/data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> + <data name="fixtureType" xsi:type="string">cmsPage</data> + <data name="data/title" xsi:type="string">NewCmsPage%isolation%</data> + <data name="data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="data/is_active" xsi:type="string">Disabled</data> + <data name="data/content/content" xsi:type="string">cms_page_text_content%isolation%</data> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageForm" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageInGrid" /> diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageRewriteEntityTest.php index 5023d9a37f2449be13b0c1153842e92014fa779c..5a0511def48fa2e7ac955637e7132367330113b4 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageRewriteEntityTest.php @@ -75,7 +75,7 @@ class CreateCmsPageRewriteEntityTest extends Injectable //Steps $this->urlRewriteIndex->open(); $this->urlRewriteIndex->getPageActionsBlock()->addNew(); - $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite); + $this->urlRewriteEdit->getUrlRewriteTypeSelectorBlock()->selectType($urlRewrite->getEntityType()); $cmsPage = $urlRewrite->getDataFieldConfig('target_path')['source']->getEntity(); $filter = ['title' => $cmsPage->getTitle()]; $this->urlRewriteEdit->getCmsGridBlock()->searchAndOpen($filter); diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsBlockEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsBlockEntityTest.xml index 472e5a6558643e5ba71f676aa4811e555ff98515..048ff19fc06e9c2126be6cf5113afdaaa5349c9a 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsBlockEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsBlockEntityTest.xml @@ -18,7 +18,6 @@ <constraint name="Magento\Cms\Test\Constraint\AssertCmsBlockOnCategoryPage" /> </variation> <variation name="UpdateCmsBlockEntityTestVariation2"> - <data name="issue" xsi:type="string">Bug: MAGETWO-35059</data> <data name="cmsBlock/data/title" xsi:type="string">block_updated_%isolation%</data> <data name="cmsBlock/data/identifier" xsi:type="string">identifier_updated_%isolation%</data> <data name="cmsBlock/data/stores/dataSet/option_0" xsi:type="string">default</data> diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageEntityTest.php index 8da0baf1779dbb8f1509e4e74ad68bf8fe31d3ea..4c8f8d1cf29e792b75501b2d16471d83671cb0cc 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageEntityTest.php @@ -32,7 +32,6 @@ class UpdateCmsPageEntityTest extends Injectable /* tags */ const MVP = 'yes'; const DOMAIN = 'PS'; - const STABLE = 'no'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php index 1385164d592ac0608f057730e41b2897938ae55f..c838565a3d1ade69fe36b7cecf324a8bcd7e5402 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php @@ -10,7 +10,7 @@ use Magento\Mtf\Client\Element; use Magento\Mtf\Client\Locator; use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\Client\Element\SimpleElement; -use Magento\Backend\Test\Block\Widget\Form as ParentForm; +use Magento\Mtf\Block\Form as ParentForm; /** * Class AffectedAttributeSet 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 9008800f6dd2ed58aec9821449f7fbd8ac12cd7f..17dc4b9d01f3141652064cfa61f058c34df4b68c 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 @@ -6,7 +6,7 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; use Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\AttributeSelector; use Magento\Mtf\Client\Element\SimpleElement; use Magento\Mtf\Client\Locator; @@ -247,7 +247,12 @@ class Attribute extends Form $attributeBlock->find($this->addOption)->click(); } $mapping = $this->dataMapping($option); - $this->_fill($mapping, $optionContainer); + foreach ($mapping as $field) { + $element = $this->getElement($optionContainer, $field); + if ($element->isVisible() && !$element->isDisabled()) { + $element->setValue($field['value']); + } + } } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php index d3c32d608a143ce63212eef08da97c7df4372a93..4d2bf2cb8268168557df928f63a3cb0b8cde12c8 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php @@ -21,14 +21,16 @@ class AttributeSelector extends SuggestElement */ public function waitResult() { - $browser = $this; - $selector = $this->searchResult; - $browser->waitUntil( - function () use ($browser, $selector) { - $element = $browser->find($selector); - return $element->isVisible() ? true : null; - } - ); + try { + $this->waitUntil( + function () { + return $this->find($this->searchResult)->isVisible() ? true : null; + } + ); + } catch (\Exception $e) { + // In parallel run on windows change the focus is lost on element + // that causes disappearing of result suggest list. + } } /** diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php index 11db5ed304636b2e2f25019e3c7b08bc5d8ac1f5..8ecdc5aa867ac14b09de37a8dfc480144d468b6f 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php @@ -8,7 +8,7 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Supe use Magento\Mtf\Client\Locator; use Magento\Backend\Test\Block\Template; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Element\SimpleElement; /** diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php index 1fbc66894cebacdfb377b9a2edc64a5e04fa17a1..6b79d3f4378eb68c03306271d9f951fae10259cd 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php @@ -34,6 +34,7 @@ class ProductForm extends \Magento\Catalog\Test\Block\Adminhtml\Product\ProductF } $this->showAdvancedSettings(); + $this->getTab('variations')->showContent(); return $this->fillTabs($tabs, $element); } } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml index 4ffc8f05740d4454c14ded3bdc171699a7d93c1c..333fd02a273cdf57938df7df7fa4e9e801d26537 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<mapping strict="0"> +<mapping strict="1"> <wrapper>rate</wrapper> <fields> <rate> 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 2f758e545f4821b7f8fc3fc271881099d2c70d82..33e1e795ca940f4dc40ade7b565ba87969a0c54f 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 @@ -34,6 +34,10 @@ class CurrencySymbolForm extends Form public function fill(FixtureInterface $fixture, SimpleElement $element = null) { $element = $this->_rootElement->find(sprintf($this->currencyRow, $fixture->getCode()), Locator::SELECTOR_XPATH); - return parent::fill($fixture, $element); + $data = $fixture->getData(); + unset($data['code']); + $mapping = $this->dataMapping($data); + $this->_fill($mapping, $element); + return $this; } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Group/Edit/Form.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Group/Edit/Form.php index b262872d048e724c5c3fc5570cb79e82b6030db4..e840b736e06357961ff3446ab37e661e27d93e58 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Group/Edit/Form.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Group/Edit/Form.php @@ -6,15 +6,10 @@ namespace Magento\Customer\Test\Block\Adminhtml\Group\Edit; -use Magento\Backend\Test\Block\Widget\Form as AbstractForm; - /** - * Class Form - * Customer group edit form - * - * @package Magento\Customer\Test\Block\Adminhtml\Group\Edit + * Customer group edit form. */ -class Form extends AbstractForm +class Form extends \Magento\Mtf\Block\Form { // } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomer.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomer.php deleted file mode 100644 index 744387049f2bc348cc2ea1ad106c6d472e3c885b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomer.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Test\Handler\Curl; - -use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Handler\Curl; -use Magento\Mtf\Util\Protocol\CurlInterface; -use Magento\Mtf\Util\Protocol\CurlTransport; - -/** - * Class CreateCustomer. - * Curl handler for creating customer through registration page. - * - */ -class CreateCustomer extends Curl -{ - /** - * Post request for creating customer - * - * @param FixtureInterface $fixture [optional] - * @return mixed|string - */ - public function persist(FixtureInterface $fixture = null) - { - $data = $fixture->getData('fields'); - $fields = []; - foreach ($data as $key => $field) { - $fields[$key] = $field['value']; - } - $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; - $curl = new CurlTransport(); - $curl->write(CurlInterface::POST, $url, '1.0', [], $fields); - $response = $curl->read(); - $curl->close(); - - return $response; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomerBackend.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomerBackend.php deleted file mode 100644 index cad3c992efa4681f8bf0851d50fa211c22aad7cc..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/CreateCustomerBackend.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Test\Handler\Curl; - -use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Handler\Curl; -use Magento\Mtf\Util\Protocol\CurlInterface; -use Magento\Mtf\Util\Protocol\CurlTransport; -use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator; - -/** - * Curl handler for creating customer in admin - * - */ -class CreateCustomerBackend extends Curl -{ - /** - * Prepare POST data for creating customer request - * - * @param FixtureInterface $fixture - * @return array - */ - protected function _prepareData(FixtureInterface $fixture) - { - $data = $fixture->getData('fields'); - foreach ($data as $key => $values) { - $value = $this->_getValue($values); - if (null === $value) { - continue; - } - $data[$key] = $value; - } - - $curlData['account'] = $data; - return $curlData; - } - - /** - * 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']; - } - - /** - * Post request for creating customer in backend - * - * @param FixtureInterface $fixture [optional] - * @return mixed|string - */ - public function persist(FixtureInterface $fixture = null) - { - $params = $this->_prepareData($fixture); - - $url = $_ENV['app_backend_url'] . 'customer/index/save/active_tab/account'; - $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 $response; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/SaveCustomerWithAddress.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/SaveCustomerWithAddress.php deleted file mode 100644 index 43456cb34eec54dc87dd5f795753e44e06856fd7..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Curl/SaveCustomerWithAddress.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Test\Handler\Curl; - -use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Handler\Curl; -use Magento\Mtf\Util\Protocol\CurlInterface; -use Magento\Mtf\Util\Protocol\CurlTransport; - -/** - * Curl handler for saving customer address in admin - * - */ -class SaveCustomerWithAddress extends Curl -{ - /** - * Url for saving data - * - * @var string - */ - protected $saveUrl = '/customer/address/formPost/?nocookie=true'; - - /** - * Url for saving customer - * - * @var string - */ - protected $saveCustomer = 'customer/account/createpost/?nocookie=true'; - - /** - * Url of new address form - * - * @var string - */ - protected $addressNew = '/customer/address/new/?nocookie=true'; - - /** - * Form key - * - * @var string - */ - protected $formKey; - - /** - * Prepare POST data for creating customer request - * - * @param array $data - * @return array - */ - protected function prepareData($data) - { - $curlData = []; - foreach ($data as $key => $values) { - $value = $this->getValue($values); - if (null === $value) { - continue; - } - $curlData[$key] = $value; - } - $curlData['success_url'] = ''; - $curlData['error_url'] = ''; - $curlData['default_billing'] = 1; - $curlData['default_shipping'] = 1; - - return $curlData; - } - - /** - * 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 - * @return mixed - */ - public function persist(FixtureInterface $fixture = null) - { - /** @var \Magento\Customer\Test\Fixture\Customer $fixture */ - $address = $fixture->getDefaultBilling(); - $fields = $this->prepareData($address->getData('fields')); - $url = $_ENV['app_frontend_url'] . $this->saveUrl; - $curl = $this->saveCustomer($fixture); - $fields['form_key'] = $this->formKey; - $curl->write(CurlInterface::POST, $url, '1.0', [], $fields); - $response = $curl->read(); - $curl->close(); - - return $response; - } - - /** - * Get from key from response - * - * @param string $response - * @return string - */ - protected function getFromKey($response) - { - preg_match('/input name="form_key" type="hidden" value="(\w+)"/', $response, $matches); - $formKey = ''; - if (!empty($matches[1])) { - $formKey = $matches[1]; - } - return $formKey; - } - - /** - * Save new customer and get form key - * - * @param \Magento\Customer\Test\Fixture\Customer $fixture - * @return CurlTransport - */ - protected function saveCustomer(\Magento\Customer\Test\Fixture\Customer $fixture) - { - $data = $fixture->getData('fields'); - $fields = []; - foreach ($data as $key => $field) { - $fields[$key] = $field['value']; - } - $url = $_ENV['app_frontend_url'] . $this->saveCustomer; - $curl = new CurlTransport(); - $curl->write(CurlInterface::POST, $url, '1.0', [], $fields); - $curl->read(); - $urlForm = $_ENV['app_frontend_url'] . $this->addressNew; - $curl->write(CurlInterface::GET, $urlForm, '1.0', []); - $response = $curl->read(); - $this->formKey = $this->getFromKey($response); - - return $curl; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index a13c263aeab7fe4db7e475dc11ee6f668fbfe4a8..2d8f5faf09f8860b6d20b3e5a08bdc2ca5b21c0f 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php @@ -195,23 +195,27 @@ class Curl extends AbstractCurl implements CustomerInterface */ protected function prepareAddressData(array $curlData) { + $address = []; foreach (array_keys($curlData['address']) as $key) { - $curlData['address'][$key]['_deleted'] = ''; - $curlData['address'][$key]['region'] = ''; - if (!is_array($curlData['address'][$key]['street'])) { - $street = $curlData['address'][$key]['street']; - $curlData['address'][$key]['street'] = []; - $curlData['address'][$key]['street'][] = $street; + $addressKey = 'new_' . $key; + $address[$addressKey] = $curlData['address'][$key]; + $address[$addressKey]['_deleted'] = ''; + $address[$addressKey]['region'] = ''; + if (!is_array($address[$addressKey]['street'])) { + $street = $address[$addressKey]['street']; + $address[$addressKey]['street'] = []; + $address[$addressKey]['street'][] = $street; } - if (isset($curlData['address'][$key]['default_billing'])) { - $value = $curlData['address'][$key]['default_billing'] === 'Yes' ? 'true' : 'false'; - $curlData['address'][$key]['default_billing'] = $value; + if (isset($address[$addressKey]['default_billing'])) { + $value = $address[$addressKey]['default_billing'] === 'Yes' ? 'true' : 'false'; + $address[$addressKey]['default_billing'] = $value; } - if (isset($curlData['address'][$key]['default_shipping'])) { - $value = $curlData['address'][$key]['default_shipping'] === 'Yes' ? 'true' : 'false'; - $curlData['address'][$key]['default_shipping'] = $value; + if (isset($address[$addressKey]['default_shipping'])) { + $value = $address[$addressKey]['default_shipping'] === 'Yes' ? 'true' : 'false'; + $address[$addressKey]['default_shipping'] = $value; } } + $curlData['address'] = $address; return $curlData; } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Ui/CreateAddress.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Ui/CreateAddress.php deleted file mode 100644 index b2e9bdd33d69766478fad90cc5c20634f96f45f6..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Ui/CreateAddress.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Test\Handler\Ui; - -use Magento\Mtf\Factory\Factory; -use Magento\Mtf\Fixture\FixtureInterface; - -/** - * UI handler for creating customer address. - */ -class CreateAddress extends \Magento\Mtf\Handler\Ui -{ - /** - * Execute handler - * - * @param FixtureInterface $fixture [optional] - * @return mixed - */ - public function persist(FixtureInterface $fixture = null) - { - /** @var \Magento\Customer\Test\Fixture\Address $fixture */ - // Pages - $loginPage = Factory::getPageFactory()->getCustomerAccountLogin(); - $addressPage = Factory::getPageFactory()->getCustomerAddressEdit(); - - $loginPage->open(); - if ($loginPage->getLoginBlock()->isVisible()) { - $loginPage->getLoginBlock()->login($fixture->getCustomer()); - } - - $addressPage->open(); - $addressPage->getEditForm()->editCustomerAddress($fixture); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Webapi/CreateCustomer.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Webapi/CreateCustomer.php deleted file mode 100644 index af06e68b03ef85b14d92d27f4044803de10e059b..0000000000000000000000000000000000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Webapi/CreateCustomer.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Test\Handler\Webapi; - -use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Handler\Webapi; -use Magento\Mtf\Util\Protocol\SoapTransport; - -/** - * Class CreateCustomer - * - */ -class CreateCustomer extends Webapi -{ - /** - * Create customer through request - * - * @param FixtureInterface $fixture [optional] - * @return mixed - */ - public function persist(FixtureInterface $fixture = null) - { - $configuration = $this->_configuration->get('handler/0/webapi/0/value'); - - $soap = new SoapTransport($configuration['soap']); - return $soap->call('customerCustomerList', $fixture->getData()); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.php index 6012db8cdd17d501e64154dfe8892b8c14dcc2f3..ab84bfc693502818ea324506b9ff465771960798 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.php @@ -25,8 +25,8 @@ class Address extends AbstractRepository 'data' => $defaultData, ]; - $this->_data['address_US_1'] = $this->_getUS1(); - $this->_data['address_US_2'] = $this->_getUS2(); + $this->_data['US_address_1'] = $this->_getUS1(); + $this->_data['US_address_2'] = $this->_getUS2(); $this->_data['address_UK'] = $this->getAddressUK(); $this->_data['address_UK_2'] = $this->getAddressUK2(); $this->_data['address_UK_with_VAT'] = $this->getAddressUKWithVAT($this->_data['address_UK']); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml index e379604530bcdc5cbafede7c11370a74e5639b94..b39490b24c48af4d2b10c1ac7e45fdc7d4a367d0 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml @@ -37,21 +37,6 @@ <field name="default_shipping" xsi:type="string">No</field> </dataset> - <dataset name="US_NY_address_billing"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> - <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="street" xsi:type="string">6262 Fifth Avenue</field> - <field name="city" xsi:type="string">New York</field> - <field name="region_id" xsi:type="string">New York</field> - <field name="postcode" xsi:type="string">90230</field> - <field name="country_id" xsi:type="string">United States</field> - <field name="telephone" xsi:type="string">555-55-555-55</field> - <field name="default_billing" xsi:type="string">No</field> - <field name="default_shipping" xsi:type="string">No</field> - </dataset> - <dataset name="US_address_default_shipping"> <field name="firstname" xsi:type="string">John</field> <field name="lastname" xsi:type="string">Doe</field> @@ -67,43 +52,42 @@ <field name="default_shipping" xsi:type="string">No</field> </dataset> - <dataset name="default_US_address"> + <dataset name="US_address_1"> + <field name="firstname" xsi:type="string">John</field> + <field name="lastname" xsi:type="string">Doe</field> <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="street" xsi:type="string">6161 West Centinela Avenue</field> + <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> <field name="city" xsi:type="string">Culver City</field> - <field name="region_id" xsi:type="string">California</field> + <field name="street" xsi:type="string">6161 West Centinela Avenue</field> <field name="postcode" xsi:type="string">90230</field> <field name="country_id" xsi:type="string">United States</field> + <field name="region_id" xsi:type="string">California</field> <field name="telephone" xsi:type="string">555-55-555-55</field> - <field name="default_billing" xsi:type="string">Yes</field> - <field name="default_shipping" xsi:type="string">Yes</field> </dataset> - <dataset name="US_address_without_email"> + <dataset name="US_address_1_without_email"> <field name="firstname" xsi:type="string">John</field> <field name="lastname" xsi:type="string">Doe</field> <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="street" xsi:type="string">6161 West Centinela Avenue</field> <field name="city" xsi:type="string">Culver City</field> - <field name="region_id" xsi:type="string">California</field> + <field name="street" xsi:type="string">6161 West Centinela Avenue</field> <field name="postcode" xsi:type="string">90230</field> <field name="country_id" xsi:type="string">United States</field> + <field name="region_id" xsi:type="string">California</field> <field name="telephone" xsi:type="string">555-55-555-55</field> </dataset> - <dataset name="US_address_NY"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> + <dataset name="US_address_2"> + <field name="firstname" xsi:type="string">Billy</field> + <field name="lastname" xsi:type="string">Holiday</field> <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="street" xsi:type="string">3222 Cliffside Drive</field> - <field name="city" xsi:type="string">Binghamton</field> - <field name="region_id" xsi:type="string">New York</field> - <field name="postcode" xsi:type="string">13901</field> + <field name="email" xsi:type="string">b.holliday@example.net</field> + <field name="city" xsi:type="string">New York</field> + <field name="street" xsi:type="string">727 5th Ave</field> + <field name="postcode" xsi:type="string">10022</field> <field name="country_id" xsi:type="string">United States</field> - <field name="telephone" xsi:type="string">607-481-7802</field> - <field name="default_billing" xsi:type="string">Yes</field> - <field name="default_shipping" xsi:type="string">Yes</field> + <field name="region_id" xsi:type="string">New York</field> + <field name="telephone" xsi:type="string">777-77-77-77</field> </dataset> <dataset name="US_address_TX"> @@ -121,21 +105,37 @@ <field name="default_shipping" xsi:type="string">Yes</field> </dataset> - <dataset name="customer_US"> + <dataset name="US_address_NY"> <field name="firstname" xsi:type="string">John</field> <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">JohnDoe_%isolation%@example.com</field> + <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="city" xsi:type="string">Culver City</field> - <field name="street" xsi:type="string">6161 West Centinela Avenue</field> + <field name="street" xsi:type="string">3222 Cliffside Drive</field> + <field name="city" xsi:type="string">Binghamton</field> + <field name="region_id" xsi:type="string">New York</field> + <field name="postcode" xsi:type="string">13901</field> + <field name="country_id" xsi:type="string">United States</field> + <field name="telephone" xsi:type="string">607-481-7802</field> + <field name="default_billing" xsi:type="string">Yes</field> + <field name="default_shipping" xsi:type="string">Yes</field> + </dataset> + + <dataset name="US_address_NY_default_no"> + <field name="firstname" xsi:type="string">John</field> + <field name="lastname" xsi:type="string">Doe</field> + <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> + <field name="company" xsi:type="string">Magento %isolation%</field> + <field name="street" xsi:type="string">6262 Fifth Avenue</field> + <field name="city" xsi:type="string">New York</field> + <field name="region_id" xsi:type="string">New York</field> <field name="postcode" xsi:type="string">90230</field> <field name="country_id" xsi:type="string">United States</field> - <field name="region_id" xsi:type="string">California</field> <field name="telephone" xsi:type="string">555-55-555-55</field> - <field name="fax" xsi:type="string">555-55-555-55</field> + <field name="default_billing" xsi:type="string">No</field> + <field name="default_shipping" xsi:type="string">No</field> </dataset> - <dataset name="customer_UK"> + <dataset name="UK_address_default_billing"> <field name="firstname" xsi:type="string">Jane</field> <field name="lastname" xsi:type="string">Doe</field> <field name="email" xsi:type="string">JaneDoe_%isolation%@example.com</field> @@ -147,9 +147,11 @@ <field name="region" xsi:type="string">London</field> <field name="telephone" xsi:type="string">444-44-444-44</field> <field name="fax" xsi:type="string">444-44-444-44</field> + <field name="default_billing" xsi:type="string">Yes</field> + <field name="default_shipping" xsi:type="string">Yes</field> </dataset> - <dataset name="address_UK_default_billing_address"> + <dataset name="UK_address"> <field name="firstname" xsi:type="string">Jane</field> <field name="lastname" xsi:type="string">Doe</field> <field name="email" xsi:type="string">JaneDoe_%isolation%@example.com</field> @@ -161,61 +163,9 @@ <field name="region" xsi:type="string">London</field> <field name="telephone" xsi:type="string">444-44-444-44</field> <field name="fax" xsi:type="string">444-44-444-44</field> - <field name="default_billing" xsi:type="string">Yes</field> - <field name="default_shipping" xsi:type="string">Yes</field> - </dataset> - - <dataset name="address_US_1"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> - <field name="city" xsi:type="string">Culver City</field> - <field name="street" xsi:type="string">6161 West Centinela Avenue</field> - <field name="postcode" xsi:type="string">90230</field> - <field name="country_id" xsi:type="string">United States</field> - <field name="region_id" xsi:type="string">California</field> - <field name="telephone" xsi:type="string">555-55-555-55</field> - </dataset> - - <dataset name="address_US_2"> - <field name="firstname" xsi:type="string">Billy</field> - <field name="lastname" xsi:type="string">Holiday</field> - <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="email" xsi:type="string">b.holliday@example.net</field> - <field name="city" xsi:type="string">New York</field> - <field name="street" xsi:type="string">727 5th Ave</field> - <field name="postcode" xsi:type="string">10022</field> - <field name="country_id" xsi:type="string">United States</field> - <field name="region_id" xsi:type="string">New York</field> - <field name="telephone" xsi:type="string">777-77-77-77</field> - </dataset> - - <dataset name="address_data_US_1"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="city" xsi:type="string">Culver City</field> - <field name="street" xsi:type="string">6161 West Centinela Avenue</field> - <field name="postcode" xsi:type="string">90230</field> - <field name="country_id" xsi:type="string">United States</field> - <field name="region_id" xsi:type="string">California</field> - <field name="telephone" xsi:type="string">555-55-555-55</field> - </dataset> - - <dataset name="address_DE"> - <field name="firstname" xsi:type="string">Jan</field> - <field name="lastname" xsi:type="string">Jansen</field> - <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="city" xsi:type="string">Berlin</field> - <field name="street" xsi:type="string">Augsburger Strabe 41</field> - <field name="postcode" xsi:type="string">10789</field> - <field name="country_id" xsi:type="string">Germany</field> - <field name="region_id" xsi:type="string">Berlin</field> - <field name="telephone" xsi:type="string">333-33-333-33</field> </dataset> - <dataset name="address_UK"> + <dataset name="UK_address_without_email"> <field name="firstname" xsi:type="string">Jane</field> <field name="lastname" xsi:type="string">Doe</field> <field name="company" xsi:type="string">Magento %isolation%</field> @@ -223,23 +173,12 @@ <field name="street" xsi:type="string">172, Westminster Bridge Rd</field> <field name="postcode" xsi:type="string">SE1 7RW</field> <field name="country_id" xsi:type="string">United Kingdom</field> - <field name="region_id" xsi:type="string">London</field> - <field name="telephone" xsi:type="string">444-44-444-44</field> - </dataset> - - <dataset name="address_UK_2"> - <field name="firstname" xsi:type="string">Jane</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="company" xsi:type="string">Magento %isolation%</field> - <field name="city" xsi:type="string">Manchester</field> - <field name="street" xsi:type="string">42 King Street West</field> - <field name="postcode" xsi:type="string">M3 2WY</field> - <field name="country_id" xsi:type="string">United Kingdom</field> - <field name="region_id" xsi:type="string">Manchester</field> + <field name="region" xsi:type="string">London</field> <field name="telephone" xsi:type="string">444-44-444-44</field> + <field name="fax" xsi:type="string">444-44-444-44</field> </dataset> - <dataset name="address_UK_with_VAT"> + <dataset name="UK_address_with_VAT"> <field name="firstname" xsi:type="string">Jane</field> <field name="lastname" xsi:type="string">Doe</field> <field name="company" xsi:type="string">Magento %isolation%</field> @@ -253,5 +192,17 @@ <field name="default_billing" xsi:type="string">Yes</field> <field name="default_shipping" xsi:type="string">Yes</field> </dataset> + + <dataset name="DE_address"> + <field name="firstname" xsi:type="string">Jan</field> + <field name="lastname" xsi:type="string">Jansen</field> + <field name="company" xsi:type="string">Magento %isolation%</field> + <field name="city" xsi:type="string">Berlin</field> + <field name="street" xsi:type="string">Augsburger Strabe 41</field> + <field name="postcode" xsi:type="string">10789</field> + <field name="country_id" xsi:type="string">Germany</field> + <field name="region_id" xsi:type="string">Berlin</field> + <field name="telephone" xsi:type="string">333-33-333-33</field> + </dataset> </repository> </config> 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 a3eb0e57b62a60790483e504a2f020e7252744b0..2dc95ab415c6d8bebb759f0726e17366ed87a627 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 @@ -76,22 +76,6 @@ </field> </dataset> - <dataset name="customer_US"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">JohnDoe_%isolation%@example.com</field> - <field name="password" xsi:type="string">123123q</field> - <field name="password_confirmation" xsi:type="string">123123q</field> - </dataset> - - <dataset name="customer_UK"> - <field name="firstname" xsi:type="string">Jane</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">JaneDoe_%isolation%@example.com</field> - <field name="password" xsi:type="string">123123q</field> - <field name="password_confirmation" xsi:type="string">123123q</field> - </dataset> - <dataset name="johndoe_unique"> <field name="firstname" xsi:type="string">John</field> <field name="lastname" xsi:type="string">Doe%isolation%</field> @@ -144,7 +128,7 @@ <field name="password" xsi:type="string">123123q</field> <field name="password_confirmation" xsi:type="string">123123q</field> <field name="address" xsi:type="array"> - <item name="presets" xsi:type="string">address_US_1</item> + <item name="presets" xsi:type="string">US_address_1</item> </field> </dataset> @@ -158,29 +142,18 @@ <field name="password" xsi:type="string">123123q</field> <field name="password_confirmation" xsi:type="string">123123q</field> <field name="address" xsi:type="array"> - <item name="presets" xsi:type="string">address_US_1</item> + <item name="presets" xsi:type="string">US_address_1</item> </field> </dataset> - <dataset name="customer_US_1"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe%isolation%</field> - <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> - <field name="password" xsi:type="string">123123q</field> - <field name="password_confirmation" xsi:type="string">123123q</field> - <field name="address" xsi:type="array"> - <item name="presets" xsi:type="string">address_US_1</item> - </field> - </dataset> - - <dataset name="customer_UK_1"> + <dataset name="customer_US"> <field name="firstname" xsi:type="string">John</field> <field name="lastname" xsi:type="string">Doe%isolation%</field> <field name="email" xsi:type="string">John.Doe%isolation%@example.com</field> <field name="password" xsi:type="string">123123q</field> <field name="password_confirmation" xsi:type="string">123123q</field> <field name="address" xsi:type="array"> - <item name="presets" xsi:type="string">address_UK</item> + <item name="presets" xsi:type="string">US_address_1</item> </field> </dataset> @@ -191,7 +164,7 @@ <field name="password" xsi:type="string">123123q</field> <field name="password_confirmation" xsi:type="string">123123q</field> <field name="address" xsi:type="array"> - <item name="presets" xsi:type="string">address_UK_default_billing_address</item> + <item name="presets" xsi:type="string">UK_address_default_billing</item> </field> </dataset> @@ -202,7 +175,7 @@ <field name="password" xsi:type="string">123123q</field> <field name="password_confirmation" xsi:type="string">123123q</field> <field name="address" xsi:type="array"> - <item name="presets" xsi:type="string">address_UK_with_VAT</item> + <item name="presets" xsi:type="string">UK_address_with_VAT</item> </field> </dataset> </repository> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php index 80e7a2eef28ff3be93e1ba8068f640151f00676e..010ed24047c38808b955e7645fccfbcccf858f6e 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php @@ -13,11 +13,9 @@ use Magento\Customer\Test\Page\CustomerAccountLogout; use Magento\Mtf\TestCase\Injectable; /** - * Test Creation for CreateExistingCustomerFrontendEntity - * - * Test Flow: * Preconditions: - * 1.Customer is created + * 1.Customer is created. + * * Steps: * 1. Go to frontend. * 2. Click Register link. @@ -36,14 +34,14 @@ class CreateExistingCustomerFrontendEntity extends Injectable /* end tags */ /** - * Page CustomerAccountCreate + * Page CustomerAccountCreate. * * @var CustomerAccountCreate */ protected $customerAccountCreate; /** - * Page CustomerAccountLogout + * Page CustomerAccountLogout. * * @var CustomerAccountLogout */ @@ -57,51 +55,48 @@ class CreateExistingCustomerFrontendEntity extends Injectable protected $cmsIndex; /** - * Injection data + * Inject pages. * * @param CustomerAccountCreate $customerAccountCreate * @param CustomerAccountLogout $customerAccountLogout * @param CmsIndex $cmsIndex - * @param Customer $customer * @return array */ public function __inject( CustomerAccountCreate $customerAccountCreate, CustomerAccountLogout $customerAccountLogout, - CmsIndex $cmsIndex, - Customer $customer + CmsIndex $cmsIndex ) { $this->customerAccountLogout = $customerAccountLogout; $this->customerAccountCreate = $customerAccountCreate; $this->cmsIndex = $cmsIndex; - //Precondition - $customer->persist(); - return [ - 'customer' => $customer, - ]; } /** - * Create Existing Customer account on frontend + * Create Existing Customer account on frontend. * * @param Customer $customer * @return void */ public function testCreateExistingCustomer(Customer $customer) { - //Steps + // Precondition + $existingCustomer = clone $customer; + $customer->persist(); + + // Steps $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink('Register'); - $this->customerAccountCreate->getRegisterForm()->registerCustomer($customer); + $this->customerAccountCreate->getRegisterForm()->registerCustomer($existingCustomer); } /** - * Logout customer from frontend account + * Logout customer from frontend account. * * @return void */ public function tearDown() { - $this->customerAccountLogout->open(); + $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.xml index 7c8b8ff68e45d059212dd8b1403f175a098f7b02..3fbdcf50f62d855f3aba5c3566609a72e0b34c8e 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.xml @@ -6,9 +6,14 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Customer\Test\TestCase\CreateExistingCustomerFrontendEntity"> - <variation name="CreateExistingCustomerFrontendEntityVariation1"> - <constraint name="Magento\Customer\Test\Constraint\AssertCustomerFailRegisterMessage"/> - </variation> - </testCase> + <testCase name="Magento\Customer\Test\TestCase\CreateExistingCustomerFrontendEntity"> + <variation name="CreateExistingCustomerFrontendEntityVariation1"> + <data name="customer/data/firstname" xsi:type="string">john</data> + <data name="customer/data/lastname" xsi:type="string">doe</data> + <data name="customer/data/email" xsi:type="string">johndoe%isolation%@example.com</data> + <data name="customer/data/password" xsi:type="string">123123q</data> + <data name="customer/data/password_confirmation" xsi:type="string">123123q</data> + <constraint name="Magento\Customer\Test\Constraint\AssertCustomerFailRegisterMessage" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.xml index f998fde69cd1802f9eb05e63c6ae26622301b614..d4c96eef41e1caf37de7b2357dbfba0dec7e7350 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerAddressTest.xml @@ -9,7 +9,7 @@ <testCase name="Magento\Customer\Test\TestCase\DeleteCustomerAddressTest"> <variation name="DeleteCustomerAddressTestVariation1"> <data name="customer/dataSet" xsi:type="string">default</data> - <data name="customer/data/address/presets" xsi:type="string">US_address_default_billing,US_NY_address_billing</data> + <data name="customer/data/address/presets" xsi:type="string">US_address_default_billing,US_address_NY_default_no</data> <constraint name="Magento\Customer\Test\Constraint\AssertAddressDeletedFrontend"/> <constraint name="Magento\Customer\Test\Constraint\AssertAddressDeletedBackend"/> </variation> 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 index 28a5aa51e2f9bfb87966e81d9f6e77129c2f070a..42e10059a897b80bc35e7c0bccffb34f56469c75 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Customer\Test\TestCase\ForgotPasswordOnFrontendTest"> <variation name="ForgotPasswordOnFrontendTestVariation1"> - <data name="customer/dataSet" xsi:type="string">customer_US_1</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> <constraint name="Magento\Customer\Test\Constraint\AssertCustomerForgotPasswordSuccessMessage" /> </variation> </testCase> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php index 2892af943fdd10dde6a8f51e40fa4580fe885047..63308bbea50d1103e598c31a2d40558952ce77d6 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php @@ -135,14 +135,4 @@ class UpdateCustomerFrontendEntityTest extends Injectable $this->customerAddressEdit->getEditForm()->fill($address); $this->customerAddressEdit->getEditForm()->saveAddress(); } - - /** - * Customer logout from account - * - * @return void - */ - public function tearDown() - { - $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php index 04aa6c4ca73d61e4ef01e61ac9929d9a225d2b59..22b8d54518de92625349f1aa55fdf5cc7044695b 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php @@ -25,7 +25,7 @@ use Magento\CurrencySymbol\Test\Page\Adminhtml\SystemCurrencyIndex; * 5. Perform assertions. * * @group Localization_(PS) - * @ZephyrId MAGETWO-12427, MAGETWO-36824 + * @ZephyrId MAGETWO-36824 */ class CreateCurrencyRateTest extends Injectable { diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml index 69a8cb56138fc5d25a46a3eb72ac00e5dd66be17..10ba00e4d5db1f8c1791e7c96b82c0ddde64d343 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml @@ -114,7 +114,6 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">10</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/weight" xsi:type="string">10</data> <data name="product/data/special_price" xsi:type="string">40</data> <data name="isRequired" xsi:type="string">No</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml index 2c81ac17aeccd868843f2979155eaebd647408d8..add7f2519646396f0697621f74646ce4986d46bb 100644 --- a/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml @@ -11,9 +11,9 @@ <data name="description" xsi:type="string">Checkout as guest using FedEx with US shipping origin and UK customer</data> <data name="products" xsi:type="string">catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product</data> <data name="checkoutMethod" xsi:type="string">guest</data> - <data name="customer/dataSet" xsi:type="string">customer_UK</data> - <data name="address/dataSet" xsi:type="string">customer_UK</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="address/dataSet" xsi:type="string">UK_address</data> + <data name="billingAddress/dataSet" xsi:type="string">UK_address</data> <data name="shipping/shipping_service" xsi:type="string">Federal Express</data> <data name="shipping/shipping_method" xsi:type="string">International Economy</data> <data name="cart/data/shipping_method" xsi:type="string">International Economy</data> diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml index 18f90c0f3157a1fc6295e3647311913f2fcf3f84..b6433e7ad8ed1e3a5d3715920b9e4f7cc85f4e47 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/TestCase/CheckoutWithGiftMessagesTest.xml @@ -9,8 +9,8 @@ <testCase name="Magento\GiftMessage\Test\TestCase\CheckoutWithGiftMessagesTest"> <variation name="CheckoutWithGiftMessagesTestVariation1"> <data name="products" xsi:type="string">catalogProductSimple::default, catalogProductVirtual::default</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1</data> <data name="checkoutMethod" xsi:type="string">login</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> @@ -26,8 +26,8 @@ </variation> <variation name="CheckoutWithGiftMessagesTestVariation2"> <data name="products" xsi:type="string">catalogProductSimple::default, catalogProductVirtual::default</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1</data> <data name="checkoutMethod" xsi:type="string">login</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> 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 d888fa31e8ef27194c3dfd21d829fb82223b2e1c..618e06a6391659476bd7fcf648193767afae8302 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 @@ -29,7 +29,7 @@ class AssociatedProducts extends Tab * * @var string */ - protected $productSearchGrid = "./ancestor::body//div[div[contains(@data-role,'add-product-dialog')]]"; + protected $productSearchGrid = './/*[@data-role="modal"][.//*[@data-role="add-product-dialog"]]'; /** * Associated products list block @@ -54,7 +54,7 @@ class AssociatedProducts extends Tab { return $this->blockFactory->create( 'Magento\GroupedProduct\Test\Block\Adminhtml\Product\Grouped\AssociatedProducts\Search\Grid', - ['element' => $this->_rootElement->find($this->productSearchGrid, Locator::SELECTOR_XPATH)] + ['element' => $this->browser->find($this->productSearchGrid, Locator::SELECTOR_XPATH)] ); } diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/ImportExport.xml b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/ImportExport.xml index 01f5463b5f052fac98c49d795f3ac38e4979139f..ac1253f96a0c0d1486389a3bf354b1842e4df1ac 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/ImportExport.xml +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/ImportExport.xml @@ -6,22 +6,22 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="importExport" module="Magento_ImportExport" type="flat" entity_type="importexport_importdata" class="Magento\ImportExport\Test\Fixture\ImportExport"> - <dataset name="default"> - <field name="entity" xsi:type="string">Products</field> - <field name="behavior" xsi:type="string">CSV</field> - </dataset> - <field name="id" is_required="1"> - <default_value xsi:type="null"/> - </field> - <field name="entity" is_required=""> - <default_value xsi:type="string">Products</default_value> - </field> - <field name="behavior" is_required=""> - <default_value xsi:type="string">CSV</default_value> - </field> - <field name="data_export" is_required=""> - <default_value xsi:type="null"/> - </field> - </fixture> + <fixture name="importExport" module="Magento_ImportExport" type="flat" entity_type="importexport_importdata" class="Magento\ImportExport\Test\Fixture\ImportExport"> + <dataset name="default"> + <field name="entity" xsi:type="string">Products</field> + <field name="behavior" xsi:type="string">CSV</field> + </dataset> + <field name="id" is_required="1"> + <default_value xsi:type="null" /> + </field> + <field name="entity" is_required=""> + <default_value xsi:type="string">Products</default_value> + </field> + <field name="file_format" is_required=""> + <default_value xsi:type="string">CSV</default_value> + </field> + <field name="data_export" is_required=""> + <default_value xsi:type="null" /> + </field> + </fixture> </config> diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Block/CreateAdmin.xml b/dev/tests/functional/tests/app/Magento/Install/Test/Block/CreateAdmin.xml index 3f1616de3dbd0340573923778b6036b34776df03..b21f140454da51bf0b7428fd6d515c84b52534b6 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Block/CreateAdmin.xml +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Block/CreateAdmin.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<mapping strict="0"> +<mapping strict="1"> <fields> <username> <selector>[name='adminUsername']</selector> diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.php b/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.php index e9e81483fa4943a59bb69b5f31ca0bb2552d954e..efe02fa2148c8c0108b0324d6790ab31df0c78c2 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.php +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.php @@ -24,11 +24,11 @@ class CustomizeStore extends Form protected $next = "[ng-click*='checkModuleConstraints']"; /** - * First field selector + * Module configuration section. * * @var string */ - protected $firstField = '[ng-model*="language"]'; + protected $moduleConfiguration = '.customize-your-store-advanced'; /** * Click on 'Next' button. @@ -49,7 +49,17 @@ class CustomizeStore extends Form */ public function fill(FixtureInterface $fixture, SimpleElement $element = null) { - $this->waitForElementVisible($this->firstField); - return parent::fill($fixture, $element); + $this->waitForElementVisible($this->moduleConfiguration); + $data = $fixture->getData(); + $storeData = []; + foreach ($data as $key => $value) { + if (strpos($key, 'store') === 0) { + $storeData[$key] = $value; + } + } + $mapping = $this->dataMapping($storeData); + $this->_fill($mapping, $element); + + return $this; } } diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.xml b/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.xml index 24eaf10fa6a1ae9b5c06b4b06d41736b6e36f93d..8c99894d4e76836ccdd88c30f6498f6fbaba0c00 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.xml +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.xml @@ -7,13 +7,13 @@ --> <mapping strict="0"> <fields> - <currency> - <selector>[ng-model*='currency']</selector> + <storeCurrency> + <selector>#storeCurrency</selector> <input>select</input> - </currency> - <language> - <selector>[ng-model*='language']</selector> + </storeCurrency> + <storeLanguage> + <selector>#storeLanguage</selector> <input>select</input> - </language> + </storeLanguage> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Block/Database.php b/dev/tests/functional/tests/app/Magento/Install/Test/Block/Database.php index e1efe0955d55b1affbec3bd5ecce0045617dad7a..b532f1d1070a6439e06709987196760716415b75 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Block/Database.php +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Block/Database.php @@ -8,6 +8,8 @@ namespace Magento\Install\Test\Block; use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Client\Element\SimpleElement; /** * Database form. @@ -28,6 +30,28 @@ class Database extends Form */ protected $next = "[ng-click*='testConnection']"; + /** + * Fill database form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null) + { + $data = $fixture->getData(); + $dbData = []; + foreach ($data as $key => $value) { + if (strpos($key, 'db') === 0) { + $dbData[$key] = $value; + } + } + $mapping = $this->dataMapping($dbData); + $this->_fill($mapping, $element); + + return $this; + } + /** * Get 'Test connection successful.' message. * diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.php b/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.php index 654dd1ffc8fe3ad117cf1db3a7bb24ee7da00594..64a90917c4c0245490565f507e3def561752cd70 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.php +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.php @@ -7,6 +7,8 @@ namespace Magento\Install\Test\Block; use Magento\Mtf\Block\Form; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Client\Element\SimpleElement; /** * Web configuration block. @@ -27,6 +29,28 @@ class WebConfiguration extends Form */ protected $advancedOptions = "[ng-click*='advanced']"; + /** + * Fill web configuration form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null) + { + $data = $fixture->getData(); + $webConfiguration = []; + foreach ($data as $key => $value) { + if (strpos($key, 'db') !== 0 && strpos($key, 'store') !== 0) { + $webConfiguration[$key] = $value; + } + } + $mapping = $this->dataMapping($webConfiguration); + $this->_fill($mapping, $element); + + return $this; + } + /** * Click on 'Next' button. * diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.xml b/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.xml index f88d760c4c9cbd9a7c8d3b81bdb73f12338a9b79..a4b04f205eebf5c1305bda785977155d6449f569 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.xml +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.xml @@ -7,7 +7,9 @@ --> <mapping strict="0"> <fields> - <web /> + <baseUrl> + <selector>[name="base_url"]</selector> + </baseUrl> <admin /> <keyOwn> <selector>[value="user"]</selector> 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 07ce519b594d395e17adffc2cc6af1ab0f0f2ffb..dec19f621eda153301cce67d640609aa1bc406d2 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 @@ -24,7 +24,7 @@ class AssertSuccessInstall extends AbstractConstraint protected $adminFieldsList = [ ['pageData' => 'username', 'fixture' => 'username'], ['pageData' => 'e-mail', 'fixture' => 'email'], - ['pageData' => 'your_store_address', 'fixture' => 'web'], + ['pageData' => 'your_store_address', 'fixture' => 'baseUrl'], ['pageData' => 'magento_admin_address', 'fixture' => 'admin'] ]; @@ -57,8 +57,8 @@ class AssertSuccessInstall extends AbstractConstraint $allData[$key] = isset($value['value']) ? $value['value'] : $value; } - $allData['web'] = (isset($allData['https']) ? $allData['https'] : $allData['web']); - $allData['admin'] = $allData['web'] . $allData['admin'] . '/'; + $allData['baseUrl'] = (isset($allData['https']) ? $allData['https'] : $allData['baseUrl']); + $allData['admin'] = $allData['baseUrl'] . $allData['admin'] . '/'; foreach ($this->adminFieldsList as $field) { \PHPUnit_Framework_Assert::assertEquals( diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Fixture/Install.xml b/dev/tests/functional/tests/app/Magento/Install/Test/Fixture/Install.xml index d846de8f0bd45b0ed71068f8146e171994d682f6..2d83153459204f88755791b178917c92d4c01c79 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/Fixture/Install.xml +++ b/dev/tests/functional/tests/app/Magento/Install/Test/Fixture/Install.xml @@ -6,25 +6,25 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> - <fixture name="install" module="Magento_Install" type="virtual" entity_type="install" repository_class="Magento\Install\Test\Repository\Install" handler_interface="Magento\Install\Test\Handler\Install\InstallInterface" class="Magento\Install\Test\Fixture\Install"> - <field name="dbHost"/> - <field name="dbUser"/> - <field name="dbPassword"/> - <field name="dbName"/> - <field name="web"/> - <field name="admin"/> - <field name="adminUsername"/> - <field name="adminEmail"/> - <field name="adminPassword"/> - <field name="adminConfirm"/> - <field name="apacheRewrites"/> - <field name="dbTablePrefix"/> - <field name="keyOwn"/> - <field name="httpsAdmin"/> - <field name="https"/> - <field name="httpsFront"/> - <field name="keyValue"/> - <field name="language"/> - <field name="currency"/> - </fixture> + <fixture name="install" module="Magento_Install" type="virtual" entity_type="install" repository_class="Magento\Install\Test\Repository\Install" handler_interface="Magento\Install\Test\Handler\Install\InstallInterface" class="Magento\Install\Test\Fixture\Install"> + <field name="dbHost" /> + <field name="dbUser" /> + <field name="dbPassword" /> + <field name="dbName" /> + <field name="dbTablePrefix" /> + <field name="baseUrl" /> + <field name="admin" /> + <field name="adminUsername" /> + <field name="adminEmail" /> + <field name="adminPassword" /> + <field name="adminConfirm" /> + <field name="apacheRewrites" /> + <field name="keyOwn" /> + <field name="httpsAdmin" /> + <field name="https" /> + <field name="httpsFront" /> + <field name="keyValue" /> + <field name="storeLanguage" /> + <field name="storeCurrency" /> + </fixture> </config> diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php index fbfb262f1206d798a750dcfede4c913b96eed3c5..ccf21709a84ab2f1d5f59eaf62cb5444a49df765 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php +++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php @@ -12,17 +12,13 @@ use Magento\Install\Test\Fixture\Install as InstallConfig; use Magento\User\Test\Fixture\User; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestCase\Injectable; -use Magento\Mtf\Config\DataInterface; use Magento\Install\Test\Constraint\AssertAgreementTextPresent; use Magento\Install\Test\Constraint\AssertSuccessfulReadinessCheck; -use Magento\Mtf\ObjectManagerFactory; /** * PLEASE ADD NECESSARY INFO BEFORE RUNNING TEST TO * ../dev/tests/functional/config/config.xml * - * Test Flow: - * * Preconditions: * 1. Uninstall Magento. * @@ -67,20 +63,20 @@ class InstallTest extends Injectable */ public function __prepare() { - $config = ObjectManagerFactory::getObjectManager()->get('Magento\Mtf\Config\DataInterface'); + $config = $this->objectManager->get('Magento\Mtf\Config\DataInterface'); // Prepare config data $configData['dbHost'] = $config->get('install/0/host/0'); $configData['dbUser'] = $config->get('install/0/user/0'); $configData['dbPassword'] = $config->get('install/0/password/0'); $configData['dbName'] = $config->get('install/0/dbName/0'); - $configData['web'] = $config->get('install/0/baseUrl/0'); + $configData['baseUrl'] = $config->get('install/0/baseUrl/0'); $configData['admin'] = $config->get('install/0/backendName/0'); return ['configData' => $configData]; } /** - * Injection data. + * Uninstall Magento. * * @param CmsIndex $homePage * @param Install $installPage @@ -99,24 +95,24 @@ class InstallTest extends Injectable * Install Magento via web interface. * * @param User $user - * @param array $install * @param array $configData * @param FixtureFactory $fixtureFactory * @param AssertAgreementTextPresent $assertLicense * @param AssertSuccessfulReadinessCheck $assertReadiness + * @param array $install [optional] * @return array */ public function test( User $user, - array $install, array $configData, FixtureFactory $fixtureFactory, AssertAgreementTextPresent $assertLicense, - AssertSuccessfulReadinessCheck $assertReadiness + AssertSuccessfulReadinessCheck $assertReadiness, + array $install = [] ) { $dataConfig = array_merge($install, $configData); - if ($dataConfig['httpsFront'] != "-") { - $dataConfig['https'] = str_replace('http', 'https', $dataConfig['web']); + if (isset($dataConfig['httpsFront'])) { + $dataConfig['https'] = str_replace('http', 'https', $dataConfig['baseUrl']); } /** @var InstallConfig $installConfig */ $installConfig = $fixtureFactory->create('Magento\Install\Test\Fixture\Install', ['data' => $dataConfig]); diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml index a527c8538f6140ecff520b4f49e72bf3731d49ca..ff6ba2d1f1d7c44aa00109c83150752118a34b5b 100644 --- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml +++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml @@ -6,113 +6,59 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Install\Test\TestCase\InstallTest"> - <variation name="InstallTestVariation1"> - <data name="user/dataSet" xsi:type="string">default</data> - <data name="install/dbTablePrefix" xsi:type="string">-</data> - <data name="install/admin" xsi:type="string">-</data> - <data name="install/httpsFront" xsi:type="string">-</data> - <data name="install/httpsAdmin" xsi:type="string">-</data> - <data name="install/apacheRewrites" xsi:type="string">-</data> - <data name="install/keyOwn" xsi:type="string">-</data> - <data name="install/keyValue" xsi:type="string">-</data> - <data name="install/language" xsi:type="string">-</data> - <data name="install/currency" xsi:type="string">-</data> - <data name="currencySymbol" xsi:type="string">-</data> - <data name="languageTemplate" xsi:type="string">-</data> - <data name="description" xsi:type="string">install with default values</data> - <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall"/> - <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin"/> - </variation> - <variation name="InstallTestVariation2"> - <data name="user/dataSet" xsi:type="string">default</data> - <data name="install/dbTablePrefix" xsi:type="string">-</data> - <data name="install/admin" xsi:type="string">custom</data> - <data name="install/httpsFront" xsi:type="string">-</data> - <data name="install/httpsAdmin" xsi:type="string">-</data> - <data name="install/apacheRewrites" xsi:type="string">-</data> - <data name="install/keyOwn" xsi:type="string">-</data> - <data name="install/keyValue" xsi:type="string">-</data> - <data name="install/language" xsi:type="string">-</data> - <data name="install/currency" xsi:type="string">-</data> - <data name="currencySymbol" xsi:type="string">-</data> - <data name="languageTemplate" xsi:type="string">-</data> - <data name="description" xsi:type="string">install with custom admin path</data> - <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall"/> - <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin"/> - </variation> - <variation name="InstallTestVariation3"> - <data name="user/dataSet" xsi:type="string">default</data> - <data name="install/dbTablePrefix" xsi:type="string">-</data> - <data name="install/admin" xsi:type="string">-</data> - <data name="install/httpsFront" xsi:type="string">-</data> - <data name="install/httpsAdmin" xsi:type="string">-</data> - <data name="install/apacheRewrites" xsi:type="string">-</data> - <data name="install/keyOwn" xsi:type="string">Yes</data> - <data name="install/keyValue" xsi:type="string">123123qa</data> - <data name="install/language" xsi:type="string">German (Germany)</data> - <data name="install/currency" xsi:type="string">Euro (EUR)</data> - <data name="currencySymbol" xsi:type="string">€</data> - <data name="languageTemplate" xsi:type="string">Suchbegriffe</data> - <data name="description" xsi:type="string">install with custom encryption key and changed currency and locale</data> - <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall"/> - <constraint name="Magento\Install\Test\Constraint\AssertKeyCreated"/> - <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin"/> - <constraint name="Magento\Install\Test\Constraint\AssertCurrencySelected"/> - <constraint name="Magento\Install\Test\Constraint\AssertLanguageSelected"/> - </variation> - <variation name="InstallTestVariation4"> - <data name="user/dataSet" xsi:type="string">default</data> - <data name="install/dbTablePrefix" xsi:type="string">prefix1_</data> - <data name="install/admin" xsi:type="string">-</data> - <data name="install/httpsFront" xsi:type="string">-</data> - <data name="install/httpsAdmin" xsi:type="string">-</data> - <data name="install/apacheRewrites" xsi:type="string">-</data> - <data name="install/keyOwn" xsi:type="string">-</data> - <data name="install/keyValue" xsi:type="string">-</data> - <data name="install/language" xsi:type="string">Chinese (China)</data> - <data name="install/currency" xsi:type="string">-</data> - <data name="currencySymbol" xsi:type="string">-</data> - <data name="languageTemplate" xsi:type="string">-</data> - <data name="description" xsi:type="string">install with table prefix</data> - <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall"/> - <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin"/> - </variation> - <variation name="InstallTestVariation5"> - <data name="user/dataSet" xsi:type="string">default</data> - <data name="install/dbTablePrefix" xsi:type="string">-</data> - <data name="install/admin" xsi:type="string">-</data> - <data name="install/httpsFront" xsi:type="string">-</data> - <data name="install/httpsAdmin" xsi:type="string">-</data> - <data name="install/apacheRewrites" xsi:type="string">Yes</data> - <data name="install/keyOwn" xsi:type="string">-</data> - <data name="install/keyValue" xsi:type="string">-</data> - <data name="install/language" xsi:type="string">-</data> - <data name="install/currency" xsi:type="string">-</data> - <data name="currencySymbol" xsi:type="string">-</data> - <data name="languageTemplate" xsi:type="string">-</data> - <data name="description" xsi:type="string">install with enabled url rewrites</data> - <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall"/> - <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin"/> - <constraint name="Magento\Install\Test\Constraint\AssertRewritesEnabled"/> - </variation> - <variation name="InstallTestVariation6"> - <data name="user/dataSet" xsi:type="string">default</data> - <data name="install/dbTablePrefix" xsi:type="string">-</data> - <data name="install/admin" xsi:type="string">-</data> - <data name="install/httpsFront" xsi:type="string">Yes</data> - <data name="install/httpsAdmin" xsi:type="string">Yes</data> - <data name="install/apacheRewrites" xsi:type="string">-</data> - <data name="install/keyOwn" xsi:type="string">-</data> - <data name="install/keyValue" xsi:type="string">-</data> - <data name="install/language" xsi:type="string">-</data> - <data name="install/currency" xsi:type="string">-</data> - <data name="currencySymbol" xsi:type="string">-</data> - <data name="languageTemplate" xsi:type="string">-</data> - <data name="description" xsi:type="string">install with enabled secure urls</data> - <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall"/> - <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin"/> - <constraint name="Magento\Install\Test\Constraint\AssertSecureUrlEnabled"/> - </variation> - </testCase> + <testCase name="Magento\Install\Test\TestCase\InstallTest"> + <variation name="InstallTestVariation1"> + <data name="description" xsi:type="string">Install with default values.</data> + <data name="user/dataSet" xsi:type="string">default</data> + <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall" /> + <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" /> + </variation> + <variation name="InstallTestVariation2"> + <data name="description" xsi:type="string">Install with custom admin path.</data> + <data name="user/dataSet" xsi:type="string">default</data> + <data name="install/admin" xsi:type="string">custom</data> + <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall" /> + <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" /> + </variation> + <variation name="InstallTestVariation3"> + <data name="description" xsi:type="string">Install with custom encryption key and changed currency and locale.</data> + <data name="user/dataSet" xsi:type="string">default</data> + <data name="install/keyOwn" xsi:type="string">Yes</data> + <data name="install/keyValue" xsi:type="string">123123qa</data> + <data name="install/storeLanguage" xsi:type="string">German (Germany)</data> + <data name="install/storeCurrency" xsi:type="string">Euro (EUR)</data> + <data name="currencySymbol" xsi:type="string">€</data> + <data name="languageTemplate" xsi:type="string">Suchbegriffe</data> + <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall" /> + <constraint name="Magento\Install\Test\Constraint\AssertKeyCreated" /> + <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" /> + <constraint name="Magento\Install\Test\Constraint\AssertCurrencySelected" /> + <constraint name="Magento\Install\Test\Constraint\AssertLanguageSelected" /> + </variation> + <variation name="InstallTestVariation4"> + <data name="description" xsi:type="string">Install with table prefix.</data> + <data name="user/dataSet" xsi:type="string">default</data> + <data name="install/dbTablePrefix" xsi:type="string">prefix1_</data> + <data name="install/storeLanguage" xsi:type="string">Chinese (China)</data> + <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall" /> + <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" /> + </variation> + <variation name="InstallTestVariation5"> + <data name="description" xsi:type="string">Install with enabled url rewrites.</data> + <data name="user/dataSet" xsi:type="string">default</data> + <data name="install/apacheRewrites" xsi:type="string">Yes</data> + <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall" /> + <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" /> + <constraint name="Magento\Install\Test\Constraint\AssertRewritesEnabled" /> + </variation> + <variation name="InstallTestVariation6"> + <data name="description" xsi:type="string">Install with enabled secure urls.</data> + <data name="user/dataSet" xsi:type="string">default</data> + <data name="install/httpsFront" xsi:type="string">Yes</data> + <data name="install/httpsAdmin" xsi:type="string">Yes</data> + <constraint name="Magento\Install\Test\Constraint\AssertSuccessInstall" /> + <constraint name="Magento\User\Test\Constraint\AssertUserSuccessLogin" /> + <constraint name="Magento\Install\Test\Constraint\AssertSecureUrlEnabled" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateEdit.xml b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateEdit.xml index c17dbfb6ada9f96177f87d9d17223643041df640..56ee9f7302d96e787e64d4e0cf408d768f65cfab 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateEdit.xml @@ -6,9 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="TemplateEdit" area="Adminhtml" mca="newsletter/template/edit" module="Magento_Newsletter"> - <block name="formPageActions" class="Magento\Newsletter\Test\Block\Adminhtml\Template\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="editForm" class="Magento\Backend\Test\Block\Widget\Form" locator="[id='page:main-container']" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="TemplateEdit" area="Adminhtml" mca="newsletter/template/edit" module="Magento_Newsletter"> + <block name="formPageActions" class="Magento\Newsletter\Test\Block\Adminhtml\Template\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="editForm" class="Magento\Mtf\Block\Form" locator="[id='page:main-container']" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateNewIndex.xml b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateNewIndex.xml index 968920909e50d99c93a0f21dcc54c7f645a07ddf..b2744b0902e2c80329f8a345cbf953555ca6554c 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateNewIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateNewIndex.xml @@ -6,9 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="TemplateNewIndex" area="Adminhtml" mca="newsletter/template/new/index" module="Magento_Newsletter"> - <block name="formPageActions" class="Magento\Newsletter\Test\Block\Adminhtml\Template\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="editForm" class="Magento\Backend\Test\Block\Widget\Form" locator="[id='page:main-container']" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="TemplateNewIndex" area="Adminhtml" mca="newsletter/template/new/index" module="Magento_Newsletter"> + <block name="formPageActions" class="Magento\Newsletter\Test\Block\Adminhtml\Template\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="editForm" class="Magento\Mtf\Block\Form" locator="[id='page:main-container']" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateQueue.xml b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateQueue.xml index 8e17bfc6814b8ab37822b55279cb9dbffaaba742..c4840bceae2123bf11213311c8756b1707b48ba7 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateQueue.xml +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Page/Adminhtml/TemplateQueue.xml @@ -6,9 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="TemplateQueue" area="Adminhtml" mca="newsletter/queue/edit" module="Magento_Newsletter"> - <block name="formPageActions" class="Magento\Newsletter\Test\Block\Adminhtml\Template\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="editForm" class="Magento\Backend\Test\Block\Widget\Form" locator="#queue_edit_form" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="TemplateQueue" area="Adminhtml" mca="newsletter/queue/edit" module="Magento_Newsletter"> + <block name="formPageActions" class="Magento\Newsletter\Test\Block\Adminhtml\Template\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="editForm" class="Magento\Mtf\Block\Form" locator="#queue_edit_form" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.xml index e996602cc41fc49ed5c141addcfd07d71325b91f..26430b8ea9c7233e8734019c057493a2435bbbf3 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/CustomerReviewReportEntityTest.xml @@ -6,36 +6,38 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Reports\Test\TestCase\CustomerReviewReportEntityTest"> - <variation name="CustomerReviewReportEntityTestVariation1"> - <data name="customerLogin" xsi:type="string">Yes</data> - <data name="product/dataSet" xsi:type="string">default</data> - <data name="review/data/nickname" xsi:type="string">name_upd_%isolation%</data> - <data name="review/data/title" xsi:type="string">title_upd_%isolation%</data> - <data name="review/data/detail" xsi:type="string">review_upd_%isolation%</data> - <data name="reviewsCount" xsi:type="string">1</data> - <constraint name="Magento\Reports\Test\Constraint\AssertProductReviewsQtyByCustomer"/> - <constraint name="Magento\Reports\Test\Constraint\AssertProductReportByCustomerInGrid"/> - </variation> - <variation name="CustomerReviewReportEntityTestVariation2"> - <data name="customerLogin" xsi:type="string">Yes</data> - <data name="product/dataSet" xsi:type="string">default</data> - <data name="review/data/nickname" xsi:type="string">name_upd_%isolation%</data> - <data name="review/data/title" xsi:type="string">title_upd_%isolation%</data> - <data name="review/data/detail" xsi:type="string">review_upd_%isolation%</data> - <data name="reviewsCount" xsi:type="string">2</data> - <constraint name="Magento\Reports\Test\Constraint\AssertProductReviewsQtyByCustomer"/> - <constraint name="Magento\Reports\Test\Constraint\AssertProductReportByCustomerInGrid"/> - </variation> - <variation name="CustomerReviewReportEntityTestVariation3"> - <data name="customerLogin" xsi:type="string">No</data> - <data name="product/dataSet" xsi:type="string">default</data> - <data name="review/data/nickname" xsi:type="string">name_upd_%isolation%</data> - <data name="review/data/title" xsi:type="string">title_upd_%isolation%</data> - <data name="review/data/detail" xsi:type="string">review_upd_%isolation%</data> - <data name="reviewsCount" xsi:type="string">2</data> - <constraint name="Magento\Reports\Test\Constraint\AssertProductReviewsQtyByCustomer"/> - <constraint name="Magento\Reports\Test\Constraint\AssertProductReportByCustomerNotInGrid"/> - </variation> - </testCase> + <testCase name="Magento\Reports\Test\TestCase\CustomerReviewReportEntityTest"> + <variation name="CustomerReviewReportEntityTestVariation1"> + <data name="customerLogin" xsi:type="string">Yes</data> + <data name="product/dataSet" xsi:type="string">default</data> + <data name="review/data/type" xsi:type="string">Customer</data> + <data name="review/data/nickname" xsi:type="string">name_upd_%isolation%</data> + <data name="review/data/title" xsi:type="string">title_upd_%isolation%</data> + <data name="review/data/detail" xsi:type="string">review_upd_%isolation%</data> + <data name="reviewsCount" xsi:type="string">1</data> + <constraint name="Magento\Reports\Test\Constraint\AssertProductReviewsQtyByCustomer" /> + <constraint name="Magento\Reports\Test\Constraint\AssertProductReportByCustomerInGrid" /> + </variation> + <variation name="CustomerReviewReportEntityTestVariation2"> + <data name="customerLogin" xsi:type="string">Yes</data> + <data name="product/dataSet" xsi:type="string">default</data> + <data name="review/data/type" xsi:type="string">Customer</data> + <data name="review/data/nickname" xsi:type="string">name_upd_%isolation%</data> + <data name="review/data/title" xsi:type="string">title_upd_%isolation%</data> + <data name="review/data/detail" xsi:type="string">review_upd_%isolation%</data> + <data name="reviewsCount" xsi:type="string">2</data> + <constraint name="Magento\Reports\Test\Constraint\AssertProductReviewsQtyByCustomer" /> + <constraint name="Magento\Reports\Test\Constraint\AssertProductReportByCustomerInGrid" /> + </variation> + <variation name="CustomerReviewReportEntityTestVariation3"> + <data name="customerLogin" xsi:type="string">No</data> + <data name="product/dataSet" xsi:type="string">default</data> + <data name="review/data/nickname" xsi:type="string">name_upd_%isolation%</data> + <data name="review/data/title" xsi:type="string">title_upd_%isolation%</data> + <data name="review/data/detail" xsi:type="string">review_upd_%isolation%</data> + <data name="reviewsCount" xsi:type="string">2</data> + <constraint name="Magento\Reports\Test\Constraint\AssertProductReviewsQtyByCustomer" /> + <constraint name="Magento\Reports\Test\Constraint\AssertProductReportByCustomerNotInGrid" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.php index a9499d608da3f1844151c1b9c81a70f4dcbf9c9a..c3ad0a3ef2d2f631d160e7da69b7de4629296d9f 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.php @@ -6,38 +6,58 @@ namespace Magento\Review\Test\Block\Adminhtml; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Client\Element\SimpleElement; /** - * Class Edit - * Review edit form + * Review edit form. */ class ReviewForm extends Form { /** - * Posted by field + * Posted by field. * * @var string */ protected $customer = '#customer'; /** - * Rating status + * Rating status. * * @var string */ protected $status = '[name=status_id]'; /** - * 'Save Review' button + * 'Save Review' button. * * @var string */ protected $saveButton = '[data-ui-id$=save-button-button]'; /** - * Get data from 'Posted By' field + * Fill the review form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null) + { + $data = $fixture->getData(); + if (isset($data['entity_id'])) { + unset($data['entity_id']); + } + $mapping = $this->dataMapping($data); + $this->_fill($mapping, $element); + + return $this; + } + + /** + * Get data from 'Posted By' field. * * @return string */ @@ -47,7 +67,7 @@ class ReviewForm extends Form } /** - * Get data from Status field + * Get data from Status field. * * @return string */ @@ -57,7 +77,7 @@ class ReviewForm extends Form } /** - * Set approve review + * Set approve review. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewForm.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewForm.php index eb6cb92c40c0f270b3fab671135d6f00bcc364a2..edf5cb90995549c5ddd0537fbf335002d8304fc3 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewForm.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewForm.php @@ -48,8 +48,8 @@ class AssertProductReviewForm extends AbstractAssertForm $fixtureData = $review->getData(); $formData = $reviewEdit->getReviewForm()->getData(); - if (isset($fixtureData['customer'])) { - $formData['customer'] = $reviewEdit->getReviewForm()->getPostedBy(); + if (isset($fixtureData['type'])) { + $formData['type'] = $reviewEdit->getReviewForm()->getPostedBy(); } $error = $this->verifyData($fixtureData, $formData); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php index b448f3ac837a261457216b46465dc4ce9e719ec6..93e28f758b9eb2408328058ca50d4d93a585b18d 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php @@ -12,13 +12,12 @@ use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\Fixture\FixtureInterface; /** - * Class AssertProductReviewInGrid - * Check that review is displayed in grid + * Check that review is displayed in grid. */ class AssertProductReviewInGrid extends AbstractConstraint { /** - * Filter params + * Filter params. * * @var array */ @@ -35,10 +34,10 @@ class AssertProductReviewInGrid extends AbstractConstraint ]; /** - * Assert that review is displayed in grid + * Assert that review is displayed in grid. * * @param ReviewIndex $reviewIndex - * @param Review $review , + * @param Review $review * @param FixtureInterface $product * @param string $gridStatus * @return void @@ -61,7 +60,7 @@ class AssertProductReviewInGrid extends AbstractConstraint } /** - * Prepare filter for assert + * Prepare filter for assert. * * @param FixtureInterface $product * @param array $review @@ -89,6 +88,9 @@ class AssertProductReviewInGrid extends AbstractConstraint case 'status_id': $value = $gridStatus != '' ? $gridStatus : (isset($review[$param]) ? $review[$param] : null); break; + case 'type': + $value = isset($review[$param]) ? $review[$param] : 'Administrator'; + break; default: $value = isset($review[$param]) ? $review[$param] : null; break; @@ -101,7 +103,7 @@ class AssertProductReviewInGrid extends AbstractConstraint } /** - * Text success exist review in grid on product reviews tab + * Text success exist review in grid on product reviews tab. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.xml b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.xml index bf97a39b60e0ab692798889c9c0d22d36a1fbd27..ee97d7bb2149563e0583afbb7328d09cf1189a3b 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.xml @@ -6,48 +6,45 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Review\Test\TestCase\CreateProductReviewBackendEntityTest"> - <variation name="CreateProductReviewBackendEntityTestVariation1"> - <data name="review/data/type" xsi:type="string">Administrator</data> - <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> - <data name="review/data/status_id" xsi:type="string">Approved</data> - <data name="review/data/select_stores/0" xsi:type="string">Main Website/Main Website Store/Default Store View</data> - <data name="review/data/ratings/rating_0/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> - <data name="review/data/ratings/rating_0/rating" xsi:type="string">3</data> - <data name="review/data/nickname" xsi:type="string">John</data> - <data name="review/data/title" xsi:type="string">title %isolation%</data> - <data name="review/data/detail" xsi:type="string">review detail %isolation%</data> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewBackendSuccessSaveMessage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage"/> - </variation> - <variation name="CreateProductReviewBackendEntityTestVariation2"> - <data name="review/data/type" xsi:type="string">Administrator</data> - <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> - <data name="review/data/status_id" xsi:type="string">Pending</data> - <data name="review/data/select_stores/0" xsi:type="string">Main Website/Main Website Store/Default Store View</data> - <data name="review/data/ratings/rating_0/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> - <data name="review/data/ratings/rating_0/rating" xsi:type="string">4</data> - <data name="review/data/nickname" xsi:type="string">Britney</data> - <data name="review/data/title" xsi:type="string">title %isolation%</data> - <data name="review/data/detail" xsi:type="string">review detail %isolation%</data> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewBackendSuccessSaveMessage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage"/> - </variation> - <variation name="CreateProductReviewBackendEntityTestVariation3"> - <data name="review/data/type" xsi:type="string">Administrator</data> - <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> - <data name="review/data/status_id" xsi:type="string">Not Approved</data> - <data name="review/data/select_stores/0" xsi:type="string">Main Website/Main Website Store/Default Store View</data> - <data name="review/data/ratings/rating_0/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> - <data name="review/data/ratings/rating_0/rating" xsi:type="string">5</data> - <data name="review/data/nickname" xsi:type="string">Michael</data> - <data name="review/data/title" xsi:type="string">title %isolation%</data> - <data name="review/data/detail" xsi:type="string">review detail %isolation%</data> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewBackendSuccessSaveMessage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage"/> - </variation> - </testCase> + <testCase name="Magento\Review\Test\TestCase\CreateProductReviewBackendEntityTest"> + <variation name="CreateProductReviewBackendEntityTestVariation1"> + <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> + <data name="review/data/status_id" xsi:type="string">Approved</data> + <data name="review/data/select_stores/0" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="review/data/ratings/rating_0/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> + <data name="review/data/ratings/rating_0/rating" xsi:type="string">3</data> + <data name="review/data/nickname" xsi:type="string">John</data> + <data name="review/data/title" xsi:type="string">title %isolation%</data> + <data name="review/data/detail" xsi:type="string">review detail %isolation%</data> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewBackendSuccessSaveMessage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage" /> + </variation> + <variation name="CreateProductReviewBackendEntityTestVariation2"> + <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> + <data name="review/data/status_id" xsi:type="string">Pending</data> + <data name="review/data/select_stores/0" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="review/data/ratings/rating_0/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> + <data name="review/data/ratings/rating_0/rating" xsi:type="string">4</data> + <data name="review/data/nickname" xsi:type="string">Britney</data> + <data name="review/data/title" xsi:type="string">title %isolation%</data> + <data name="review/data/detail" xsi:type="string">review detail %isolation%</data> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewBackendSuccessSaveMessage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage" /> + </variation> + <variation name="CreateProductReviewBackendEntityTestVariation3"> + <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> + <data name="review/data/status_id" xsi:type="string">Not Approved</data> + <data name="review/data/select_stores/0" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="review/data/ratings/rating_0/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> + <data name="review/data/ratings/rating_0/rating" xsi:type="string">5</data> + <data name="review/data/nickname" xsi:type="string">Michael</data> + <data name="review/data/title" xsi:type="string">title %isolation%</data> + <data name="review/data/detail" xsi:type="string">review detail %isolation%</data> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewBackendSuccessSaveMessage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.xml b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.xml index 747044f00e030859b162598332c766a74b5c283c..ee9096bce936c26452574d0d8362293f90933c68 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.xml @@ -6,37 +6,35 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Review\Test\TestCase\CreateProductReviewFrontendEntityTest"> - <variation name="CreateProductReviewFrontendEntityTestVariation1"> - <data name="description" xsi:type="string">Create product review with rating</data> - <data name="review/data/customer" xsi:type="string">-</data> - <data name="review/data/nickname" xsi:type="string">name_%isolation%</data> - <data name="review/data/title" xsi:type="string">title_%isolation%</data> - <data name="review/data/detail" xsi:type="string">review_%isolation%</data> - <data name="review/data/ratings/1/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> - <data name="review/data/ratings/1/rating" xsi:type="string">4</data> - <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> - <constraint name="Magento\Review\Test\Constraint\AssertReviewCreationSuccessMessage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductRatingOnReviewPage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage"/> - </variation> - <variation name="CreateProductReviewFrontendEntityTestVariation2"> - <data name="description" xsi:type="string">MAGETWO-12403 - Add Product Review from Customer's Prospective</data> - <data name="review/data/customer" xsi:type="string">Guest</data> - <data name="review/data/nickname" xsi:type="string">name_%isolation%</data> - <data name="review/data/title" xsi:type="string">title_%isolation%</data> - <data name="review/data/detail" xsi:type="string">review_%isolation%</data> - <data name="review/data/ratings/1/dataSet" xsi:type="string">-</data> - <data name="review/data/ratings/1/rating" xsi:type="string">-</data> - <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> - <data name="tag" xsi:type="string">test_type:acceptance_test</data> - <constraint name="Magento\Review\Test\Constraint\AssertReviewCreationSuccessMessage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewIsAbsentOnProductPage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewForm"/> - <constraint name="Magento\Review\Test\Constraint\AssertSetApprovedProductReview"/> - <constraint name="Magento\Review\Test\Constraint\AssertReviewLinksIsPresentOnProductPage"/> - <constraint name="Magento\Review\Test\Constraint\AssertProductReviewOnProductPage"/> - </variation> - </testCase> + <testCase name="Magento\Review\Test\TestCase\CreateProductReviewFrontendEntityTest"> + <variation name="CreateProductReviewFrontendEntityTestVariation1"> + <data name="description" xsi:type="string">Create product review with rating</data> + <data name="review/data/type" xsi:type="string">Guest</data> + <data name="review/data/nickname" xsi:type="string">name_%isolation%</data> + <data name="review/data/title" xsi:type="string">title_%isolation%</data> + <data name="review/data/detail" xsi:type="string">review_%isolation%</data> + <data name="review/data/ratings/1/dataSet" xsi:type="string">visibleOnDefaultWebsite</data> + <data name="review/data/ratings/1/rating" xsi:type="string">4</data> + <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> + <constraint name="Magento\Review\Test\Constraint\AssertReviewCreationSuccessMessage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewInGrid" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductRatingOnReviewPage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductRatingInProductPage" /> + </variation> + <variation name="CreateProductReviewFrontendEntityTestVariation2"> + <data name="description" xsi:type="string">MAGETWO-12403 - Add Product Review from Customer's Prospective</data> + <data name="review/data/type" xsi:type="string">Guest</data> + <data name="review/data/nickname" xsi:type="string">name_%isolation%</data> + <data name="review/data/title" xsi:type="string">title_%isolation%</data> + <data name="review/data/detail" xsi:type="string">review_%isolation%</data> + <data name="review/data/entity_id/dataSet" xsi:type="string">catalogProductSimple::default</data> + <data name="tag" xsi:type="string">test_type:acceptance_test</data> + <constraint name="Magento\Review\Test\Constraint\AssertReviewCreationSuccessMessage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewIsAbsentOnProductPage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewForm" /> + <constraint name="Magento\Review\Test\Constraint\AssertSetApprovedProductReview" /> + <constraint name="Magento\Review\Test\Constraint\AssertReviewLinksIsPresentOnProductPage" /> + <constraint name="Magento\Review\Test\Constraint\AssertProductReviewOnProductPage" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Address.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Address.xml index 369d359cf8a55a41421c7228d0b91c6a924e7ac6..2439e6aeac763956de84b836bf817642a915135b 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Address.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Billing/Address.xml @@ -23,8 +23,5 @@ </region_id> <postcode /> <telephone /> - <save_in_address_book> - <input>checkbox</input> - </save_in_address_book> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php index 0a350725839b9e8833b90dda8003c051b0c7293c..14ec5f4336b64d6429c6c04caa8bf5501666ac09 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php @@ -6,7 +6,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Create; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Client\Locator; diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Form/Account.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Form/Account.xml index 768fef18f37797e49cb835efa48e80e45b746f6a..ece7a7be14cf2e6234031368e4bb83310b869e49 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Form/Account.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Form/Account.xml @@ -5,12 +5,12 @@ * See COPYING.txt for license details. */ --> -<mapping strict="0"> +<mapping strict="1"> <wrapper>order[account]</wrapper> <fields> - <group> + <group_id> <input>select</input>> - </group> + </group_id> <email /> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php index 03ec6f8187c16a1a697a93f64e6a8d861a0130fe..efcf05d2a42144b7ed72c3b2e0a9b0fd5243d911 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php @@ -8,6 +8,8 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Create\Items; use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Client\Element\SimpleElement; /** * Class ItemProduct @@ -76,6 +78,28 @@ class ItemProduct extends Form return $result; } + /** + * Fill the root form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null) + { + $data = $fixture->getData(); + if (isset($data['cartItem'])) { + unset($data['cartItem']); + } + if (isset($data['options'])) { + unset($data['options']); + } + $mapping = $this->dataMapping($data); + $this->_fill($mapping, $element); + + return $this; + } + /** * Click Configure button. * diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusEdit.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusEdit.xml index c1d712de6a2d0f33e4545ce3a3983a101dd96e11..298289698a18295d355e73f5f66f515e040b2620 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusEdit.xml @@ -6,9 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="OrderStatusEdit" area="Adminhtml" mca="sales/order_status/edit" module="Magento_Sales"> - <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="orderStatusForm" class="Magento\Backend\Test\Block\Widget\Form" locator="#edit_form" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="OrderStatusEdit" area="Adminhtml" mca="sales/order_status/edit" module="Magento_Sales"> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="orderStatusForm" class="Magento\Mtf\Block\Form" locator="#edit_form" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusNew.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusNew.xml index 856880560d3ed1eaa69d6746666788ce166ce286..0457f3a4b1899a46bd3b850b7c6349733cd3d515 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusNew.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderStatusNew.xml @@ -6,9 +6,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="OrderStatusNew" area="Adminhtml" mca="sales/order_status/new" module="Magento_Sales"> - <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="orderStatusForm" class="Magento\Backend\Test\Block\Widget\Form" locator="#edit_form" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> - </page> + <page name="OrderStatusNew" area="Adminhtml" mca="sales/order_status/new" module="Magento_Sales"> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="orderStatusForm" class="Magento\Mtf\Block\Form" locator="#edit_form" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml index 6371ae09b9981d48b42be0a1e9fd1c54897e91cd..ce5a4f0d95671ebaf4caf9ff4a8984b6c0853b57 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml @@ -10,8 +10,8 @@ <variation name="CreateOrderBackendTestVariation1"> <data name="description" xsi:type="string">Create order with simple product for registered US customer using Fixed shipping method and Cash on Delivery payment method</data> <data name="products" xsi:type="string">catalogProductSimple::default</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1_without_email</data> <data name="saveAddress" xsi:type="string">No</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> @@ -31,8 +31,8 @@ <variation name="CreateOrderBackendTestVariation2"> <data name="description" xsi:type="string">Create order with virtual product for registered UK customer using Check/Money Order payment method</data> <data name="products" xsi:type="string">catalogProductVirtual::default</data> - <data name="customer/dataSet" xsi:type="string">customer_UK</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">UK_address_without_email</data> <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">10.00</item> </data> @@ -49,8 +49,8 @@ <variation name="CreateOrderBackendTestVariation3"> <data name="description" xsi:type="string">Create order with simple product for registered US customer using Fixed shipping method and Bank Transfer payment method</data> <data name="products" xsi:type="string">catalogProductSimple::default</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1_without_email</data> <data name="saveAddress" xsi:type="string">No</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> @@ -71,8 +71,8 @@ <data name="tag" xsi:type="string">to_maintain:yes</data> <data name="description" xsi:type="string">Create order with virtual product for registered UK customer using Bank Transfer payment method</data> <data name="products" xsi:type="string">catalogProductVirtual::default</data> - <data name="customer/dataSet" xsi:type="string">customer_UK</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">UK_address_without_email</data> <data name="saveAddress" xsi:type="string">No</data> <data name="prices" xsi:type="array"> <item name="grandTotal" xsi:type="string">10.00</item> @@ -91,9 +91,9 @@ <data name="tag" xsi:type="string">to_maintain:yes</data> <data name="description" xsi:type="string">Create order with simple product for registered US customer using Fixed shipping method and Purchase Order payment method</data> <data name="products" xsi:type="string">catalogProductSimple::default</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> <data name="saveAddress" xsi:type="string">No</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1_without_email</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> @@ -114,10 +114,10 @@ <data name="description" xsi:type="string">MAGETWO-12395 - Create Offline Order for Registered Customer in Admin</data> <data name="products" xsi:type="string">catalogProductSimple::simple_10_dollar, configurableProduct::with_one_option</data> <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> <data name="saveAddress" xsi:type="string">No</data> <data name="checkoutMethod" xsi:type="string">login</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1_without_email</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> @@ -132,10 +132,10 @@ <data name="description" xsi:type="string">MAGETWO-12520 - Create Order for New Customer in Admin with Offline Payment Method</data> <data name="products" xsi:type="string">catalogProductSimple::simple_10_dollar, configurableProduct::with_one_option</data> <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> <data name="saveAddress" xsi:type="string">Yes</data> <data name="checkoutMethod" xsi:type="string">register</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1_without_email</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml index 200b45de0adb16a93d2c5343434e3038d064973d..20b862a735ee7e9977599fd0c8f82598384d6637 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml @@ -11,8 +11,8 @@ <data name="description" xsi:type="string">Reorder placed order (update products, billing address).</data> <data name="order/dataSet" xsi:type="string">two_simple_product</data> <data name="salesRule" xsi:type="string">active_sales_rule_with_fixed_price_discount_coupon</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_method" xsi:type="string">Fixed</data> <data name="prices" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml index 7e75ac518b8e7a2e66c38e5d9798c220d281e39f..bacb199390c0d3982e726b71db8c8adc51e9e9bd 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml @@ -6,7 +6,7 @@ */ --> <mapping strict="0"> - <wrapper>creditmemo</wrapper> + <wrapper>shipment</wrapper> <fields> <comment_text /> <shipping_amount /> diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapNew.xml b/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapNew.xml index 4f33714bfae86e6ab15c88cb3b5c500ad429e4ad..6852866408294adf0b9516a3013a41855534e24e 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapNew.xml +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapNew.xml @@ -6,8 +6,8 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="SitemapNew" area="Adminhtml" mca="sitemap/new/index" module="Magento_Sitemap"> - <block name="sitemapForm" class="Magento\Backend\Test\Block\Widget\Form" locator="#add_sitemap_form" strategy="css selector"/> - <block name="sitemapPageActions" class="Magento\Sitemap\Test\Block\Adminhtml\SitemapPageActions" locator=".page-main-actions" strategy="css selector"/> - </page> + <page name="SitemapNew" area="Adminhtml" mca="sitemap/new/index" module="Magento_Sitemap"> + <block name="sitemapForm" class="Magento\Mtf\Block\Form" locator="#add_sitemap_form" strategy="css selector" /> + <block name="sitemapPageActions" class="Magento\Sitemap\Test\Block\Adminhtml\SitemapPageActions" locator=".page-main-actions" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php index 970bede06def9787026240f7fd543488d39ed4a7..43e431fbbea44d9a0d3f6964961747b69f1cb104 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php @@ -31,10 +31,7 @@ class AssertTaxRateForm extends AbstractConstraint TaxRate $taxRate, TaxRate $initialTaxRate = null ) { - $data = ($initialTaxRate !== null) - ? array_merge($initialTaxRate->getData(), $taxRate->getData()) - : $taxRate->getData(); - $data = $this->prepareData($data); + $data = $this->prepareData($taxRate, $initialTaxRate); $filter = [ 'code' => $data['code'], ]; @@ -53,11 +50,20 @@ class AssertTaxRateForm extends AbstractConstraint /** * Preparing data for verification * - * @param array $data + * @param TaxRate $taxRate + * @param TaxRate $initialTaxRate * @return array */ - protected function prepareData(array $data) + protected function prepareData(TaxRate $taxRate, TaxRate $initialTaxRate = null) { + if ($initialTaxRate !== null) { + $data = array_merge($initialTaxRate->getData(), $taxRate->getData()); + if ($taxRate->hasData('tax_country_id') && !$taxRate->hasData('tax_region_id')) { + unset($data['tax_region_id']); + } + } else { + $data = $taxRate->getData(); + } if ($data['zip_is_range'] === 'Yes') { unset($data['tax_postcode']); } else { 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 index ae3c83014c7f0169da523f9e15c065671c69f167..d5407ecf878f38d62433a282d67c5b7e2f7f942a 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/ApplyTaxBasedOnVatIdTest.xml @@ -11,11 +11,11 @@ <data name="description" xsi:type="string">MAGETWO-13436: Automatic Apply Tax Based on VAT ID.</data> <data name="vatConfig/dataSet" xsi:type="string">enable_VAT_on_frontend</data> <data name="configData" xsi:type="string">default_tax_configuration, flatrate, checkmo, store_information_DE_with_VAT, enable_VAT_on_frontend</data> - <data name="customer/dataSet" xsi:type="string">address_UK_with_VAT</data> + <data name="customer/dataSet" xsi:type="string">customer_UK_address_with_VAT</data> <data name="order/dataSet" xsi:type="string">default</data> <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::product_10_dollar</data> <data name="order/data/customer_id/dataSet" xsi:type="string">customer_UK_address_with_VAT</data> - <data name="order/data/billing_address_id/dataSet" xsi:type="string">address_UK_with_VAT</data> + <data name="order/data/billing_address_id/dataSet" xsi:type="string">UK_address_with_VAT</data> <data name="taxRule/dataSet" xsi:type="string">retailer_uk_full_tax_rule</data> <data name="customerGroup" xsi:type="string">valid_intra_union_group</data> <data name="cart/data/subtotal" xsi:type="string">10</data> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRateEntityTest.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRateEntityTest.xml index bee3fb886b6f598dd767fe1706a967247ea05736..9602d171bf546587b59734b79042e4b42d6618fc 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRateEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/CreateTaxRateEntityTest.xml @@ -14,7 +14,6 @@ <data name="taxRate/data/zip_to" xsi:type="string">-</data> <data name="taxRate/data/tax_postcode" xsi:type="string">*</data> <data name="taxRate/data/tax_country_id" xsi:type="string">Australia</data> - <data name="taxRate/data/tax_region_id" xsi:type="string">*</data> <data name="taxRate/data/rate" xsi:type="string">20</data> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateSuccessSaveMessage" /> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateInGrid" /> @@ -55,7 +54,6 @@ <data name="taxRate/data/zip_to" xsi:type="string">7800935</data> <data name="taxRate/data/tax_postcode" xsi:type="string">-</data> <data name="taxRate/data/tax_country_id" xsi:type="string">United Kingdom</data> - <data name="taxRate/data/tax_region_id" xsi:type="string">*</data> <data name="taxRate/data/rate" xsi:type="string">7.75</data> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateSuccessSaveMessage" /> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateForm" /> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest.xml index 5f3a3e5fba76bad0aa9afb2fa85624cddb1e4beb..c8205ff306c4f0a543f0ab0cea2d619a6df8004a 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest.xml @@ -11,8 +11,6 @@ <data name="initialTaxRate/dataSet" xsi:type="string">default</data> <data name="taxRate/data/code" xsi:type="string">TaxIdentifier%isolation%</data> <data name="taxRate/data/zip_is_range" xsi:type="string">No</data> - <data name="taxRate/data/zip_from" xsi:type="string">-</data> - <data name="taxRate/data/zip_to" xsi:type="string">-</data> <data name="taxRate/data/tax_postcode" xsi:type="string">90001</data> <data name="taxRate/data/tax_country_id" xsi:type="string">United States</data> <data name="taxRate/data/tax_region_id" xsi:type="string">California</data> @@ -27,7 +25,6 @@ <data name="taxRate/data/zip_is_range" xsi:type="string">Yes</data> <data name="taxRate/data/zip_from" xsi:type="string">90001</data> <data name="taxRate/data/zip_to" xsi:type="string">96162</data> - <data name="taxRate/data/tax_postcode" xsi:type="string">-</data> <data name="taxRate/data/tax_country_id" xsi:type="string">United States</data> <data name="taxRate/data/tax_region_id" xsi:type="string">California</data> <data name="taxRate/data/rate" xsi:type="string">15.05</data> @@ -39,11 +36,8 @@ <data name="initialTaxRate/dataSet" xsi:type="string">default</data> <data name="taxRate/data/code" xsi:type="string">TaxIdentifier%isolation%</data> <data name="taxRate/data/zip_is_range" xsi:type="string">No</data> - <data name="taxRate/data/zip_from" xsi:type="string">-</data> - <data name="taxRate/data/zip_to" xsi:type="string">-</data> <data name="taxRate/data/tax_postcode" xsi:type="string">*</data> <data name="taxRate/data/tax_country_id" xsi:type="string">United Kingdom</data> - <data name="taxRate/data/tax_region_id" xsi:type="string">*</data> <data name="taxRate/data/rate" xsi:type="string">777</data> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateSuccessSaveMessage" /> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateInGrid" /> @@ -53,8 +47,6 @@ <data name="initialTaxRate/dataSet" xsi:type="string">withZipRange</data> <data name="taxRate/data/code" xsi:type="string">TaxIdentifier%isolation%</data> <data name="taxRate/data/zip_is_range" xsi:type="string">No</data> - <data name="taxRate/data/zip_from" xsi:type="string">-</data> - <data name="taxRate/data/zip_to" xsi:type="string">-</data> <data name="taxRate/data/tax_postcode" xsi:type="string">180</data> <data name="taxRate/data/tax_country_id" xsi:type="string">Canada</data> <data name="taxRate/data/tax_region_id" xsi:type="string">*</data> @@ -69,9 +61,7 @@ <data name="taxRate/data/zip_is_range" xsi:type="string">Yes</data> <data name="taxRate/data/zip_from" xsi:type="string">1</data> <data name="taxRate/data/zip_to" xsi:type="string">7800935</data> - <data name="taxRate/data/tax_postcode" xsi:type="string">-</data> <data name="taxRate/data/tax_country_id" xsi:type="string">United Kingdom</data> - <data name="taxRate/data/tax_region_id" xsi:type="string">*</data> <data name="taxRate/data/rate" xsi:type="string">12.99</data> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateSuccessSaveMessage" /> <constraint name="Magento\Tax\Test\Constraint\AssertTaxRateForm" /> @@ -80,8 +70,6 @@ <data name="initialTaxRate/dataSet" xsi:type="string">withZipRange</data> <data name="taxRate/data/code" xsi:type="string">TaxIdentifier%isolation%</data> <data name="taxRate/data/zip_is_range" xsi:type="string">No</data> - <data name="taxRate/data/zip_from" xsi:type="string">-</data> - <data name="taxRate/data/zip_to" xsi:type="string">-</data> <data name="taxRate/data/tax_postcode" xsi:type="string">*</data> <data name="taxRate/data/tax_country_id" xsi:type="string">France</data> <data name="taxRate/data/tax_region_id" xsi:type="string">Val-d'Oise</data> diff --git a/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml index 850c839e08fd3a5e50591d5c9912922b4467803e..fcb92ddb6be2a91c3c689bd686687517c4c6ef16 100644 --- a/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml @@ -11,8 +11,8 @@ <data name="description" xsi:type="string">MAGETWO-12848 – Use UPS Online Shipping Carrier on Checkout as a Registered Customer</data> <data name="products" xsi:type="string">catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product</data> <data name="checkoutMethod" xsi:type="string">login</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1</data> <data name="shipping/shipping_service" xsi:type="string">United Parcel Service</data> <data name="shipping/shipping_method" xsi:type="string">UPS Ground</data> <data name="cart/data/shipping_method" xsi:type="string">UPS Ground</data> @@ -27,9 +27,9 @@ <data name="description" xsi:type="string">Checkout as guest using UPS with US shipping origin and UK customer</data> <data name="products" xsi:type="string">catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product</data> <data name="checkoutMethod" xsi:type="string">guest</data> - <data name="customer/dataSet" xsi:type="string">customer_UK</data> - <data name="address/dataSet" xsi:type="string">customer_UK</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="address/dataSet" xsi:type="string">UK_address</data> + <data name="billingAddress/dataSet" xsi:type="string">UK_address</data> <data name="shipping/shipping_service" xsi:type="string">United Parcel Service</data> <data name="shipping/shipping_method" xsi:type="string">UPS Worldwide Expedited</data> <data name="cart/data/shipping_method" xsi:type="string">UPS Worldwide Expedited</data> diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Block/Adminhtml/Catalog/Edit/UrlRewriteForm.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Block/Adminhtml/Catalog/Edit/UrlRewriteForm.php index 373c6c4cabd7c90d4920667f958868594b4b3946..5fb3fc21d02d69cd99399f7af6741da752448522 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Block/Adminhtml/Catalog/Edit/UrlRewriteForm.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Block/Adminhtml/Catalog/Edit/UrlRewriteForm.php @@ -6,7 +6,7 @@ namespace Magento\UrlRewrite\Test\Block\Adminhtml\Catalog\Edit; -use Magento\Backend\Test\Block\Widget\Form; +use Magento\Mtf\Block\Form; use Magento\Mtf\Client\Element\SimpleElement; use Magento\Mtf\Client\Element; use Magento\Mtf\Fixture\FixtureInterface; @@ -16,6 +16,42 @@ use Magento\Mtf\Fixture\FixtureInterface; */ class UrlRewriteForm extends Form { + /** + * Prepare data for url rewrite fixture. + * + * @param FixtureInterface $fixture + * @return array + */ + protected function prepareData(FixtureInterface $fixture) + { + $data = $fixture->getData(); + if (empty($data['entity_type']) && empty($this->getData()['target_path']) && !isset($data['target_path'])) { + $entity = $fixture->getDataFieldConfig('target_path')['source']->getEntity(); + $data['target_path'] = $entity->hasData('identifier') + ? $entity->getIdentifier() + : $entity->getUrlKey() . '.html'; + } + return $data; + } + + /** + * Fill visible fields on the form. + * + * @param array $data + * @param SimpleElement $context + * @retun void + */ + protected function fillFields(array $data, SimpleElement $context) + { + $mapping = $this->dataMapping($data); + foreach ($mapping as $field) { + $element = $this->getElement($context, $field); + if ($element->isVisible() && !$element->isDisabled()) { + $element->setValue($field['value']); + } + } + } + /** * Fill the root form. * @@ -29,13 +65,8 @@ class UrlRewriteForm extends Form SimpleElement $element = null, array $replace = [] ) { - $data = $fixture->getData(); - if (empty($data['entity_type']) && empty($this->getData()['target_path']) && !isset($data['target_path'])) { - $entity = $fixture->getDataFieldConfig('target_path')['source']->getEntity(); - $data['target_path'] = $entity->hasData('identifier') - ? $entity->getIdentifier() - : $entity->getUrlKey() . '.html'; - } + $context = ($element === null) ? $this->_rootElement : $element; + $data = $this->prepareData($fixture); foreach ($replace as $key => $value) { if (isset($data[$key])) { @@ -43,8 +74,7 @@ class UrlRewriteForm extends Form } } - $mapping = $this->dataMapping($data); - $this->_fill($mapping, $element); + $this->fillFields($data, $context); return $this; } diff --git a/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml index db8db09e418ca18c1adee18b65fbc9391a1a303e..25c488a697e577f4589ef24fd679ae5e52ed3f89 100644 --- a/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml @@ -11,8 +11,8 @@ <data name="description" xsi:type="string">MAGETWO-12444 – Use USPS Online Shipping Carrier on Checkout as a Registered Customer</data> <data name="products" xsi:type="string">catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product</data> <data name="checkoutMethod" xsi:type="string">login</data> - <data name="customer/dataSet" xsi:type="string">customer_US</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="billingAddress/dataSet" xsi:type="string">US_address_1</data> <data name="shipping/shipping_service" xsi:type="string">United States Postal Service</data> <data name="shipping/shipping_method" xsi:type="string">Priority Mail 1-Day</data> <data name="cart/data/shipping_method" xsi:type="string">Priority Mail 1-Day</data> @@ -27,9 +27,9 @@ <data name="description" xsi:type="string">Checkout as guest using USPS with US shipping origin and UK customer</data> <data name="products" xsi:type="string">catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product</data> <data name="checkoutMethod" xsi:type="string">guest</data> - <data name="customer/dataSet" xsi:type="string">customer_UK</data> - <data name="address/dataSet" xsi:type="string">customer_UK</data> - <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="customer/dataSet" xsi:type="string">default</data> + <data name="address/dataSet" xsi:type="string">UK_address</data> + <data name="billingAddress/dataSet" xsi:type="string">UK_address</data> <data name="shipping/shipping_service" xsi:type="string">United States Postal Service</data> <data name="shipping/shipping_method" xsi:type="string">Priority Mail International</data> <data name="cart/data/shipping_method" xsi:type="string">Priority Mail International</data> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php index 736d2e0e8136600a99ebc424ef73e57fbfdb2a00..b3102c9d7f960e4205fd633bfb10c18008fd10f5 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AbstractWishlistTest.php @@ -119,11 +119,9 @@ abstract class AbstractWishlistTest extends Injectable */ protected function addToWishlist(array $products, $configure = false) { - $addProductsToWishlistStep = $this->objectManager->create( + $this->objectManager->create( 'Magento\Wishlist\Test\TestStep\AddProductsToWishlistStep', ['products' => $products, 'configure' => $configure] - ); - - $addProductsToWishlistStep->run(); + )->run(); } } diff --git a/dev/tests/functional/utils/generate/constraint.php b/dev/tests/functional/utils/generate/constraint.php deleted file mode 100644 index 5dfd019f6c17046591a153cb136e0245dac581a3..0000000000000000000000000000000000000000 --- a/dev/tests/functional/utils/generate/constraint.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -require_once dirname(__DIR__) . '/' . 'bootstrap.php'; - -$objectManager->create('Magento\Mtf\Util\Generate\Constraint')->launch(); -\Magento\Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php index 6acd799855c98ff4bdfce79c329196a94919fea0..ca4260d5c037668987898fb26a647e0ee85aa113 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php @@ -5,6 +5,8 @@ */ namespace Magento\CatalogInventory\Model\Stock; +use Magento\Indexer\Model\Indexer\State; + class ItemTest extends \PHPUnit_Framework_TestCase { /** @@ -21,6 +23,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase /** * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoAppIsolation enabled */ public function testSaveWithNullQty() { @@ -31,11 +34,11 @@ class ItemTest extends \PHPUnit_Framework_TestCase $product->load(1); /** @var \Magento\CatalogInventory\Model\Stock\StockItemRepository $stockItemRepository */ - $stockItemRepository = $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $stockItemRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\CatalogInventory\Model\Stock\StockItemRepository'); /** @var \Magento\CatalogInventory\Api\StockItemCriteriaInterface $stockItemCriteria */ - $stockItemCriteria = $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $stockItemCriteria = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\CatalogInventory\Api\StockItemCriteriaInterface'); $savedStockItem = current($stockItemRepository->getList($stockItemCriteria)->getItems()); @@ -60,15 +63,49 @@ class ItemTest extends \PHPUnit_Framework_TestCase /** * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoAppIsolation enabled + */ + public function testIndexerInvalidation() + { + /** @var \Magento\CatalogInventory\Model\Stock\StockItemRepository $stockItemRepository */ + $stockItemRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\CatalogInventory\Model\Stock\StockItemRepository'); + + /** @var \Magento\CatalogInventory\Api\StockItemCriteriaInterface $stockItemCriteria */ + $stockItemCriteria = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\CatalogInventory\Api\StockItemCriteriaInterface'); + /** @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor $indexerProcessor */ + $indexerProcessor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\CatalogInventory\Model\Indexer\Stock\Processor'); + $indexer = $indexerProcessor->getIndexer(); + $indexer->setScheduled(true); + $indexer->getState()->setStatus(State::STATUS_VALID)->save(); + + /** @var \Magento\CatalogInventory\Api\Data\StockItemInterface $savedStockItem */ + $savedStockItem = current($stockItemRepository->getList($stockItemCriteria)->getItems()); + $savedStockItem->setQty(1); + $savedStockItem->setIsInStock(false); + $savedStockItem->save(); + + + $this->assertEquals('invalid', $indexerProcessor->getIndexer()->getStatus()); + + $indexer->setScheduled(false); + $indexer->getState()->setStatus(State::STATUS_VALID)->save(); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoAppIsolation enabled */ public function testStockStatusChangedAuto() { /** @var \Magento\CatalogInventory\Model\Stock\StockItemRepository $stockItemRepository */ - $stockItemRepository = $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $stockItemRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\CatalogInventory\Model\Stock\StockItemRepository'); /** @var \Magento\CatalogInventory\Api\StockItemCriteriaInterface $stockItemCriteria */ - $stockItemCriteria = $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $stockItemCriteria = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\CatalogInventory\Api\StockItemCriteriaInterface'); $savedStockItem = current($stockItemRepository->getList($stockItemCriteria)->getItems()); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index 70d92a6e3a017440a5333f356da2216e9d9b9d64..16e47b8b867ebd5dd2cd757c33f465634b73b998 100755 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -32,8 +32,8 @@ class TemplateTest extends \PHPUnit_Framework_TestCase )->setConstructorArgs( [ $objectManager->get('Magento\Framework\Model\Context'), - $objectManager->get('Magento\Framework\View\DesignInterface'), $objectManager->get('Magento\Framework\Registry'), + $objectManager->get('Magento\Framework\View\DesignInterface'), $objectManager->get('Magento\Store\Model\App\Emulation'), $objectManager->get('Magento\Store\Model\StoreManager'), $objectManager->create('Magento\Framework\Filesystem'), diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/actions.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/actions.test.js new file mode 100644 index 0000000000000000000000000000000000000000..331dbef78d040a791fd30f9f58efa2e5153164b8 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/actions.test.js @@ -0,0 +1,100 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore', + 'Magento_Ui/js/grid/columns/actions' +], function (_, Actions) { + 'use strict'; + + describe('ui/js/grid/columns/actions', function () { + var model, + action; + + beforeEach(function () { + model = new Actions({ + index: 'actions', + name: 'listing_action', + indexField: 'id', + dataScope: '', + rows: [{ + identifier: 'row' + }] + }); + action = { + index: 'delete', + hidden: true, + rowIndex: 0, + callback: function() { + return true; + } + }; + }); + + it('Check addAction function', function () { + expect(model.addAction('delete', action)).toBe(model); + }); + + it('Check getAction function', function () { + var someAction = _.clone(action); + + someAction.index = 'edit'; + model.addAction('edit', someAction); + expect(model.getAction(0, 'edit')).toEqual(someAction); + }); + + it('Check getVisibleActions function', function () { + var someAction = _.clone(action); + + someAction.hidden = false; + someAction.index= 'view'; + model.addAction('delete', action); + model.addAction('view', someAction); + expect(model.getVisibleActions('0')).toEqual([someAction]); + }); + + it('Check updateActions function', function () { + expect(model.updateActions()).toEqual(model); + }); + + it('Check applyAction function', function () { + model.addAction('delete', action); + expect(model.applyAction('delete', 0)).toEqual(model); + }); + + it('Check isSingle and isMultiple function', function () { + var someAction = _.clone(action); + + action.hidden = false; + model.addAction('delete', action); + expect(model.isSingle(0)).toBeTruthy(); + someAction.hidden = false; + someAction.index = 'edit'; + model.addAction('edit', someAction); + expect(model.isSingle(0)).toBeFalsy(); + expect(model.isMultiple(0)).toBeTruthy(); + }); + + it('Check isActionVisible function', function () { + expect(model.isActionVisible(action)).toBeFalsy(); + action.hidden = false; + expect(model.isActionVisible(action)).toBeTruthy(); + }); + + it('Check toggleList function', function () { + model.toggleList(0); + expect(model.opened()).toEqual(0); + model.toggleList(0); + expect(model.opened()).toBeFalsy(); + }); + + it('Check closeList function', function () { + model.toggleList(0); + expect(model.opened()).toEqual(0); + model.closeList(0); + expect(model.opened()).toBeFalsy(); + }); + }); +}); \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dialog/dialog.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js similarity index 60% rename from dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dialog/dialog.test.js rename to dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js index be1e6dfa867088f6174526b3d41c6fade7276b8a..b5e2837467bebad4e5e15bea402121a1be7e96ae 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dialog/dialog.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js @@ -5,23 +5,23 @@ define([ 'jquery', - 'Magento_Ui/js/dialog/dialog' + 'Magento_Ui/js/modal/modal' ], function ($) { 'use strict'; - describe('ui/js/dialog/dialog', function () { + describe('ui/js/modal/modal', function () { var element = $('<div>some element</div>'), - dialog = element.dialog({}).data('mage-dialog'); + modal = element.modal({}).data('mage-modal'); - it('Check for dialog definition', function () { - expect(dialog).toBeDefined(); + it('Check for modal definition', function () { + expect(modal).toBeDefined(); }); it('Show/hide function check', function () { expect(element.trigger('openDialog')).toBe(element); expect(element.trigger('closeDialog')).toBe(element); }); it('Check for transition support', function () { - expect(dialog.whichTransitionEvent()).toBe('webkitTransitionEnd'); + expect(modal.whichTransitionEvent()).toBe('webkitTransitionEnd'); }); }); }); \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php index b190aee7f88acc5bd18af6e1f986472dd6c35627..9bc08c21c00f0379c39d9061b6da22eacb7488d5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php @@ -7,6 +7,8 @@ */ namespace Magento\Test\Integrity; +use Magento\Framework\App\Utility\Classes; + class ClassesTest extends \PHPUnit_Framework_TestCase { /** @@ -31,7 +33,7 @@ class ClassesTest extends \PHPUnit_Framework_TestCase */ function ($file) { $contents = file_get_contents($file); - $classes = \Magento\Framework\App\Utility\Classes::getAllMatches( + $classes = Classes::getAllMatches( $contents, '/ # ::getResourceModel ::getBlockSingleton ::getModel ::getSingleton @@ -57,7 +59,7 @@ class ClassesTest extends \PHPUnit_Framework_TestCase ); // without modifier "i". Starting from capital letter is a significant characteristic of a class name - \Magento\Framework\App\Utility\Classes::getAllMatches( + Classes::getAllMatches( $contents, '/(?:\-> | parent\:\:)(?:_init | setType)\(\s* \'([A-Z][a-z\d][A-Za-z\d\\\\]+)\'(?:,\s*\'([A-Z][a-z\d][A-Za-z\d\\\\]+)\') @@ -82,7 +84,7 @@ class ClassesTest extends \PHPUnit_Framework_TestCase protected function _collectResourceHelpersPhp($contents, &$classes) { $regex = '/(?:\:\:|\->)getResourceHelper\(\s*\'([a-z\d\\\\]+)\'\s*\)/ix'; - $matches = \Magento\Framework\App\Utility\Classes::getAllMatches($contents, $regex); + $matches = Classes::getAllMatches($contents, $regex); foreach ($matches as $moduleName) { $classes[] = "{$moduleName}\\Model\\Resource\\Helper\\Mysql4"; } @@ -96,7 +98,7 @@ class ClassesTest extends \PHPUnit_Framework_TestCase * @param string $path */ function ($path) { - $classes = \Magento\Framework\App\Utility\Classes::collectClassesInConfig(simplexml_load_file($path)); + $classes = Classes::collectClassesInConfig(simplexml_load_file($path)); $this->_assertClassesExist($classes, $path); }, \Magento\Framework\App\Utility\Files::init()->getMainConfigFiles() @@ -113,26 +115,26 @@ class ClassesTest extends \PHPUnit_Framework_TestCase function ($path) { $xml = simplexml_load_file($path); - $classes = \Magento\Framework\App\Utility\Classes::getXmlNodeValues( + $classes = Classes::getXmlNodeValues( $xml, '/layout//*[contains(text(), "\\\\Block\\\\") or contains(text(), "\\\\Model\\\\") or contains(text(), "\\\\Helper\\\\")]' ); - foreach (\Magento\Framework\App\Utility\Classes::getXmlAttributeValues( + foreach (Classes::getXmlAttributeValues( $xml, '/layout//@helper', 'helper' ) as $class) { - $classes[] = \Magento\Framework\App\Utility\Classes::getCallbackClass($class); + $classes[] = Classes::getCallbackClass($class); } - foreach (\Magento\Framework\App\Utility\Classes::getXmlAttributeValues( + foreach (Classes::getXmlAttributeValues( $xml, '/layout//@module', 'module' ) as $module) { $classes[] = str_replace('_', '\\', "{$module}_Helper_Data"); } - $classes = array_merge($classes, \Magento\Framework\App\Utility\Classes::collectLayoutClasses($xml)); + $classes = array_merge($classes, Classes::collectLayoutClasses($xml)); $this->_assertClassesExist(array_unique($classes), $path); }, @@ -159,7 +161,7 @@ class ClassesTest extends \PHPUnit_Framework_TestCase $badUsages = []; foreach ($classes as $class) { try { - if (strrchr($class, '\\') == false) { + if (strrchr($class, '\\') === false and !Classes::isVirtual($class)) { $badUsages[] = $class; continue; } else { @@ -168,9 +170,9 @@ class ClassesTest extends \PHPUnit_Framework_TestCase self::$_existingClasses[$class] ) || \Magento\Framework\App\Utility\Files::init()->classFileExists( $class - ) || \Magento\Framework\App\Utility\Classes::isVirtual( + ) || Classes::isVirtual( $class - ) || \Magento\Framework\App\Utility\Classes::isAutogenerated( + ) || Classes::isAutogenerated( $class ) ); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ConfigTest.php index 58d662260d8271730806151c01eba88e356a7b0a..6b439124a3238ac31ad21fa1e2b341c3c0be460a 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ConfigTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Test\Integrity; +use Magento\Framework\App\Utility\Classes; + class ConfigTest extends \PHPUnit_Framework_TestCase { public function testPaymentMethods() @@ -19,12 +21,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $nodes = $config->xpath('/config/default/payment/*/model') ?: []; $formalModuleName = str_replace('_', '\\', $moduleName); foreach ($nodes as $node) { - $this->assertStringStartsWith( - $formalModuleName . '\Model\\', - (string)$node, - "'{$node}' payment method is declared in '{$configFile}' module, " . - "but doesn't belong to '{$moduleName}' module" - ); + if (!Classes::isVirtual((string)$node)) { + $this->assertStringStartsWith( + $formalModuleName . '\Model\\', + (string)$node, + "'{$node}' payment method is declared in '{$configFile}' module, " . + "but doesn't belong to '{$moduleName}' module" + ); + } } }, $this->paymentMethodsDataProvider() diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php index 1ae037a2b477a3957cc658ecdac90f7e737eef1e..ffd2dd8bb778d3e9c0650350d663d3c1d1dd8b7b 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php @@ -90,7 +90,6 @@ return [ 'cataloginventory_stock_status' => 'Magento\CatalogInventory', 'cataloginventory_stock_status_idx' => 'Magento\CatalogInventory', 'cataloginventory_stock_status_tmp' => 'Magento\CatalogInventory', - 'catalogrule_affected_product' => 'Magento\CatalogRule', 'catalogrule_customer_group' => 'Magento\CatalogRule', 'catalogrule' => 'Magento\CatalogRule', 'catalogrule_group_website' => 'Magento\CatalogRule', diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php index 28353e7f953138cfa0dd3d91b04c17f70062e07a..751ffc6cb8c6f0c2ce01289c788d22b66a110588 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php @@ -349,7 +349,8 @@ class LayoutTest extends \PHPUnit_Framework_TestCase 'setWrapperClass', 'unsetChild', 'unsetChildren', - 'updateButton' + 'updateButton', + 'setIsProductListingContext' ]; } } diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php index b154d0183f2a3583c5bb0c1183e6fc2ffc3c7d6e..f8889d4f2cb4937f0d4a12aefb1c04254a8d78f7 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php @@ -105,7 +105,6 @@ return [ 'cataloginventory/stock_status' => 'cataloginventory_stock_status', 'cataloginventory/stock_status_indexer_idx' => 'cataloginventory_stock_status_idx', 'cataloginventory/stock_status_indexer_tmp' => 'cataloginventory_stock_status_tmp', - 'catalogrule/affected_product' => 'catalogrule_affected_product', 'catalogrule/customer_group' => 'catalogrule_customer_group', 'catalogrule/rule' => 'catalogrule', 'catalogrule/rule_group_website' => 'catalogrule_group_website', diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index b0b03dfcb471f368da7964d27b52ab16cae7f171..fb61d6803b3681c56a7af5ad3a29cc8468484e27 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-beta13'; + const VERSION = '0.74.0-beta14'; /** * Launch application diff --git a/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php b/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php index 96eb992ade3f58cd9e3d6860c36fc1310baacd4b..8bee03a383ef497ade430b261df56d493f6790f3 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php +++ b/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php @@ -129,6 +129,16 @@ interface AdapterInterface */ public function createTemporaryTable(Table $table); + /** + * Create temporary table from other table + * + * @param string $temporaryTableName + * @param string $originTableName + * @param bool $ifNotExists + * @return \Zend_Db_Statement_Interface + */ + public function createTemporaryTableLike($temporaryTableName, $originTableName, $ifNotExists = false); + /** * Drop temporary table from database * diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index 74d74986e0e68fb81a46da87df2e4d8b359cf2d4..94cbf428fd0d3022b596922cbd5196b8da8d9584 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -396,8 +396,9 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface protected function _checkDdlTransaction($sql) { if (is_string($sql) && $this->getTransactionLevel() > 0) { - $startSql = strtolower(substr(ltrim($sql), 0, 3)); - if (in_array($startSql, $this->_ddlRoutines)) { + $sqlMessage = explode(' ', $sql, 3); + $startSql = strtolower(substr(ltrim($sqlMessage[0]), 0, 3)); + if (in_array($startSql, $this->_ddlRoutines) && strcasecmp($sqlMessage[1], 'temporary') !== 0) { trigger_error(AdapterInterface::ERROR_DDL_MESSAGE, E_USER_ERROR); } } @@ -2002,6 +2003,24 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface return $this->query($sql); } + /** + * Create temporary table like + * + * @param string $temporaryTableName + * @param string $originTableName + * @param bool $ifNotExists + * @return \Zend_Db_Statement_Pdo + */ + public function createTemporaryTableLike($temporaryTableName, $originTableName, $ifNotExists = false) + { + $ifNotExistsSql = ($ifNotExists ? 'IF NOT EXISTS' : ''); + $temporaryTable = $this->quoteIdentifier($this->_getTableName($temporaryTableName)); + $originTable = $this->quoteIdentifier($this->_getTableName($originTableName)); + $sql = sprintf('CREATE TEMPORARY TABLE %s %s LIKE %s', $ifNotExistsSql, $temporaryTable, $originTable); + + return $this->query($sql); + } + /** * Rename several tables * diff --git a/lib/internal/Magento/Framework/Intl/DateTimeFactory.php b/lib/internal/Magento/Framework/Intl/DateTimeFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..089dc90170965d0a32eb46bd9196001ccebd997a --- /dev/null +++ b/lib/internal/Magento/Framework/Intl/DateTimeFactory.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Intl; + +/** + * Class DateTimeFactory + * @package Magento\Framework + */ +class DateTimeFactory +{ + /** + * Factory method for \DateTime + * + * @param string $time + * @param \DateTimeZone $timezone + * @return \DateTime + */ + public function create($time = 'now', \DateTimeZone $timezone = null) + { + return new \DateTime($time, $timezone); + } +} diff --git a/lib/internal/Magento/Framework/Intl/README.md b/lib/internal/Magento/Framework/Intl/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7257506ebe47cde86a94a0166e8599fbdd2b39dc --- /dev/null +++ b/lib/internal/Magento/Framework/Intl/README.md @@ -0,0 +1,3 @@ +# Intl + +**Intl** provides an access to Intl extension library wrappers. diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php index ba80e64a256222d7d02ac7eaae6cd95f7ec3717a..87732d71a0f068818c993fd836d8baa8bb9d9d3a 100644 --- a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php @@ -625,6 +625,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso * @return $this * @throws AlreadyExistsException * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _checkUnique(\Magento\Framework\Model\AbstractModel $object) { @@ -640,13 +641,13 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso foreach ($fields as $unique) { $select->reset(\Zend_Db_Select::WHERE); - - if (is_array($unique['field'])) { - foreach ($unique['field'] as $field) { - $select->where($field . '=?', trim($data->getData($field))); + foreach ((array)$unique['field'] as $field) { + $value = $data->getData($field); + if ($value === null) { + $select->where($field . ' IS NULL'); + } else { + $select->where($field . '=?', trim($value)); } - } else { - $select->where($unique['field'] . '=?', trim($data->getData($unique['field']))); } if ($object->getId() || $object->getId() === '0') { diff --git a/lib/internal/Magento/Framework/ObjectManager/TMap.php b/lib/internal/Magento/Framework/ObjectManager/TMap.php index 759ed739d624497ce65ee5e2678b4d9cbe3c99a0..b15b87ed467203a7b5c9be009408e5fdbfe219da 100644 --- a/lib/internal/Magento/Framework/ObjectManager/TMap.php +++ b/lib/internal/Magento/Framework/ObjectManager/TMap.php @@ -44,24 +44,16 @@ class TMap implements \IteratorAggregate, \Countable, \ArrayAccess */ private $configInterface; - /** - * @var ClassReaderInterface - */ - private $classReaderInterface; - - /** * @param string $type * @param ObjectManagerInterface $objectManager * @param ConfigInterface $configInterface - * @param ClassReaderInterface $classReaderInterface * @param array $array */ public function __construct( $type, ObjectManagerInterface $objectManager, ConfigInterface $configInterface, - ClassReaderInterface $classReaderInterface, array $array = [] ) { if (!class_exists($this->type) && !interface_exists($type)) { @@ -72,7 +64,6 @@ class TMap implements \IteratorAggregate, \Countable, \ArrayAccess $this->objectManager = $objectManager; $this->configInterface = $configInterface; - $this->classReaderInterface = $classReaderInterface; array_walk( $array, @@ -99,7 +90,12 @@ class TMap implements \IteratorAggregate, \Countable, \ArrayAccess $this->configInterface->getPreference($instanceName) ); - if (!in_array($this->type, $this->classReaderInterface->getParents($realType), true)) { + if ( + !in_array( + $this->type, + array_unique(array_merge(class_parents($realType), class_implements($realType))), + true + )) { $this->throwTypeException($realType, $index); } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php index 6ce188335d8c6aa1f9e8dba25addacfb2d116847..4e599bd2356dbe77f1e748733e3496822c59376c 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/TMapTest.php @@ -22,11 +22,6 @@ class TMapTest extends \PHPUnit_Framework_TestCase */ private $omConfig; - /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Code\Reader\ClassReaderInterface - */ - private $cReader; - public function setUp() { $this->om = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') @@ -34,9 +29,6 @@ class TMapTest extends \PHPUnit_Framework_TestCase $this->omConfig = $this->getMockBuilder('Magento\Framework\ObjectManager\ConfigInterface') ->getMockForAbstractClass(); - - $this->cReader = $this->getMockBuilder('Magento\Framework\Code\Reader\ClassReaderInterface') - ->getMockForAbstractClass(); } public function testConstructor() @@ -154,19 +146,10 @@ class TMapTest extends \PHPUnit_Framework_TestCase ] ); - $this->cReader->expects(static::exactly($exactlyCalls)) - ->method('getParents') - ->willReturnMap( - [ - ['TClass', ['TInterface']] - ] - ); - return new TMap( 'TInterface', $this->om, $this->omConfig, - $this->cReader, $testClasses ); } diff --git a/lib/internal/Magento/Framework/View/Element/Template.php b/lib/internal/Magento/Framework/View/Element/Template.php index a7f4b683343f87bdda4c73305a248ea92b6d81c6..8e1c8e4cb27946799946680b342aff3ae78949df 100644 --- a/lib/internal/Magento/Framework/View/Element/Template.php +++ b/lib/internal/Magento/Framework/View/Element/Template.php @@ -7,7 +7,6 @@ namespace Magento\Framework\View\Element; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; -use Magento\Framework\View\Template\Html\Minifier; /** * Base html block diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 1307d01001635ca7553aabcd9dcd94884d01801c..29ca6222b30be7c45122ac19c9f1c48c04c408fc 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -2,7 +2,7 @@ "name": "magento/framework", "description": "N/A", "type": "magento2-library", - "version": "0.74.0-beta13", + "version": "0.74.0-beta14", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/lib/web/css/source/components/_modals.less b/lib/web/css/source/components/_modals.less index c7776d6684e7e5880247625d2032f0cd4b33fc02..df5c973eef2de55b58b941178d1acf677ee0a219 100644 --- a/lib/web/css/source/components/_modals.less +++ b/lib/web/css/source/components/_modals.less @@ -28,6 +28,8 @@ @modal-slide-header__padding-vertical: 2.1rem; +@modal-popup-confirm__width: 50rem; + // // Utilities // --------------------------------------------- @@ -181,6 +183,16 @@ padding-top: @modal-popup__padding; padding-bottom: @modal-popup__padding; } + &.confirm { + .modal-inner-wrap { + margin-left: -(@modal-popup-confirm__width/2); + left: 50%; + width: @modal-popup-confirm__width; + } + .modal-footer { + text-align: right; + } + } } // diff --git a/lib/web/css/source/lib/_navigation.less b/lib/web/css/source/lib/_navigation.less index 6bc9cb68b243392a50bf5026f8bc510146a1f71a..a0af0e4ebd85069255dd6e8c5d13c82206552855 100644 --- a/lib/web/css/source/lib/_navigation.less +++ b/lib/web/css/source/lib/_navigation.less @@ -329,7 +329,6 @@ margin: 0 !important; position: absolute; left: 0; - top: 100%; z-index: 1; .css(background, @_submenu-background-color); .css(border, @_submenu-border-width @_submenu-border-style @_submenu-border-color); @@ -370,6 +369,10 @@ top: 0 !important; left: 100% !important; } + .submenu-reverse{ + left: auto !important; + right: 100%; + } } &.more { position: relative; diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js index dfb3ef72d8c4d8424c949ea44dfba20b3a8f01be..f4efd12693997985cdc08232778491db37a74848 100644 --- a/lib/web/mage/backend/suggest.js +++ b/lib/web/mage/backend/suggest.js @@ -178,16 +178,47 @@ _bind: function () { this._on($.extend({ keydown: function (event) { - var keyCode = $.ui.keyCode; + var keyCode = $.ui.keyCode, + suggestList, + hasSuggestedItems, + hasSelectedItems, + selectedItem; + switch (event.keyCode) { case keyCode.PAGE_UP: - case keyCode.PAGE_DOWN: case keyCode.UP: + if (!event.shiftKey) { + event.preventDefault(); + this._proxyEvents(event); + } + + suggestList = event.currentTarget.parentNode.getElementsByTagName('ul')[0]; + hasSuggestedItems = event.currentTarget.parentNode.getElementsByTagName('ul')[0].children.length >= 0; + if (hasSuggestedItems) { + selectedItem = $(suggestList.getElementsByClassName('_active')[0]).removeClass('_active').prev().addClass('_active'); + event.currentTarget.value = selectedItem.find("a").text(); + } + + break; + case keyCode.PAGE_DOWN: case keyCode.DOWN: if (!event.shiftKey) { event.preventDefault(); this._proxyEvents(event); } + + suggestList = event.currentTarget.parentNode.getElementsByTagName('ul')[0]; + hasSuggestedItems = event.currentTarget.parentNode.getElementsByTagName('ul')[0].children.length >= 0; + if(hasSuggestedItems){ + hasSelectedItems = suggestList.getElementsByClassName('_active').length === 0; + if(hasSelectedItems) { + selectedItem = $(suggestList.children[0]).addClass('_active'); + event.currentTarget.value = selectedItem.find("a").text(); + }else { + selectedItem = $(suggestList.getElementsByClassName('_active')[0]).removeClass('_active').next().addClass('_active'); + event.currentTarget.value = selectedItem.find("a").text(); + } + } break; case keyCode.TAB: if (this.isDropdownShown()) { @@ -197,6 +228,7 @@ break; case keyCode.ENTER: case keyCode.NUMPAD_ENTER: + if (this.isDropdownShown() && this._focused) { this._proxyEvents(event); event.preventDefault(); diff --git a/lib/web/mage/menu.js b/lib/web/mage/menu.js index 94055ff0a1ddbda398323f9d8e31a9060ac7bfd3..925ae9df33791441a2e54ed6457753a62cba0751 100644 --- a/lib/web/mage/menu.js +++ b/lib/web/mage/menu.js @@ -8,7 +8,7 @@ define([ "jquery/ui", "jquery/jquery.mobile.custom", "mage/translate" -], function($, mediaCheck){ +], function ($, mediaCheck) { 'use strict'; /** @@ -20,22 +20,30 @@ define([ expanded: false, delay: 300 }, + _create: function () { + var self = this; - _init: function() { + this._super(); + $(window).on('resize', function () { + self.element.find('.submenu-reverse').removeClass('submenu-reverse'); + }); + }, + + _init: function () { this._super(); this.delay = this.options.delay; - if(this.options.expanded === true) { + if (this.options.expanded === true) { this.isExpanded(); } - if(this.options.responsive === true){ + if (this.options.responsive === true) { mediaCheck({ media: '(max-width: 640px)', - entry: $.proxy(function() { + entry: $.proxy(function () { this._toggleMobileMode(); }, this), - exit: $.proxy(function() { + exit: $.proxy(function () { this._toggleDesktopMode(); }, this) }); @@ -44,7 +52,7 @@ define([ this._assignControls()._listen(); }, - _assignControls: function() { + _assignControls: function () { this.controls = { toggleBtn: $('[data-action="toggle-nav"]'), swipeArea: $('.nav-sections') @@ -53,125 +61,125 @@ define([ return this; }, - _listen: function() { + _listen: function () { var controls = this.controls; var toggle = this.toggle; - this._on(controls.toggleBtn, { 'click' : toggle }); - this._on(controls.swipeArea, { 'swipeleft': toggle }); + this._on(controls.toggleBtn, {'click': toggle}); + this._on(controls.swipeArea, {'swipeleft': toggle}); }, - toggle: function() { + toggle: function () { if ($('html').hasClass('nav-open')) { $('html').removeClass('nav-open'); - setTimeout(function() { + setTimeout(function () { $('html').removeClass('nav-before-open'); - },300); + }, 300); } else { $('html').addClass('nav-before-open'); - setTimeout(function() { + setTimeout(function () { $('html').addClass('nav-open'); - },42); + }, 42); } }, //Add class for expanded option - isExpanded: function() { - var subMenus = this.element.find( this.options.menus ), + isExpanded: function () { + var subMenus = this.element.find(this.options.menus), expandedMenus = subMenus.find('ul'); expandedMenus.addClass('expanded'); }, - _activate: function( event ) { + _activate: function (event) { window.location.href = this.active.find('> a').attr('href'); this.collapseAll(event); }, - _keydown: function(event) { + _keydown: function (event) { var match, prev, character, skip, regex, - preventDefault = true; + preventDefault = true; - function escape( value ) { - return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ); + function escape(value) { + return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); } - if(this.active.closest('ul').attr('aria-expanded') != 'true') { + if (this.active.closest('ul').attr('aria-expanded') != 'true') { - switch ( event.keyCode ) { + switch (event.keyCode) { case $.ui.keyCode.PAGE_UP: - this.previousPage( event ); + this.previousPage(event); break; case $.ui.keyCode.PAGE_DOWN: - this.nextPage( event ); + this.nextPage(event); break; case $.ui.keyCode.HOME: - this._move( "first", "first", event ); + this._move("first", "first", event); break; case $.ui.keyCode.END: - this._move( "last", "last", event ); + this._move("last", "last", event); break; case $.ui.keyCode.UP: - this.previous( event ); + this.previous(event); break; case $.ui.keyCode.DOWN: - if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { - this.expand( event ); + if (this.active && !this.active.is(".ui-state-disabled")) { + this.expand(event); } break; case $.ui.keyCode.LEFT: - this.previous( event ); + this.previous(event); break; case $.ui.keyCode.RIGHT: - this.next( event ); + this.next(event); break; case $.ui.keyCode.ENTER: case $.ui.keyCode.SPACE: - this._activate( event ); + this._activate(event); break; case $.ui.keyCode.ESCAPE: - this.collapse( event ); + this.collapse(event); break; default: preventDefault = false; prev = this.previousFilter || ""; - character = String.fromCharCode( event.keyCode ); + character = String.fromCharCode(event.keyCode); skip = false; - clearTimeout( this.filterTimer ); + clearTimeout(this.filterTimer); - if ( character === prev ) { + if (character === prev) { skip = true; } else { character = prev + character; } - regex = new RegExp( "^" + escape( character ), "i" ); - match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { - return regex.test( $( this ).children( "a" ).text() ); + regex = new RegExp("^" + escape(character), "i"); + match = this.activeMenu.children(".ui-menu-item").filter(function () { + return regex.test($(this).children("a").text()); }); - match = skip && match.index( this.active.next() ) !== -1 ? - this.active.nextAll( ".ui-menu-item" ) : + match = skip && match.index(this.active.next()) !== -1 ? + this.active.nextAll(".ui-menu-item") : match; // If no matches on the current filter, reset to the last character pressed // to move down the menu to the first item that starts with that character - if ( !match.length ) { - character = String.fromCharCode( event.keyCode ); - regex = new RegExp( "^" + escape( character ), "i" ); - match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { - return regex.test( $( this ).children( "a" ).text() ); + if (!match.length) { + character = String.fromCharCode(event.keyCode); + regex = new RegExp("^" + escape(character), "i"); + match = this.activeMenu.children(".ui-menu-item").filter(function () { + return regex.test($(this).children("a").text()); }); } - if ( match.length ) { - this.focus( event, match ); - if ( match.length > 1 ) { + if (match.length) { + this.focus(event, match); + if (match.length > 1) { this.previousFilter = character; - this.filterTimer = this._delay(function() { + this.filterTimer = this._delay(function () { delete this.previousFilter; - }, 1000 ); + }, 1000); } else { delete this.previousFilter; } @@ -180,65 +188,65 @@ define([ } } } else { - switch ( event.keyCode ) { + switch (event.keyCode) { case $.ui.keyCode.DOWN: - this.next( event ); + this.next(event); break; case $.ui.keyCode.UP: - this.previous( event ); + this.previous(event); break; case $.ui.keyCode.RIGHT: - if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { - this.expand( event ); + if (this.active && !this.active.is(".ui-state-disabled")) { + this.expand(event); } break; case $.ui.keyCode.ENTER: case $.ui.keyCode.SPACE: - this._activate( event ); + this._activate(event); break; case $.ui.keyCode.LEFT: case $.ui.keyCode.ESCAPE: - this.collapse( event ); + this.collapse(event); break; default: preventDefault = false; prev = this.previousFilter || ""; - character = String.fromCharCode( event.keyCode ); + character = String.fromCharCode(event.keyCode); skip = false; - clearTimeout( this.filterTimer ); + clearTimeout(this.filterTimer); - if ( character === prev ) { + if (character === prev) { skip = true; } else { character = prev + character; } - regex = new RegExp( "^" + escape( character ), "i" ); - match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { - return regex.test( $( this ).children( "a" ).text() ); + regex = new RegExp("^" + escape(character), "i"); + match = this.activeMenu.children(".ui-menu-item").filter(function () { + return regex.test($(this).children("a").text()); }); - match = skip && match.index( this.active.next() ) !== -1 ? - this.active.nextAll( ".ui-menu-item" ) : + match = skip && match.index(this.active.next()) !== -1 ? + this.active.nextAll(".ui-menu-item") : match; // If no matches on the current filter, reset to the last character pressed // to move down the menu to the first item that starts with that character - if ( !match.length ) { - character = String.fromCharCode( event.keyCode ); - regex = new RegExp( "^" + escape( character ), "i" ); - match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { - return regex.test( $( this ).children( "a" ).text() ); + if (!match.length) { + character = String.fromCharCode(event.keyCode); + regex = new RegExp("^" + escape(character), "i"); + match = this.activeMenu.children(".ui-menu-item").filter(function () { + return regex.test($(this).children("a").text()); }); } - if ( match.length ) { - this.focus( event, match ); - if ( match.length > 1 ) { + if (match.length) { + this.focus(event, match); + if (match.length > 1) { this.previousFilter = character; - this.filterTimer = this._delay(function() { + this.filterTimer = this._delay(function () { delete this.previousFilter; - }, 1000 ); + }, 1000); } else { delete this.previousFilter; } @@ -248,27 +256,27 @@ define([ } } - if ( preventDefault ) { + if (preventDefault) { event.preventDefault(); } }, - _toggleMobileMode: function() { + _toggleMobileMode: function () { $(this.element).off('mouseenter mouseleave'); this._on({ - "click .ui-menu-item:has(a)": function( event ) { + "click .ui-menu-item:has(a)": function (event) { event.preventDefault(); - var target = $( event.target ).closest( ".ui-menu-item" ); - - if ( !target.hasClass('level-top') || !target.has( ".ui-menu" ).length ) { + var target = $(event.target).closest(".ui-menu-item"); + + if (!target.hasClass('level-top') || !target.has(".ui-menu").length) { window.location.href = target.find('> a').attr('href'); } } }); var subMenus = this.element.find('.level-top'); - $.each(subMenus, $.proxy(function(index, item) { + $.each(subMenus, $.proxy(function (index, item) { var category = $(item).find('> a span').not('.ui-menu-icon').text(), categoryUrl = $(item).find('> a').attr('href'), menu = $(item).find('> .ui-menu'); @@ -281,58 +289,79 @@ define([ .addClass('ui-menu-item all-category') .html(this.categoryLink); - if(menu.find('.all-category').length === 0) { + if (menu.find('.all-category').length === 0) { menu.prepend(this.categoryParent); } }, this)); }, - _toggleDesktopMode: function() { + _toggleDesktopMode: function () { this._on({ // Prevent focus from sticking to links inside menu after clicking // them (focus should always stay on UL during navigation). - "mousedown .ui-menu-item > a": function( event ) { + "mousedown .ui-menu-item > a": function (event) { event.preventDefault(); }, - "click .ui-state-disabled > a": function( event ) { + "click .ui-state-disabled > a": function (event) { event.preventDefault(); }, - "click .ui-menu-item:has(a)": function( event ) { - var target = $( event.target ).closest( ".ui-menu-item" ); - if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { - this.select( event ); + "click .ui-menu-item:has(a)": function (event) { + var target = $(event.target).closest(".ui-menu-item"); + if (!this.mouseHandled && target.not(".ui-state-disabled").length) { + this.select(event); // Only set the mouseHandled flag if the event will bubble, see #9469. - if ( !event.isPropagationStopped() ) { + if (!event.isPropagationStopped()) { this.mouseHandled = true; } // Open submenu on click - if ( target.has( ".ui-menu" ).length ) { - this.expand( event ); - } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) { + if (target.has(".ui-menu").length) { + this.expand(event); + } else if (!this.element.is(":focus") && $(this.document[0].activeElement).closest(".ui-menu").length) { // Redirect focus to the menu - this.element.trigger( "focus", [ true ] ); + this.element.trigger("focus", [true]); // If the active item is on the top level, let it stay active. // Otherwise, blur the active item since it is no longer visible. - if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) { - clearTimeout( this.timer ); + if (this.active && this.active.parents(".ui-menu").length === 1) { + clearTimeout(this.timer); } } } }, - "mouseenter .ui-menu-item": function( event ) { - var target = $( event.currentTarget ); + "mouseenter .ui-menu-item": function (event) { + var target = $(event.currentTarget), + ulElement, + ulElementWidth, + width, + targetPageX, + rightBound; + + if (target.has('ul')) { + ulElement = target.find('ul'); + ulElementWidth = target.find('ul').outerWidth(true); + width = target.outerWidth() * 2; + targetPageX = target.offset().left; + rightBound = $(window).width(); + + if ((ulElementWidth + width + targetPageX) > rightBound) { + ulElement.addClass('submenu-reverse'); + } + if ((targetPageX - ulElementWidth) < 0) { + ulElement.removeClass('submenu-reverse'); + } + } + // Remove ui-state-active class from siblings of the newly focused menu item // to avoid a jump caused by adjacent elements both having a class with a border - target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" ); - this.focus( event, target ); + target.siblings().children(".ui-state-active").removeClass("ui-state-active"); + this.focus(event, target); }, - "mouseleave": function( event ){ - this.collapseAll( event, true ); + "mouseleave": function (event) { + this.collapseAll(event, true); }, "mouseleave .ui-menu": "collapseAll" }); @@ -349,11 +378,14 @@ define([ }, 300); } }, - _delay: function(handler, delay) { - handler.apply(this, arguments); - - return setTimeout(function() {}, delay || 0); + var instance = this, + handlerProxy = function () { + return (typeof handler === "string" ? instance[handler] : handler) + .apply(instance, arguments); + }; + + return setTimeout(handlerProxy, delay || 0); } }); @@ -368,7 +400,7 @@ define([ breakpoint: 768 }, - _init: function() { + _init: function () { this._super(); var that = this, @@ -383,24 +415,24 @@ define([ this.setMaxItems(); //check responsive option - if(responsive == "onResize") { - $(window).on('resize', function() { - if($(window).width() > that.options.breakpoint) { - that._responsive(); - $('[responsive=more]').show(); + if (responsive == "onResize") { + $(window).on('resize', function () { + if ($(window).width() > that.options.breakpoint) { + that._responsive(); + $('[responsive=more]').show(); } else { that.element.children().show(); $('[responsive=more]').hide(); } }); - } else if(responsive == "onReload") { + } else if (responsive == "onReload") { this._responsive(); } }, - setupMoreMenu: function() { + setupMoreMenu: function () { var moreListItems = this.element.children().clone(), - moreLink = $('<a>'+ this.options.moreText +'</a>'); + moreLink = $('<a>' + this.options.moreText + '</a>'); moreListItems.hide(); @@ -418,15 +450,15 @@ define([ .attr('responsive', 'more') .append(this.moreListContainer) .menu({ - position : { - my : "right top", - at : "right bottom" + position: { + my: "right top", + at: "right bottom" } }) .insertAfter(this.element); }, - _responsive: function() { + _responsive: function () { var container = $(this.options.container), containerSize = container.width(), width = 0, @@ -434,7 +466,7 @@ define([ more = $('.ui-menu-more > li > ul > li a'); - items = items.map(function() { + items = items.map(function () { var item = {}; item.item = $(this); @@ -442,36 +474,36 @@ define([ return item; }); - $.each(items, function(index, item){ + $.each(items, function (index, item) { var itemText = items[index].item - .find('a:first') - .text(); + .find('a:first') + .text(); width += parseInt(items[index].itemSize, null); - if(width < containerSize) { + if (width < containerSize) { items[index].item.show(); - more.each(function() { - var text = $(this).text(); - if(text === itemText){ - $(this).parent().hide(); - } - }); - } else if(width > containerSize) { + more.each(function () { + var text = $(this).text(); + if (text === itemText) { + $(this).parent().hide(); + } + }); + } else if (width > containerSize) { items[index].item.hide(); - more.each(function() { - var text = $(this).text(); - if(text === itemText){ - $(this).parent().show(); - } - }); + more.each(function () { + var text = $(this).text(); + if (text === itemText) { + $(this).parent().show(); + } + }); } }); }, - setMaxItems: function() { + setMaxItems: function () { var items = this.element.children('li'), itemsCount = items.length, maxItems = this.options.maxItems, @@ -480,23 +512,23 @@ define([ overflowItems.hide(); - overflowItems.each(function(){ + overflowItems.each(function () { var itemText = $(this).find('a:first').text(); $(this).hide(); - $('.ui-menu-more > li > ul > li a').each(function() { - var text = $(this).text(); - if(text === itemText){ - $(this).parent().show(); - } - }); + $('.ui-menu-more > li > ul > li a').each(function () { + var text = $(this).text(); + if (text === itemText) { + $(this).parent().show(); + } + }); }); } }); - + return { - menu: $.mage.menu, + menu: $.mage.menu, navigation: $.mage.navigation }; }); diff --git a/lib/web/mage/utils/arrays.js b/lib/web/mage/utils/arrays.js index 54fb9a6189a8df0335808a989c5be5b859643ed8..d931fc1c7118a76ac5fe4f3b2dbc9cf4df9756a7 100644 --- a/lib/web/mage/utils/arrays.js +++ b/lib/web/mage/utils/arrays.js @@ -8,6 +8,25 @@ define([ ], function (_, utils) { 'use strict'; + /** + * Defines index of an item in a specified container. + * + * @param {*} item - Item whose index should be defined. + * @param {Array} container - Container upon which to perform search. + * @returns {Number} + */ + function getIndex(item, container) { + var index = container.indexOf(item); + + if (~index) { + return index; + } + + return _.findIndex(container, function (value) { + return value && value.name === item; + }); + } + return { /** * Facade method to remove/add value from/to array @@ -62,21 +81,6 @@ define([ return this; }, - /** - * Extends an incoming array with a specified ammount of undefined values - * starting from a specified position. - * - * @param {Array} container - Array to be extended. - * @param {Number} size - Ammount of values to be added. - * @param {Number} [offset=0] - Position at which to start inserting values. - * @returns {Array} Modified array. - */ - reserve: function (container, size, offset) { - container.splice(offset || 0, 0, new Array(size)); - - return _.flatten(container); - }, - /** * Compares multiple arrays without tracking order of their elements. * @@ -93,7 +97,64 @@ define([ }); }, - formatOffset: function(elems, offset) { + /** + * Inserts specified item into container at specified position. + * + * @param {*} item - Item to be inserted into container. + * @param {Array} container - Container of items. + * @param {*} [position=-1] - Position at which item should be inserted. + * Position can represent: + * - specific index in container + * - item which might already be present in container + * - structure with one of these properties: after, before + * @returns {Boolean|*} + * - true if element has changed its' position + * - false if nothing has changed + * - inserted value if it wasn't present in container + */ + insert: function (item, container, position) { + var currentIndex = getIndex(item, container), + newIndex, + target; + + if (typeof position === 'undefined') { + position = -1; + } else if (typeof position === 'string') { + position = isNaN(+position) ? position : +position; + } + + newIndex = position; + + if (~currentIndex) { + target = container.splice(currentIndex, 1)[0]; + + if (typeof item === 'string') { + item = target; + } + } + + if (typeof position !== 'number') { + target = position.after || position.before || position; + + newIndex = getIndex(target, container); + + if (~newIndex && (position.after || newIndex >= currentIndex)) { + newIndex++; + } + } + + if (newIndex < 0) { + newIndex += container.length + 1; + } + + container[newIndex] ? + container.splice(newIndex, 0, item) : + container[newIndex] = item; + + return !~currentIndex ? item : currentIndex !== newIndex; + }, + + formatOffset: function (elems, offset) { if (utils.isEmpty(offset)) { offset = -1; } diff --git a/lib/web/mage/utils/objects.js b/lib/web/mage/utils/objects.js index 7cd4924e492a39ee5609bb7e25c9bdef887c2ebb..4aa5d7216c6f3b4c4496071da48516e7d029e78b 100644 --- a/lib/web/mage/utils/objects.js +++ b/lib/web/mage/utils/objects.js @@ -207,7 +207,12 @@ define([ return result; }, - extend: function (target) { + /** + * Performs deep extend of specified objects. + * + * @returns {Object|Array} Extended object. + */ + extend: function () { var args = _.toArray(arguments); args.unshift(true); @@ -215,15 +220,36 @@ define([ return $.extend.apply($, args); }, + /** + * Performs a deep clone of a specified object. + * + * @param {(Object|Array)} data - Data that should be copied. + * @returns {Object|Array} Cloned object. + */ copy: function (data) { - return this.extend({}, data); + var result = data, + isArray = Array.isArray(data), + placeholder; + + if (this.isObject(data) || isArray) { + placeholder = isArray ? [] : {}; + result = this.extend(placeholder, data); + } + + return result; }, - isObject: function (data) { + /** + * Checks if provided value is a plain object. + * + * @param {*} value - Value to be checked. + * @returns {Boolean} + */ + isObject: function (value) { var objProto = Object.prototype; - return typeof data == 'object' ? - objProto.toString.call(data) === '[object Object]' : + return typeof value == 'object' ? + objProto.toString.call(value) === '[object Object]' : false; } }; diff --git a/lib/web/mage/utils/strings.js b/lib/web/mage/utils/strings.js index 185951886aaf3271e84cfc4d79d16016aec1d5ef..914ca72c1bdf63a6525eca1fc2c2c7372e60ade3 100644 --- a/lib/web/mage/utils/strings.js +++ b/lib/web/mage/utils/strings.js @@ -7,7 +7,29 @@ define([ ], function (_) { 'use strict'; + var jsonRe = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/; + return { + /** + * Attempts to convert string to one of the primitive values, + * or to parse it as a valid json object. + * + * @param {String} str - String to be processed. + * @returns {*} + */ + castString: function (str) { + try { + str = str === 'true' ? true : + str === 'false' ? false : + str === 'null' ? null : + +str + '' === str ? +str : + jsonRe.test(str) ? JSON.parse(str) : + str; + } catch (e) {} + + return str; + }, + /** * Splits string by separator if it's possible, * otherwise returns the incoming value. @@ -62,6 +84,13 @@ define([ return value === '' || _.isUndefined(value) || _.isNull(value); }, + /** + * Adds 'prefix' to the 'part' value if it was provided. + * + * @param {String} prefix + * @param {String} part + * @returns {String} + */ fullPath: function (prefix, part) { return prefix ? prefix + '.' + part : part; } diff --git a/lib/web/mage/utils/template.js b/lib/web/mage/utils/template.js index a2b8cd462f6669405c84a39a89785cec54cb472b..d76f0e890f665582b06071a7ab1253717eb3656a 100644 --- a/lib/web/mage/utils/template.js +++ b/lib/web/mage/utils/template.js @@ -4,8 +4,9 @@ */ define([ 'underscore', - 'mage/utils/objects' -], function (_, utils) { + 'mage/utils/objects', + 'mage/utils/strings' +], function (_, utils, stringUtils) { 'use strict'; var tmplSettings = _.templateSettings, @@ -28,6 +29,7 @@ define([ })(); if (hasStringTmpls) { + /*eslint-disable no-unused-vars, no-eval*/ /** * Evaluates template string using ES6 templates. * @@ -38,6 +40,7 @@ define([ template = function (tmpl, $) { return eval('`' + tmpl + '`'); }; + /*eslint-enable no-unused-vars, no-eval*/ } else { /** * Fallback function used when ES6 templates are not supported. @@ -52,7 +55,9 @@ define([ tmplSettings.interpolate = interpolate; - tmpl = _.template(tmpl, {variable: '$'})(data); + tmpl = _.template(tmpl, { + variable: '$' + })(data); tmplSettings.interpolate = cached; @@ -63,7 +68,7 @@ define([ /** * Checks if provided value contains template syntax. * - * @param {*} value - Value to be check. + * @param {*} value - Value to be checked. * @returns {Boolean} */ function isTemplate(value) { @@ -76,9 +81,12 @@ define([ * * @param {String} tmpl - Template string. * @param {Object} data - Data object used in a template. - * @returns {String} Compiled template. + * @param {Boolean} [castString=false] - Flag that indicates whether template + * should be casted after evaluation to a value of another type or + * that it should be leaved as a string. + * @returns {*} Compiled template. */ - function render(tmpl, data) { + function render(tmpl, data, castString) { var last = tmpl; data = Object.create(data); @@ -93,7 +101,9 @@ define([ last = tmpl; } - return tmpl; + return castString ? + stringUtils.castString(tmpl) : + tmpl; } return { @@ -102,7 +112,10 @@ define([ * * @param {Object|String} tmpl * @param {Object} [data] - Data object to match with template. - * @returns {Object|String} + * @param {Boolean} [castString=false] - Flag that indicates whether template + * should be casted after evaluation to a value of another type or + * that it should be leaved as a string. + * @returns {*} * * @example Template defined as a string. * var source = { foo: 'Random Stuff', bar: 'Some' }; @@ -114,6 +127,8 @@ define([ * var tmpl = { * key: {'${ $.$data.bar }': '${ $.$data.foo }'}, * foo: 'bar', + * x1: 2, x2: 5, + * delta: '${ $.x2 - $.x1 }', * baz: 'Upper ${ $.foo.toUpperCase() }' * }; * @@ -121,19 +136,25 @@ define([ * => { * key: {'Some': 'Random Stuff'}, * foo: 'bar', + * x1: 2, x2: 5, + * delta: 3, * baz: 'Upper BAR' * }; */ - template: function (tmpl, data) { + template: function (tmpl, data, castString) { + var iterate; + if (typeof tmpl === 'string') { - return render(tmpl, data); + return render(tmpl, data, castString); } - tmpl = utils.extend({}, tmpl); - + tmpl = utils.copy(tmpl); tmpl.$data = data || {}; - _.each(tmpl, function iterate(value, key, list) { + /** + * Template iterator function. + */ + iterate = function (value, key, list) { if (key === '$data') { return; } @@ -146,11 +167,13 @@ define([ } if (isTemplate(value)) { - list[key] = render(value, tmpl); - } else if (_.isObject(value)) { + list[key] = render(value, tmpl, castString); + } else if (utils.isObject(value) || Array.isArray(value)) { _.each(value, iterate); } - }); + }; + + _.each(tmpl, iterate); delete tmpl.$data;