diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php b/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php index d1b94795ecb32..d9991e65504c9 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php @@ -40,7 +40,7 @@ public function afterDeleteAdvancedPricing(AdvancedPricing $subject) /** * Get price indexer * - * @return \Magento\Indexer\Model\IndexerInterface + * @return \Magento\Framework\Indexer\IndexerInterface */ protected function getPriceIndexer() { diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php index f12d4026ef829..d9e22043ccc57 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php @@ -11,7 +11,7 @@ class ImportTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\IndexerInterface |\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface |\PHPUnit_Framework_MockObject_MockObject */ protected $indexer; @@ -27,7 +27,7 @@ class ImportTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->indexer = $this->getMockForAbstractClass('\Magento\Indexer\Model\IndexerInterface', [], '', false); + $this->indexer = $this->getMockForAbstractClass('\Magento\Framework\Indexer\IndexerInterface', [], '', false); $this->import = $this->getMock( '\Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import', ['getPriceIndexer', 'invalidateIndexer'], diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index a36f20f4f699e..7c745801c12c9 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -210,7 +210,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements /** @var UrlFinderInterface */ protected $urlFinder; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** @@ -240,7 +240,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements * @param Indexer\Category\Flat\State $flatState * @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator * @param UrlFinderInterface $urlFinder - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param CategoryRepositoryInterface $categoryRepository * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -264,7 +264,7 @@ public function __construct( Indexer\Category\Flat\State $flatState, \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator, UrlFinderInterface $urlFinder, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, CategoryRepositoryInterface $categoryRepository, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, diff --git a/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php b/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php index ee3f56b70d965..1787ff1cf66c6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php +++ b/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php @@ -29,17 +29,17 @@ abstract class AbstractFlatState */ protected $isAvailable; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param bool $isAvailable */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, $isAvailable = false ) { $this->scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/AffectCache.php b/app/code/Magento/Catalog/Model/Indexer/Category/AffectCache.php index 124424648050d..6e8f57f37bd99 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/AffectCache.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/AffectCache.php @@ -12,26 +12,26 @@ class AffectCache { /** - * @var \Magento\Indexer\Model\CacheContext + * @var \Magento\Framework\Indexer\CacheContext */ protected $context; /** - * @param \Magento\Indexer\Model\CacheContext $context + * @param \Magento\Framework\Indexer\CacheContext $context */ public function __construct( - \Magento\Indexer\Model\CacheContext $context + \Magento\Framework\Indexer\CacheContext $context ) { $this->context = $context; } /** - * @param \Magento\Indexer\Model\ActionInterface $subject + * @param \Magento\Framework\Indexer\ActionInterface $subject * @param array $ids * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeExecute(\Magento\Indexer\Model\ActionInterface $subject, $ids) + public function beforeExecute(\Magento\Framework\Indexer\ActionInterface $subject, $ids) { $this->context->registerEntities(\Magento\Catalog\Model\Category::CACHE_TAG, $ids); return [$ids]; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php index 16f10216ed945..fa3bc07ac3f64 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Category; -class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Flat implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory @@ -17,18 +17,18 @@ class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework */ protected $rowsActionFactory; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** * @param Flat\Action\FullFactory $fullActionFactory * @param Flat\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ public function __construct( Flat\Action\FullFactory $fullActionFactory, Flat\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry ) { $this->fullActionFactory = $fullActionFactory; $this->rowsActionFactory = $rowsActionFactory; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php index 29c42f6e15773..8ef69f4fb5d96 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php @@ -7,7 +7,7 @@ class StoreGroup { - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** @@ -16,11 +16,11 @@ class StoreGroup protected $state; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Catalog\Model\Indexer\Category\Flat\State $state */ public function __construct( - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Catalog\Model\Indexer\Category\Flat\State $state ) { $this->indexerRegistry = $indexerRegistry; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php index eac2cb0d79b33..df01da1a9cf77 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php @@ -13,14 +13,14 @@ class Mode extends \Magento\Framework\App\Config\Value /** @var \Magento\Indexer\Model\Indexer\State */ protected $indexerState; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Indexer\Model\Indexer\State $indexerState * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -30,7 +30,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Indexer\Model\Indexer\State $indexerState, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, @@ -62,7 +62,7 @@ public function processValue() if ((bool)$this->getValue() != (bool)$this->getOldValue()) { if ((bool)$this->getValue()) { $this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID); - $this->indexerState->setStatus(\Magento\Indexer\Model\Indexer\State::STATUS_INVALID); + $this->indexerState->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->indexerState->save(); } else { $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID) diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php index 78c0e84fa7993..fcd29869abe72 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Category; -class Product implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Product implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * Indexer ID in configuration @@ -22,18 +22,18 @@ class Product implements \Magento\Indexer\Model\ActionInterface, \Magento\Framew */ protected $rowsActionFactory; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** * @param Product\Action\FullFactory $fullActionFactory * @param Product\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ public function __construct( Product\Action\FullFactory $fullActionFactory, Product\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry ) { $this->fullActionFactory = $fullActionFactory; $this->rowsActionFactory = $rowsActionFactory; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php index ef9def1354927..c8b79bc66877b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php @@ -7,13 +7,13 @@ class StoreGroup { - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ - public function __construct(\Magento\Indexer\Model\IndexerRegistry $indexerRegistry) + public function __construct(\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry) { $this->indexerRegistry = $indexerRegistry; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Processor.php index 704cfb685c287..612b8ac6d5476 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Processor.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Category\Product; -class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class Processor extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/AffectCache.php b/app/code/Magento/Catalog/Model/Indexer/Product/AffectCache.php index 5e997400ec23e..37cbca1907735 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/AffectCache.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/AffectCache.php @@ -12,26 +12,26 @@ class AffectCache { /** - * @var \Magento\Indexer\Model\CacheContext $context + * @var \Magento\Framework\Indexer\CacheContext $context */ protected $context; /** - * @param \Magento\Indexer\Model\CacheContext $context + * @param \Magento\Framework\Indexer\CacheContext $context */ public function __construct( - \Magento\Indexer\Model\CacheContext $context + \Magento\Framework\Indexer\CacheContext $context ) { $this->context = $context; } /** - * @param \Magento\Indexer\Model\ActionInterface $subject + * @param \Magento\Framework\Indexer\ActionInterface $subject * @param array $ids * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeExecute(\Magento\Indexer\Model\ActionInterface $subject, $ids) + public function beforeExecute(\Magento\Framework\Indexer\ActionInterface $subject, $ids) { $this->context->registerEntities(\Magento\Catalog\Model\Product::CACHE_TAG, $ids); return [$ids]; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category.php index f90f86f8f0bff..ed268cf8997f9 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Category.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category.php @@ -15,12 +15,12 @@ class Category extends \Magento\Catalog\Model\Indexer\Category\Product /** * @param \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory $fullActionFactory * @param Category\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ public function __construct( \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory $fullActionFactory, Category\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry ) { parent::__construct($fullActionFactory, $rowsActionFactory, $indexerRegistry); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Processor.php index e99442ef43fe3..dcefc5953cefd 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Processor.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Category; -class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class Processor extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php b/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php index 54ca94657d5e1..a87a4e5e82e6c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product; -class Eav implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Eav implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * @var \Magento\Catalog\Model\Indexer\Product\Eav\Action\Row diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Processor.php index 1799d549499fd..598d96d2f86ac 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Processor.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Eav; -class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class Processor extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php index 82a9203d9a328..d151b98af56f6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product; -class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Flat implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Action\Row diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php index e7181ba7098b4..0e0238b3a6dd5 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Flat; -class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class Processor extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID @@ -18,11 +18,11 @@ class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor protected $_state; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param State $state */ public function __construct( - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Catalog\Model\Indexer\Product\Flat\State $state ) { parent::__construct($indexerRegistry); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php index 1680f2d72e57a..4afcfcd52947a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php @@ -24,13 +24,13 @@ class State extends \Magento\Catalog\Model\Indexer\AbstractFlatState /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Catalog\Helper\Product\Flat\Indexer $flatIndexerHelper * @param bool $isAvailable */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Catalog\Helper\Product\Flat\Indexer $flatIndexerHelper, $isAvailable = false ) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php index fddf5015b841c..a0206fc2b4390 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php @@ -66,7 +66,7 @@ public function processValue() if ((bool)$this->getValue() != (bool)$this->getOldValue()) { if ((bool)$this->getValue()) { $this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID); - $this->indexerState->setStatus(\Magento\Indexer\Model\Indexer\State::STATUS_INVALID); + $this->indexerState->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->indexerState->save(); } else { $this->_productFlatIndexerProcessor->getIndexer()->setScheduled(false); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price.php index 8b060e4813a89..f8d80ad185e47 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product; -class Price implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Price implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Action\Row diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php index b22b4cc2c2561..68a7ff84a1a92 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php @@ -7,13 +7,13 @@ abstract class AbstractPlugin { - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ - public function __construct(\Magento\Indexer\Model\IndexerRegistry $indexerRegistry) + public function __construct(\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry) { $this->indexerRegistry = $indexerRegistry; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php index 4fa565b611041..e416fefb15cab 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Processor.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Price; -class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class Processor extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php index 596495c247e91..42e27c7bd3e0d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php @@ -10,14 +10,14 @@ */ class PriceScope extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data @@ -26,7 +26,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index d37dee90cbfa3..dd0f5ec4ead4f 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -216,7 +216,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements */ protected $_filesystem; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** @@ -344,7 +344,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements * @param Resource\Product\Collection $resourceCollection * @param \Magento\Framework\Data\CollectionFactory $collectionFactory * @param \Magento\Framework\Filesystem $filesystem - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param Indexer\Product\Price\Processor $productPriceIndexerProcessor * @param Indexer\Product\Eav\Processor $productEavIndexerProcessor @@ -383,7 +383,7 @@ public function __construct( Resource\Product\Collection $resourceCollection, \Magento\Framework\Data\CollectionFactory $collectionFactory, \Magento\Framework\Filesystem $filesystem, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor, diff --git a/app/code/Magento/Catalog/Model/Product/Action.php b/app/code/Magento/Catalog/Model/Product/Action.php index 3bc9a563dca08..b9ef8e4baa4a9 100644 --- a/app/code/Magento/Catalog/Model/Product/Action.php +++ b/app/code/Magento/Catalog/Model/Product/Action.php @@ -22,7 +22,7 @@ class Action extends \Magento\Framework\Model\AbstractModel */ protected $_productWebsiteFactory; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** @@ -39,7 +39,7 @@ class Action extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param WebsiteFactory $productWebsiteFactory - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -50,7 +50,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\Product\WebsiteFactory $productWebsiteFactory, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Eav\Model\Config $eavConfig, \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php index a6975725dfa8a..645bd4478b93f 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php @@ -82,7 +82,7 @@ class Flat extends \Magento\Indexer\Model\Resource\AbstractResource * Class constructor * * @param \Magento\Framework\Model\Resource\Db\Context $context - * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy + * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param CollectionFactory $categoryCollectionFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -92,7 +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\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, 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 606d91cf415fe..50e0a9c789ba8 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php @@ -23,13 +23,13 @@ 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\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param string $connectionName */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, - \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, $connectionName = null ) { 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 eb664cc8d7bf5..83041be40e9f9 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,14 +23,14 @@ 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\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param string $connectionName */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, - \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, $connectionName = null 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 1fc02a3f2fed7..804be08a5b521 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,7 +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\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper @@ -33,7 +33,7 @@ class Source extends AbstractEav */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, - \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Resource\Helper $resourceHelper, 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 a38e1787038e3..e1ff4568ae04f 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php @@ -45,7 +45,7 @@ class DefaultPrice 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\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Module\Manager $moduleManager @@ -53,7 +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\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Module\Manager $moduleManager, @@ -67,7 +67,7 @@ public function __construct( /** * Get Table strategy * - * @return \Magento\Indexer\Model\Indexer\Table\StrategyInterface + * @return \Magento\Framework\Indexer\Table\StrategyInterface */ public function getTableStrategy() { diff --git a/app/code/Magento/Catalog/Plugin/Model/Product/Action/UpdateAttributesFlushCache.php b/app/code/Magento/Catalog/Plugin/Model/Product/Action/UpdateAttributesFlushCache.php index 22133ccc921a1..37e418217f30c 100644 --- a/app/code/Magento/Catalog/Plugin/Model/Product/Action/UpdateAttributesFlushCache.php +++ b/app/code/Magento/Catalog/Plugin/Model/Product/Action/UpdateAttributesFlushCache.php @@ -7,7 +7,7 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Action; -use Magento\Indexer\Model\CacheContext; +use Magento\Framework\Indexer\CacheContext; use Magento\Framework\Event\ManagerInterface as EventManager; class UpdateAttributesFlushCache diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php index cf4fbe668a4fb..e8a165f8baac1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php @@ -61,10 +61,10 @@ class CategoryTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Catalog\Model\Indexer\Category\Flat\State|\PHPUnit_Framework_MockObject_MockObject */ protected $flatState; - /** @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $flatIndexer; - /** @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $productIndexer; /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator|\PHPUnit_Framework_MockObject_MockObject */ @@ -76,7 +76,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Model\Resource\AbstractResource|\PHPUnit_Framework_MockObject_MockObject */ protected $resource; - /** @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistry; /** @@ -140,8 +140,8 @@ protected function setUp() false ); $this->flatState = $this->getMock('Magento\Catalog\Model\Indexer\Category\Flat\State', [], [], '', false); - $this->flatIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); - $this->productIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); + $this->flatIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); + $this->productIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); $this->categoryUrlPathGenerator = $this->getMock( 'Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator', [], @@ -157,7 +157,7 @@ protected function setUp() '', false ); - $this->indexerRegistry = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); $this->metadataServiceMock = $this->getMock('\Magento\Catalog\Api\CategoryAttributeRepositoryInterface'); $this->attributeValueFactory = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/AffectCacheTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/AffectCacheTest.php index 5200af2d484a8..f7d937162e87a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/AffectCacheTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/AffectCacheTest.php @@ -16,12 +16,12 @@ class AffectCacheTest extends \PHPUnit_Framework_TestCase protected $plugin; /** - * @var \Magento\Indexer\Model\CacheContext|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; /** - * @var \Magento\Indexer\Model\ActionInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ActionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $subjectMock; @@ -30,9 +30,9 @@ class AffectCacheTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->subjectMock = $this->getMockForAbstractClass('Magento\Indexer\Model\ActionInterface', + $this->subjectMock = $this->getMockForAbstractClass('Magento\Framework\Indexer\ActionInterface', [], '', false, true, true, []); - $this->contextMock = $this->getMock('Magento\Indexer\Model\CacheContext', + $this->contextMock = $this->getMock('Magento\Framework\Indexer\CacheContext', [], [], '', false); $this->plugin = new \Magento\Catalog\Model\Indexer\Category\AffectCache($this->contextMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php index def1e5bf393f2..f0cca672ff9ac 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php @@ -10,7 +10,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -30,7 +30,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected $subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -47,7 +47,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -75,7 +75,13 @@ protected function setUp() return false; }; - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new StoreGroup($this->indexerRegistryMock, $this->stateMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php index 7847dd46f0047..dfe07e9870b63 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php @@ -10,7 +10,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -25,7 +25,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -42,7 +42,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -61,7 +61,13 @@ protected function setUp() return false; }; $this->subjectMock = $this->getMock('Magento\Store\Model\Resource\Store', [], [], '', false); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new StoreView($this->indexerRegistryMock, $this->stateMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php index d1504bd77dc8e..6b36ba41a5459 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/StateTest.php @@ -18,12 +18,12 @@ class StateTest extends \PHPUnit_Framework_TestCase protected $scopeConfigMock; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $flatIndexerMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -32,7 +32,7 @@ protected function setUp() $this->scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); $this->flatIndexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -41,7 +41,13 @@ protected function setUp() ['getId', 'getState', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); } public function testIsFlatEnabled() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php index cfc71fb65953d..3fc50823e08ec 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Flat/System/Config/ModeTest.php @@ -23,12 +23,12 @@ class ModeTest extends \PHPUnit_Framework_TestCase protected $indexerStateMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistry; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $flatIndexer; @@ -42,9 +42,9 @@ protected function setUp() '', false ); - $this->indexerRegistry = $this->getMock('Magento\Indexer\Model\IndexerRegistry', [], [], '', false); + $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); - $this->flatIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); + $this->flatIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php index 8dae8ec6e214d..124823fbd7ab0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/FlatTest.php @@ -23,12 +23,12 @@ class FlatTest extends \PHPUnit_Framework_TestCase protected $rowsMock; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -51,7 +51,7 @@ protected function setUp() ); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -60,7 +60,13 @@ protected function setUp() ['getId', 'load', 'isInvalid', 'isWorking', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat( $this->fullMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php index 8ccc466199bb5..aded427157724 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php @@ -10,7 +10,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -25,7 +25,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected $subject; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -37,7 +37,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -46,7 +46,13 @@ protected function setUp() ['getId', 'getState', '__wakeup'] ); $this->subject = $this->getMock('Magento\Store\Model\Resource\Group', [], [], '', false); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new StoreGroup($this->indexerRegistryMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php index f8bef7dd200da..1114bc4a8a838 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/Product/Plugin/StoreViewTest.php @@ -10,7 +10,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -25,7 +25,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -37,7 +37,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -46,7 +46,13 @@ protected function setUp() ['getId', 'getState', '__wakeup'] ); $this->subject = $this->getMock('Magento\Store\Model\Resource\Group', [], [], '', false); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new StoreView($this->indexerRegistryMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php index 92eaed39e9977..45b3b9fdb5d5e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php @@ -23,12 +23,12 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected $rowsMock; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -51,7 +51,7 @@ protected function setUp() ); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -60,7 +60,13 @@ protected function setUp() ['getId', 'load', 'isInvalid', 'isWorking', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new \Magento\Catalog\Model\Indexer\Category\Product( $this->fullMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/AffectCacheTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/AffectCacheTest.php index ed64b28b39e09..394237d8474b7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/AffectCacheTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/AffectCacheTest.php @@ -16,12 +16,12 @@ class AffectCacheTest extends \PHPUnit_Framework_TestCase protected $plugin; /** - * @var \Magento\Indexer\Model\CacheContext|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; /** - * @var \Magento\Indexer\Model\ActionInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ActionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $subjectMock; @@ -30,9 +30,9 @@ class AffectCacheTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->subjectMock = $this->getMockForAbstractClass('Magento\Indexer\Model\ActionInterface', + $this->subjectMock = $this->getMockForAbstractClass('Magento\Framework\Indexer\ActionInterface', [], '', false, true, true, []); - $this->contextMock = $this->getMock('Magento\Indexer\Model\CacheContext', + $this->contextMock = $this->getMock('Magento\Framework\Indexer\CacheContext', [], [], '', false); $this->plugin = new \Magento\Catalog\Model\Indexer\Product\AffectCache($this->contextMock); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php index e5f77d3e03c97..4429d6f5093aa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php @@ -23,12 +23,12 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected $rowsMock; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -51,7 +51,7 @@ protected function setUp() ); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -60,7 +60,13 @@ protected function setUp() ['getId', 'load', 'isInvalid', 'isWorking', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new \Magento\Catalog\Model\Indexer\Product\Category( $this->fullMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php index 3a93d36e0d292..ba7dc020a5576 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/ProcessorTest.php @@ -28,7 +28,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected $_stateMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -52,7 +52,13 @@ public function setUp() '', false ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->_model = $this->_objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Flat\Processor', [ 'indexerRegistry' => $this->indexerRegistryMock, 'state' => $this->_stateMock diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php index 95699536643f3..60d324c26f557 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/System/Config/ModeTest.php @@ -170,7 +170,7 @@ public function testProcessValueOff($oldValue, $value) $this->indexerStateMock->expects($this->never())->method('save'); $indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php index 3af8c6cba916c..f448c1f174053 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php @@ -26,7 +26,7 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase protected $_subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -46,7 +46,7 @@ public function setUp() false ); $indexerMock->expects($this->once())->method('invalidate'); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); $this->indexerRegistryMock->expects($this->once()) ->method('get') ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php index bced5a0626683..49dcd0ead296f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php @@ -23,7 +23,7 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase protected $_indexerMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -38,7 +38,13 @@ public function setUp() '', false ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); $registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php index c172b705c3e80..448f6d43f24c8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/ActionTest.php @@ -43,7 +43,7 @@ class ActionTest extends \PHPUnit_Framework_TestCase protected $eavAttribute; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -101,7 +101,13 @@ public function setUp() '', false ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index 9549a2bc97886..97f42ea1d09ab 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -44,7 +44,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected $stockItemFactoryMock; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $categoryIndexerMock; @@ -99,7 +99,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private $website; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -168,7 +168,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->categoryIndexerMock = $this->getMockForAbstractClass('\Magento\Indexer\Model\IndexerInterface'); + $this->categoryIndexerMock = $this->getMockForAbstractClass('\Magento\Framework\Indexer\IndexerInterface'); $this->moduleManager = $this->getMock( 'Magento\Framework\Module\Manager', @@ -269,7 +269,7 @@ public function setUp() $storeManager->expects($this->any()) ->method('getWebsite') ->will($this->returnValue($this->website)); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); $this->_catalogProduct = $this->getMock( diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php index 3d70aac87798a..7a0804081ac7f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/Product/Action/UpdateAttributesFlushCacheTest.php @@ -17,7 +17,7 @@ public function testAroundUpdateAttributes() $productActionMock = $this->getMock('Magento\Catalog\Model\Product\Action', [], [], '', false); - $cacheContextMock = $this->getMock('Magento\Indexer\Model\CacheContext', [], [], '', false); + $cacheContextMock = $this->getMock('Magento\Framework\Indexer\CacheContext', [], [], '', false); $cacheContextMock->expects($this->once()) ->method('registerEntities') ->with(Product::CACHE_TAG, $productIds); diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 9e71f84526077..e52c7c305a825 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -267,7 +267,7 @@ - Magento\Indexer\Model\IndexerInterface + Magento\Framework\Indexer\IndexerInterface diff --git a/app/code/Magento/Catalog/etc/indexer.xml b/app/code/Magento/Catalog/etc/indexer.xml index 0b2c706d94e6b..9d47564852fb7 100644 --- a/app/code/Magento/Catalog/etc/indexer.xml +++ b/app/code/Magento/Catalog/etc/indexer.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Product Flat Data Reorganize EAV product structure to flat structure diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index d188b9d3315fe..e9a3d4ef3af48 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -475,7 +475,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $dateTime; /** - * @var \Magento\Indexer\Model\IndexerRegistry + * @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; @@ -579,7 +579,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param DateTime $dateTime * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param Product\StoreResolver $storeResolver * @param Product\SkuProcessor $skuProcessor * @param Product\CategoryProcessor $categoryProcessor @@ -615,7 +615,7 @@ public function __construct( \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, DateTime $dateTime, \Psr\Log\LoggerInterface $logger, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, Product\StoreResolver $storeResolver, Product\SkuProcessor $skuProcessor, Product\CategoryProcessor $categoryProcessor, diff --git a/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php b/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php index 573130b8f6b9d..92601218057e5 100644 --- a/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php +++ b/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php @@ -27,7 +27,7 @@ public function afterImportSource(\Magento\ImportExport\Model\Import $subject, $ /** * Get price indexer * - * @return \Magento\Indexer\Model\IndexerInterface + * @return \Magento\Framework\Indexer\IndexerInterface */ protected function getPriceIndexer() { diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php index d9a7920de0e79..7161180b355b0 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php @@ -120,7 +120,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_localeDate; - /** @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistry; /** @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -271,7 +271,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->indexerRegistry = - $this->getMockBuilder('\Magento\Indexer\Model\IndexerRegistry') + $this->getMockBuilder('\Magento\Framework\Indexer\IndexerRegistry') ->disableOriginalConstructor() ->getMock(); $this->_logger = diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php index 7a3de72fa291e..facc5632db4b3 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php @@ -23,7 +23,7 @@ class ImportTest extends \PHPUnit_Framework_TestCase protected $_indexerMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -39,7 +39,7 @@ public function setUp() false ); $this->indexerRegistryMock = $this->getMock( - 'Magento\Indexer\Model\IndexerRegistry', + 'Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 8f11d20528b36..9a6011863f5fa 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -6,7 +6,6 @@ "magento/module-catalog": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", "magento/module-import-export": "1.0.0-beta", - "magento/module-indexer": "1.0.0-beta", "magento/module-store": "1.0.0-beta", "magento/module-tax": "1.0.0-beta", "magento/module-catalog-inventory": "1.0.0-beta", diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php index 0bbbd6cb544b3..b17fd8eba2d59 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php @@ -8,7 +8,7 @@ namespace Magento\CatalogInventory\Model\Indexer; -class Stock implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Stock implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * @var \Magento\CatalogInventory\Model\Indexer\Stock\Action\Row diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock/AbstractAction.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock/AbstractAction.php index a4bb358e3b5dd..7faea3bfcc83c 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock/AbstractAction.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock/AbstractAction.php @@ -56,7 +56,7 @@ abstract class AbstractAction protected $_isNeedUseIdxTable = false; /** - * @var \Magento\Indexer\Model\CacheContext + * @var \Magento\Framework\Indexer\CacheContext */ private $cacheContext; @@ -70,14 +70,14 @@ abstract class AbstractAction * @param Resource $resource * @param \Magento\CatalogInventory\Model\Resource\Indexer\StockFactory $indexerFactory * @param \Magento\Catalog\Model\Product\Type $catalogProductType - * @param \Magento\Indexer\Model\CacheContext $cacheContext + * @param \Magento\Framework\Indexer\CacheContext $cacheContext * @param \Magento\Framework\Event\ManagerInterface $eventManager */ public function __construct( Resource $resource, \Magento\CatalogInventory\Model\Resource\Indexer\StockFactory $indexerFactory, \Magento\Catalog\Model\Product\Type $catalogProductType, - \Magento\Indexer\Model\CacheContext $cacheContext, + \Magento\Framework\Indexer\CacheContext $cacheContext, \Magento\Framework\Event\ManagerInterface $eventManager ) { $this->_resource = $resource; diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock/Processor.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock/Processor.php index b4432bcd6554e..05ebd1ba89daa 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock/Processor.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock/Processor.php @@ -8,7 +8,7 @@ namespace Magento\CatalogInventory\Model\Indexer\Stock; -class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class Processor extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID 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 08a751fd77f61..c9d979962eb25 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php @@ -36,14 +36,14 @@ 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\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param string $connectionName */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, - \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, $connectionName = null diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php index d9ce970227043..096919b3dc9d4 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php @@ -17,7 +17,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_indexerMock; diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 35cb2e22f35f3..5e222e8917bf0 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -7,7 +7,6 @@ "magento/module-store": "1.0.0-beta", "magento/module-catalog": "1.0.0-beta", "magento/module-customer": "1.0.0-beta", - "magento/module-indexer": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", "magento/module-quote": "1.0.0-beta", "magento/framework": "1.0.0-beta", diff --git a/app/code/Magento/CatalogInventory/etc/indexer.xml b/app/code/Magento/CatalogInventory/etc/indexer.xml index 3ee2f839950d1..80b1c5f4faa8e 100644 --- a/app/code/Magento/CatalogInventory/etc/indexer.xml +++ b/app/code/Magento/CatalogInventory/etc/indexer.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Stock Index stock diff --git a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php index 74f2f984cdd19..acb979d5205a3 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php @@ -6,7 +6,7 @@ namespace Magento\CatalogRule\Model\Indexer; use Magento\Framework\Mview\ActionInterface as MviewActionInterface; -use Magento\Indexer\Model\ActionInterface as IndexerActionInterface; +use Magento\Framework\Indexer\ActionInterface as IndexerActionInterface; use Magento\Framework\DataObject\IdentityInterface as IdentityInterface; abstract class AbstractIndexer implements IndexerActionInterface, MviewActionInterface, IdentityInterface diff --git a/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php b/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php index c930f7cf21bb3..912b900b47569 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Model\Indexer\Product; -use Magento\Indexer\Model\Indexer\AbstractProcessor; +use Magento\Framework\Indexer\AbstractProcessor; class ProductRuleProcessor extends AbstractProcessor { diff --git a/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php b/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php index 4eab6e156aa83..27319c5422a20 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Model\Indexer\Rule; -use Magento\Indexer\Model\Indexer\AbstractProcessor; +use Magento\Framework\Indexer\AbstractProcessor; class RuleProductProcessor extends AbstractProcessor { diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php index 285429e8af872..dbf6958530ac8 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php @@ -207,7 +207,7 @@ public function dataProviderCallbackValidateProduct() */ public function testAfterDelete() { - $indexer = $this->getMock('\Magento\Indexer\Model\IndexerInterface'); + $indexer = $this->getMock('\Magento\Framework\Indexer\IndexerInterface'); $indexer->expects($this->once())->method('invalidate'); $this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer)); $this->rule->afterDelete(); @@ -221,7 +221,7 @@ public function testAfterDelete() public function testAfterUpdate() { $this->rule->isObjectNew(false); - $indexer = $this->getMock('\Magento\Indexer\Model\IndexerInterface'); + $indexer = $this->getMock('\Magento\Framework\Indexer\IndexerInterface'); $indexer->expects($this->once())->method('invalidate'); $this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer)); $this->rule->afterSave(); @@ -242,7 +242,7 @@ public function testIsRuleBehaviorChanged($dataArray, $originDataArray, $isObjec { $this->rule->setData('website_ids', []); $this->rule->isObjectNew($isObjectNew); - $indexer = $this->getMock('\Magento\Indexer\Model\IndexerInterface'); + $indexer = $this->getMock('\Magento\Framework\Indexer\IndexerInterface'); $indexer->expects($this->any())->method('invalidate'); $this->_ruleProductProcessor->expects($this->any())->method('getIndexer')->will($this->returnValue($indexer)); diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 6984fa5d748fc..fc76a727f7fee 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -9,7 +9,6 @@ "magento/module-customer": "1.0.0-beta", "magento/module-backend": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", - "magento/module-indexer": "1.0.0-beta", "magento/module-import-export": "1.0.0-beta", "magento/framework": "1.0.0-beta", "magento/magento-composer-installer": "*" diff --git a/app/code/Magento/CatalogRule/etc/indexer.xml b/app/code/Magento/CatalogRule/etc/indexer.xml index 7d59dfb6d8391..b957d9c664004 100644 --- a/app/code/Magento/CatalogRule/etc/indexer.xml +++ b/app/code/Magento/CatalogRule/etc/indexer.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Catalog Rule Product Indexed rule/product association diff --git a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php index eb1f48340c3ff..12cc44bc6c201 100644 --- a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php @@ -10,14 +10,14 @@ */ class Engine extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data @@ -26,7 +26,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index 1e043eda14bbf..385758d0abf3c 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -11,7 +11,7 @@ use Magento\Framework\Search\Request\DimensionFactory; use Magento\Store\Model\StoreManagerInterface; -class Fulltext implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\Mview\ActionInterface +class Fulltext implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { /** * Indexer ID in configuration diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php index fd56848f0ef04..d5db695199086 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php @@ -107,7 +107,7 @@ class Full protected $engine; /** - * @var \Magento\Framework\IndexerInterface + * @var \Magento\Framework\Indexer\SaveHandler\IndexerInterface */ protected $indexHandler; @@ -168,7 +168,7 @@ class Full * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource * @param \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory - * @param \Magento\Indexer\Model\ConfigInterface $indexerConfig + * @param \Magento\Framework\Indexer\ConfigInterface $indexerConfig * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -188,7 +188,7 @@ public function __construct( \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\CatalogSearch\Model\Resource\Fulltext $fulltextResource, \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory, - \Magento\Indexer\Model\ConfigInterface $indexerConfig + \Magento\Framework\Indexer\ConfigInterface $indexerConfig ) { $this->resource = $resource; $this->connection = $resource->getConnection(); diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php index 586b386257c40..921be59221e1a 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php @@ -9,14 +9,14 @@ abstract class AbstractPlugin { - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ public function __construct( - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry ) { $this->indexerRegistry = $indexerRegistry; } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php index 8aaf8e1e6b41d..3be577512eaab 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php @@ -15,11 +15,11 @@ class Attribute extends AbstractPlugin private $config; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Search\Request\Config $config */ public function __construct( - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Search\Request\Config $config ) { parent::__construct($indexerRegistry); // TODO: Change the autogenerated stub diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php index f429417a5be31..a74de05ce636e 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php @@ -8,7 +8,7 @@ use Magento\CatalogSearch\Model\Indexer\Fulltext as FulltextIndexer; use Magento\CatalogSearch\Model\Indexer\IndexerHandlerFactory; use Magento\Framework\Search\Request\DimensionFactory; -use Magento\Indexer\Model\ConfigInterface; +use Magento\Framework\Indexer\ConfigInterface; class Store { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php index 47f0e9a002923..8f18d48b9db8a 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php @@ -10,9 +10,10 @@ use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Search\Request\Dimension; -use Magento\Indexer\Model\ScopeResolver\IndexScopeResolver; +use Magento\Framework\Indexer\IndexStructureInterface; +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; -class IndexStructure +class IndexStructure implements IndexStructureInterface { /** * @var Resource @@ -40,7 +41,7 @@ public function __construct( * @param Dimension[] $dimensions * @return void */ - public function delete($index, array $dimensions) + public function delete($index, array $dimensions = []) { $tableName = $this->indexScopeResolver->resolve($index, $dimensions); if ($this->resource->getConnection()->isTableExists($tableName)) { @@ -50,10 +51,12 @@ public function delete($index, array $dimensions) /** * @param string $index - * @param Dimension[] $dimensions + * @param array $fields + * @param array $dimensions + * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @return void */ - public function create($index, array $dimensions) + public function create($index, array $fields, array $dimensions = []) { $this->createFulltextIndex($this->indexScopeResolver->resolve($index, $dimensions)); } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php index 862f23b1cba5c..affc5787532c7 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php @@ -8,11 +8,11 @@ use Magento\Eav\Model\Config; use Magento\Framework\App\Resource; use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\IndexerInterface; +use Magento\Framework\Indexer\SaveHandler\IndexerInterface; use Magento\Framework\Search\Request\Dimension; use Magento\Framework\Search\Request\IndexScopeResolverInterface; -use Magento\Indexer\Model\SaveHandler\Batch; -use Magento\Indexer\Model\ScopeResolver\IndexScopeResolver; +use Magento\Framework\Indexer\SaveHandler\Batch; +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; class IndexerHandler implements IndexerInterface { @@ -61,7 +61,7 @@ class IndexerHandler implements IndexerInterface * @param Resource|Resource $resource * @param Config $eavConfig * @param Batch $batch - * @param \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver $indexScopeResolver + * @param \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver $indexScopeResolver * @param array $data * @param int $batchSize */ @@ -113,7 +113,7 @@ public function deleteIndex($dimensions, \Traversable $documents) public function cleanIndex($dimensions) { $this->indexStructure->delete($this->getIndexName(), $dimensions); - $this->indexStructure->create($this->getIndexName(), $dimensions); + $this->indexStructure->create($this->getIndexName(), [], $dimensions); } /** diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php index d680cffc29ea9..9793bbcbc2c22 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php @@ -6,7 +6,7 @@ namespace Magento\CatalogSearch\Model\Indexer; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\IndexerInterface; +use Magento\Framework\Indexer\SaveHandler\IndexerInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Store\Model\ScopeInterface; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php b/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php index 03f0fb14eadce..13fdbde76c11f 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php @@ -3,13 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\CatalogSearch\Model\Indexer\Mview; - use Magento\CatalogSearch\Model\Indexer\Fulltext; use Magento\Framework\Mview\ActionInterface; -use Magento\Indexer\Model\IndexerInterfaceFactory; +use Magento\Framework\Indexer\IndexerInterfaceFactory; class Action implements ActionInterface { @@ -35,7 +33,7 @@ public function __construct(IndexerInterfaceFactory $indexerFactory) */ public function execute($ids) { - /** @var \Magento\Indexer\Model\IndexerInterface $indexer */ + /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ $indexer = $this->indexerFactory->create()->load(Fulltext::INDEXER_ID); $indexer->reindexList($ids); } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php b/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php index 21b14e6f0ee30..e595fe239b494 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php @@ -10,7 +10,7 @@ use Magento\Eav\Model\Config; use Magento\Eav\Model\Entity\Attribute; -class ProductFieldset implements \Magento\Indexer\Model\FieldsetInterface +class ProductFieldset implements \Magento\Framework\Indexer\FieldsetInterface { /** * @var Config @@ -27,24 +27,16 @@ class ProductFieldset implements \Magento\Indexer\Model\FieldsetInterface */ private $searchableAttributes; - /** - * @var string - */ - private $defaultHandler; - /** * @param Config $eavConfig * @param CollectionFactory $collectionFactory - * @param string $defaultHandler */ public function __construct( Config $eavConfig, - CollectionFactory $collectionFactory, - $defaultHandler = 'Magento\Indexer\Model\Handler\DefaultHandler' + CollectionFactory $collectionFactory ) { $this->eavConfig = $eavConfig; $this->collectionFactory = $collectionFactory; - $this->defaultHandler = $defaultHandler; } /** @@ -62,14 +54,6 @@ public function addDynamicData(array $data) return $data; } - /** - * {@inheritdoc} - */ - public function getDefaultHandler() - { - return $this->defaultHandler; - } - /** * Retrieve searchable attributes * diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Engine.php b/app/code/Magento/CatalogSearch/Model/Resource/Engine.php index a3c39528a1d0f..86a5a16578f85 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Engine.php @@ -27,7 +27,7 @@ class Engine implements EngineInterface protected $catalogProductVisibility; /** - * @var \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver + * @var \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver */ private $indexScopeResolver; @@ -35,11 +35,11 @@ class Engine implements EngineInterface * Construct * * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility - * @param \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver $indexScopeResolver + * @param \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver $indexScopeResolver */ public function __construct( \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver $indexScopeResolver + \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver $indexScopeResolver ) { $this->catalogProductVisibility = $catalogProductVisibility; $this->indexScopeResolver = $indexScopeResolver; diff --git a/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php b/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php index 7eeafda0441c5..4e35ffdde8e22 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php @@ -15,7 +15,7 @@ use Magento\Framework\Search\Request\QueryInterface; use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface; use Magento\Framework\Search\RequestInterface; -use Magento\Indexer\Model\ScopeResolver\IndexScopeResolver; +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; diff --git a/app/code/Magento/CatalogSearch/Setup/InstallData.php b/app/code/Magento/CatalogSearch/Setup/InstallData.php index 8c758d2535440..3779dab0fa4ee 100644 --- a/app/code/Magento/CatalogSearch/Setup/InstallData.php +++ b/app/code/Magento/CatalogSearch/Setup/InstallData.php @@ -3,14 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\CatalogSearch\Setup; - use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; -use Magento\Indexer\Model\IndexerInterfaceFactory; +use Magento\Framework\Indexer\IndexerInterfaceFactory; use Magento\Catalog\Api\ProductAttributeRepositoryInterface; class InstallData implements InstallDataInterface @@ -49,7 +47,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface /** * @param string $indexerId - * @return \Magento\Indexer\Model\IndexerInterface + * @return \Magento\Framework\Indexer\IndexerInterface */ private function getIndexer($indexerId) { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/AttributeTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/AttributeTest.php index f6dd67b848ec1..38d6089b6910e 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/AttributeTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/AttributeTest.php @@ -10,7 +10,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -20,7 +20,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected $subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -33,7 +33,7 @@ protected function setUp() { $this->subjectMock = $this->getMock('Magento\Catalog\Model\Resource\Attribute', [], [], '', false); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -41,7 +41,13 @@ protected function setUp() true, ['getId', 'getState', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->config = $this->getMockBuilder(\Magento\Framework\Search\Request\Config::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php index b882cb8718aa2..1f4684a056df7 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php @@ -8,11 +8,10 @@ use \Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product\Action; - class ActionTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -22,7 +21,7 @@ class ActionTest extends \PHPUnit_Framework_TestCase protected $subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -36,7 +35,7 @@ protected function setUp() $this->subjectMock = $this->getMock('Magento\Catalog\Model\Product\Action', [], [], '', false); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -44,7 +43,13 @@ protected function setUp() true, ['getId', 'getState', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new Action($this->indexerRegistryMock); } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/ProductTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/ProductTest.php index bccbe9a59ce8b..49f37b71f1a10 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/ProductTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/ProductTest.php @@ -8,11 +8,10 @@ use \Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product; - class ProductTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -22,7 +21,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected $subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -36,7 +35,7 @@ protected function setUp() $this->subjectMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -45,7 +44,13 @@ protected function setUp() ['getId', 'getState', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new Product($this->indexerRegistryMock); } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php index 36ba1e0c83435..96176e560ebc5 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php @@ -10,7 +10,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -20,7 +20,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected $subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -33,7 +33,7 @@ protected function setUp() { $this->subjectMock = $this->getMock('Magento\Store\Model\Resource\Group', [], [], '', false); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -41,7 +41,13 @@ protected function setUp() true, ['getId', 'getState', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new Group($this->indexerRegistryMock); } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php index 7f2dddf3e3d46..9ca5dc2c13e0b 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php @@ -10,7 +10,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Indexer\IndexerInterface */ protected $indexerMock; @@ -20,7 +20,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected $subjectMock; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -33,7 +33,7 @@ protected function setUp() { $this->subjectMock = $this->getMock('Magento\Store\Model\Resource\Store', [], [], '', false); $this->indexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', [], '', false, @@ -41,7 +41,13 @@ protected function setUp() true, ['getId', 'getState', '__wakeup'] ); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock( + 'Magento\Framework\Indexer\IndexerRegistry', + ['get'], + [], + '', + false + ); $this->model = new View($this->indexerRegistryMock); } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php index e5f7b7399f58f..8eab58800df3f 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php @@ -83,7 +83,7 @@ protected function setUp() $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')->getMock(); - $this->scopeResolver = $this->getMockBuilder('\Magento\Indexer\Model\ScopeResolver\IndexScopeResolver') + $this->scopeResolver = $this->getMockBuilder('\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver') ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php index 040e80c7a005d..8b7bba0b04a4d 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/Indexer/IndexStructureTest.php @@ -11,12 +11,12 @@ use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** - * Test for \Magento\Indexer\Model\IndexStructure + * Test for \Magento\Framework\Indexer\IndexStructure */ class IndexStructureTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject */ private $indexScopeResolver; /** @@ -45,11 +45,7 @@ protected function setUp() $this->resource->expects($this->atLeastOnce()) ->method('getConnection') ->willReturn($this->connection); - $this->indexScopeResolver = $this->getMockBuilder('\Magento\Indexer\Model\ScopeResolver\IndexScopeResolver') - ->setMethods(['resolve']) - ->disableOriginalConstructor() - ->getMock(); - $this->flatScopeResolver = $this->getMockBuilder('\Magento\Indexer\Model\ScopeResolver\FlatScopeResolver') + $this->indexScopeResolver = $this->getMockBuilder('\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver') ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMock(); @@ -103,9 +99,9 @@ public function testCreateWithEmptyFields() ->method('resolve') ->with($index, $dimensions) ->willReturn($expectedTable); - $position = $this->mockFulltextTable($position, $expectedTable, true); + $this->mockFulltextTable($position, $expectedTable, true); - $this->target->create($index, $dimensions); + $this->target->create($index, [], $dimensions); } /** diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index fd495276886b8..31a8a1a8abc71 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -8,7 +8,6 @@ "magento/module-search": "1.0.0-beta", "magento/module-customer": "1.0.0-beta", "magento/module-directory": "1.0.0-beta", - "magento/module-indexer": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", "magento/module-backend": "1.0.0-beta", "magento/module-theme": "1.0.0-beta", diff --git a/app/code/Magento/CatalogSearch/etc/indexer.xml b/app/code/Magento/CatalogSearch/etc/indexer.xml index 3efa7c7c2e401..e86e606ea201c 100644 --- a/app/code/Magento/CatalogSearch/etc/indexer.xml +++ b/app/code/Magento/CatalogSearch/etc/indexer.xml @@ -5,9 +5,12 @@ * See COPYING.txt for license details. */ --> - + Catalog Search Rebuild Catalog product fulltext search index + + + diff --git a/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php b/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php index 427dbe5f1b67a..7d8193c4bab99 100644 --- a/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php +++ b/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php @@ -31,7 +31,8 @@ class Collection extends BlockCollection implements SearchResultInterface * @param string $resourceModel * @param string $model * @param string|null $connection - * @param \Magento\Framework\Model\Resource\Db\AbstractDb|null $resource + * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( diff --git a/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php index f2df536005439..5e3cb9254b28e 100644 --- a/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php +++ b/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php @@ -33,6 +33,7 @@ class Collection extends PageCollection implements SearchResultInterface * @param string $model * @param null $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb|null $resource + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( diff --git a/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php b/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php new file mode 100644 index 0000000000000..ceeb4cff8c4b6 --- /dev/null +++ b/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php @@ -0,0 +1,14 @@ + - */ -namespace Magento\Customer\Block\Adminhtml; - -class Customer extends \Magento\Backend\Block\Widget\Grid\Container -{ - /** - * Constructor - * - * @return void - */ - protected function _construct() - { - $this->_controller = 'adminhtml'; - $this->_blockGroup = 'Magento_Customer'; - $this->_headerText = __('Customers'); - $this->_addButtonLabel = __('Add New Customer'); - parent::_construct(); - } -} diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php new file mode 100644 index 0000000000000..94fd533646ebe --- /dev/null +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php @@ -0,0 +1,95 @@ +filter = $filter; + $this->collectionFactory = $collectionFactory; + } + + /** + * Execute action + * + * @return \Magento\Backend\Model\View\Result\Redirect + * @throws \Magento\Framework\Exception\LocalizedException|\Exception + */ + public function execute() + { + try { + $collection = $this->filter->getCollection($this->collectionFactory->create()); + return $this->massAction($collection); + } catch (\Exception $e) { + $this->messageManager->addError($e->getMessage()); + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + return $resultRedirect->setPath($this->redirectUrl); + } + } + + /** + * Check the permission to Manage Customers + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magento_Customer::manage'); + } + + /** + * Return component referer url + * TODO: Technical dept referer url should be implement as a part of Action configuration in in appropriate way + * + * @return null|string + */ + protected function getComponentRefererUrl() + { + return $this->filter->getComponentRefererUrl()?: 'customer/*/index'; + } + + /** + * Execute action to collection items + * + * @param AbstractCollection $collection + * @return ResponseInterface|ResultInterface + */ + abstract protected function massAction(AbstractCollection $collection); +} diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Grid.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Grid.php deleted file mode 100644 index e5839fccd0e92..0000000000000 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Grid.php +++ /dev/null @@ -1,20 +0,0 @@ -resultLayoutFactory->create(); - return $resultLayout; - } -} diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/MassDelete.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/MassDelete.php index 0f5a813facadd..443cf7c72a5e4 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/MassDelete.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/MassDelete.php @@ -5,27 +5,58 @@ */ namespace Magento\Customer\Controller\Adminhtml\Index; -class MassDelete extends \Magento\Customer\Controller\Adminhtml\Index +use Magento\Backend\App\Action\Context; +use Magento\Customer\Model\Resource\Customer\CollectionFactory; +use Magento\Eav\Model\Entity\Collection\AbstractCollection; +use Magento\Ui\Component\MassAction\Filter; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Controller\ResultFactory; + +/** + * Class MassDelete + */ +class MassDelete extends AbstractMassAction { /** - * Customer mass delete action - * + * @var CustomerRepositoryInterface + */ + protected $customerRepository; + + /** + * @param Context $context + * @param Filter $filter + * @param CollectionFactory $collectionFactory + * @param CustomerRepositoryInterface $customerRepository + */ + public function __construct( + Context $context, + Filter $filter, + CollectionFactory $collectionFactory, + CustomerRepositoryInterface $customerRepository + ) { + parent::__construct($context, $filter, $collectionFactory); + $this->customerRepository = $customerRepository; + } + + /** + * @param AbstractCollection $collection * @return \Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $customerIds = $this->getRequest()->getParam('customer'); - $customersDeleted = $this->actUponMultipleCustomers( - function ($customerId) { - $this->_customerRepository->deleteById($customerId); - }, - $customerIds - ); + $customersDeleted = 0; + foreach ($collection->getAllIds() as $customerId) { + $this->customerRepository->deleteById($customerId); + $customersDeleted++; + } + if ($customersDeleted) { $this->messageManager->addSuccess(__('A total of %1 record(s) were deleted.', $customersDeleted)); } - $resultRedirect = $this->resultRedirectFactory->create(); - $resultRedirect->setPath('customer/*/index'); + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + $resultRedirect->setPath($this->getComponentRefererUrl()); + return $resultRedirect; } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/MassSubscribe.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/MassSubscribe.php index 55d165504c551..0ba982ebbfa2e 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/MassSubscribe.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/MassSubscribe.php @@ -5,29 +5,71 @@ */ namespace Magento\Customer\Controller\Adminhtml\Index; -class MassSubscribe extends \Magento\Customer\Controller\Adminhtml\Index +use Magento\Backend\App\Action\Context; +use Magento\Ui\Component\MassAction\Filter; +use Magento\Customer\Model\Resource\Customer\CollectionFactory; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Newsletter\Model\SubscriberFactory; +use Magento\Eav\Model\Entity\Collection\AbstractCollection; +use Magento\Framework\Controller\ResultFactory; + +/** + * Class MassSubscribe + */ +class MassSubscribe extends AbstractMassAction { + /** + * @var CustomerRepositoryInterface + */ + protected $customerRepository; + + /** + * @var SubscriberFactory + */ + protected $subscriberFactory; + + /** + * @param Context $context + * @param Filter $filter + * @param CollectionFactory $collectionFactory + * @param CustomerRepositoryInterface $customerRepository + * @param SubscriberFactory $subscriberFactory + */ + public function __construct( + Context $context, + Filter $filter, + CollectionFactory $collectionFactory, + CustomerRepositoryInterface $customerRepository, + SubscriberFactory $subscriberFactory + ) { + parent::__construct($context, $filter, $collectionFactory); + $this->customerRepository = $customerRepository; + $this->subscriberFactory = $subscriberFactory; + } + /** * Customer mass subscribe action * + * @param AbstractCollection $collection * @return \Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $customerIds = $this->getRequest()->getParam('customer'); - $customersUpdated = $this->actUponMultipleCustomers( - function ($customerId) { - // Verify customer exists - $this->_customerRepository->getById($customerId); - $this->_subscriberFactory->create()->subscribeCustomerById($customerId); - }, - $customerIds - ); + $customersUpdated = 0; + foreach ($collection->getAllIds() as $customerId) { + // Verify customer exists + $this->customerRepository->getById($customerId); + $this->subscriberFactory->create()->subscribeCustomerById($customerId); + $customersUpdated++; + } + if ($customersUpdated) { $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', $customersUpdated)); } - $resultRedirect = $this->resultRedirectFactory->create(); - $resultRedirect->setPath('customer/*/index'); + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + $resultRedirect->setPath($this->getComponentRefererUrl()); + return $resultRedirect; } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/MassUnsubscribe.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/MassUnsubscribe.php index abfc94844b33d..56f5c054fa6f6 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/MassUnsubscribe.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/MassUnsubscribe.php @@ -5,29 +5,71 @@ */ namespace Magento\Customer\Controller\Adminhtml\Index; -class MassUnsubscribe extends \Magento\Customer\Controller\Adminhtml\Index +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Controller\ResultFactory; +use Magento\Backend\App\Action\Context; +use Magento\Newsletter\Model\SubscriberFactory; +use Magento\Ui\Component\MassAction\Filter; +use Magento\Customer\Model\Resource\Customer\CollectionFactory; +use Magento\Eav\Model\Entity\Collection\AbstractCollection; + +/** + * Class MassUnsubscribe + */ +class MassUnsubscribe extends AbstractMassAction { + /** + * @var CustomerRepositoryInterface + */ + protected $customerRepository; + + /** + * @var SubscriberFactory + */ + protected $subscriberFactory; + + /** + * @param Context $context + * @param Filter $filter + * @param CollectionFactory $collectionFactory + * @param CustomerRepositoryInterface $customerRepository + * @param SubscriberFactory $subscriberFactory + */ + public function __construct( + Context $context, + Filter $filter, + CollectionFactory $collectionFactory, + CustomerRepositoryInterface $customerRepository, + SubscriberFactory $subscriberFactory + ) { + parent::__construct($context, $filter, $collectionFactory); + $this->customerRepository = $customerRepository; + $this->subscriberFactory = $subscriberFactory; + } + /** * Customer mass unsubscribe action * + * @param AbstractCollection $collection * @return \Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $customerIds = $this->getRequest()->getParam('customer'); - $customersUpdated = $this->actUponMultipleCustomers( - function ($customerId) { - // Verify customer exists - $this->_customerRepository->getById($customerId); - $this->_subscriberFactory->create()->unsubscribeCustomerById($customerId); - }, - $customerIds - ); + $customersUpdated = 0; + foreach ($collection->getAllIds() as $customerId) { + // Verify customer exists + $this->customerRepository->getById($customerId); + $this->subscriberFactory->create()->unsubscribeCustomerById($customerId); + $customersUpdated++; + } + if ($customersUpdated) { $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', $customersUpdated)); } - $resultRedirect = $this->resultRedirectFactory->create(); - $resultRedirect->setPath('customer/*/index'); + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + $resultRedirect->setPath($this->getComponentRefererUrl()); + return $resultRedirect; } } diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index be22772a636b8..c80b2aba4be32 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -9,6 +9,7 @@ use Magento\Customer\Api\Data\AddressInterfaceFactory; use Magento\Customer\Api\Data\AddressInterface; use Magento\Customer\Api\Data\RegionInterfaceFactory; +use Magento\Framework\Indexer\StateInterface; /** * Customer address model @@ -41,6 +42,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress */ protected $dataObjectHelper; + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ + protected $indexerRegistry; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -57,9 +63,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param CustomerFactory $customerFactory * @param \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor - * @param \Magento\Framework\Model\Resource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Model\Resource\AbstractResource|null $resource + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -78,12 +86,14 @@ public function __construct( \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, CustomerFactory $customerFactory, \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->dataProcessor = $dataProcessor; $this->_customerFactory = $customerFactory; + $this->indexerRegistry = $indexerRegistry; parent::__construct( $context, $registry, @@ -300,4 +310,41 @@ public function getEntityTypeId() { return $this->getEntityType()->getId(); } + + /** + * Processing object after save data + * + * @return $this + */ + public function afterSave() + { + $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); + if ($indexer->getState()->getStatus() == StateInterface::STATUS_VALID) { + $this->_getResource()->addCommitCallback([$this, 'reindex']); + } + return parent::afterSave(); + } + + /** + * Init indexing process after customer delete + * + * @return \Magento\Framework\Model\AbstractModel + */ + public function afterDeleteCommit() + { + $this->reindex(); + return parent::afterDeleteCommit(); + } + + /** + * Init indexing process after customer save + * + * @return void + */ + public function reindex() + { + /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ + $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); + $indexer->reindexRow($this->getCustomerId()); + } } diff --git a/app/code/Magento/Customer/Model/Attribute.php b/app/code/Magento/Customer/Model/Attribute.php index cf87d2683af47..ebb6d54bce354 100644 --- a/app/code/Magento/Customer/Model/Attribute.php +++ b/app/code/Magento/Customer/Model/Attribute.php @@ -5,10 +5,15 @@ */ namespace Magento\Customer\Model; +use Magento\Framework\Api\AttributeValueFactory; +use Magento\Catalog\Api\Data\EavAttributeInterface; +use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface; + /** * Customer attribute model * * @method int getSortOrder() + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Attribute extends \Magento\Eav\Model\Attribute { @@ -31,6 +36,81 @@ class Attribute extends \Magento\Eav\Model\Attribute */ protected $_eventObject = 'attribute'; + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ + protected $indexerRegistry; + + /** + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Eav\Model\Config $eavConfig + * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Eav\Model\Resource\Helper $resourceHelper + * @param \Magento\Framework\Validator\UniversalFactory $universalFactory + * @param \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory $optionDataFactory + * @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor + * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Catalog\Model\Product\ReservedAttributeList $reservedAttributeList + * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param DateTimeFormatterInterface $dateTimeFormatter + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Model\Resource\AbstractResource|null $resource + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection + * @param array $data + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + */ + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + AttributeValueFactory $customAttributeFactory, + \Magento\Eav\Model\Config $eavConfig, + \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Eav\Model\Resource\Helper $resourceHelper, + \Magento\Framework\Validator\UniversalFactory $universalFactory, + \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory $optionDataFactory, + \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, + \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Catalog\Model\Product\ReservedAttributeList $reservedAttributeList, + \Magento\Framework\Locale\ResolverInterface $localeResolver, + DateTimeFormatterInterface $dateTimeFormatter, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, + array $data = [] + ) { + $this->indexerRegistry = $indexerRegistry; + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $eavConfig, + $eavTypeFactory, + $storeManager, + $resourceHelper, + $universalFactory, + $optionDataFactory, + $dataObjectProcessor, + $dataObjectHelper, + $localeDate, + $reservedAttributeList, + $localeResolver, + $dateTimeFormatter, + $resource, + $resourceCollection, + $data + ); + } + /** * Init resource model * @@ -40,4 +120,65 @@ protected function _construct() { $this->_init('Magento\Customer\Model\Resource\Attribute'); } + + /** + * Processing object after save data + * + * @return $this + */ + public function afterSave() + { + if ($this->isObjectNew() && (bool)$this->getData(EavAttributeInterface::IS_USED_IN_GRID)) { + $this->_getResource()->addCommitCallback([$this, 'invalidate']); + } elseif (!$this->isObjectNew() && $this->dataHasChangedFor(EavAttributeInterface::IS_USED_IN_GRID)) { + $this->_getResource()->addCommitCallback([$this, 'invalidate']); + } + return parent::afterSave(); + } + + /** + * Init indexing process after customer delete + * + * @return \Magento\Framework\Model\AbstractModel + */ + public function afterDeleteCommit() + { + if ($this->getData(EavAttributeInterface::IS_USED_IN_GRID) == true) { + $this->invalidate(); + } + return parent::afterDeleteCommit(); + } + + /** + * Init indexing process after customer save + * + * @return void + */ + public function invalidate() + { + /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ + $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); + $indexer->invalidate(); + } + + /** + * Check whether attribute is searchable in admin grid and it is allowed + * + * @return bool + */ + public function canBeSearchableInGrid() + { + return $this->getData('is_searchable_in_grid') && in_array($this->getFrontendInput(), ['text', 'textarea']); + } + + /** + * Check whether attribute is filterable in admin grid and it is allowed + * + * @return bool + */ + public function canBeFilterableInGrid() + { + return $this->getData('is_filterable_in_grid') + && in_array($this->getFrontendInput(), ['text', 'date', 'select', 'boolean']); + } } diff --git a/app/code/Magento/Customer/Model/AttributeMetadataConverter.php b/app/code/Magento/Customer/Model/AttributeMetadataConverter.php index a9fc1eb30fd22..01f741581a596 100644 --- a/app/code/Magento/Customer/Model/AttributeMetadataConverter.php +++ b/app/code/Magento/Customer/Model/AttributeMetadataConverter.php @@ -109,6 +109,10 @@ public function createMetadataAttribute($attribute) ->setIsSystem((boolean)$attribute->getIsSystem()) ->setIsUserDefined((boolean)$attribute->getIsUserDefined()) ->setBackendType($attribute->getBackendType()) - ->setSortOrder((int)$attribute->getSortOrder()); + ->setSortOrder((int)$attribute->getSortOrder()) + ->setIsUsedInGrid($attribute->getIsUsedInGrid()) + ->setIsVisibleInGrid($attribute->getIsVisibleInGrid()) + ->setIsFilterableInGrid($attribute->getIsFilterableInGrid()) + ->setIsSearchableInGrid($attribute->getIsSearchableInGrid()); } } diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index c607dcbd62f46..dc8085e7e25fd 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -16,6 +16,7 @@ use Magento\Framework\Exception\EmailNotConfirmedException; use Magento\Framework\Exception\InvalidEmailOrPasswordException; use Magento\Framework\Exception\AuthenticationException; +use Magento\Framework\Indexer\StateInterface; /** * Customer model @@ -69,6 +70,8 @@ class Customer extends \Magento\Framework\Model\AbstractModel const ENTITY = 'customer'; + const CUSTOMER_GRID_INDEXER_ID = 'customer_grid'; + /** * Configuration path to expiration period of reset password link */ @@ -198,27 +201,33 @@ class Customer extends \Magento\Framework\Model\AbstractModel */ protected $metadataService; + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ + protected $indexerRegistry; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $config - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param ScopeConfigInterface $scopeConfig * @param ResourceCustomer $resource * @param Share $configShare * @param AddressFactory $addressFactory * @param CollectionFactory $addressesFactory * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param GroupRepositoryInterface $groupRepository - * @param AttributeFactory $attributeFactory * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param CustomerInterfaceFactory $customerDataFactory * @param DataObjectProcessor $dataObjectProcessor * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param CustomerMetadataInterface $metadataService - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -239,6 +248,7 @@ public function __construct( DataObjectProcessor $dataObjectProcessor, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Customer\Api\CustomerMetadataInterface $metadataService, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { @@ -256,6 +266,7 @@ public function __construct( $this->customerDataFactory = $customerDataFactory; $this->dataObjectProcessor = $dataObjectProcessor; $this->dataObjectHelper = $dataObjectHelper; + $this->indexerRegistry = $indexerRegistry; parent::__construct( $context, $registry, @@ -1069,6 +1080,43 @@ public function beforeDelete() return parent::beforeDelete(); } + /** + * Processing object after save data + * + * @return $this + */ + public function afterSave() + { + $indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID); + if ($indexer->getState()->getStatus() == StateInterface::STATUS_VALID) { + $this->_getResource()->addCommitCallback([$this, 'reindex']); + } + return parent::afterSave(); + } + + /** + * Init indexing process after customer delete + * + * @return \Magento\Framework\Model\AbstractModel + */ + public function afterDeleteCommit() + { + $this->reindex(); + return parent::afterDeleteCommit(); + } + + /** + * Init indexing process after customer save + * + * @return void + */ + public function reindex() + { + /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ + $indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID); + $indexer->reindexRow($this->getId()); + } + /** * Get customer created at date timestamp * diff --git a/app/code/Magento/Customer/Model/Data/AttributeMetadata.php b/app/code/Magento/Customer/Model/Data/AttributeMetadata.php index dbf7feb726e23..136ea015067e8 100644 --- a/app/code/Magento/Customer/Model/Data/AttributeMetadata.php +++ b/app/code/Magento/Customer/Model/Data/AttributeMetadata.php @@ -6,6 +6,8 @@ namespace Magento\Customer\Model\Data; +use Magento\Customer\Api\Data\AttributeMetadataInterface; + /** * Customer attribute metadata class. */ @@ -334,4 +336,68 @@ public function setBackendType($backendType) { return $this->setData(self::BACKEND_TYPE, $backendType); } + + /** + * @inheritDoc + */ + public function getIsUsedInGrid() + { + return $this->_get(self::IS_USED_IN_GRID); + } + + /** + * @inheritDoc + */ + public function getIsVisibleInGrid() + { + return $this->_get(self::IS_VISIBLE_IN_GRID); + } + + /** + * @inheritDoc + */ + public function getIsFilterableInGrid() + { + return $this->_get(self::IS_FILTERABLE_IN_GRID); + } + + /** + * @inheritDoc + */ + public function getIsSearchableInGrid() + { + return $this->_get(self::IS_SEARCHABLE_IN_GRID); + } + + /** + * @inheritDoc + */ + public function setIsUsedInGrid($isUsedInGrid) + { + return $this->setData(self::IS_USED_IN_GRID, $isUsedInGrid); + } + + /** + * @inheritDoc + */ + public function setIsVisibleInGrid($isVisibleInGrid) + { + return $this->setData(self::IS_VISIBLE_IN_GRID, $isVisibleInGrid); + } + + /** + * @inheritDoc + */ + public function setIsFilterableInGrid($isFilterableInGrid) + { + return $this->setData(self::IS_FILTERABLE_IN_GRID, $isFilterableInGrid); + } + + /** + * @inheritDoc + */ + public function setIsSearchableInGrid($isSearchableInGrid) + { + return $this->setData(self::IS_SEARCHABLE_IN_GRID, $isSearchableInGrid); + } } diff --git a/app/code/Magento/Customer/Model/Indexer/Address/AttributeProvider.php b/app/code/Magento/Customer/Model/Indexer/Address/AttributeProvider.php new file mode 100644 index 0000000000000..b2a607b535cc2 --- /dev/null +++ b/app/code/Magento/Customer/Model/Indexer/Address/AttributeProvider.php @@ -0,0 +1,27 @@ +resource = $resource; + $this->flatScopeResolver = $flatScopeResolver; + $this->indexerRegistry = $indexerRegistry; + } + + /** + * @param array $attributes + * @return array + */ + public function filter(array $attributes) + { + $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); + if ($indexer->getState()->getStatus() != StateInterface::STATUS_VALID) { + $tableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []); + $columns = $this->resource->getConnection()->describeTable($tableName); + + foreach (array_keys($attributes) as $attributeCode) { + if (!isset($columns[$attributeCode])) { + unset($attributes[$attributeCode]); + } + } + } + + return $attributes; + } +} diff --git a/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php b/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php new file mode 100644 index 0000000000000..53f7a695e4cd9 --- /dev/null +++ b/app/code/Magento/Customer/Model/Indexer/AttributeProvider.php @@ -0,0 +1,154 @@ +eavConfig = $eavConfig; + } + + /** + * Add EAV attribute fields to fieldset + * + * @param array $data + * @return array + */ + public function addDynamicData(array $data) + { + $additionalFields = $this->convert($this->getAttributes(), $data); + $data['fields'] = $this->merge($data['fields'], $additionalFields); + return $data; + } + + /** + * Retrieve all attributes + * + * @return Attribute[] + */ + private function getAttributes() + { + if ($this->attributes === null) { + $this->attributes = []; + $entityType = $this->eavConfig->getEntityType(static::ENTITY); + /** @var \Magento\Customer\Model\Attribute[] $attributes */ + $attributes = $entityType->getAttributeCollection()->getItems(); + /** @var \Magento\Customer\Model\Resource\Customer $entity */ + $entity = $entityType->getEntity(); + + foreach ($attributes as $attribute) { + $attribute->setEntity($entity); + } + $this->attributes = $attributes; + } + + return $this->attributes; + } + + /** + * Convert attributes to fields + * + * @param Attribute[] $attributes + * @param array $fieldset + * @return array + */ + protected function convert(array $attributes, array $fieldset) + { + $fields = []; + foreach ($attributes as $attribute) { + if (!$attribute->isStatic()) { + if ($attribute->getData('is_used_in_grid')) { + $fields[$attribute->getName()] = [ + 'name' => $attribute->getName(), + 'handler' => 'Magento\Framework\Indexer\Handler\AttributeHandler', + 'origin' => $attribute->getName(), + 'type' => $this->getType($attribute), + 'dataType' => $attribute->getBackendType(), + 'filters' => [], + 'entity' => static::ENTITY, + 'bind' => isset($fieldset['references']['customer']['to']) + ? $fieldset['references']['customer']['to'] + : null, + ]; + } + } else { + $fields[$attribute->getName()] = [ + 'type' => $this->getType($attribute), + ]; + } + } + + return $fields; + } + + /** + * Get field type for attribute + * + * @param Attribute $attribute + * @return string + */ + protected function getType(Attribute $attribute) + { + if ($attribute->canBeSearchableInGrid()) { + $type = 'searchable'; + } elseif ($attribute->canBeFilterableInGrid()) { + $type = 'filterable'; + } else { + $type = 'virtual'; + } + + return $type; + } + + /** + * Merge fields with attribute fields + * + * @param array $dataFields + * @param array $searchableFields + * @return array + */ + protected function merge(array $dataFields, array $searchableFields) + { + foreach ($searchableFields as $name => $field) { + if (!isset($field['name']) && !isset($dataFields[$name])) { + continue; + } + if (!isset($dataFields[$name])) { + $dataFields[$name] = []; + } + foreach ($field as $key => $value) { + $dataFields[$name][$key] = $value; + } + } + + return $dataFields; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/AddressMetadataManagement.php b/app/code/Magento/Customer/Model/Metadata/AddressMetadataManagement.php new file mode 100644 index 0000000000000..3c8ae5c3284d9 --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/AddressMetadataManagement.php @@ -0,0 +1,47 @@ +attributeResolver = $attributeResolver; + } + + /** + * {@inheritdoc} + */ + public function canBeSearchableInGrid(AttributeMetadataInterface $attribute) + { + return $this->attributeResolver->getModelByAttribute(self::ENTITY_TYPE_ADDRESS, $attribute) + ->canBeSearchableInGrid(); + } + + /** + * {@inheritdoc} + */ + public function canBeFilterableInGrid(AttributeMetadataInterface $attribute) + { + return $this->attributeResolver->getModelByAttribute(self::ENTITY_TYPE_ADDRESS, $attribute) + ->canBeFilterableInGrid(); + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/AttributeResolver.php b/app/code/Magento/Customer/Model/Metadata/AttributeResolver.php new file mode 100644 index 0000000000000..57c814f9a74bd --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/AttributeResolver.php @@ -0,0 +1,60 @@ +attributeMetadataDataProvider = $attributeMetadataDataProvider; + } + + /** + * Get attribute model by attribute data object + * + * @param string $entityType + * @param AttributeMetadataInterface $attribute + * @return Attribute + * @throws NoSuchEntityException + */ + public function getModelByAttribute($entityType, AttributeMetadataInterface $attribute) + { + /** @var Attribute $model */ + $model = $this->attributeMetadataDataProvider->getAttribute( + $entityType, + $attribute->getAttributeCode() + ); + if ($model) { + return $model; + } else { + throw new NoSuchEntityException( + __( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => 'entityType', + 'fieldValue' => $entityType, + 'field2Name' => 'attributeCode', + 'field2Value' => $attribute->getAttributeCode(), + ] + ) + ); + } + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/CustomerMetadataManagement.php b/app/code/Magento/Customer/Model/Metadata/CustomerMetadataManagement.php new file mode 100644 index 0000000000000..67ba212dbdff8 --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/CustomerMetadataManagement.php @@ -0,0 +1,47 @@ +attributeResolver = $attributeResolver; + } + + /** + * {@inheritdoc} + */ + public function canBeSearchableInGrid(AttributeMetadataInterface $attribute) + { + return $this->attributeResolver->getModelByAttribute(self::ENTITY_TYPE_CUSTOMER, $attribute) + ->canBeSearchableInGrid(); + } + + /** + * {@inheritdoc} + */ + public function canBeFilterableInGrid(AttributeMetadataInterface $attribute) + { + return $this->attributeResolver->getModelByAttribute(self::ENTITY_TYPE_CUSTOMER, $attribute) + ->canBeFilterableInGrid(); + } +} diff --git a/app/code/Magento/Customer/Model/Observer/Grid.php b/app/code/Magento/Customer/Model/Observer/Grid.php new file mode 100644 index 0000000000000..7b958a5f251b7 --- /dev/null +++ b/app/code/Magento/Customer/Model/Observer/Grid.php @@ -0,0 +1,33 @@ +customerGrid = $grid; + } + + /** + * @return void + */ + public function syncCustomerGrid() + { + $this->customerGrid->syncCustomerGrid(); + } +} diff --git a/app/code/Magento/Customer/Model/Resource/Customer/Grid.php b/app/code/Magento/Customer/Model/Resource/Customer/Grid.php new file mode 100644 index 0000000000000..0c216fcc6e811 --- /dev/null +++ b/app/code/Magento/Customer/Model/Resource/Customer/Grid.php @@ -0,0 +1,82 @@ +resource = $resource; + $this->indexerRegistry = $indexerRegistry; + $this->flatScopeResolver = $flatScopeResolver; + } + + /** + * Synchronize customer grid + * + * @return void + */ + public function syncCustomerGrid() + { + $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); + $customerIds = $this->getCustomerIdsForReindex(); + if ($customerIds) { + $indexer->reindexList($customerIds); + } + } + + /** + * Retrieve customer IDs for reindex + * + * @return array + */ + protected function getCustomerIdsForReindex() + { + $connection = $this->resource->getConnection(); + $gridTableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []); + + $select = $connection->select() + ->from($connection->getTableName($gridTableName), 'last_visit_at') + ->order('last_visit_at DESC') + ->limit(1); + $lastVisitAt = $connection->query($select)->fetchColumn(); + + $select = $connection->select() + ->from($connection->getTableName('customer_log'), 'customer_id') + ->where('last_login_at > ?', $lastVisitAt); + + $customerIds = []; + foreach ($connection->query($select)->fetchAll() as $row) { + $customerIds[] = $row['customer_id']; + } + + return $customerIds; + } +} diff --git a/app/code/Magento/Customer/Model/Resource/Customer/Grid/ServiceCollection.php b/app/code/Magento/Customer/Model/Resource/Customer/Grid/ServiceCollection.php deleted file mode 100644 index de8f7aa1bf338..0000000000000 --- a/app/code/Magento/Customer/Model/Resource/Customer/Grid/ServiceCollection.php +++ /dev/null @@ -1,104 +0,0 @@ -customerRepository = $customerRepository; - } - - /** - * {@inheritdoc} - */ - public function loadData($printQuery = false, $logQuery = false) - { - if (!$this->isLoaded()) { - $searchCriteria = $this->getSearchCriteria(); - $searchResults = $this->customerRepository->getList($searchCriteria); - $this->_totalRecords = $searchResults->getTotalCount(); - /** @var CustomerInterface[] $customers */ - $customers = $searchResults->getItems(); - foreach ($customers as $customer) { - $this->_addItem($this->createCustomerItem($customer)); - } - $this->_setIsLoaded(); - } - return $this; - } - - /** - * Creates a collection item that represents a customer for the customer Grid. - * - * @param CustomerInterface $customer Input data for creating the item. - * @return \Magento\Framework\DataObject Collection item that represents a customer - */ - protected function createCustomerItem(CustomerInterface $customer) - { - $customerNameParts = [ - $customer->getPrefix(), - $customer->getFirstname(), - $customer->getMiddlename(), - $customer->getLastname(), - $customer->getSuffix(), - ]; - $customerItem = new \Magento\Framework\DataObject(); - $customerItem->setId($customer->getId()); - $customerItem->setEntityId($customer->getId()); - // All parts of the customer name must be displayed in the name column of the grid - $customerItem->setName(implode(' ', array_filter($customerNameParts))); - $customerItem->setEmail($customer->getEmail()); - $customerItem->setWebsiteId($customer->getWebsiteId()); - $customerItem->setCreatedAt($customer->getCreatedAt()); - $customerItem->setGroupId($customer->getGroupId()); - - $billingAddress = null; - foreach ($customer->getAddresses() as $address) { - if ($address->isDefaultBilling()) { - $billingAddress = $address; - break; - } - } - if ($billingAddress !== null) { - $customerItem->setBillingTelephone($billingAddress->getTelephone()); - $customerItem->setBillingPostcode($billingAddress->getPostcode()); - $customerItem->setBillingCountryId($billingAddress->getCountryId()); - $region = $billingAddress->getRegion() === null ? '' : $billingAddress->getRegion()->getRegion(); - $customerItem->setBillingRegion($region); - } - return $customerItem; - } -} diff --git a/app/code/Magento/Customer/Model/Resource/Setup/PropertyMapper.php b/app/code/Magento/Customer/Model/Resource/Setup/PropertyMapper.php index 72704aa94f9dd..f375962b7dbfc 100644 --- a/app/code/Magento/Customer/Model/Resource/Setup/PropertyMapper.php +++ b/app/code/Magento/Customer/Model/Resource/Setup/PropertyMapper.php @@ -17,6 +17,8 @@ class PropertyMapper extends PropertyMapperAbstract * @param array $input * @param int $entityTypeId * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function map(array $input, $entityTypeId) { @@ -27,7 +29,11 @@ public function map(array $input, $entityTypeId) 'multiline_count' => $this->_getValue($input, 'multiline_count', 0), 'validate_rules' => $this->_getValue($input, 'validate_rules', null), 'data_model' => $this->_getValue($input, 'data', null), - 'sort_order' => $this->_getValue($input, 'position', 0) + 'sort_order' => $this->_getValue($input, 'position', 0), + 'is_used_in_grid' => $this->_getValue($input, 'is_used_in_grid', 0), + 'is_visible_in_grid' => $this->_getValue($input, 'is_visible_in_grid', 0), + 'is_filterable_in_grid' => $this->_getValue($input, 'is_filterable_in_grid', 0), + 'is_searchable_in_grid' => $this->_getValue($input, 'is_searchable_in_grid', 0), ]; } } diff --git a/app/code/Magento/Customer/Model/Resource/Visitor/Collection.php b/app/code/Magento/Customer/Model/Resource/Visitor/Collection.php new file mode 100644 index 0000000000000..bfb12448688c2 --- /dev/null +++ b/app/code/Magento/Customer/Model/Resource/Visitor/Collection.php @@ -0,0 +1,19 @@ +_init('Magento\Customer\Model\Visitor', 'Magento\Customer\Model\Resource\Visitor'); + } +} diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php index 4eac407129ffe..164490b953005 100644 --- a/app/code/Magento/Customer/Model/Visitor.php +++ b/app/code/Magento/Customer/Model/Visitor.php @@ -6,9 +6,12 @@ namespace Magento\Customer\Model; +use Magento\Framework\Indexer\StateInterface; + /** * Class Visitor * @package Magento\Customer\Model + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Visitor extends \Magento\Framework\Model\AbstractModel { @@ -59,15 +62,21 @@ class Visitor extends \Magento\Framework\Model\AbstractModel */ protected $dateTime; + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ + protected $indexerRegistry; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Framework\HTTP\Header $httpHeader - * @param \Magento\Framework\Model\Resource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Model\Resource\AbstractResource|null $resource + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $ignoredUserAgents * @param array $ignores * @param array $data @@ -81,6 +90,7 @@ public function __construct( \Magento\Framework\HTTP\Header $httpHeader, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $ignoredUserAgents = [], @@ -94,6 +104,7 @@ public function __construct( $this->ignores = $ignores; $this->scopeConfig = $scopeConfig; $this->dateTime = $dateTime; + $this->indexerRegistry = $indexerRegistry; } /** diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php new file mode 100644 index 0000000000000..a93a89503a042 --- /dev/null +++ b/app/code/Magento/Customer/Setup/UpgradeData.php @@ -0,0 +1,196 @@ +customerSetupFactory = $customerSetupFactory; + $this->indexerRegistry = $indexerRegistry; + $this->eavConfig = $eavConfig; + } + + /** + * {@inheritdoc} + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + { + $setup->startSetup(); + + if (version_compare($context->getVersion(), '2.0.1', '<')) { + /** @var CustomerSetup $customerSetup */ + $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); + + $entityAttributes = [ + 'customer' => [ + 'website_id' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'created_in' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + 'email' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ], + 'group_id' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'dob' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'taxvat' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + 'confirmation' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'created_at' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'gender' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + ], + 'customer_address' => [ + 'company' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => false, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + 'street' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => false, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + 'city' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => false, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + 'country_id' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'region' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + 'region_id' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => false, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => false, + ], + 'postcode' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ], + 'telephone' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ], + 'fax' => [ + 'is_used_in_grid' => true, + 'is_visible_in_grid' => false, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ], + ], + ]; + + foreach ($entityAttributes as $entityType => $attributes) { + foreach ($attributes as $attributeCode => $attributeData) { + $attribute = $customerSetup->getEavConfig()->getAttribute($entityType, $attributeCode); + foreach ($attributeData as $key => $value) { + $attribute->setData($key, $value); + } + $attribute->save(); + } + } + } + + $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); + $indexer->reindexAll(); + $this->eavConfig->clear(); + + $setup->endSetup(); + } +} diff --git a/app/code/Magento/Customer/Setup/UpgradeSchema.php b/app/code/Magento/Customer/Setup/UpgradeSchema.php index 296fd06a36a60..933556fec7dc3 100644 --- a/app/code/Magento/Customer/Setup/UpgradeSchema.php +++ b/app/code/Magento/Customer/Setup/UpgradeSchema.php @@ -32,6 +32,53 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con ); } + if (version_compare($context->getVersion(), '2.0.1', '<')) { + $setup->getConnection()->addColumn( + $setup->getTable('customer_eav_attribute'), + 'is_used_in_grid', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + 'comment' => 'Is Used in Grid' + ] + ); + $setup->getConnection()->addColumn( + $setup->getTable('customer_eav_attribute'), + 'is_visible_in_grid', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + 'comment' => 'Is Visible in Grid' + ] + ); + $setup->getConnection()->addColumn( + $setup->getTable('customer_eav_attribute'), + 'is_filterable_in_grid', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + 'comment' => 'Is Filterable in Grid' + ] + ); + $setup->getConnection()->addColumn( + $setup->getTable('customer_eav_attribute'), + 'is_searchable_in_grid', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + 'comment' => 'Is Searchable in Grid' + ] + ); + } + $setup->endSetup(); } } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php new file mode 100644 index 0000000000000..b59404ba8bb48 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php @@ -0,0 +1,195 @@ +contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $resultRedirectFactory = $this->getMock( + 'Magento\Backend\Model\View\Result\RedirectFactory', + [], + [], + '', + false + ); + $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->customerCollectionMock = $this->getMockBuilder('Magento\Customer\Model\Resource\Customer\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->customerCollectionFactoryMock = + $this->getMockBuilder('Magento\Customer\Model\Resource\Customer\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock->expects($this->any()) + ->method('create') + ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) + ->willReturn($redirectMock); + + $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); + + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock); + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $this->contextMock->expects($this->any()) + ->method('getResultRedirectFactory') + ->willReturn($resultRedirectFactory); + $this->contextMock->expects($this->any()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + + $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock->expects($this->once()) + ->method('getCollection') + ->with($this->customerCollectionMock) + ->willReturnArgument(0); + $this->customerCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->customerCollectionMock); + $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + ->getMockForAbstractClass(); + $this->massAction = $objectManagerHelper->getObject( + 'Magento\Customer\Controller\Adminhtml\Index\MassDelete', + [ + 'context' => $this->contextMock, + 'filter' => $this->filterMock, + 'collectionFactory' => $this->customerCollectionFactoryMock, + 'customerRepository' => $this->customerRepositoryMock, + ] + ); + } + + public function testExecute() + { + $customersIds = [10, 11, 12]; + + $this->customerCollectionMock->expects($this->any()) + ->method('getAllIds') + ->willReturn($customersIds); + + $this->customerRepositoryMock->expects($this->any()) + ->method('deleteById') + ->willReturnMap([[10, true], [11, true], [12, true]]); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with(__('A total of %1 record(s) were deleted.', count($customersIds))); + + $this->resultRedirectMock->expects($this->any()) + ->method('setPath') + ->with('customer/*/index') + ->willReturnSelf(); + + $this->massAction->execute(); + } + + public function testExecuteWithException() + { + $customersIds = [10, 11, 12]; + + $this->customerCollectionMock->expects($this->any()) + ->method('getAllIds') + ->willReturn($customersIds); + + $this->customerRepositoryMock->expects($this->any()) + ->method('deleteById') + ->willThrowException(new \Exception('Some message.')); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Some message.'); + + $this->massAction->execute(); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php new file mode 100644 index 0000000000000..eab3d880dbf93 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php @@ -0,0 +1,211 @@ +contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $resultRedirectFactory = $this->getMock( + 'Magento\Backend\Model\View\Result\RedirectFactory', + [], + [], + '', + false + ); + $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->customerCollectionMock = $this->getMockBuilder('Magento\Customer\Model\Resource\Customer\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->customerCollectionFactoryMock = + $this->getMockBuilder('Magento\Customer\Model\Resource\Customer\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock->expects($this->any()) + ->method('create') + ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) + ->willReturn($redirectMock); + $this->subscriberMock = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); + $subscriberFactoryMock = $this->getMockBuilder('Magento\Newsletter\Model\SubscriberFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $subscriberFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->subscriberMock); + + $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); + + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock); + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $this->contextMock->expects($this->any()) + ->method('getResultRedirectFactory') + ->willReturn($resultRedirectFactory); + $this->contextMock->expects($this->any()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + + $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock->expects($this->once()) + ->method('getCollection') + ->with($this->customerCollectionMock) + ->willReturnArgument(0); + $this->customerCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->customerCollectionMock); + $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + ->getMockForAbstractClass(); + $this->massAction = $objectManagerHelper->getObject( + 'Magento\Customer\Controller\Adminhtml\Index\MassSubscribe', + [ + 'context' => $this->contextMock, + 'filter' => $this->filterMock, + 'collectionFactory' => $this->customerCollectionFactoryMock, + 'customerRepository' => $this->customerRepositoryMock, + 'subscriberFactory' => $subscriberFactoryMock, + ] + ); + } + + public function testExecute() + { + $customersIds = [10, 11, 12]; + + $this->customerCollectionMock->expects($this->any()) + ->method('getAllIds') + ->willReturn($customersIds); + + $this->customerRepositoryMock->expects($this->any()) + ->method('getById') + ->willReturnMap([[10, true], [11, true], [12, true]]); + + $this->subscriberMock->expects($this->any()) + ->method('subscribeCustomerById') + ->willReturnMap([[10, true], [11, true], [12, true]]); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with(__('A total of %1 record(s) were updated.', count($customersIds))); + + $this->resultRedirectMock->expects($this->any()) + ->method('setPath') + ->with('customer/*/index') + ->willReturnSelf(); + + $this->massAction->execute(); + } + + public function testExecuteWithException() + { + $customersIds = [10, 11, 12]; + + $this->customerCollectionMock->expects($this->any()) + ->method('getAllIds') + ->willReturn($customersIds); + + $this->customerRepositoryMock->expects($this->any()) + ->method('getById') + ->willThrowException(new \Exception('Some message.')); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Some message.'); + + $this->massAction->execute(); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php new file mode 100644 index 0000000000000..4e167af550fbe --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php @@ -0,0 +1,211 @@ +contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $resultRedirectFactory = $this->getMock( + 'Magento\Backend\Model\View\Result\RedirectFactory', + [], + [], + '', + false + ); + $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false); + $this->customerCollectionMock = $this->getMockBuilder('Magento\Customer\Model\Resource\Customer\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->customerCollectionFactoryMock = + $this->getMockBuilder('Magento\Customer\Model\Resource\Customer\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock->expects($this->any()) + ->method('create') + ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) + ->willReturn($redirectMock); + $this->subscriberMock = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false); + $subscriberFactoryMock = $this->getMockBuilder('Magento\Newsletter\Model\SubscriberFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $subscriberFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->subscriberMock); + + $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); + + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock); + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $this->contextMock->expects($this->any()) + ->method('getResultRedirectFactory') + ->willReturn($resultRedirectFactory); + $this->contextMock->expects($this->any()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + + $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false); + $this->filterMock->expects($this->once()) + ->method('getCollection') + ->with($this->customerCollectionMock) + ->willReturnArgument(0); + $this->customerCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->customerCollectionMock); + $this->customerRepositoryMock = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface') + ->getMockForAbstractClass(); + $this->massAction = $objectManagerHelper->getObject( + 'Magento\Customer\Controller\Adminhtml\Index\MassUnsubscribe', + [ + 'context' => $this->contextMock, + 'filter' => $this->filterMock, + 'collectionFactory' => $this->customerCollectionFactoryMock, + 'customerRepository' => $this->customerRepositoryMock, + 'subscriberFactory' => $subscriberFactoryMock, + ] + ); + } + + public function testExecute() + { + $customersIds = [10, 11, 12]; + + $this->customerCollectionMock->expects($this->any()) + ->method('getAllIds') + ->willReturn($customersIds); + + $this->customerRepositoryMock->expects($this->any()) + ->method('getById') + ->willReturnMap([[10, true], [11, true], [12, true]]); + + $this->subscriberMock->expects($this->any()) + ->method('unsubscribeCustomerById') + ->willReturnMap([[10, true], [11, true], [12, true]]); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with(__('A total of %1 record(s) were updated.', count($customersIds))); + + $this->resultRedirectMock->expects($this->any()) + ->method('setPath') + ->with('customer/*/index') + ->willReturnSelf(); + + $this->massAction->execute(); + } + + public function testExecuteWithException() + { + $customersIds = [10, 11, 12]; + + $this->customerCollectionMock->expects($this->any()) + ->method('getAllIds') + ->willReturn($customersIds); + + $this->customerRepositoryMock->expects($this->any()) + ->method('getById') + ->willThrowException(new \Exception('Some message.')); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Some message.'); + + $this->massAction->execute(); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php index 3a73c5ece810b..06c6c2a3ecb2f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php @@ -9,6 +9,9 @@ namespace Magento\Customer\Test\Unit\Model; use Magento\Customer\Model\Attribute; +use Magento\Customer\Model\Customer; +use Magento\Eav\Api\Data\AttributeInterface; +use Magento\Framework\Indexer\IndexerInterface; /** * @SuppressWarnings(PHPMD.TooManyFields) @@ -106,6 +109,11 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ private $dataObjectHelperMock; + /** + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + private $indexerRegistryMock; + /** * @var \Magento\Framework\Api\ExtensionAttributesFactory|\PHPUnit_Framework_MockObject_MockObject */ @@ -182,6 +190,10 @@ protected function setUp() ->method('getEventDispatcher') ->willReturn($this->eventDispatcher); + $this->indexerRegistryMock = $this->getMockBuilder('Magento\Framework\Indexer\IndexerRegistry') + ->disableOriginalConstructor() + ->getMock(); + $this->attribute = new Attribute( $this->contextMock, $this->registryMock, @@ -199,6 +211,7 @@ protected function setUp() $this->reservedAttributeListMock, $this->resolverMock, $this->dateTimeFormatter, + $this->indexerRegistryMock, $this->resourceMock ); } @@ -226,4 +239,95 @@ public function testAfterDeleteEavCache() $this->attribute->afterDelete(); } + + public function testInvalidate() + { + /** @var IndexerInterface|\PHPUnit_Framework_MockObject_MockObject $indexerMock */ + $indexerMock = $this->getMockBuilder('Magento\Framework\Indexer\IndexerInterface') + ->getMockForAbstractClass(); + + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(Customer::CUSTOMER_GRID_INDEXER_ID) + ->willReturn($indexerMock); + + $indexerMock->expects($this->once()) + ->method('invalidate'); + + $this->attribute->invalidate(); + } + + /** + * @param int $isSearchableInGrid + * @param string $frontendInput + * @param bool $result + * @dataProvider dataProviderCanBeSearchableInGrid + */ + public function testCanBeSearchableInGrid($isSearchableInGrid, $frontendInput, $result) + { + $this->attribute->setData('is_searchable_in_grid', $isSearchableInGrid); + $this->attribute->setData(AttributeInterface::FRONTEND_INPUT, $frontendInput); + + $this->assertEquals($result, $this->attribute->canBeSearchableInGrid()); + } + + /** + * @return array + */ + public function dataProviderCanBeSearchableInGrid() + { + return [ + [0, 'text', false], + [0, 'textarea', false], + [1, 'text', true], + [1, 'textarea', true], + [1, 'date', false], + [1, 'boolean', false], + [1, 'select', false], + [1, 'media_image', false], + [1, 'gallery', false], + [1, 'multiselect', false], + [1, 'image', false], + [1, 'price', false], + [1, 'weight', false], + ]; + } + + /** + * @param int $isFilterableInGrid + * @param string $frontendInput + * @param bool $result + * @dataProvider dataProviderCanBeFilterableInGrid + */ + public function testCanBeFilterableInGrid($isFilterableInGrid, $frontendInput, $result) + { + $this->attribute->setData('is_filterable_in_grid', $isFilterableInGrid); + $this->attribute->setData(AttributeInterface::FRONTEND_INPUT, $frontendInput); + + $this->assertEquals($result, $this->attribute->canBeFilterableInGrid()); + } + + /** + * @return array + */ + public function dataProviderCanBeFilterableInGrid() + { + return [ + [0, 'text', false], + [0, 'date', false], + [0, 'select', false], + [0, 'boolean', false], + [1, 'text', true], + [1, 'date', true], + [1, 'select', true], + [1, 'boolean', true], + [1, 'textarea', false], + [1, 'media_image', false], + [1, 'gallery', false], + [1, 'multiselect', false], + [1, 'image', false], + [1, 'price', false], + [1, 'weight', false], + ]; + } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php b/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php new file mode 100644 index 0000000000000..33f3701d9a002 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php @@ -0,0 +1,118 @@ +resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $this->connection = $this->getMockForAbstractClass( + 'Magento\Framework\DB\Adapter\AdapterInterface', + [], + '', + false + ); + $this->flatScopeResolver = $this->getMock( + 'Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver', + [], + [], + '', + false + ); + $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); + $this->indexer = $this->getMockForAbstractClass('Magento\Framework\Indexer\IndexerInterface', [], '', false); + $this->indexerState = $this->getMockForAbstractClass('Magento\Framework\Indexer\StateInterface', [], '', false); + + $this->model = new Filter( + $this->resource, + $this->flatScopeResolver, + $this->indexerRegistry + ); + } + + public function testFilter() + { + $attributeCode = 'attribute-code'; + $attributeCodeTwo = 'attribute-code2'; + $tableName = 'customer_grid_flat'; + + $attributes = [ + $attributeCode => [ + AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCode, + AttributeMetadataInterface::FRONTEND_INPUT => 'input', + AttributeMetadataInterface::FRONTEND_LABEL => 'Frontend label', + AttributeMetadataInterface::BACKEND_TYPE => 'static', + AttributeMetadataInterface::OPTIONS => [], + AttributeMetadataInterface::IS_USED_IN_GRID => true, + AttributeMetadataInterface::IS_VISIBLE_IN_GRID => true, + AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => true, + AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => true, + ], + $attributeCodeTwo => [ + AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCodeTwo, + AttributeMetadataInterface::FRONTEND_INPUT => 'input', + AttributeMetadataInterface::FRONTEND_LABEL => 'Frontend label two', + AttributeMetadataInterface::BACKEND_TYPE => 'static', + AttributeMetadataInterface::OPTIONS => [], + AttributeMetadataInterface::IS_USED_IN_GRID => false, + AttributeMetadataInterface::IS_VISIBLE_IN_GRID => false, + AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => false, + AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => false, + ] + ]; + + $this->indexerRegistry->expects($this->once()) + ->method('get') + ->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID) + ->willReturn($this->indexer); + $this->indexer->expects($this->once()) + ->method('getState') + ->willReturn($this->indexerState); + $this->indexerState->expects($this->once()) + ->method('getStatus') + ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); + $this->flatScopeResolver->expects($this->once()) + ->method('resolve') + ->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID, []) + ->willReturn($tableName); + $this->resource->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connection); + $this->connection->expects($this->once()) + ->method('describeTable') + ->with($tableName) + ->willReturn([ + 'attribute-code' => ['Attribute data'] + ]); + + $this->assertArrayNotHasKey($attributeCodeTwo, $this->model->filter($attributes)); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php new file mode 100644 index 0000000000000..908a74a3b78b1 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php @@ -0,0 +1,345 @@ +eavConfig = $this->getMockBuilder('Magento\Eav\Model\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->object = new AttributeProvider( + $this->eavConfig + ); + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testAddDynamicData() + { + $existentName = 'field'; + $existentField = [ + 'name' => $existentName, + 'handler' => 'handler', + 'origin' => $existentName, + 'type' => 'type', + 'filters' => ['filter'], + 'dataType' => 'data_type', + ]; + $data = ['fields' => [$existentName => $existentField]]; + $attrName = 'attrName'; + $attrBackendType = 'b_type'; + $attrFrontendInput = 'int'; + + /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */ + $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + ->disableOriginalConstructor() + ->getMock(); + /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ + $collectionMock = $this->getMockBuilder('Magento\Eav\Model\Resource\Entity\Attribute\Collection') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Magento\Customer\Model\Resource\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */ + $entity = $this->getMockBuilder('Magento\Customer\Model\Resource\Customer') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ + $attribute = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->setMethods( + [ + 'setEntity', + 'getName', + 'getFrontendInput', + 'getBackendType', + 'canBeSearchableInGrid', + 'canBeFilterableInGrid', + 'getData', + ] + ) + ->getMock(); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with(Customer::ENTITY) + ->willReturn($entityType); + $entityType->expects($this->once()) + ->method('getEntity') + ->willReturn($entity); + $entityType->expects($this->once()) + ->method('getAttributeCollection') + ->willReturn($collectionMock); + $collectionMock->expects($this->once()) + ->method('getItems') + ->willReturn([$attribute]); + $attribute->expects($this->once()) + ->method('setEntity') + ->with($entity) + ->willReturnSelf(); + $attribute->expects($this->exactly(3)) + ->method('getName') + ->willReturn($attrName); + $attribute->expects($this->any()) + ->method('getBackendType') + ->willReturn($attrBackendType); + $attribute->expects($this->any()) + ->method('getFrontendInput') + ->willReturn($attrFrontendInput); + $attribute->expects($this->any()) + ->method('canBeSearchableInGrid') + ->willReturn(false); + $attribute->expects($this->any()) + ->method('canBeFilterableInGrid') + ->willReturn(false); + $attribute->expects($this->any()) + ->method('getData') + ->willReturnMap( + [ + ['is_used_in_grid', null, true], + ] + ); + + $this->assertEquals( + ['fields' => + [ + $existentName => $existentField, + $attrName => [ + 'name' => $attrName, + 'handler' => 'Magento\Framework\Indexer\Handler\AttributeHandler', + 'origin' => $attrName, + 'type' => 'virtual', + 'filters' => [], + 'dataType' => $attrBackendType, + 'entity' => Customer::ENTITY, + 'bind' => null, + ], + ], + ], + $this->object->addDynamicData($data) + ); + } + + public function testAddDynamicDataWithStaticAndSearchable() + { + $existentName = 'field'; + $existentField = [ + 'name' => $existentName, + 'handler' => 'handler', + 'origin' => $existentName, + 'type' => 'searchable', + 'filters' => ['filter'], + 'dataType' => 'data_type', + ]; + $data = ['fields' => [$existentName => $existentField]]; + $attrName = $existentName; + $attrBackendType = 'static'; + $attrFrontendInput = 'text'; + + /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */ + $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + ->disableOriginalConstructor() + ->getMock(); + /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ + $collectionMock = $this->getMockBuilder('Magento\Eav\Model\Resource\Entity\Attribute\Collection') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Magento\Customer\Model\Resource\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */ + $entity = $this->getMockBuilder('Magento\Customer\Model\Resource\Customer') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ + $attribute = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->setMethods( + [ + 'setEntity', + 'getName', + 'getFrontendInput', + 'getBackendType', + 'canBeSearchableInGrid', + 'canBeFilterableInGrid', + 'getData', + ] + ) + ->getMock(); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with(Customer::ENTITY) + ->willReturn($entityType); + $entityType->expects($this->once()) + ->method('getAttributeCollection') + ->willReturn($collectionMock); + $collectionMock->expects($this->once()) + ->method('getItems') + ->willReturn([$attribute]); + $entityType->expects($this->once()) + ->method('getEntity') + ->willReturn($entity); + $attribute->expects($this->once()) + ->method('setEntity') + ->with($entity) + ->willReturnSelf(); + $attribute->expects($this->any()) + ->method('getFrontendInput') + ->willReturn($attrFrontendInput); + $attribute->expects($this->any()) + ->method('getBackendType') + ->willReturn($attrBackendType); + $attribute->expects($this->any()) + ->method('canBeSearchableInGrid') + ->willReturn(true); + $attribute->expects($this->never()) + ->method('canBeFilterableInGrid'); + + $this->assertEquals( + ['fields' => + [ + $attrName => [ + 'name' => $attrName, + 'handler' => 'handler', + 'origin' => $attrName, + 'type' => 'searchable', + 'filters' => ['filter'], + 'dataType' => 'data_type', + ], + ], + ], + $this->object->addDynamicData($data) + ); + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testAddDynamicDataWithStaticAndFilterable() + { + $existentName = 'field'; + $existentField = [ + 'name' => $existentName, + 'handler' => 'handler', + 'origin' => $existentName, + 'type' => 'type', + 'filters' => ['filter'], + 'dataType' => 'data_type', + ]; + $data = [ + 'fields' => [$existentName => $existentField], + 'references' => [ + 'customer' => [ + 'to' => 'to_field', + ], + ], + ]; + $attrName = $existentName; + $attrBackendType = 'varchar'; + $attrFrontendInput = 'text'; + + /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */ + $entityType = $this->getMockBuilder('Magento\Eav\Model\Entity\Type') + ->disableOriginalConstructor() + ->getMock(); + /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */ + $collectionMock = $this->getMockBuilder('Magento\Eav\Model\Resource\Entity\Attribute\Collection') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Magento\Customer\Model\Resource\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */ + $entity = $this->getMockBuilder('Magento\Customer\Model\Resource\Customer') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ + $attribute = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->setMethods( + [ + 'setEntity', + 'getName', + 'getFrontendInput', + 'getBackendType', + 'canBeSearchableInGrid', + 'canBeFilterableInGrid', + 'getData', + ] + ) + ->getMock(); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with(Customer::ENTITY) + ->willReturn($entityType); + $entityType->expects($this->once()) + ->method('getAttributeCollection') + ->willReturn($collectionMock); + $collectionMock->expects($this->once()) + ->method('getItems') + ->willReturn([$attribute]); + $entityType->expects($this->once()) + ->method('getEntity') + ->willReturn($entity); + $attribute->expects($this->once()) + ->method('setEntity') + ->with($entity) + ->willReturnSelf(); + $attribute->expects($this->exactly(3)) + ->method('getName') + ->willReturn($attrName); + $attribute->expects($this->any()) + ->method('getFrontendInput') + ->willReturn($attrFrontendInput); + $attribute->expects($this->any()) + ->method('getBackendType') + ->willReturn($attrBackendType); + $attribute->expects($this->any()) + ->method('canBeSearchableInGrid') + ->willReturn(false); + $attribute->expects($this->any()) + ->method('canBeFilterableInGrid') + ->willReturn(true); + $attribute->expects($this->any()) + ->method('getData') + ->willReturnMap( + [ + ['is_used_in_grid', null, true], + ] + ); + + $this->assertEquals( + ['fields' => + [ + $attrName => [ + 'name' => $attrName, + 'handler' => 'Magento\Framework\Indexer\Handler\AttributeHandler', + 'origin' => $attrName, + 'type' => 'filterable', + 'filters' => [], + 'dataType' => 'varchar', + 'entity' => Customer::ENTITY, + 'bind' => 'to_field', + ], + ], + 'references' => [ + 'customer' => [ + 'to' => 'to_field', + ], + ], + ], + $this->object->addDynamicData($data) + ); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php new file mode 100644 index 0000000000000..83429316dba99 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php @@ -0,0 +1,77 @@ +attributeResolverMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\AttributeResolver') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new AddressMetadataManagement( + $this->attributeResolverMock + ); + } + + public function testCanBeSearchableInGrid() + { + /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ + $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + ->getMockForAbstractClass(); + + /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ + $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeResolverMock->expects($this->once()) + ->method('getModelByAttribute') + ->with(AddressMetadataManagementInterface::ENTITY_TYPE_ADDRESS, $attributeMock) + ->willReturn($modelMock); + + $modelMock->expects($this->once()) + ->method('canBeSearchableInGrid') + ->willReturn(true); + + $this->assertTrue($this->model->canBeSearchableInGrid($attributeMock)); + } + + public function testCanBeFilterableInGrid() + { + /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ + $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + ->getMockForAbstractClass(); + + /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ + $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeResolverMock->expects($this->once()) + ->method('getModelByAttribute') + ->with(AddressMetadataManagementInterface::ENTITY_TYPE_ADDRESS, $attributeMock) + ->willReturn($modelMock); + + $modelMock->expects($this->once()) + ->method('canBeFilterableInGrid') + ->willReturn(true); + + $this->assertTrue($this->model->canBeFilterableInGrid($attributeMock)); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php new file mode 100644 index 0000000000000..0d75d83e5b067 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php @@ -0,0 +1,82 @@ +metadataDataProviderMock = $this->getMockBuilder('Magento\Customer\Model\AttributeMetadataDataProvider') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new AttributeResolver( + $this->metadataDataProviderMock + ); + } + + public function testGetModelByAttribute() + { + $entityType = 'type'; + $attributeCode = 'code'; + + /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ + $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + ->disableOriginalConstructor() + ->getMock(); + $attributeMock->expects($this->once()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + + /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ + $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->getMock(); + + $this->metadataDataProviderMock->expects($this->once()) + ->method('getAttribute') + ->with($entityType, $attributeCode) + ->willReturn($modelMock); + + $this->assertEquals($modelMock, $this->model->getModelByAttribute($entityType, $attributeMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage No such entity with entityType = type, attributeCode = code + */ + public function testGetModelByAttributeWithoutModel() + { + $entityType = 'type'; + $attributeCode = 'code'; + + /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ + $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + ->disableOriginalConstructor() + ->getMock(); + $attributeMock->expects($this->exactly(2)) + ->method('getAttributeCode') + ->willReturn($attributeCode); + + $this->metadataDataProviderMock->expects($this->once()) + ->method('getAttribute') + ->with($entityType, $attributeCode) + ->willReturn(false); + + $this->model->getModelByAttribute($entityType, $attributeMock); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php new file mode 100644 index 0000000000000..9834470bf162b --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php @@ -0,0 +1,76 @@ +attributeResolverMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\AttributeResolver') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new CustomerMetadataManagement( + $this->attributeResolverMock + ); + } + + public function testCanBeSearchableInGrid() + { + /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ + $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + ->getMockForAbstractClass(); + + /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ + $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeResolverMock->expects($this->once()) + ->method('getModelByAttribute') + ->with(CustomerMetadataManagement::ENTITY_TYPE_CUSTOMER, $attributeMock) + ->willReturn($modelMock); + + $modelMock->expects($this->once()) + ->method('canBeSearchableInGrid') + ->willReturn(true); + + $this->assertTrue($this->model->canBeSearchableInGrid($attributeMock)); + } + + public function testCanBeFilterableInGrid() + { + /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */ + $attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface') + ->getMockForAbstractClass(); + + /** @var Attribute|\PHPUnit_Framework_MockObject_MockObject $modelMock */ + $modelMock = $this->getMockBuilder('Magento\Customer\Model\Attribute') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeResolverMock->expects($this->once()) + ->method('getModelByAttribute') + ->with(CustomerMetadataManagement::ENTITY_TYPE_CUSTOMER, $attributeMock) + ->willReturn($modelMock); + + $modelMock->expects($this->once()) + ->method('canBeFilterableInGrid') + ->willReturn(true); + + $this->assertTrue($this->model->canBeFilterableInGrid($attributeMock)); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Resource/Customer/GridTest.php b/app/code/Magento/Customer/Test/Unit/Model/Resource/Customer/GridTest.php new file mode 100644 index 0000000000000..14768adf1d50d --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Resource/Customer/GridTest.php @@ -0,0 +1,135 @@ +resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $this->indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); + $this->flatScopeResolver = $this->getMock( + 'Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver', + [], + [], + '', + false + ); + $this->indexer = $this->getMockForAbstractClass( + 'Magento\Framework\Indexer\IndexerInterface', + [], + '', + false + ); + $this->connection = $this->getMockForAbstractClass( + 'Magento\Framework\DB\Adapter\AdapterInterface', + [], + '', + false + ); + $this->select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + $this->queryResult = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false + ); + + $this->observer = new Grid( + $this->resource, + $this->indexerRegistry, + $this->flatScopeResolver + ); + } + + public function testSyncCustomerGrid() + { + $gridTable = 'customer_grid_flat'; + $customerLogTable = 'customer_log'; + + $this->indexerRegistry->expects($this->once()) + ->method('get') + ->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID) + ->willReturn($this->indexer); + $this->resource + ->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connection); + $this->flatScopeResolver + ->expects($this->once()) + ->method('resolve') + ->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID, []) + ->willReturn($gridTable); + + $this->connection->expects($this->exactly(2)) + ->method('getTableName') + ->willReturnMap([ + [$gridTable], + [$customerLogTable], + ]); + + $this->connection->expects($this->exactly(2)) + ->method('select') + ->willReturn($this->select); + $this->select->expects($this->exactly(2)) + ->method('from') + ->willReturnSelf(); + $this->select->expects($this->once()) + ->method('order') + ->with('last_visit_at DESC') + ->willReturnSelf(); + $this->select->expects($this->once()) + ->method('limit') + ->with(1) + ->willReturnSelf(); + $this->connection->expects($this->atLeastOnce()) + ->method('query') + ->with($this->select) + ->willReturn($this->queryResult); + $this->queryResult->expects($this->once()) + ->method('fetchColumn') + ->willReturn('2015-08-13 10:36:44'); + + $this->select->expects($this->once()) + ->method('where') + ->with('last_login_at > ?', '2015-08-13 10:36:44') + ->willReturnSelf(); + $this->queryResult->expects($this->once()) + ->method('fetchAll') + ->willReturn([['customer_id' => 23], ['customer_id' => 65]]); + $this->indexer->expects($this->once()) + ->method('reindexList') + ->with(['23', '65']); + + $this->observer->syncCustomerGrid(); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php new file mode 100644 index 0000000000000..4b0d7626492ef --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -0,0 +1,117 @@ +context = $this->getMockForAbstractClass( + 'Magento\Framework\View\Element\UiComponent\ContextInterface', + [], + '', + false + ); + $this->componentFactory = $this->getMock( + 'Magento\Framework\View\Element\UiComponentFactory', + ['create'], + [], + '', + false + ); + $this->attributeMetadata = $this->getMockForAbstractClass( + 'Magento\Customer\Api\Data\AttributeMetadataInterface', + [], + '', + false + ); + $this->column = $this->getMockForAbstractClass( + 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + [], + '', + false + ); + $this->attributeOption = $this->getMockForAbstractClass( + 'Magento\Customer\Api\Data\OptionInterface', + [], + '', + false + ); + + $this->columnFactory = new ColumnFactory($this->componentFactory); + } + + public function testCreate() + { + $columnName = 'created_at'; + $config = [ + 'data' => [ + 'js_config' => [ + 'component' => 'Magento_Ui/js/grid/columns/column', + ], + 'config' => [ + 'label' => __('Label'), + 'dataType' => 'text', + 'align' => 'left', + 'visible' => true, + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ] + ], + ], + 'context' => $this->context, + ]; + $attributeData = [ + 'attribute_code' => 'billing_attribute_code', + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'Label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ]; + + $this->componentFactory->expects($this->once()) + ->method('create') + ->with($columnName, 'column', $config) + ->willReturn($this->column); + + $this->assertSame( + $this->column, + $this->columnFactory->create($attributeData, $columnName, $this->context) + ); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php new file mode 100644 index 0000000000000..18096b6de01a3 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -0,0 +1,107 @@ +context = $this->getMockForAbstractClass( + 'Magento\Framework\View\Element\UiComponent\ContextInterface', + [], + '', + false + ); + $this->componentFactory = $this->getMock( + 'Magento\Framework\View\Element\UiComponentFactory', + ['create'], + [], + '', + false + ); + $this->attributeMetadata = $this->getMockForAbstractClass( + 'Magento\Customer\Api\Data\AttributeMetadataInterface', + [], + '', + false + ); + $this->filter = $this->getMockForAbstractClass( + 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + [], + '', + false + ); + $this->attributeOption = $this->getMockForAbstractClass( + 'Magento\Customer\Api\Data\OptionInterface', + [], + '', + false + ); + + $this->filterFactory = new FilterFactory($this->componentFactory); + } + + public function testCreate() + { + $filterName = 'created_at'; + $config = [ + 'data' => [ + 'config' => [ + 'dataScope' => $filterName, + 'label' => __('Label'), + 'options' => [['value' => 'Value', 'label' => 'Label']], + 'caption' => __('Select...'), + ], + ], + 'context' => $this->context, + ]; + $attributeData = [ + 'attribute_code' => $filterName, + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'Label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ]; + $this->componentFactory->expects($this->once()) + ->method('create') + ->with($filterName, 'filterInput', $config) + ->willReturn($this->filter); + + $this->assertSame( + $this->filter, + $this->filterFactory->create($attributeData, $this->context) + ); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php new file mode 100644 index 0000000000000..fcd5ff19400e9 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php @@ -0,0 +1,153 @@ +customerMetadataManagement = $this->getMockForAbstractClass( + 'Magento\Customer\Api\CustomerMetadataManagementInterface', + [], + '', + false + ); + $this->addressMetadataManagement = $this->getMockForAbstractClass( + 'Magento\Customer\Api\AddressMetadataManagementInterface', + [], + '', + false + ); + $this->customerMetadata = $this->getMockForAbstractClass( + 'Magento\Customer\Api\CustomerMetadataInterface', + [], + '', + false + ); + $this->addressMetadata = $this->getMockForAbstractClass( + 'Magento\Customer\Api\AddressMetadataInterface', + [], + '', + false + ); + $this->attribute = $this->getMockForAbstractClass( + 'Magento\Customer\Api\Data\AttributeMetadataInterface', + [], + '', + false + ); + $this->option = $this->getMock('Magento\Customer\Api\Data\OptionInterface', [], [], '', false); + + $this->attributeFilter = $this->getMock('Magento\Customer\Model\Indexer\Attribute\Filter', [], [], '', false); + + $this->component = new AttributeRepository( + $this->customerMetadataManagement, + $this->addressMetadataManagement, + $this->customerMetadata, + $this->addressMetadata, + $this->attributeFilter + ); + } + + public function testGetList() + { + $attributeCode = 'attribute_code'; + $billingPrefix = 'billing_'; + + $this->customerMetadata->expects($this->once()) + ->method('getAllAttributesMetadata') + ->willReturn([]); + $this->addressMetadata->expects($this->once()) + ->method('getAllAttributesMetadata') + ->willReturn([$this->attribute]); + $this->addressMetadataManagement->expects($this->once()) + ->method('canBeFilterableInGrid') + ->with($this->attribute) + ->willReturn(true); + $this->addressMetadataManagement->expects($this->once()) + ->method('canBeSearchableInGrid') + ->with($this->attribute) + ->willReturn(true); + $this->attribute->expects($this->atLeastOnce()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $this->attribute->expects($this->once()) + ->method('getFrontendInput') + ->willReturn('frontend-input'); + $this->attribute->expects($this->once()) + ->method('getFrontendLabel') + ->willReturn('frontend-label'); + $this->attribute->expects($this->once()) + ->method('getBackendType') + ->willReturn('backend-type'); + $this->attribute->expects($this->once()) + ->method('getOptions') + ->willReturn([$this->option]); + $this->attribute->expects($this->once()) + ->method('getIsUsedInGrid') + ->willReturn(true); + $this->attribute->expects($this->once()) + ->method('getIsVisibleInGrid') + ->willReturn(true); + $this->option->expects($this->once()) + ->method('getLabel') + ->willReturn('Label'); + $this->option->expects($this->once()) + ->method('getValue') + ->willReturn('Value'); + $this->attributeFilter->expects($this->once()) + ->method('filter') + ->willReturnArgument(0); + + $this->assertEquals( + [ + $billingPrefix . $attributeCode => [ + 'attribute_code' => 'billing_attribute_code', + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ] + ], + $this->component->getList() + ); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php new file mode 100644 index 0000000000000..d329c4befd1f7 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -0,0 +1,97 @@ +context = $this->getMockForAbstractClass( + 'Magento\Framework\View\Element\UiComponent\ContextInterface', + [], + '', + false + ); + $this->uiComponentFactory = $this->getMock( + 'Magento\Framework\View\Element\UiComponentFactory', + [], + [], + '', + false + ); + $this->urlBuilder = $this->getMockForAbstractClass( + 'Magento\Framework\UrlInterface', + [], + '', + false + ); + $this->component = new Actions( + $this->context, + $this->uiComponentFactory, + $this->urlBuilder + ); + $this->component->setData('name', 'name'); + } + + public function testPrepareDataSource() + { + $dataSource = [ + 'data' => [ + 'items' => [ + [ + 'entity_id' => 1 + ], + ] + ] + ]; + $expectedDataSource = [ + 'data' => [ + 'items' => [ + [ + 'entity_id' => 1, + 'name' => [ + 'edit' => [ + 'href' => 'http://magento.com/customer/index/edit', + 'label' => new \Magento\Framework\Phrase('Edit'), + 'hidden' => false + ] + ] + ], + ] + ] + ]; + + $this->context->expects($this->once()) + ->method('getFilterParam') + ->with('store_id') + ->willReturn(null); + $this->urlBuilder->expects($this->once()) + ->method('getUrl') + ->with( + 'customer/*/edit', + ['id' => 1, 'store' => null] + ) + ->willReturn('http://magento.com/customer/index/edit'); + + $this->component->prepareDataSource($dataSource); + + $this->assertEquals($expectedDataSource, $dataSource); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php new file mode 100644 index 0000000000000..ec5772d9d09b1 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php @@ -0,0 +1,132 @@ +context = $this->getMockForAbstractClass( + 'Magento\Framework\View\Element\UiComponent\ContextInterface', + [], + '', + false + ); + $this->uiComponentFactory = $this->getMock( + 'Magento\Framework\View\Element\UiComponentFactory', + [], + [], + '', + false + ); + $this->attributeRepository = $this->getMock( + 'Magento\Customer\Ui\Component\Listing\AttributeRepository', + [], + [], + '', + false + ); + $this->attributeMetadata = $this->getMockForAbstractClass( + '\Magento\Customer\Api\Data\AttributeMetadataInterface', + [], + '', + false + ); + + $this->component = new AttributeColumn( + $this->context, + $this->uiComponentFactory, + $this->attributeRepository + ); + $this->component->setData('name', 'gender'); + } + + public function testPrepareDataSourceWithoutItems() + { + $dataSource = [ + 'data' => [ + + ] + ]; + $this->attributeRepository->expects($this->never()) + ->method('getMetadataByCode'); + + $this->assertNull($this->component->prepareDataSource($dataSource)); + } + + public function testPrepareDataSource() + { + $genderOptionId = 1; + $genderOptionLabel = 'Male'; + + $dataSource = [ + 'data' => [ + 'items' => [ + [ + 'name' => 'testName' + ], + [ + 'gender' => $genderOptionId + ] + ] + ] + ]; + $expectedSource = [ + 'data' => [ + 'items' => [ + [ + 'name' => 'testName' + ], + [ + 'gender' => $genderOptionLabel + ] + ] + ] + ]; + + $this->attributeRepository->expects($this->once()) + ->method('getMetadataByCode') + ->with('gender') + ->willReturn([ + 'attribute_code' => 'billing_attribute_code', + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => $genderOptionLabel, + 'value' => $genderOptionId + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ]); + + $this->component->prepareDataSource($dataSource); + + $this->assertEquals($expectedSource, $dataSource); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php new file mode 100644 index 0000000000000..92ec5d4082f3e --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php @@ -0,0 +1,201 @@ +context = $this->getMockForAbstractClass( + 'Magento\Framework\View\Element\UiComponent\ContextInterface', + [], + '', + false + ); + $this->columnFactory = $this->getMock( + 'Magento\Customer\Ui\Component\ColumnFactory', + ['create'], + [], + '', + false + ); + $this->attributeRepository = $this->getMock( + 'Magento\Customer\Ui\Component\Listing\AttributeRepository', + [], + [], + '', + false + ); + $this->attribute = $this->getMock( + 'Magento\Customer\Model\Attribute', + [], + [], + '', + false + ); + $this->column = $this->getMockForAbstractClass( + 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + [], + '', + false + ); + + $this->component = new Columns( + $this->context, + $this->columnFactory, + $this->attributeRepository + ); + } + + public function testPrepareWithAddColumn() + { + $attributeCode = 'attribute_code'; + + $this->attributeRepository->expects($this->atLeastOnce()) + ->method('getList') + ->willReturn( + [ + $attributeCode => [ + 'attribute_code' => 'billing_attribute_code', + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ] + ] + ); + $this->columnFactory->expects($this->once()) + ->method('create') + ->willReturn($this->column); + $this->column->expects($this->once()) + ->method('prepare'); + + $this->component->prepare(); + } + + public function testPrepareWithUpdateColumn() + { + $attributeCode = 'billing_attribute_code'; + $backendType = 'backend-type'; + $attributeData = [ + 'attribute_code' => 'billing_attribute_code', + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ]; + + $this->attributeRepository->expects($this->atLeastOnce()) + ->method('getList') + ->willReturn([$attributeCode => $attributeData]); + $this->columnFactory->expects($this->once()) + ->method('create') + ->willReturn($this->column); + $this->column->expects($this->once()) + ->method('prepare'); + $this->column->expects($this->atLeastOnce()) + ->method('getData') + ->with('config') + ->willReturn([]); + $this->column->expects($this->once()) + ->method('setData') + ->with( + 'config', + [ + 'name' => $attributeCode, + 'dataType' => $backendType, + 'visible' => true + ] + ); + + $this->component->addColumn($attributeData, $attributeCode); + $this->component->prepare(); + } + + public function testPrepareWithUpdateStaticColumn() + { + $attributeCode = 'billing_attribute_code'; + $backendType = 'static'; + $attributeData = [ + 'attribute_code' => 'billing_attribute_code', + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => $backendType, + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ]; + + $this->attributeRepository->expects($this->atLeastOnce()) + ->method('getList') + ->willReturn([$attributeCode => $attributeData]); + $this->columnFactory->expects($this->once()) + ->method('create') + ->willReturn($this->column); + $this->column->expects($this->once()) + ->method('prepare'); + $this->column->expects($this->atLeastOnce()) + ->method('getData') + ->with('config') + ->willReturn([]); + $this->column->expects($this->once()) + ->method('setData') + ->with( + 'config', + [ + 'visible' => true + ] + ); + + $this->component->addColumn($attributeData, $attributeCode); + $this->component->prepare(); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php new file mode 100644 index 0000000000000..2dc73c58104a5 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php @@ -0,0 +1,135 @@ +context = $this->getMockForAbstractClass( + 'Magento\Framework\View\Element\UiComponent\ContextInterface', + [], + '', + false + ); + $this->filterFactory = $this->getMock( + 'Magento\Customer\Ui\Component\FilterFactory', + ['create'], + [], + '', + false + ); + $this->attributeRepository = $this->getMock( + 'Magento\Customer\Ui\Component\Listing\AttributeRepository', + [], + [], + '', + false + ); + $this->attributeMetadata = $this->getMockForAbstractClass( + 'Magento\Customer\Api\Data\AttributeMetadataInterface', + [], + '', + false + ); + $this->filter = $this->getMockForAbstractClass( + 'Magento\Ui\Component\Listing\Columns\ColumnInterface', + [], + '', + false + ); + + $this->component = new Filters( + $this->context, + $this->filterFactory, + $this->attributeRepository + ); + } + + public function testPrepare() + { + $attributeCode = 'billing_attribute_code'; + $attributeData = [ + 'attribute_code' => $attributeCode, + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => true, + 'is_searchable_in_grid' => true, + ]; + + $this->attributeRepository->expects($this->atLeastOnce()) + ->method('getList') + ->willReturn([$attributeCode => $attributeData]); + $this->filterFactory->expects($this->once()) + ->method('create') + ->with($attributeData, $this->context) + ->willReturn($this->filter); + $this->filter->expects($this->once()) + ->method('prepare'); + + $this->component->prepare(); + $this->assertSame($this->filter, $this->component->getComponent($attributeCode)); + } + + public function testPrepareWithAlreadyAddedComponent() + { + $attributeCode = 'billing_attribute_code'; + $attributeData = [ + 'attribute_code' => $attributeCode, + 'frontend_input' => 'frontend-input', + 'frontend_label' => 'frontend-label', + 'backend_type' => 'backend-type', + 'options' => [ + [ + 'label' => 'Label', + 'value' => 'Value' + ] + ], + 'is_used_in_grid' => true, + 'is_visible_in_grid' => true, + 'is_filterable_in_grid' => false, + 'is_searchable_in_grid' => true, + ]; + + $this->component->addComponent($attributeCode, $this->filter); + + $this->attributeRepository->expects($this->atLeastOnce()) + ->method('getList') + ->willReturn([$attributeCode => $attributeData]); + + $this->component->prepare(); + $this->assertEquals(null, $this->component->getComponent($attributeCode)); + } +} diff --git a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php new file mode 100644 index 0000000000000..59a6fca610d28 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php @@ -0,0 +1,96 @@ + 'Magento_Ui/js/grid/columns/column', + 'date' => 'Magento_Ui/js/grid/columns/date', + ]; + + /** + * @var array + */ + protected $dataTypeMap = [ + 'default' => 'text', + 'text' => 'text', + 'boolean' => 'text', + 'select' => 'text', + 'multiselect' => 'text', + 'date' => 'date', + ]; + + /** + * @param \Magento\Framework\View\Element\UiComponentFactory $componentFactory + */ + public function __construct( + \Magento\Framework\View\Element\UiComponentFactory $componentFactory + ) { + $this->componentFactory = $componentFactory; + } + + /** + * @param array $attributeData + * @param string $columnName + * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context + * @param array $config + * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface + */ + public function create(array $attributeData, $columnName, $context, array $config = []) + { + $config = array_merge([ + 'label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL]), + 'dataType' => $this->getDataType($attributeData[AttributeMetadata::FRONTEND_INPUT]), + 'align' => 'left', + 'visible' => (bool)$attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID], + ], $config); + + if ($attributeData[AttributeMetadata::OPTIONS]) { + $config['options'] = $attributeData[AttributeMetadata::OPTIONS]; + } + $arguments = [ + 'data' => [ + 'js_config' => [ + 'component' => $this->getJsComponent($config['dataType']), + ], + 'config' => $config, + ], + 'context' => $context, + ]; + return $this->componentFactory->create($columnName, 'column', $arguments); + } + + /** + * @param string $dataType + * @return string + */ + protected function getJsComponent($dataType) + { + return $this->jsComponentMap[$dataType]; + } + + /** + * @param string $frontendType + * @return string + */ + protected function getDataType($frontendType) + { + return isset($this->dataTypeMap[$frontendType]) + ? $this->dataTypeMap[$frontendType] + : $this->dataTypeMap['default']; + } +} diff --git a/app/code/Magento/Customer/Ui/Component/DataProvider.php b/app/code/Magento/Customer/Ui/Component/DataProvider.php new file mode 100644 index 0000000000000..91a14122678c9 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/DataProvider.php @@ -0,0 +1,119 @@ +attributeRepository = $attributeRepository; + parent::__construct( + $name, + $primaryFieldName, + $requestFieldName, + $reporting, + $searchCriteriaBuilder, + $request, + $filterBuilder, + $meta, + $data + ); + } + + /** + * Retrieve custom attributes options + * + * @return array + */ + public function getCustomAttributesOptions() + { + $attributes = []; + foreach ($this->attributeRepository->getList() as $attributeCode => $attributeData) { + if ($attributeData[AttributeMetadataInterface::BACKEND_TYPE] != 'static' + && $attributeData[AttributeMetadataInterface::IS_USED_IN_GRID] + && $attributeData[AttributeMetadataInterface::OPTIONS] + ) { + $attributes[$attributeCode] = $attributeData[AttributeMetadataInterface::OPTIONS]; + } + } + return $attributes; + } + + /** + * Retrieve attribute option label by option value + * + * @param array $attributeData + * @param string $value + * @return string + */ + protected function getAttributeOptionLabelByValue(array $attributeData, $value) + { + if (empty($value)) { + return $value; + } + foreach ($attributeData as $option) { + if ($option['value'] === $value) { + return $option['label']; + } + } + return $value; + } + + /** + * {@inheritdoc} + */ + public function getData() + { + $data = $this->searchResultToOutput($this->getSearchResult()); + $customAttributesOptions = $this->getCustomAttributesOptions(); + foreach ($customAttributesOptions as $attributeCode => $attributeData) { + foreach ($data['items'] as &$item) { + if (isset($item[$attributeCode])) { + $item[$attributeCode] = $this->getAttributeOptionLabelByValue( + $attributeData, + $item[$attributeCode] + ); + } + } + } + return $data; + } +} diff --git a/app/code/Magento/Customer/Ui/Component/FilterFactory.php b/app/code/Magento/Customer/Ui/Component/FilterFactory.php new file mode 100644 index 0000000000000..75f20f29a1cbd --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/FilterFactory.php @@ -0,0 +1,73 @@ + 'filterInput', + 'select' => 'filterSelect', + 'boolean' => 'filterSelect', + 'multiselect' => 'filterSelect', + 'date' => 'filterDate', + ]; + + /** + * @param \Magento\Framework\View\Element\UiComponentFactory $componentFactory + */ + public function __construct(\Magento\Framework\View\Element\UiComponentFactory $componentFactory) + { + $this->componentFactory = $componentFactory; + } + + /** + * @param array $attributeData + * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context + * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface + */ + public function create(array $attributeData, $context) + { + $config = [ + 'dataScope' => $attributeData[AttributeMetadata::ATTRIBUTE_CODE], + 'label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL]), + ]; + if ($attributeData[AttributeMetadata::OPTIONS]) { + $config['options'] = $attributeData[AttributeMetadata::OPTIONS]; + $config['caption'] = __('Select...'); + } + $arguments = [ + 'data' => [ + 'config' => $config, + ], + 'context' => $context, + ]; + + return $this->componentFactory->create( + $attributeData[AttributeMetadata::ATTRIBUTE_CODE], + $this->getFilterType($attributeData[AttributeMetadata::FRONTEND_INPUT]), + $arguments + ); + } + + /** + * @param string $frontendInput + * @return string + */ + protected function getFilterType($frontendInput) + { + return isset($this->filterMap[$frontendInput]) ? $this->filterMap[$frontendInput] : $this->filterMap['default']; + } +} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php new file mode 100644 index 0000000000000..294fa32b3e872 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php @@ -0,0 +1,132 @@ +customerMetadataManagement = $customerMetadataManagement; + $this->addressMetadataManagement = $addressMetadataManagement; + $this->customerMetadata = $customerMetadata; + $this->addressMetadata = $addressMetadata; + $this->attributeFilter = $attributeFiltering; + } + + /** + * @return array + */ + public function getList() + { + if (!$this->attributes) { + $this->attributes = $this->getListForEntity( + $this->customerMetadata->getAllAttributesMetadata(), + CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, + $this->customerMetadataManagement + ); + $this->attributes = array_merge( + $this->attributes, + $this->getListForEntity( + $this->addressMetadata->getAllAttributesMetadata(), + AddressMetadataInterface::ENTITY_TYPE_ADDRESS, + $this->addressMetadataManagement + ) + ); + } + + return $this->attributeFilter->filter($this->attributes); + } + + /** + * @param AttributeMetadataInterface[] $metadata + * @param string $entityTypeCode + * @param MetadataManagementInterface $management + * @return array + */ + protected function getListForEntity(array $metadata, $entityTypeCode, MetadataManagementInterface $management) + { + $attributes = []; + /** @var AttributeMetadataInterface $attribute */ + foreach ($metadata as $attribute) { + $attributeCode = $attribute->getAttributeCode(); + if ($entityTypeCode == AddressMetadataInterface::ENTITY_TYPE_ADDRESS) { + $attributeCode = self::BILLING_ADDRESS_PREFIX . $attribute->getAttributeCode(); + } + $attributes[$attributeCode] = [ + AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCode, + AttributeMetadataInterface::FRONTEND_INPUT => $attribute->getFrontendInput(), + AttributeMetadataInterface::FRONTEND_LABEL => $attribute->getFrontendLabel(), + AttributeMetadataInterface::BACKEND_TYPE => $attribute->getBackendType(), + AttributeMetadataInterface::OPTIONS => $this->getOptionArray($attribute->getOptions()), + AttributeMetadataInterface::IS_USED_IN_GRID => $attribute->getIsUsedInGrid(), + AttributeMetadataInterface::IS_VISIBLE_IN_GRID => $attribute->getIsVisibleInGrid(), + AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => $management->canBeFilterableInGrid($attribute), + AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => $management->canBeSearchableInGrid($attribute), + ]; + } + + return $attributes; + } + + protected function getOptionArray(array $options) + { + /** @var \Magento\Customer\Api\Data\OptionInterface $option */ + foreach ($options as &$option) { + $option = ['label' => $option->getLabel(), 'value' => $option->getValue()]; + } + return $options; + } + + + /** + * @param string $code + * @return [] + */ + public function getMetadataByCode($code) + { + return isset($this->getList()[$code]) ? $this->getList()[$code] : null; + } +} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php new file mode 100644 index 0000000000000..8d85411f99c24 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php @@ -0,0 +1,64 @@ +urlBuilder = $urlBuilder; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array &$dataSource) + { + if (isset($dataSource['data']['items'])) { + $storeId = $this->context->getFilterParam('store_id'); + + foreach ($dataSource['data']['items'] as &$item) { + $item[$this->getData('name')]['edit'] = [ + 'href' => $this->urlBuilder->getUrl( + 'customer/*/edit', + ['id' => $item['entity_id'], 'store' => $storeId] + ), + 'label' => __('Edit'), + 'hidden' => false, + ]; + } + } + } +} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php new file mode 100644 index 0000000000000..54985c4f9ccb9 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php @@ -0,0 +1,64 @@ +attributeRepository = $attributeRepository; + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array &$dataSource) + { + if (!isset($dataSource['data']['items'])) { + return null; + } + + $metaData = $this->attributeRepository->getMetadataByCode($this->getName()); + if ($metaData && count($metaData[AttributeMetadata::OPTIONS])) { + foreach ($dataSource['data']['items'] as &$item) { + if (!isset($item[$this->getName()])) { + continue; + } + foreach ($metaData[AttributeMetadata::OPTIONS] as $option) { + if ($option['value'] == $item[$this->getName()]) { + $item[$this->getName()] = $option['label']; + break; + } + } + } + } + } +} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php new file mode 100644 index 0000000000000..2f74af7f6bd16 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php @@ -0,0 +1,137 @@ +columnFactory = $columnFactory; + $this->attributeRepository = $attributeRepository; + } + + /** + * @return int + */ + protected function getDefaultSortOrder() + { + $max = 0; + foreach ($this->components as $component) { + $config = $component->getData('config'); + if (isset($config['sortOrder']) && $config['sortOrder'] > $max) { + $max = $config['sortOrder']; + } + } + return ++$max; + } + + /** + * Update actions column sort order + * + * @return void + */ + protected function updateActionColumnSortOrder() + { + if (isset($this->components['actions'])) { + $component = $this->components['actions']; + $component->setData( + 'config', + array_merge($component->getData('config'), ['sortOrder' => ++$this->columnSortOrder]) + ); + } + } + + /** + * {@inheritdoc} + */ + public function prepare() + { + $this->columnSortOrder = $this->getDefaultSortOrder(); + foreach ($this->attributeRepository->getList() as $newAttributeCode => $attributeData) { + if (isset($this->components[$newAttributeCode])) { + $this->updateColumn($attributeData, $newAttributeCode); + } elseif (!$attributeData[AttributeMetadata::BACKEND_TYPE] != 'static' + && $attributeData[AttributeMetadata::IS_USED_IN_GRID] + ) { + $this->addColumn($attributeData, $newAttributeCode); + } + } + $this->updateActionColumnSortOrder(); + parent::prepare(); + } + + /** + * @param array $attributeData + * @param string $columnName + * @return void + */ + public function addColumn(array $attributeData, $columnName) + { + $config['sortOrder'] = ++$this->columnSortOrder; + $column = $this->columnFactory->create($attributeData, $columnName, $this->getContext(), $config); + $column->prepare(); + $this->addComponent($attributeData[AttributeMetadata::ATTRIBUTE_CODE], $column); + } + + /** + * @param array $attributeData + * @param string $newAttributeCode + * @return void + */ + public function updateColumn(array $attributeData, $newAttributeCode) + { + $component = $this->components[$attributeData[AttributeMetadata::ATTRIBUTE_CODE]]; + + if ($attributeData[AttributeMetadata::BACKEND_TYPE] != 'static') { + if ($attributeData[AttributeMetadata::IS_USED_IN_GRID]) { + $config = array_merge( + $component->getData('config'), + [ + 'name' => $newAttributeCode, + 'dataType' => $attributeData[AttributeMetadata::BACKEND_TYPE], + 'visible' => $attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID] + ] + ); + $component->setData('config', $config); + } + } else { + $component->setData( + 'config', + array_merge( + $component->getData('config'), + ['visible' => $attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID]] + ) + ); + } + } +} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Filters.php b/app/code/Magento/Customer/Ui/Component/Listing/Filters.php new file mode 100644 index 0000000000000..2e0816d079729 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/Listing/Filters.php @@ -0,0 +1,55 @@ +filterFactory = $filterFactory; + $this->attributeRepository = $attributeRepository; + } + + /** + * {@inheritdoc} + */ + public function prepare() + { + /** @var \Magento\Customer\Model\Attribute $attribute */ + foreach ($this->attributeRepository->getList() as $attributeCode => $attributeData) { + if (!isset($this->components[$attributeCode])) { + if (!$attributeData[AttributeMetadata::BACKEND_TYPE] != 'static' + && $attributeData[AttributeMetadata::IS_USED_IN_GRID] + && $attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID] + ) { + $filter = $this->filterFactory->create($attributeData, $this->getContext()); + $filter->prepare(); + $this->addComponent($attributeCode, $filter); + } + } elseif ($attributeData[AttributeMetadata::IS_USED_IN_GRID] + && !$attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID] + ) { + unset($this->components[$attributeCode]); + } + } + parent::prepare(); + } +} diff --git a/app/code/Magento/Customer/etc/crontab.xml b/app/code/Magento/Customer/etc/crontab.xml index 21b4e0f9824f5..26f1056f2d724 100644 --- a/app/code/Magento/Customer/etc/crontab.xml +++ b/app/code/Magento/Customer/etc/crontab.xml @@ -11,4 +11,9 @@ 0 0 * * * + + + */5 * * * * + + diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index f6197ce876ddc..3deee7dcbfb97 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -37,6 +37,10 @@ type="Magento\Customer\Model\Metadata\CustomerCachedMetadata" /> + + Magento\Customer\Model\Config\Share\Proxy @@ -168,13 +172,136 @@ EavVersionControlSnapshot + + + customer_grid_flat + Magento\Customer\Model\Resource\Customer + + + Magento\Customer\Model\Resource\Grid\Collection Magento\Customer\Model\Resource\Online\Grid\Collection + + + CustomerNameExpression + + + + + ShippingAddressExpression + + + + + BillingAddressExpression + + + + + LastVisitAtSubSelect + + + + + customer_visitor + last_visit_at + + + e + entity_id + + + + last_visit_at + + + + + + e + + + e + prefix + + + e + firstname + + + e + middlename + + + e + lastname + + + e + suffix + + + + + + + + + shipping + street + + + shipping + city + + + shipping + region + + + shipping + postcode + + + + + + + + + billing + street + + + billing + city + + + billing + region + + + billing + postcode + + + + + + + Magento\Customer\Model\Resource\Attribute\Collection + + + + + Magento\Customer\Model\Resource\Address\Attribute\Collection + + customer_visitor diff --git a/app/code/Magento/Customer/etc/indexer.xml b/app/code/Magento/Customer/etc/indexer.xml new file mode 100644 index 0000000000000..093bb0b559fe3 --- /dev/null +++ b/app/code/Magento/Customer/etc/indexer.xml @@ -0,0 +1,53 @@ + + + + + Customer Grid + Rebuild Customer grid index + +
+ + + + + + + + + + + +
+ +
+ + +
+ +
+ + + + + + + + + + + + +
+ + + +
+
diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 33f923e05015b..2c2e691319465 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/Customer/etc/mview.xml b/app/code/Magento/Customer/etc/mview.xml new file mode 100644 index 0000000000000..bdb6d2b667fb6 --- /dev/null +++ b/app/code/Magento/Customer/etc/mview.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_grid.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_grid.xml deleted file mode 100644 index 8c0352d29311f..0000000000000 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_grid.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_grid_block.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_grid_block.xml deleted file mode 100644 index 2deaefacb01aa..0000000000000 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_grid_block.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - customerGrid - Magento\Customer\Model\Resource\Customer\Grid\ServiceCollection - entity_id - asc - true - true - - 1 - - - - - entity_id - customer - - - Delete - customer/*/massDelete - Are you sure you want to delete? - - - Subscribe to Newsletter - customer/*/massSubscribe - - - Unsubscribe from Newsletter - customer/*/massUnsubscribe - - - Assign a Customer Group - customer/*/massAssignGroup - grid.groups - - - - - - - - group - select - required-entry - Group - Magento\Customer\Model\Config\Source\Group - - - - - - - - - customer/*/edit - - getId - - - - - - ID - number - entity_id - entity_id - - - - - Name - name - - - - - Email - email - - - - - Group - group_id - options - - - - - - Phone - billing_telephone - col-phone - col-phone - - - - - ZIP - billing_postcode - - - - - Country - billing_country_id - options - - - - - - State/Province - billing_region - - - - - Customer Since - datetime - created_at - true - - - - - Web Site - col-store - col-store - options - - website_id - - - - - action - Action - action - getId - false - false - stores - true - - - Edit - - customer/*/edit - - id - - - col-actions - col-actions - - - - - - - diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_index.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_index.xml index edd047e00e523..b45c461ad53a8 100644 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_index.xml +++ b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_index.xml @@ -7,11 +7,9 @@ --> - - - + diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml new file mode 100644 index 0000000000000..5a8646470b015 --- /dev/null +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml @@ -0,0 +1,694 @@ + + ++ + + customer_listing.customer_listing_data_source + customer_listing.customer_listing_data_source + + customer_columns + + + add + Add New Customer + primary + */*/new + + + + + + Magento\Customer\Ui\Component\DataProvider + customer_listing_data_source + entity_id + id + + + + + + + + + Magento_Ui/js/grid/provider + + + + + + + ui/grid/toolbar + + + + + + Magento_Ui/js/grid/controls/bookmarks/bookmarks + dataGridActions + + + + customer_listing + + + + + + + + + customer_listing.customer_listing.customer_columns + + Magento_Ui/js/grid/controls/columns + dataGridActions + + + + + + + customer_listing.customer_listing.customer_columns.ids + + + + + + + Magento_Ui/js/grid/search/search + dataGridFilters + customer_listing.customer_listing_data_source + customer_listing.customer_listing.listing_top.listing_filters_chips + + customer_listing.customer_listing.listing_top.bookmarks + current.search + + + + + + + + dataGridFilters + filters + + customer_listing.customer_listing.listing_top.bookmarks + current.filters + + + customer_listing.customer_listing.listing_top.listing_filters + + customer_listing.customer_listing.listing_top.bookmarks:current.columns.${ $.index }.visible + + + + + + + + entity_id + ID + + customer_listing.customer_listing.listing_top.listing_filters + + + + + + + from + from + From + + + + + + + to + to + To + + + + + + + + name + Name + + + + + + + email + Email + + + + + + Magento\Customer\Model\Config\Source\Group\Multiselect + + + + group_id + Group + Select... + + + + + + + billing_telephone + Phone + + + + + + + billing_postcode + ZIP + + + + + + Magento\Directory\Model\Resource\Country\Collection + + + + billing_country_id + Country + Select... + + + + + + + billing_region + State/Province + + + + + + + created_at + Customer Since + + customer_listing.customer_listing.listing_top.listing_filters + + + + + + + from + From + From + MM/dd/YYYY + + + + + + + to + To + To + MM/dd/YYYY + + + + + + + Magento\Config\Model\Config\Source\Website + + + + website_id + Website + Select... + + + + + + + + customer_listing.customer_listing.customer_columns.ids + bottom + + + delete + Delete + customer/index/massDelete + + Delete items + Are you sure you wan't to delete selected items? + + + + subscribe + Subscribe to Newsletter + customer/index/massSubscribe + + + unsubscribe + Unsubscribe from Newsletter + customer/index/massUnsubscribe + + + entity_id + + + + + + + + customer_listing.customer_listing.listing_top.bookmarks + current.paging + + customer_listing.customer_listing.customer_columns.ids + bottom + + + 20 + 20 + + + 30 + 30 + + + 50 + 50 + + + 100 + 100 + + + 200 + 200 + + + + + + + + + + + customer_listing.customer_listing.listing_top.bookmarks + current + + + + customer_listing.customer_listing.customer_columns.actions + applyAction + + edit + ${ $.$data.rowIndex } + + + true + + customer_listing.customer_listing.listing_top.bookmarks + columns.${ $.index } + current.${ $.storageConfig.root } + + + + + + + + Magento_Ui/js/grid/columns/multiselect + + + entity_id + false + 10 + + + + + + + Magento_Ui/js/grid/columns/column + + + text + asc + true + left + ID + 20 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + text + left + Name + 30 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + text + left + Email + 40 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + text + left + Group + 50 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + text + left + Phone + 60 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + text + left + ZIP + 70 + + + + + + + Magento_Ui/js/grid/columns/column + + + text + left + Country + 80 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + text + left + State/Province + 90 + + + + + + + Magento_Ui/js/grid/columns/date + + + true + date + left + Customer Since + 100 + + + + + + + Magento_Ui/js/grid/columns/date + + + text + left + Web Site + 110 + + + + + + + Magento_Ui/js/grid/columns/date + + + true + false + date + left + Last Logged In + 120 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + Confirmed email + 130 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + Account Created in + 140 + + + + + + + Magento_Ui/js/grid/columns/column + + + false + text + left + Billing Address + 150 + + + + + + + Magento_Ui/js/grid/columns/column + + + false + text + left + Shipping Address + 160 + + + + + + + Magento_Ui/js/grid/columns/date + + + true + false + date + left + Date Of Birth + 170 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + Tax VAT Number + 180 + + + + + + + Magento_Ui/js/grid/columns/column + + + false + text + left + Gender + 190 + + + + + + + Magento_Ui/js/grid/columns/column + + + false + text + left + Street Address + 200 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + City + 210 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + Fax + 220 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + VAT Number + 230 + + + + + + + Magento_Ui/js/grid/columns/column + + + true + false + text + left + Company + 240 + + + + + + + false + actions + entity_id + left + Action + actions + false + false + + + + + diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index 54018f381b4ed..1efc6e8346c5d 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -1041,11 +1041,22 @@ public function exportToArray() * @return string */ public function getRowIdFieldName() + { + return $this->getIdFieldName(); + } + + /** + * Id field name getter + * + * @return string + */ + public function getIdFieldName() { if ($this->_idFieldName === null) { $this->_setIdFieldName($this->getEntity()->getIdFieldName()); } - return $this->getIdFieldName(); + + return $this->_idFieldName; } /** diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php index 04d7f729f8c86..0514979402645 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php @@ -42,7 +42,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected $stockItemFactoryMock; /** - * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $categoryIndexerMock; @@ -97,7 +97,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private $website; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistryMock; @@ -161,7 +161,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->categoryIndexerMock = $this->getMockForAbstractClass('\Magento\Indexer\Model\IndexerInterface'); + $this->categoryIndexerMock = $this->getMockForAbstractClass('\Magento\Framework\Indexer\IndexerInterface'); $this->moduleManager = $this->getMock( 'Magento\Framework\Module\Manager', @@ -260,7 +260,7 @@ public function setUp() $storeManager->expects($this->any()) ->method('getWebsite') ->will($this->returnValue($this->website)); - $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', ['get'], [], '', false); $this->categoryRepository = $this->getMock('Magento\Catalog\Api\CategoryRepositoryInterface'); $this->_catalogProduct = $this->getMock( diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index 4a42c4abab403..e46e82e6abe8d 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -126,7 +126,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel protected $_uploaderFactory; /** - * @var \Magento\Indexer\Model\IndexerRegistry + * @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; @@ -152,7 +152,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel * @param FileTransferFactory $httpFactory * @param \Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory * @param Source\Import\Behavior\Factory $behaviorFactory - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param History $importHistoryModel * @param \Magento\Framework\Stdlib\DateTime\DateTime * @param array $data @@ -170,7 +170,7 @@ public function __construct( \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory, \Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory, \Magento\ImportExport\Model\Source\Import\Behavior\Factory $behaviorFactory, - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\ImportExport\Model\History $importHistoryModel, \Magento\Framework\Stdlib\DateTime\DateTime $localeDate, array $data = [] diff --git a/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php b/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php index d73b7230d9bed..deaed0a6d0d08 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php @@ -152,7 +152,7 @@ public function testGetSummaryStats() '', false ); - $indexerRegistry = $this->getMock('Magento\Indexer\Model\IndexerRegistry', [], [], '', false); + $indexerRegistry = $this->getMock('Magento\Framework\Indexer\IndexerRegistry', [], [], '', false); $importHistoryModel = $this->getMock('Magento\ImportExport\Model\History', [], [], '', false); $localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); $import = new \Magento\ImportExport\Model\Import( diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php index 1083fc1e15acf..66b249b836222 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php @@ -59,7 +59,7 @@ class ImportTest extends \PHPUnit_Framework_TestCase protected $_uploaderFactory; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $indexerRegistry; @@ -151,7 +151,7 @@ public function setUp() $this->_behaviorFactory = $this->getMockBuilder('\Magento\ImportExport\Model\Source\Import\Behavior\Factory') ->disableOriginalConstructor() ->getMock(); - $this->indexerRegistry = $this->getMockBuilder('\Magento\Indexer\Model\IndexerRegistry') + $this->indexerRegistry = $this->getMockBuilder('\Magento\Framework\Indexer\IndexerRegistry') ->disableOriginalConstructor() ->getMock(); $this->historyModel = $this->getMockBuilder('\Magento\ImportExport\Model\History') diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 8a19a4779907e..54ca6f4265ae5 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -6,7 +6,6 @@ "magento/module-store": "1.0.0-beta", "magento/module-backend": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", - "magento/module-indexer": "1.0.0-beta", "magento/module-media-storage": "1.0.0-beta", "magento/framework": "1.0.0-beta", "ext-ctype": "*", diff --git a/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php index d108b27b83faf..a8388ea8413ff 100644 --- a/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php +++ b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php @@ -18,15 +18,15 @@ public function render(\Magento\Framework\DataObject $row) $class = ''; $text = ''; switch ($this->_getValue($row)) { - case \Magento\Indexer\Model\Indexer\State::STATUS_INVALID: + case \Magento\Framework\Indexer\StateInterface::STATUS_INVALID: $class = 'grid-severity-critical'; $text = __('Reindex required'); break; - case \Magento\Indexer\Model\Indexer\State::STATUS_VALID: + case \Magento\Framework\Indexer\StateInterface::STATUS_VALID: $class = 'grid-severity-notice'; $text = __('Ready'); break; - case \Magento\Indexer\Model\Indexer\State::STATUS_WORKING: + case \Magento\Framework\Indexer\StateInterface::STATUS_WORKING: $class = 'grid-severity-major'; $text = __('Processing'); break; diff --git a/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php b/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php index 2c7c12a3cfc71..6af8664c62a2b 100644 --- a/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php +++ b/app/code/Magento/Indexer/Console/Command/AbstractIndexerManageCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; -use Magento\Indexer\Model\IndexerInterface; +use Magento\Framework\Indexer\IndexerInterface; /** * An Abstract class for all Indexer related commands. diff --git a/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php b/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php index d02ee885ee4ca..830c36d0f9f3d 100644 --- a/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php +++ b/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php @@ -34,13 +34,13 @@ protected function execute(InputInterface $input, OutputInterface $output) foreach ($indexers as $indexer) { $status = 'unknown'; switch ($indexer->getStatus()) { - case \Magento\Indexer\Model\Indexer\State::STATUS_VALID: + case \Magento\Framework\Indexer\StateInterface::STATUS_VALID: $status = 'Ready'; break; - case \Magento\Indexer\Model\Indexer\State::STATUS_INVALID: + case \Magento\Framework\Indexer\StateInterface::STATUS_INVALID: $status = 'Reindex required'; break; - case \Magento\Indexer\Model\Indexer\State::STATUS_WORKING: + case \Magento\Framework\Indexer\StateInterface::STATUS_WORKING: $status = 'Processing'; break; } diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php index e39cc3cc5fa63..1ea64de8b75d6 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php @@ -21,8 +21,8 @@ public function execute() } else { try { foreach ($indexerIds as $indexerId) { - /** @var \Magento\Indexer\Model\IndexerInterface $model */ - $model = $this->_objectManager->get('Magento\Indexer\Model\IndexerRegistry')->get($indexerId); + /** @var \Magento\Framework\Indexer\IndexerInterface $model */ + $model = $this->_objectManager->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId); $model->setScheduled(true); } $this->messageManager->addSuccess( diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php index 27def97e6b154..fecf0df7a53d7 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php @@ -21,8 +21,8 @@ public function execute() } else { try { foreach ($indexerIds as $indexerId) { - /** @var \Magento\Indexer\Model\IndexerInterface $model */ - $model = $this->_objectManager->get('Magento\Indexer\Model\IndexerRegistry')->get($indexerId); + /** @var \Magento\Framework\Indexer\IndexerInterface $model */ + $model = $this->_objectManager->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId); $model->setScheduled(false); } $this->messageManager->addSuccess( diff --git a/app/code/Magento/Indexer/Model/Action/Entity.php b/app/code/Magento/Indexer/Model/Action/Entity.php deleted file mode 100644 index 544be3646fca8..0000000000000 --- a/app/code/Magento/Indexer/Model/Action/Entity.php +++ /dev/null @@ -1,31 +0,0 @@ -getPrimaryResource(); - foreach ($this->getPrimaryFieldset()['fields'] as $field) { - $handler = $field['handler']; - /** @var HandlerInterface $handler */ - $handler->prepareSql($collection, $field); - } - $collection->addFieldToFilter($collection->getIdFieldName(), $ids); - - return $collection; - } -} diff --git a/app/code/Magento/Indexer/Model/Config.php b/app/code/Magento/Indexer/Model/Config.php index dc67bbb4f0980..21ab6a4a6ce11 100644 --- a/app/code/Magento/Indexer/Model/Config.php +++ b/app/code/Magento/Indexer/Model/Config.php @@ -5,6 +5,8 @@ */ namespace Magento\Indexer\Model; +use Magento\Framework\Indexer\ConfigInterface; + class Config implements ConfigInterface { /** diff --git a/app/code/Magento/Indexer/Model/Config/Data.php b/app/code/Magento/Indexer/Model/Config/Data.php index 7c0fd646e8fbf..0ce139b80c729 100644 --- a/app/code/Magento/Indexer/Model/Config/Data.php +++ b/app/code/Magento/Indexer/Model/Config/Data.php @@ -13,13 +13,13 @@ class Data extends \Magento\Framework\Config\Data protected $stateCollection; /** - * @param \Magento\Indexer\Model\Config\Reader $reader + * @param \Magento\Framework\Indexer\Config\Reader $reader * @param \Magento\Framework\Config\CacheInterface $cache * @param \Magento\Indexer\Model\Resource\Indexer\State\Collection $stateCollection * @param string $cacheId */ public function __construct( - \Magento\Indexer\Model\Config\Reader $reader, + \Magento\Framework\Indexer\Config\Reader $reader, \Magento\Framework\Config\CacheInterface $cache, \Magento\Indexer\Model\Resource\Indexer\State\Collection $stateCollection, $cacheId = 'indexer_config' diff --git a/app/code/Magento/Indexer/Model/Config/SchemaLocator.php b/app/code/Magento/Indexer/Model/Config/SchemaLocator.php deleted file mode 100644 index 861a9ab0e9285..0000000000000 --- a/app/code/Magento/Indexer/Model/Config/SchemaLocator.php +++ /dev/null @@ -1,53 +0,0 @@ -getModuleDir('etc', 'Magento_Indexer'); - $this->_schema = $etcDir . '/indexer_merged.xsd'; - $this->_perFileSchema = $etcDir . '/indexer.xsd'; - } - - /** - * Get path to merged config schema - * - * @return string|null - */ - public function getSchema() - { - return $this->_schema; - } - - /** - * Get path to pre file validation schema - * - * @return string|null - */ - public function getPerFileSchema() - { - return $this->_perFileSchema; - } -} diff --git a/app/code/Magento/Indexer/Model/Handler/DefaultHandler.php b/app/code/Magento/Indexer/Model/Handler/DefaultHandler.php deleted file mode 100644 index 365e02ef455ba..0000000000000 --- a/app/code/Magento/Indexer/Model/Handler/DefaultHandler.php +++ /dev/null @@ -1,35 +0,0 @@ -addFieldToSelect( - isset($fieldInfo['origin']) ? $fieldInfo['origin'] : $fieldInfo['name'], - $fieldInfo['name'] - ); - } - - /** - * @param SourceProviderInterface $source - * @param array $fieldInfo - * @return void - */ - public function prepareData(SourceProviderInterface $source, $fieldInfo) - { - new \Exception('Not implemented yet'); - } -} diff --git a/app/code/Magento/Indexer/Model/Indexer.php b/app/code/Magento/Indexer/Model/Indexer.php index 43436f1ce1041..3dcc39608ac0b 100644 --- a/app/code/Magento/Indexer/Model/Indexer.php +++ b/app/code/Magento/Indexer/Model/Indexer.php @@ -5,7 +5,18 @@ */ namespace Magento\Indexer\Model; -class Indexer extends \Magento\Framework\DataObject implements IndexerInterface +use Magento\Framework\Indexer\ActionFactory; +use Magento\Framework\Indexer\ActionInterface; +use Magento\Framework\Indexer\ConfigInterface; +use Magento\Framework\Indexer\IndexerInterface as IdxInterface; +use Magento\Framework\Indexer\IndexStructureInterface; +use Magento\Framework\Indexer\StateInterface; +use Magento\Framework\Indexer\StructureFactory; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Indexer extends \Magento\Framework\DataObject implements IdxInterface { /** * @var string @@ -22,6 +33,11 @@ class Indexer extends \Magento\Framework\DataObject implements IndexerInterface */ protected $actionFactory; + /** + * @var StructureFactory + */ + protected $structureFactory; + /** * @var \Magento\Framework\Mview\ViewInterface */ @@ -45,6 +61,7 @@ class Indexer extends \Magento\Framework\DataObject implements IndexerInterface /** * @param ConfigInterface $config * @param ActionFactory $actionFactory + * @param StructureFactory $structureFactory * @param \Magento\Framework\Mview\ViewInterface $view * @param Indexer\StateFactory $stateFactory * @param Indexer\CollectionFactory $indexersFactory @@ -53,6 +70,7 @@ class Indexer extends \Magento\Framework\DataObject implements IndexerInterface public function __construct( ConfigInterface $config, ActionFactory $actionFactory, + StructureFactory $structureFactory, \Magento\Framework\Mview\ViewInterface $view, Indexer\StateFactory $stateFactory, Indexer\CollectionFactory $indexersFactory, @@ -60,6 +78,7 @@ public function __construct( ) { $this->config = $config; $this->actionFactory = $actionFactory; + $this->structureFactory = $structureFactory; $this->view = $view; $this->stateFactory = $stateFactory; $this->indexersFactory = $indexersFactory; @@ -192,7 +211,7 @@ public function getHandlers() * Fill indexer data from config * * @param string $indexerId - * @return IndexerInterface + * @return IdxInterface * @throws \InvalidArgumentException */ public function load($indexerId) @@ -224,7 +243,7 @@ public function getView() /** * Return related state object * - * @return Indexer\State + * @return StateInterface */ public function getState() { @@ -238,10 +257,10 @@ public function getState() /** * Set indexer state object * - * @param Indexer\State $state - * @return IndexerInterface + * @param StateInterface $state + * @return IdxInterface */ - public function setState(Indexer\State $state) + public function setState(StateInterface $state) { $this->state = $state; return $this; @@ -280,7 +299,7 @@ public function setScheduled($scheduled) */ public function isValid() { - return $this->getState()->getStatus() == Indexer\State::STATUS_VALID; + return $this->getState()->getStatus() == StateInterface::STATUS_VALID; } /** @@ -290,7 +309,7 @@ public function isValid() */ public function isInvalid() { - return $this->getState()->getStatus() == Indexer\State::STATUS_INVALID; + return $this->getState()->getStatus() == StateInterface::STATUS_INVALID; } /** @@ -300,7 +319,7 @@ public function isInvalid() */ public function isWorking() { - return $this->getState()->getStatus() == Indexer\State::STATUS_WORKING; + return $this->getState()->getStatus() == StateInterface::STATUS_WORKING; } /** @@ -311,7 +330,7 @@ public function isWorking() public function invalidate() { $state = $this->getState(); - $state->setStatus(Indexer\State::STATUS_INVALID); + $state->setStatus(StateInterface::STATUS_INVALID); $state->save(); } @@ -352,7 +371,26 @@ public function getLatestUpdated() */ protected function getActionInstance() { - return $this->actionFactory->create($this->getActionClass(), ['data' => $this->getData()]); + return $this->actionFactory->create( + $this->getActionClass(), + [ + 'indexStructure' => $this->getStructureInstance(), + 'data' => $this->getData(), + ] + ); + } + + /** + * Return indexer structure instance + * + * @return IndexStructureInterface + */ + protected function getStructureInstance() + { + if (!$this->getData('structure')) { + return null; + } + return $this->structureFactory->create($this->getData('structure')); } /** @@ -363,20 +401,20 @@ protected function getActionInstance() */ public function reindexAll() { - if ($this->getState()->getStatus() != Indexer\State::STATUS_WORKING) { + if ($this->getState()->getStatus() != StateInterface::STATUS_WORKING) { $state = $this->getState(); - $state->setStatus(Indexer\State::STATUS_WORKING); + $state->setStatus(StateInterface::STATUS_WORKING); $state->save(); if ($this->getView()->isEnabled()) { $this->getView()->suspend(); } try { $this->getActionInstance()->executeFull(); - $state->setStatus(Indexer\State::STATUS_VALID); + $state->setStatus(StateInterface::STATUS_VALID); $state->save(); $this->getView()->resume(); } catch (\Exception $exception) { - $state->setStatus(Indexer\State::STATUS_INVALID); + $state->setStatus(StateInterface::STATUS_INVALID); $state->save(); $this->getView()->resume(); throw $exception; @@ -398,7 +436,7 @@ public function reindexRow($id) /** * Regenerate rows in index by ID list - * + *5 * @param int[] $ids * @return void */ diff --git a/app/code/Magento/Indexer/Model/Indexer/Collection.php b/app/code/Magento/Indexer/Model/Indexer/Collection.php index 5a6c05d25b020..32fbf14b1ca63 100644 --- a/app/code/Magento/Indexer/Model/Indexer/Collection.php +++ b/app/code/Magento/Indexer/Model/Indexer/Collection.php @@ -12,10 +12,10 @@ class Collection extends \Magento\Framework\Data\Collection * * @var string */ - protected $_itemObjectClass = 'Magento\Indexer\Model\IndexerInterface'; + protected $_itemObjectClass = 'Magento\Framework\Indexer\IndexerInterface'; /** - * @var \Magento\Indexer\Model\ConfigInterface + * @var \Magento\Framework\Indexer\ConfigInterface */ protected $config; @@ -26,12 +26,12 @@ class Collection extends \Magento\Framework\Data\Collection /** * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory - * @param \Magento\Indexer\Model\ConfigInterface $config + * @param \Magento\Framework\Indexer\ConfigInterface $config * @param \Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory $statesFactory */ public function __construct( \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, - \Magento\Indexer\Model\ConfigInterface $config, + \Magento\Framework\Indexer\ConfigInterface $config, \Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory $statesFactory ) { $this->config = $config; @@ -53,7 +53,7 @@ public function loadData($printQuery = false, $logQuery = false) if (!$this->isLoaded()) { $states = $this->statesFactory->create(); foreach (array_keys($this->config->getIndexers()) as $indexerId) { - /** @var \Magento\Indexer\Model\IndexerInterface $indexer */ + /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ $indexer = $this->getNewEmptyItem(); $indexer->load($indexerId); foreach ($states->getItems() as $state) { diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index f386d5ca9cdbd..0937cce28dee5 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -5,24 +5,10 @@ */ namespace Magento\Indexer\Model\Indexer; -/** - * @method string getIndexerId() - * @method \Magento\Indexer\Model\Indexer\State setIndexerId($value) - * @method string getStatus() - * @method string getUpdated() - * @method \Magento\Indexer\Model\Indexer\State setUpdated($value) - */ -class State extends \Magento\Framework\Model\AbstractModel -{ - /** - * Indexer statuses - */ - const STATUS_WORKING = 'working'; - - const STATUS_VALID = 'valid'; - - const STATUS_INVALID = 'invalid'; +use Magento\Framework\Indexer\StateInterface; +class State extends \Magento\Framework\Model\AbstractModel implements StateInterface +{ /** * Prefix of model events names * @@ -57,6 +43,58 @@ public function __construct( parent::__construct($context, $registry, $resource, $resourceCollection, $data); } + /** + * Return indexer id + * + * @return string + */ + public function getIndexerId() + { + return parent::getIndexerId(); + } + + /** + * Set indexer id + * + * @param string $value + * @return $this + */ + public function setIndexerId($value) + { + return parent::setIndexerId($value); + } + + /** + * Return status + * + * @return string + */ + public function getStatus() + { + return parent::getStatus(); + } + + /** + * Return updated + * + * @return string + */ + public function getUpdated() + { + return parent::getUpdated(); + } + + /** + * Set updated + * + * @param string $value + * @return $this + */ + public function setUpdated($value) + { + return parent::setUpdated($value); + } + /** * Fill object with state data by view ID * diff --git a/app/code/Magento/Indexer/Model/Message/Invalid.php b/app/code/Magento/Indexer/Model/Message/Invalid.php index bc8da0010fd82..33ffc5020c7de 100644 --- a/app/code/Magento/Indexer/Model/Message/Invalid.php +++ b/app/code/Magento/Indexer/Model/Message/Invalid.php @@ -31,7 +31,7 @@ public function isDisplayed() { /** @var \Magento\Indexer\Model\Indexer $indexer */ foreach ($this->collection->getItems() as $indexer) { - if ($indexer->getStatus() == \Magento\Indexer\Model\Indexer\State::STATUS_INVALID) { + if ($indexer->getStatus() == \Magento\Framework\Indexer\StateInterface::STATUS_INVALID) { return true; } } diff --git a/app/code/Magento/Indexer/Model/Processor.php b/app/code/Magento/Indexer/Model/Processor.php index 98cdfb46dd7bd..dec0175102273 100644 --- a/app/code/Magento/Indexer/Model/Processor.php +++ b/app/code/Magento/Indexer/Model/Processor.php @@ -5,6 +5,9 @@ */ namespace Magento\Indexer\Model; +use Magento\Framework\Indexer\ConfigInterface; +use Magento\Framework\Indexer\IndexerInterface; + class Processor { /** diff --git a/app/code/Magento/Indexer/Model/Processor/Handler.php b/app/code/Magento/Indexer/Model/Processor/Handler.php index 653c28f80e3b8..23ce8c24b3fed 100644 --- a/app/code/Magento/Indexer/Model/Processor/Handler.php +++ b/app/code/Magento/Indexer/Model/Processor/Handler.php @@ -5,8 +5,8 @@ */ namespace Magento\Indexer\Model\Processor; -use Magento\Indexer\Model\HandlerInterface; -use Magento\Indexer\Model\HandlerPool; +use Magento\Framework\Indexer\HandlerInterface; +use Magento\Framework\Indexer\HandlerPool; class Handler { diff --git a/app/code/Magento/Indexer/Model/Processor/InvalidateCache.php b/app/code/Magento/Indexer/Model/Processor/InvalidateCache.php index df397b3f720fd..5347b9e076005 100644 --- a/app/code/Magento/Indexer/Model/Processor/InvalidateCache.php +++ b/app/code/Magento/Indexer/Model/Processor/InvalidateCache.php @@ -12,7 +12,7 @@ class InvalidateCache { /** - * @var \Magento\Indexer\Model\CacheContext + * @var \Magento\Framework\Indexer\CacheContext */ protected $context; @@ -27,12 +27,12 @@ class InvalidateCache protected $moduleManager; /** - * @param \Magento\Indexer\Model\CacheContext $context + * @param \Magento\Framework\Indexer\CacheContext $context * @param \Magento\Framework\Event\Manager $eventManager * @param \Magento\Framework\Module\Manager $moduleManager */ public function __construct( - \Magento\Indexer\Model\CacheContext $context, + \Magento\Framework\Indexer\CacheContext $context, \Magento\Framework\Event\Manager $eventManager, \Magento\Framework\Module\Manager $moduleManager ) { diff --git a/app/code/Magento/Indexer/Model/Resource/AbstractResource.php b/app/code/Magento/Indexer/Model/Resource/AbstractResource.php index 9f7cc10532d3d..24c2e537b0def 100644 --- a/app/code/Magento/Indexer/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Indexer/Model/Resource/AbstractResource.php @@ -19,7 +19,7 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs /** * Constructor * - * @var \Magento\Indexer\Model\Indexer\Table\StrategyInterface + * @var \Magento\Framework\Indexer\Table\StrategyInterface */ protected $tableStrategy; @@ -27,12 +27,12 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs * Class constructor * * @param \Magento\Framework\Model\Resource\Db\Context $context - * @param \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy + * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param string $connectionName */ public function __construct( \Magento\Framework\Model\Resource\Db\Context $context, - \Magento\Indexer\Model\Indexer\Table\StrategyInterface $tableStrategy, + \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, $connectionName = null ) { $this->tableStrategy = $tableStrategy; diff --git a/app/code/Magento/Indexer/Setup/InstallData.php b/app/code/Magento/Indexer/Setup/InstallData.php index c2fbcace85baa..c2ea10a826175 100644 --- a/app/code/Magento/Indexer/Setup/InstallData.php +++ b/app/code/Magento/Indexer/Setup/InstallData.php @@ -8,10 +8,11 @@ use Magento\Framework\Encryption\Encryptor; use Magento\Framework\Encryption\EncryptorInterface; +use Magento\Framework\Indexer\StateInterface; use Magento\Framework\Json\EncoderInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; -use Magento\Indexer\Model\ConfigInterface; +use Magento\Framework\Indexer\ConfigInterface; use Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory; use Magento\Indexer\Model\Indexer\State; use Magento\Indexer\Model\Indexer\StateFactory; @@ -100,7 +101,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $state = $this->stateFactory->create(); $state->loadByIndexer($indexerId); $state->setHashConfig($hash); - $state->setStatus(State::STATUS_INVALID); + $state->setStatus(StateInterface::STATUS_INVALID); $state->save(); } } diff --git a/app/code/Magento/Indexer/Setup/Recurring.php b/app/code/Magento/Indexer/Setup/Recurring.php index e453e18bc7d9f..845a14cb4b0bd 100644 --- a/app/code/Magento/Indexer/Setup/Recurring.php +++ b/app/code/Magento/Indexer/Setup/Recurring.php @@ -8,11 +8,12 @@ use Magento\Framework\Encryption\Encryptor; use Magento\Framework\Encryption\EncryptorInterface; +use Magento\Framework\Indexer\StateInterface; use Magento\Framework\Json\EncoderInterface; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; -use Magento\Indexer\Model\ConfigInterface; +use Magento\Framework\Indexer\ConfigInterface; use Magento\Indexer\Model\Indexer\State; use Magento\Indexer\Model\Indexer\StateFactory; use Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory; @@ -94,7 +95,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con if (isset($stateIndexers[$indexerId])) { if ($stateIndexers[$indexerId]->getHashConfig() != $expectedHashConfig) { - $stateIndexers[$indexerId]->setStatus(State::STATUS_INVALID); + $stateIndexers[$indexerId]->setStatus(StateInterface::STATUS_INVALID); $stateIndexers[$indexerId]->setHashConfig($expectedHashConfig); $stateIndexers[$indexerId]->save(); } @@ -103,7 +104,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $state = $this->stateFactory->create(); $state->loadByIndexer($indexerId); $state->setHashConfig($expectedHashConfig); - $state->setStatus(State::STATUS_INVALID); + $state->setStatus(StateInterface::STATUS_INVALID); $state->save(); } } diff --git a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php index 699e5dcd63621..7fee908bf92c2 100644 --- a/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Block/Backend/Grid/Column/Renderer/StatusTest.php @@ -37,15 +37,15 @@ public function renderDataProvider() { return [ 'set1' => [ - [\Magento\Indexer\Model\Indexer\State::STATUS_INVALID], + [\Magento\Framework\Indexer\StateInterface::STATUS_INVALID], ['class' => 'grid-severity-critical', 'text' => 'Reindex required'] ], 'set2' => [ - [\Magento\Indexer\Model\Indexer\State::STATUS_VALID], + [\Magento\Framework\Indexer\StateInterface::STATUS_VALID], ['class' => 'grid-severity-notice', 'text' => 'Ready'] ], 'set3' => [ - [\Magento\Indexer\Model\Indexer\State::STATUS_WORKING], + [\Magento\Framework\Indexer\StateInterface::STATUS_WORKING], ['class' => 'grid-severity-major', 'text' => 'Processing'] ] ]; diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php index 198dd451da12b..7b82d38805260 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php @@ -26,19 +26,19 @@ public function testExecuteAll() $indexerOne ->expects($this->once()) ->method('getStatus') - ->willReturn(\Magento\Indexer\Model\Indexer\State::STATUS_VALID); + ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_VALID); $indexerTwo = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); $indexerTwo->expects($this->once())->method('getTitle')->willReturn('Title_indexerTwo'); $indexerTwo ->expects($this->once()) ->method('getStatus') - ->willReturn(\Magento\Indexer\Model\Indexer\State::STATUS_INVALID); + ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $indexerThree = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); $indexerThree->expects($this->once())->method('getTitle')->willReturn('Title_indexerThree'); $indexerThree ->expects($this->once()) ->method('getStatus') - ->willReturn(\Magento\Indexer\Model\Indexer\State::STATUS_WORKING); + ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_WORKING); $indexerFour = $this->getMock('Magento\Indexer\Model\Indexer', [], [], '', false); $indexerFour->expects($this->once())->method('getTitle')->willReturn('Title_indexerFour'); $collection diff --git a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php index 2b1b3a1428013..133a763f8312d 100644 --- a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassChangelogTest.php @@ -57,7 +57,7 @@ class MassChangelogTest extends \PHPUnit_Framework_TestCase protected $messageManager; /** - * @var \Magento\Indexer\Model\IndexerRegistry + * @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexReg; @@ -83,6 +83,7 @@ class MassChangelogTest extends \PHPUnit_Framework_TestCase /** * Set up test + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function setUp() { @@ -144,7 +145,13 @@ protected function setUp() $this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager); $this->actionFlag = $this->getMock('\Magento\Framework\App\ActionFlag', ['get'], [], '', false); $this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager); - $this->objectManager = $this->getMock('Magento\Framework\TestFramework\Unit\Helper\ObjectManager', ['get'], [], '', false); + $this->objectManager = $this->getMock( + 'Magento\Framework\TestFramework\Unit\Helper\ObjectManager', + ['get'], + [], + '', + false + ); $this->request = $this->getMockForAbstractClass( '\Magento\Framework\App\RequestInterface', ['getParam', 'getRequest'], @@ -164,7 +171,7 @@ protected function setUp() ); $this->indexReg = $this->getMock( - 'Magento\Indexer\Model\IndexerRegistry', + 'Magento\Framework\Indexer\IndexerRegistry', ['get', 'setScheduled'], [], '', @@ -200,10 +207,10 @@ public function testExecute($indexerIds, $exception, $expectsExceptionValues) } else { $this->objectManager->expects($this->any()) - ->method('get')->with('Magento\Indexer\Model\IndexerRegistry') + ->method('get')->with('Magento\Framework\Indexer\IndexerRegistry') ->will($this->returnValue($this->indexReg)); $indexerInterface = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', ['setScheduled'], '', false diff --git a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php index 3dbf8a5ee7976..c535ed59f686f 100644 --- a/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Controller/Adminhtml/Indexer/MassOnTheFlyTest.php @@ -57,7 +57,7 @@ class MassOnTheFlyTest extends \PHPUnit_Framework_TestCase protected $messageManager; /** - * @var \Magento\Indexer\Model\IndexerRegistry + * @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexReg; @@ -83,6 +83,7 @@ class MassOnTheFlyTest extends \PHPUnit_Framework_TestCase /** * Set up test + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function setUp() { @@ -144,7 +145,13 @@ protected function setUp() $this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager); $this->actionFlag = $this->getMock('\Magento\Framework\App\ActionFlag', ['get'], [], '', false); $this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager); - $this->objectManager = $this->getMock('Magento\Framework\TestFramework\Unit\Helper\ObjectManager', ['get'], [], '', false); + $this->objectManager = $this->getMock( + 'Magento\Framework\TestFramework\Unit\Helper\ObjectManager', + ['get'], + [], + '', + false + ); $this->request = $this->getMockForAbstractClass( '\Magento\Framework\App\RequestInterface', ['getParam', 'getRequest'], @@ -164,7 +171,7 @@ protected function setUp() ); $this->indexReg = $this->getMock( - 'Magento\Indexer\Model\IndexerRegistry', + 'Magento\Framework\Indexer\IndexerRegistry', ['get', 'setScheduled'], [], '', @@ -200,10 +207,10 @@ public function testExecute($indexerIds, $exception, $expectsExceptionValues) } else { $this->objectManager->expects($this->any()) - ->method('get')->with('Magento\Indexer\Model\IndexerRegistry') + ->method('get')->with('Magento\Framework\Indexer\IndexerRegistry') ->will($this->returnValue($this->indexReg)); $indexerInterface = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', + 'Magento\Framework\Indexer\IndexerInterface', ['setScheduled'], '', false diff --git a/app/code/Magento/Indexer/Test/Unit/Model/CacheContextTest.php b/app/code/Magento/Indexer/Test/Unit/Model/CacheContextTest.php index 0baef4bd4b7f3..47bd79ccf4b61 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/CacheContextTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/CacheContextTest.php @@ -9,7 +9,7 @@ class CacheContextTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\CacheContext + * @var \Magento\Framework\Indexer\CacheContext */ protected $context; @@ -18,7 +18,7 @@ class CacheContextTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->context = new \Magento\Indexer\Model\CacheContext(); + $this->context = new \Magento\Framework\Indexer\CacheContext(); } /** diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php index c8955b355b11e..3cd17862c88ad 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php @@ -13,7 +13,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Indexer\Model\Config\Reader|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\Config\Reader|\PHPUnit_Framework_MockObject_MockObject */ protected $reader; @@ -39,7 +39,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->reader = $this->getMock('Magento\Indexer\Model\Config\Reader', ['read'], [], '', false); + $this->reader = $this->getMock('Magento\Framework\Indexer\Config\Reader', ['read'], [], '', false); $this->cache = $this->getMockForAbstractClass( 'Magento\Framework\Config\CacheInterface', [], diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorStub.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorStub.php index e32ab2ee334ec..2e5b9b8d7369c 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorStub.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorStub.php @@ -5,7 +5,7 @@ */ namespace Magento\Indexer\Test\Unit\Model\Indexer; -class AbstractProcessorStub extends \Magento\Indexer\Model\Indexer\AbstractProcessor +class AbstractProcessorStub extends \Magento\Framework\Indexer\AbstractProcessor { /** * Indexer ID diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php index b81648a476650..49e233c29fcbc 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/AbstractProcessorTest.php @@ -15,14 +15,14 @@ class AbstractProcessorTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $_indexerRegistryMock; protected function setUp() { $this->_indexerRegistryMock = $this->getMock( - '\Magento\Indexer\Model\IndexerRegistry', + '\Magento\Framework\Indexer\IndexerRegistry', ['isScheduled', 'get', 'reindexRow', 'reindexList', 'reindexAll', 'invalidate'], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php index fc0136fa578e9..0cb275394d37b 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/CollectionTest.php @@ -18,7 +18,7 @@ public function testLoadData() ['create'] )->getMock(); - $config = $this->getMockBuilder('Magento\Indexer\Model\ConfigInterface')->getMock(); + $config = $this->getMockBuilder('Magento\Framework\Indexer\ConfigInterface')->getMock(); $statesFactory = $this->getMockBuilder( 'Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory' @@ -53,7 +53,7 @@ public function testLoadData() )->method( 'create' )->with( - 'Magento\Indexer\Model\IndexerInterface' + 'Magento\Framework\Indexer\IndexerInterface' )->will( $this->returnValue($indexer) ); diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php index 2b79e1e4b6986..62004ab2d92ce 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Indexer\Test\Unit\Model; +use Magento\Framework\Indexer\StateInterface; use Magento\Indexer\Model\Indexer\State; class IndexerTest extends \PHPUnit_Framework_TestCase @@ -15,12 +16,12 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Indexer\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $configMock; /** - * @var \Magento\Indexer\Model\ActionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ActionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $actionFactoryMock; @@ -42,7 +43,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\ConfigInterface', + 'Magento\Framework\Indexer\ConfigInterface', [], '', false, @@ -51,7 +52,7 @@ protected function setUp() ['getIndexer'] ); $this->actionFactoryMock = $this->getMock( - 'Magento\Indexer\Model\ActionFactory', + 'Magento\Framework\Indexer\ActionFactory', ['create'], [], '', @@ -80,9 +81,16 @@ protected function setUp() '', false ); + $structureFactory = $this->getMockBuilder('Magento\Framework\Indexer\StructureFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + /** @var \Magento\Framework\Indexer\StructureFactory $structureFactory */ $this->model = new \Magento\Indexer\Model\Indexer( $this->configMock, $this->actionFactoryMock, + $structureFactory, $this->viewMock, $this->stateFactoryMock, $this->indexFactoryMock @@ -219,7 +227,7 @@ public function testReindexAll() $this->viewMock->expects($this->once())->method('resume'); $actionMock = $this->getMock( - 'Magento\Indexer\Model\ActionInterface', + 'Magento\Framework\Indexer\ActionInterface', ['executeFull', 'executeList', 'executeRow'], [], '', @@ -267,7 +275,7 @@ public function testReindexAllWithException() $this->viewMock->expects($this->once())->method('resume'); $actionMock = $this->getMock( - 'Magento\Indexer\Model\ActionInterface', + 'Magento\Framework\Indexer\ActionInterface', ['executeFull', 'executeList', 'executeRow'], [], '', @@ -392,7 +400,7 @@ public function setScheduledDataProvider() public function testGetStatus() { - $status = State::STATUS_WORKING; + $status = StateInterface::STATUS_WORKING; $stateMock = $this->getMock( '\Magento\Indexer\Model\Indexer\State', ['load', 'getStatus'], @@ -432,9 +440,9 @@ public function testStatus($method, $status) public function statusDataProvider() { return [ - ['isValid', State::STATUS_VALID], - ['isInvalid', State::STATUS_INVALID], - ['isWorking', State::STATUS_WORKING] + ['isValid', StateInterface::STATUS_VALID], + ['isInvalid', StateInterface::STATUS_INVALID], + ['isWorking', StateInterface::STATUS_WORKING] ]; } @@ -449,7 +457,7 @@ public function testInvalidate() ); $this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock)); - $stateMock->expects($this->once())->method('setStatus')->with(State::STATUS_INVALID)->will( + $stateMock->expects($this->once())->method('setStatus')->with(StateInterface::STATUS_INVALID)->will( $this->returnSelf() ); $stateMock->expects($this->once())->method('save')->will($this->returnSelf()); @@ -468,7 +476,7 @@ public function testReindexRow() false ); $actionMock = $this->getMock( - 'Magento\Indexer\Model\ActionInterface', + 'Magento\Framework\Indexer\ActionInterface', ['executeFull', 'executeList', 'executeRow'], [], '', @@ -501,7 +509,7 @@ public function testReindexList() false ); $actionMock = $this->getMock( - 'Magento\Indexer\Model\ActionInterface', + 'Magento\Framework\Indexer\ActionInterface', ['executeFull', 'executeList', 'executeRow'], [], '', diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php index b4d8c0152f8bb..2beb3acf5e21f 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Message/InvalidTest.php @@ -48,7 +48,7 @@ protected function setUp() public function testDisplayMessage() { $this->indexerMock->expects($this->any())->method('getStatus')->with() - ->willReturn(\Magento\Indexer\Model\Indexer\State::STATUS_INVALID); + ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->assertTrue($this->model->isDisplayed()); } 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 90c5606b85da7..6fc692c1f7d97 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Processor/InvalidateCacheTest.php @@ -18,14 +18,14 @@ class InvalidateCacheTest extends \PHPUnit_Framework_TestCase /** * Mock for context * - * @var \Magento\Indexer\Model\CacheContext|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\CacheContext|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; /** * Subject mock * - * @var \Magento\Indexer\Model\ActionInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ActionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $subjectMock; @@ -49,7 +49,7 @@ 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->contextMock = $this->getMock('Magento\Framework\Indexer\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( diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php index 6db69a068ae6c..f72d10cbb7ca5 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ProcessorTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Indexer\Test\Unit\Model; +use Magento\Framework\Indexer\StateInterface; use Magento\Indexer\Model\Indexer\State; class ProcessorTest extends \PHPUnit_Framework_TestCase @@ -15,7 +16,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Indexer\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $configMock; @@ -37,7 +38,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\ConfigInterface', + 'Magento\Framework\Indexer\ConfigInterface', [], '', false, @@ -91,7 +92,7 @@ public function testReindexAllInvalid() )->method( 'getStatus' )->will( - $this->returnValue(State::STATUS_INVALID) + $this->returnValue(StateInterface::STATUS_INVALID) ); $indexer1Mock = $this->getMock( 'Magento\Indexer\Model\Indexer', @@ -115,7 +116,7 @@ public function testReindexAllInvalid() )->method( 'getStatus' )->will( - $this->returnValue(State::STATUS_VALID) + $this->returnValue(StateInterface::STATUS_VALID) ); $indexer2Mock = $this->getMock( 'Magento\Indexer\Model\Indexer', 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 723adf8d62997..728b20681528c 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php @@ -18,7 +18,7 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase protected $_resourceMock; /** - * @var \Magento\Indexer\Model\Indexer\Table\StrategyInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\Table\StrategyInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_tableStrategyInterface; @@ -30,7 +30,7 @@ protected function setUp() ->getMock(); $this->_tableStrategyInterface = $this->getMock( - 'Magento\Indexer\Model\Indexer\Table\StrategyInterface', + 'Magento\Framework\Indexer\Table\StrategyInterface', [], [], '', diff --git a/app/code/Magento/Indexer/etc/di.xml b/app/code/Magento/Indexer/etc/di.xml index 0c2eafb8a9e01..b3b3275dbed8c 100644 --- a/app/code/Magento/Indexer/etc/di.xml +++ b/app/code/Magento/Indexer/etc/di.xml @@ -8,10 +8,10 @@ - - - - + + + + Magento\Framework\Mview\View diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php index 53dc90c91e2ed..5b6e80aa85203 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php @@ -78,6 +78,7 @@ class Pdfdocs extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassActi * @param InvoiceCollectionFactory $invoiceCollectionFactory * @param CreditmemoCollectionFactory $creditmemoCollectionFactory * @param OrderCollectionFactory $orderCollectionFactory + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php index 4c9b57a55558a..292eb6eadf11c 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php @@ -17,7 +17,6 @@ use Magento\Sales\Model\Resource\Order\CollectionFactory; /** - * Class Pdfshipments * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction diff --git a/app/code/Magento/Sales/Model/Resource/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Grid/Collection.php index 57d2d31060dcf..041a27003ee90 100644 --- a/app/code/Magento/Sales/Model/Resource/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Grid/Collection.php @@ -33,6 +33,7 @@ class Collection extends AbstractCollection implements SearchResultInterface * @param string $model * @param string|null $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml index c9f6758153c87..db861ca057aea 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml @@ -65,19 +65,6 @@ sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns.ids - dataGridActions - - - csv - CSV - mui/export/gridToCsv - - - xml - Excel XML - mui/export/gridToCsv - - diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml index df77cdd12091d..efae39c0634ca 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml @@ -73,19 +73,6 @@ sales_order_grid.sales_order_grid.sales_order_columns.ids - dataGridActions - - - csv - CSV - mui/export/gridToCsv - - - xml - Excel XML - mui/export/gridToCsv - - diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml index 072539d481891..ad8b0d2a1f114 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml @@ -65,19 +65,6 @@ sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.ids - dataGridActions - - - csv - CSV - mui/export/gridToCsv - - - xml - Excel XML - mui/export/gridToCsv - - diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml index 45ca566605822..5d18e373a0078 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml @@ -65,19 +65,6 @@ sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.ids - dataGridActions - - - csv - CSV - mui/export/gridToCsv - - - xml - Excel XML - mui/export/gridToCsv - - diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml index 15b85280df3aa..ba4ad84692d97 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml @@ -68,19 +68,6 @@ sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid.sales_order_view_creditmemo_columns.ids - dataGridActions - - - csv - CSV - sales/creditmemo/exportCsv - - - xml - Excel XML - sales/creditmemo/exportExcel - - diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml index a194c0b37dc5e..beb1b3caad924 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml @@ -68,19 +68,6 @@ sales_order_view_invoice_grid.sales_order_view_invoice_grid.sales_order_view_invoice_columns.ids - dataGridActions - - - csv - CSV - mui/export/gridToCsv - - - xml - Excel XML - mui/export/gridToCsv - - diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml index 46fa0fc448aaa..3fb4fbfe9c5db 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml @@ -68,19 +68,6 @@ sales_order_view_shipment_grid.sales_order_view_shipment_grid.sales_order_view_shipment_columns.ids - dataGridActions - - - csv - CSV - mui/export/gridToCsv - - - xml - Excel XML - mui/export/gridToCsv - - diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php index 027d8eeec6e7d..9db8516006b8e 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php @@ -19,7 +19,6 @@ use Magento\Sales\Model\Resource\Order\CollectionFactory; /** - * Class MassPrintShippingLabel * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class MassPrintShippingLabel extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction diff --git a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml index f99d3f101fcbb..f71333df72624 100644 --- a/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml +++ b/app/code/Magento/Theme/view/adminhtml/page_layout/admin-1column.xml @@ -30,7 +30,7 @@ - + diff --git a/app/code/Magento/Ui/Component/Filters/Type/AbstractFilter.php b/app/code/Magento/Ui/Component/Filters/Type/AbstractFilter.php index b4381a4dbecde..02b8767c3e263 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/AbstractFilter.php +++ b/app/code/Magento/Ui/Component/Filters/Type/AbstractFilter.php @@ -38,7 +38,7 @@ abstract class AbstractFilter extends AbstractComponent protected $uiComponentFactory; /** - * @var \Magento\Framework\Api\FilterBuilder + * @var FilterBuilder */ protected $filterBuilder; diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv.php b/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv.php index 93be6f46466ff..158f90512c6a1 100644 --- a/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv.php +++ b/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv.php @@ -7,7 +7,6 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; -use Magento\Framework\View\Element\UiComponentFactory; use Magento\Ui\Model\Export\ConvertToCsv; use Magento\Framework\App\Response\Http\FileFactory; @@ -16,11 +15,6 @@ */ class GridToCsv extends Action { - /** - * @var UiComponentFactory - */ - protected $factory; - /** * @var ConvertToCsv */ @@ -33,18 +27,15 @@ class GridToCsv extends Action /** * @param Context $context - * @param UiComponentFactory $factory * @param ConvertToCsv $converter * @param FileFactory $fileFactory */ public function __construct( Context $context, - UiComponentFactory $factory, ConvertToCsv $converter, FileFactory $fileFactory ) { parent::__construct($context); - $this->factory = $factory; $this->converter = $converter; $this->fileFactory = $fileFactory; } @@ -58,6 +49,5 @@ public function __construct( public function execute() { return $this->fileFactory->create('export.csv', $this->converter->getCsvFile(), 'var'); - } } diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToXml.php b/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToXml.php new file mode 100644 index 0000000000000..f4de9d2da2b87 --- /dev/null +++ b/app/code/Magento/Ui/Controller/Adminhtml/Export/GridToXml.php @@ -0,0 +1,53 @@ +converter = $converter; + $this->fileFactory = $fileFactory; + } + + /** + * Export data provider to XML + * + * @throws \Magento\Framework\Exception\LocalizedException + * @return \Magento\Framework\App\ResponseInterface + */ + public function execute() + { + return $this->fileFactory->create('export.xml', $this->converter->getXmlFile(), 'var'); + } +} diff --git a/app/code/Magento/Ui/Model/Export/ConvertToCsv.php b/app/code/Magento/Ui/Model/Export/ConvertToCsv.php index 450ba515e3fc1..9094805896dcb 100644 --- a/app/code/Magento/Ui/Model/Export/ConvertToCsv.php +++ b/app/code/Magento/Ui/Model/Export/ConvertToCsv.php @@ -6,11 +6,10 @@ namespace Magento\Ui\Model\Export; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\WriteInterface; use Magento\Ui\Component\MassAction\Filter; -use Magento\Framework\View\Element\UiComponentInterface; -use Magento\Framework\Api\Search\DocumentInterface; -use Magento\Framework\Data\OptionSourceInterface; -use Magento\Ui\Component\Filters\Type\Select; /** * Class ConvertToCsv @@ -18,212 +17,56 @@ class ConvertToCsv { /** - * @var \Magento\Framework\Filesystem\Directory\WriteInterface + * @var WriteInterface */ protected $directory; /** - * @var Filter + * @var MetadataProvider */ - protected $filter; + protected $metadataProvider; /** - * @var array - */ - protected $columns; - - /** - * @param \Magento\Framework\Filesystem $filesystem + * @param Filesystem $filesystem * @param Filter $filter + * @param MetadataProvider $metadataProvider */ public function __construct( - \Magento\Framework\Filesystem $filesystem, - Filter $filter + Filesystem $filesystem, + Filter $filter, + MetadataProvider $metadataProvider ) { $this->filter = $filter; $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); - } - - /** - * Returns Columns component - * - * @param UiComponentInterface $component - * @return UiComponentInterface - * @throws \Exception - */ - protected function getColumnsComponent(UiComponentInterface $component) - { - foreach ($component->getChildComponents() as $childComponent) { - if ($childComponent instanceof \Magento\Ui\Component\Listing\Columns) { - return $childComponent; - } - } - throw new \Exception('No columns found'); - } - - /** - * Returns columns list - * - * @param UiComponentInterface $component - * @return UiComponentInterface[] - */ - protected function getColumns(UiComponentInterface $component) - { - if (!isset($this->columns[$component->getName()])) { - $columns = $this->getColumnsComponent($component); - foreach ($columns->getChildComponents() as $column) { - $this->columns[$component->getName()][$column->getName()] = $column; - } - } - return $this->columns[$component->getName()]; - } - - /** - * Retrieve Headers row array for Export - * - * @param UiComponentInterface $component - * @return string[] - */ - protected function getHeaders(UiComponentInterface $component) - { - $row = []; - foreach ($this->getColumns($component) as $column) { - if ($column->getData('config/label')) { - $row[] = $column->getData('config/label'); - } - } - return $row; - } - - /** - * Returns DB fields list - * - * @param UiComponentInterface $component - * @return array - */ - protected function getFields(UiComponentInterface $component) - { - $row = []; - foreach ($this->getColumns($component) as $column) { - if ($column->getData('config/label')) { - $row[] = $column->getName(); - } - } - return $row; - } - - /** - * Returns row data - * - * @param DocumentInterface $document - * @param array $fields - * @param array $options - * @return array - */ - protected function getRowData(DocumentInterface $document, $fields, $options) - { - $row = []; - foreach ($fields as $column) { - if (isset($options[$column])) { - $key = $document->getCustomAttribute($column)->getValue(); - if (isset($options[$column][$key])) { - $row[] = $options[$column][$key]; - } - $row[] = ''; - } else { - $row[] = $document->getCustomAttribute($column)->getValue(); - } - } - return $row; - } - - /** - * Returns complex option - * - * @param array $list - * @param string $label - * @param array $output - * @return void - */ - protected function getComplexLabel($list, $label, &$output) - { - foreach ($list as $item) { - if (!is_array($item['value'])) { - $output[$item['value']] = $label . $item['label']; - } else { - $this->getComplexLabel($item['value'], $label . $item['label'], $output); - } - } - } - - /** - * Returns array of Select options - * - * @param Select $filter - * @return array - */ - protected function getFilterOptions(Select $filter) - { - $options = []; - foreach ($filter->getOptionProvider()->toOptionArray() as $option) { - if (!is_array($option['value'])) { - $options[$option['value']] = $option['label']; - } else { - $this->getComplexLabel( - $option['value'], - $option['label'], - $options - ); - } - } - return $options; - } - /** - * Returns Filters with options - * - * @return array - */ - protected function getOptions() - { - $options = []; - $component = $this->filter->getComponent(); - $childComponents = $component->getChildComponents(); - $listingTop = $childComponents['listing_top']; - foreach ($listingTop->getChildComponents() as $child) { - if ($child instanceof \Magento\Ui\Component\Filters) { - foreach ($child->getChildComponents() as $filter) { - if ($filter instanceof Select) { - $options[$filter->getName()] = $this->getFilterOptions($filter); - } - } - } - } - return $options; + $this->metadataProvider = $metadataProvider; } /** * Returns CSV file * * @return array - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function getCsvFile() { - $options = $this->getOptions(); $component = $this->filter->getComponent(); + $name = md5(microtime()); $file = 'export/'. $component->getName() . $name . '.csv'; + $this->filter->prepareComponent($component); $this->filter->applySelectionOnTargetProvider(); + $searchResult = $component->getContext()->getDataProvider()->getSearchResult(); + $fields = $this->metadataProvider->getFields($component); + $options = $this->metadataProvider->getOptions(); + $this->directory->create('export'); $stream = $this->directory->openFile($file, 'w+'); - - $fields = $this->getFields($component); $stream->lock(); - $stream->writeCsv($this->getHeaders($component)); + $stream->writeCsv($this->metadataProvider->getHeaders($component)); foreach ($searchResult->getItems() as $document) { - $stream->writeCsv($this->getRowData($document, $fields, $options)); + $stream->writeCsv($this->metadataProvider->getRowData($document, $fields, $options)); } $stream->unlock(); $stream->close(); diff --git a/app/code/Magento/Ui/Model/Export/ConvertToXml.php b/app/code/Magento/Ui/Model/Export/ConvertToXml.php new file mode 100644 index 0000000000000..b1d943eeea863 --- /dev/null +++ b/app/code/Magento/Ui/Model/Export/ConvertToXml.php @@ -0,0 +1,156 @@ +filter = $filter; + $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $this->metadataProvider = $metadataProvider; + $this->excelFactory = $excelFactory; + $this->iteratorFactory = $iteratorFactory; + } + + /** + * Returns Filters with options + * + * @return array + */ + protected function getOptions() + { + if (!$this->options) { + $this->options = $this->metadataProvider->getOptions(); + } + return $this->options; + } + + /** + * Returns DB fields list + * + * @return array + */ + protected function getFields() + { + if (!$this->fields) { + $component = $this->filter->getComponent(); + $this->fields = $this->metadataProvider->getFields($component); + } + return $this->fields; + } + + /** + * Returns row data + * + * @param DocumentInterface $document + * @return array + */ + public function getRowData(DocumentInterface $document) + { + return $this->metadataProvider->getRowData($document, $this->getFields(), $this->getOptions()); + } + + /** + * Returns XML file + * + * @return array + * @throws LocalizedException + */ + public function getXmlFile() + { + $component = $this->filter->getComponent(); + + $name = md5(microtime()); + $file = 'export/'. $component->getName() . $name . '.xml'; + + $this->filter->prepareComponent($component); + $this->filter->applySelectionOnTargetProvider(); + + /** @var SearchResultInterface $searchResult */ + $searchResult = $component->getContext()->getDataProvider()->getSearchResult(); + + /** @var SearchResultIterator $searchResultIterator */ + $searchResultIterator = $this->iteratorFactory->create(['items' => $searchResult->getItems()]); + + /** @var Excel $excel */ + $excel = $this->excelFactory->create([ + 'iterator' => $searchResultIterator, + 'rowCallback'=> [$this, 'getRowData'], + ]); + + $this->directory->create('export'); + $stream = $this->directory->openFile($file, 'w+'); + $stream->lock(); + + $excel->setDataHeader($this->metadataProvider->getHeaders($component)); + $excel->write($stream, $component->getName() . '.xml'); + + $stream->unlock(); + $stream->close(); + + return [ + 'type' => 'filename', + 'value' => $file, + 'rm' => true // can delete file after use + ]; + } +} diff --git a/app/code/Magento/Ui/Model/Export/MetadataProvider.php b/app/code/Magento/Ui/Model/Export/MetadataProvider.php new file mode 100644 index 0000000000000..e9a95e914ed72 --- /dev/null +++ b/app/code/Magento/Ui/Model/Export/MetadataProvider.php @@ -0,0 +1,194 @@ +filter = $filter; + } + + /** + * Returns Columns component + * + * @param UiComponentInterface $component + * @return UiComponentInterface + * @throws \Exception + */ + protected function getColumnsComponent(UiComponentInterface $component) + { + foreach ($component->getChildComponents() as $childComponent) { + if ($childComponent instanceof Columns) { + return $childComponent; + } + } + throw new \Exception('No columns found'); + } + + /** + * Returns columns list + * + * @param UiComponentInterface $component + * @return UiComponentInterface[] + */ + protected function getColumns(UiComponentInterface $component) + { + if (!isset($this->columns[$component->getName()])) { + $columns = $this->getColumnsComponent($component); + foreach ($columns->getChildComponents() as $column) { + $this->columns[$component->getName()][$column->getName()] = $column; + } + } + return $this->columns[$component->getName()]; + } + + /** + * Retrieve Headers row array for Export + * + * @param UiComponentInterface $component + * @return string[] + */ + public function getHeaders(UiComponentInterface $component) + { + $row = []; + foreach ($this->getColumns($component) as $column) { + if ($column->getData('config/label')) { + $row[] = $column->getData('config/label'); + } + } + return $row; + } + + /** + * Returns DB fields list + * + * @param UiComponentInterface $component + * @return array + */ + public function getFields(UiComponentInterface $component) + { + $row = []; + foreach ($this->getColumns($component) as $column) { + if ($column->getData('config/label')) { + $row[] = $column->getName(); + } + } + return $row; + } + + /** + * Returns row data + * + * @param DocumentInterface $document + * @param array $fields + * @param array $options + * @return array + */ + public function getRowData(DocumentInterface $document, $fields, $options) + { + $row = []; + foreach ($fields as $column) { + if (isset($options[$column])) { + $key = $document->getCustomAttribute($column)->getValue(); + if (isset($options[$column][$key])) { + $row[] = $options[$column][$key]; + } else { + $row[] = ''; + } + } else { + $row[] = $document->getCustomAttribute($column)->getValue(); + } + } + return $row; + } + + /** + * Returns complex option + * + * @param array $list + * @param string $label + * @param array $output + * @return void + */ + protected function getComplexLabel($list, $label, &$output) + { + foreach ($list as $item) { + if (!is_array($item['value'])) { + $output[$item['value']] = $label . $item['label']; + } else { + $this->getComplexLabel($item['value'], $label . $item['label'], $output); + } + } + } + + /** + * Returns array of Select options + * + * @param Select $filter + * @return array + */ + protected function getFilterOptions(Select $filter) + { + $options = []; + foreach ($filter->getData('config/options') as $option) { + if (!is_array($option['value'])) { + $options[$option['value']] = $option['label']; + } else { + $this->getComplexLabel( + $option['value'], + $option['label'], + $options + ); + } + } + return $options; + } + + /** + * Returns Filters with options + * + * @return array + */ + public function getOptions() + { + $options = []; + $component = $this->filter->getComponent(); + $childComponents = $component->getChildComponents(); + $listingTop = $childComponents['listing_top']; + foreach ($listingTop->getChildComponents() as $child) { + if ($child instanceof Filters) { + foreach ($child->getChildComponents() as $filter) { + if ($filter instanceof Select) { + $options[$filter->getName()] = $this->getFilterOptions($filter); + } + } + } + } + return $options; + } +} diff --git a/app/code/Magento/Ui/Model/Export/SearchResultIterator.php b/app/code/Magento/Ui/Model/Export/SearchResultIterator.php new file mode 100644 index 0000000000000..aa584c3f7e7e3 --- /dev/null +++ b/app/code/Magento/Ui/Model/Export/SearchResultIterator.php @@ -0,0 +1,63 @@ +items = $items; + } + + /** + * @return array|mixed + */ + public function current() + { + return current($this->items); + } + + /** + * @return int|mixed + */ + public function key() + { + return key($this->items); + } + + /** + * @return void + */ + public function next() + { + next($this->items); + } + + /** + * @return void + */ + public function rewind() + { + reset($this->items); + } + + /** + * @return bool + */ + public function valid() + { + return (bool)$this->key(); + } +} diff --git a/app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Export/GridToCsvTest.php b/app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Export/GridToCsvTest.php new file mode 100644 index 0000000000000..ad295672a6cad --- /dev/null +++ b/app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Export/GridToCsvTest.php @@ -0,0 +1,71 @@ +context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->converter = $this->getMockBuilder('Magento\Ui\Model\Export\ConvertToCsv') + ->disableOriginalConstructor() + ->getMock(); + + $this->fileFactory = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->controller = new GridToCsv( + $this->context, + $this->converter, + $this->fileFactory + ); + } + + public function testExecute() + { + $content = 'test'; + + $this->converter->expects($this->once()) + ->method('getCsvFile') + ->willReturn($content); + + $this->fileFactory->expects($this->once()) + ->method('create') + ->with('export.csv', $content, 'var') + ->willReturn($content); + + $this->assertEquals($content, $this->controller->execute()); + } +} diff --git a/app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Export/GridToXmlTest.php b/app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Export/GridToXmlTest.php new file mode 100644 index 0000000000000..427a14e42dd40 --- /dev/null +++ b/app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Export/GridToXmlTest.php @@ -0,0 +1,71 @@ +context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->converter = $this->getMockBuilder('Magento\Ui\Model\Export\ConvertToXml') + ->disableOriginalConstructor() + ->getMock(); + + $this->fileFactory = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->controller = new GridToXml( + $this->context, + $this->converter, + $this->fileFactory + ); + } + + public function testExecute() + { + $content = 'test'; + + $this->converter->expects($this->once()) + ->method('getXmlFile') + ->willReturn($content); + + $this->fileFactory->expects($this->once()) + ->method('create') + ->with('export.xml', $content, 'var') + ->willReturn($content); + + $this->assertEquals($content, $this->controller->execute()); + } +} diff --git a/app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToCsvTest.php b/app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToCsvTest.php new file mode 100644 index 0000000000000..f54a9343b0b24 --- /dev/null +++ b/app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToCsvTest.php @@ -0,0 +1,236 @@ +directory = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + ->getMockForAbstractClass(); + + $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + ->disableOriginalConstructor() + ->getMock(); + $this->filesystem->expects($this->any()) + ->method('getDirectoryWrite') + ->with(DirectoryList::VAR_DIR) + ->willReturn($this->directory); + + $this->filter = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter') + ->disableOriginalConstructor() + ->getMock(); + + $this->metadataProvider = $this->getMockBuilder('Magento\Ui\Model\Export\MetadataProvider') + ->disableOriginalConstructor() + ->getMock(); + + $this->component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + + $this->stream = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + ->setMethods([ + 'lock', + 'unlock', + 'close', + ]) + ->getMockForAbstractClass(); + + $this->model = new ConvertToCsv( + $this->filesystem, + $this->filter, + $this->metadataProvider + ); + } + + public function testGetCsvFile() + { + $componentName = 'component_name'; + $data = ['data_value']; + + $document = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface') + ->getMockForAbstractClass(); + + $this->mockComponent($componentName, [$document]); + $this->mockFilter(); + $this->mockDirectory(); + + $this->stream->expects($this->once()) + ->method('lock') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('unlock') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('close') + ->willReturnSelf(); + $this->stream->expects($this->any()) + ->method('writeCsv') + ->with($data) + ->willReturnSelf(); + + $this->metadataProvider->expects($this->once()) + ->method('getOptions') + ->willReturn([]); + $this->metadataProvider->expects($this->once()) + ->method('getHeaders') + ->with($this->component) + ->willReturn($data); + $this->metadataProvider->expects($this->once()) + ->method('getFields') + ->with($this->component) + ->willReturn([]); + $this->metadataProvider->expects($this->once()) + ->method('getRowData') + ->with($document, [], []) + ->willReturn($data); + + $result = $this->model->getCsvFile(); + $this->assertTrue(is_array($result)); + $this->assertArrayHasKey('type', $result); + $this->assertArrayHasKey('value', $result); + $this->assertArrayHasKey('rm', $result); + $this->assertContains($componentName, $result); + $this->assertContains('.csv', $result); + } + + /** + * @param array $expected + */ + protected function mockStream($expected) + { + $this->stream = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + ->setMethods([ + 'lock', + 'unlock', + 'close', + ]) + ->getMockForAbstractClass(); + + $this->stream->expects($this->once()) + ->method('lock') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('unlock') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('close') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('writeCsv') + ->with($expected) + ->willReturnSelf(); + } + + /** + * @param string $componentName + * @param array $items + */ + protected function mockComponent($componentName, $items) + { + $context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->setMethods(['getDataProvider']) + ->getMockForAbstractClass(); + + $dataProvider = $this->getMockBuilder( + 'Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface' + ) + ->setMethods(['getSearchResult']) + ->getMockForAbstractClass(); + + $searchResult = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultInterface') + ->setMethods(['getItems']) + ->getMockForAbstractClass(); + + $this->component->expects($this->any()) + ->method('getName') + ->willReturn($componentName); + $this->component->expects($this->once()) + ->method('getContext') + ->willReturn($context); + + $context->expects($this->once()) + ->method('getDataProvider') + ->willReturn($dataProvider); + + $dataProvider->expects($this->once()) + ->method('getSearchResult') + ->willReturn($searchResult); + + $searchResult->expects($this->once()) + ->method('getItems') + ->willReturn($items); + } + + protected function mockFilter() + { + $this->filter->expects($this->once()) + ->method('getComponent') + ->willReturn($this->component); + $this->filter->expects($this->once()) + ->method('prepareComponent') + ->with($this->component) + ->willReturnSelf(); + $this->filter->expects($this->once()) + ->method('applySelectionOnTargetProvider') + ->willReturnSelf(); + } + + protected function mockDirectory() + { + $this->directory->expects($this->once()) + ->method('create') + ->with('export') + ->willReturnSelf(); + $this->directory->expects($this->once()) + ->method('openFile') + ->willReturn($this->stream); + } +} diff --git a/app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToXmlTest.php b/app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToXmlTest.php new file mode 100644 index 0000000000000..b4eb36b5c4a56 --- /dev/null +++ b/app/code/Magento/Ui/Test/Unit/Model/Export/ConvertToXmlTest.php @@ -0,0 +1,280 @@ +directory = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + ->getMockForAbstractClass(); + + $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') + ->disableOriginalConstructor() + ->getMock(); + $this->filesystem->expects($this->any()) + ->method('getDirectoryWrite') + ->with(DirectoryList::VAR_DIR) + ->willReturn($this->directory); + + $this->filter = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter') + ->disableOriginalConstructor() + ->getMock(); + + $this->metadataProvider = $this->getMockBuilder('Magento\Ui\Model\Export\MetadataProvider') + ->disableOriginalConstructor() + ->getMock(); + + $this->excelFactory = $this->getMockBuilder('Magento\Framework\Convert\ExcelFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->iteratorFactory = $this->getMockBuilder('Magento\Ui\Model\Export\SearchResultIteratorFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + + $this->stream = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') + ->setMethods([ + 'lock', + 'unlock', + 'close', + ]) + ->getMockForAbstractClass(); + + $this->model = new ConvertToXml( + $this->filesystem, + $this->filter, + $this->metadataProvider, + $this->excelFactory, + $this->iteratorFactory + ); + } + + public function testGetRowData() + { + $data = ['data_value']; + + $document = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface') + ->getMockForAbstractClass(); + + $this->metadataProvider->expects($this->once()) + ->method('getRowData') + ->with($document, [], []) + ->willReturn($data); + $this->metadataProvider->expects($this->once()) + ->method('getFields') + ->with($this->component) + ->willReturn([]); + $this->metadataProvider->expects($this->once()) + ->method('getOptions') + ->willReturn([]); + + $this->filter->expects($this->once()) + ->method('getComponent') + ->willReturn($this->component); + + $result = $this->model->getRowData($document); + $this->assertEquals($data, $result); + } + + public function testGetXmlFile() + { + $componentName = 'component_name'; + + $this->mockComponent($componentName); + $this->mockStream(); + $this->mockFilter(); + $this->mockDirectory(); + $this->mockExcel($componentName); + + $this->metadataProvider->expects($this->once()) + ->method('getHeaders') + ->with($this->component) + ->willReturn([]); + + $result = $this->model->getXmlFile(); + $this->assertTrue(is_array($result)); + $this->assertArrayHasKey('type', $result); + $this->assertArrayHasKey('value', $result); + $this->assertArrayHasKey('rm', $result); + $this->assertContains($componentName, $result); + $this->assertContains('.xml', $result); + } + + protected function mockStream() + { + $this->stream->expects($this->once()) + ->method('lock') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('unlock') + ->willReturnSelf(); + $this->stream->expects($this->once()) + ->method('close') + ->willReturnSelf(); + } + + /** + * @param string $componentName + */ + protected function mockExcel($componentName) + { + $searchResultIterator = $this->getMockBuilder('Magento\Ui\Model\Export\SearchResultIterator') + ->disableOriginalConstructor() + ->getMock(); + + $excel = $this->getMockBuilder('Magento\Framework\Convert\Excel') + ->disableOriginalConstructor() + ->getMock(); + + $this->iteratorFactory->expects($this->once()) + ->method('create') + ->with(['items' => []]) + ->willReturn($searchResultIterator); + + $this->excelFactory->expects($this->once()) + ->method('create') + ->with([ + 'iterator' => $searchResultIterator, + 'rowCallback' => [$this->model, 'getRowData'], + ]) + ->willReturn($excel); + + $excel->expects($this->once()) + ->method('setDataHeader') + ->with([]) + ->willReturnSelf(); + $excel->expects($this->once()) + ->method('write') + ->with($this->stream, $componentName . '.xml') + ->willReturnSelf(); + } + + /** + * @param string $componentName + */ + protected function mockComponent($componentName) + { + $context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->setMethods(['getDataProvider']) + ->getMockForAbstractClass(); + + $dataProvider = $this->getMockBuilder( + 'Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface' + ) + ->setMethods(['getSearchResult']) + ->getMockForAbstractClass(); + + $searchResult = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultInterface') + ->setMethods(['getItems']) + ->getMockForAbstractClass(); + + $this->component->expects($this->any()) + ->method('getName') + ->willReturn($componentName); + $this->component->expects($this->once()) + ->method('getContext') + ->willReturn($context); + + $context->expects($this->once()) + ->method('getDataProvider') + ->willReturn($dataProvider); + + $dataProvider->expects($this->once()) + ->method('getSearchResult') + ->willReturn($searchResult); + + $searchResult->expects($this->once()) + ->method('getItems') + ->willReturn([]); + } + + protected function mockFilter() + { + $this->filter->expects($this->once()) + ->method('getComponent') + ->willReturn($this->component); + $this->filter->expects($this->once()) + ->method('prepareComponent') + ->with($this->component) + ->willReturnSelf(); + $this->filter->expects($this->once()) + ->method('applySelectionOnTargetProvider') + ->willReturnSelf(); + } + + protected function mockDirectory() + { + $this->directory->expects($this->once()) + ->method('create') + ->with('export') + ->willReturnSelf(); + $this->directory->expects($this->once()) + ->method('openFile') + ->willReturn($this->stream); + } +} diff --git a/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php b/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php new file mode 100644 index 0000000000000..9b86aae40d279 --- /dev/null +++ b/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php @@ -0,0 +1,290 @@ +filter = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new MetadataProvider( + $this->filter + ); + } + + public function testGetHeaders() + { + $componentName = 'component_name'; + $columnName = 'column_name'; + $columnLabel = 'column_label'; + + $component = $this->prepareColumns($componentName, $columnName, $columnLabel); + + $result = $this->model->getHeaders($component); + $this->assertTrue(is_array($result)); + $this->assertCount(1, $result); + $this->assertEquals($columnLabel, $result[0]); + } + + public function testGetFields() + { + $componentName = 'component_name'; + $columnName = 'column_name'; + $columnLabel = 'column_label'; + + $component = $this->prepareColumns($componentName, $columnName, $columnLabel); + + $result = $this->model->getFields($component); + $this->assertTrue(is_array($result)); + $this->assertCount(1, $result); + $this->assertEquals($columnName, $result[0]); + } + + /** + * @param $componentName + * @param $columnName + * @param $columnLabel + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function prepareColumns($componentName, $columnName, $columnLabel) + { + $component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + + $columns = $this->getMockBuilder('Magento\Ui\Component\Listing\Columns') + ->disableOriginalConstructor() + ->getMock(); + + $column = $this->getMockBuilder('Magento\Ui\Component\Listing\Columns\Column') + ->disableOriginalConstructor() + ->getMock(); + + $component->expects($this->any()) + ->method('getName') + ->willReturn($componentName); + $component->expects($this->once()) + ->method('getChildComponents') + ->willReturn([$columns]); + + $columns->expects($this->once()) + ->method('getChildComponents') + ->willReturn([$column]); + + $column->expects($this->any()) + ->method('getName') + ->willReturn($columnName); + $column->expects($this->any()) + ->method('getData') + ->with('config/label') + ->willReturn($columnLabel); + return $component; + } + + /** + * @param string $key + * @param array $fields + * @param array $options + * @param array $expected + * @dataProvider getRowDataProvider + */ + public function testGetRowData($key, $fields, $options, $expected) + { + $document = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface') + ->getMockForAbstractClass(); + + $attribute = $this->getMockBuilder('Magento\Framework\Api\AttributeInterface') + ->getMockForAbstractClass(); + + $document->expects($this->once()) + ->method('getCustomAttribute') + ->with($fields[0]) + ->willReturn($attribute); + + $attribute->expects($this->once()) + ->method('getValue') + ->willReturn($key); + + $result = $this->model->getRowData($document, $fields, $options); + $this->assertTrue(is_array($result)); + $this->assertCount(1, $result); + $this->assertEquals($expected, $result); + } + + /** + * @return array + */ + public function getRowDataProvider() + { + return [ + [ + 'key' => 'key_1', + 'fields' => ['column'], + 'options' => [ + 'column' => [ + 'key_1' => 'value_1', + ], + ], + 'expected' => [ + 'value_1', + ], + ], + [ + 'key' => 'key_2', + 'fields' => ['column'], + 'options' => [ + 'column' => [ + 'key_1' => 'value_1', + ], + ], + 'expected' => [ + '', + ], + ], + [ + 'key' => 'key_1', + 'fields' => ['column'], + 'options' => [], + 'expected' => [ + 'key_1', + ], + ], + ]; + } + + /** + * @param string $filter + * @param array $options + * @param array $expected + * @dataProvider getOptionsDataProvider + */ + public function testGetOptions($filter, $options, $expected) + { + $component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + + $childComponent = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + + $filters = $this->getMockBuilder('Magento\Ui\Component\Filters') + ->disableOriginalConstructor() + ->getMock(); + + $select = $this->getMockBuilder('Magento\Ui\Component\Filters\Type\Select') + ->disableOriginalConstructor() + ->getMock(); + + $this->filter->expects($this->once()) + ->method('getComponent') + ->willReturn($component); + + $component->expects($this->once()) + ->method('getChildComponents') + ->willReturn(['listing_top' => $childComponent]); + + $childComponent->expects($this->once()) + ->method('getChildComponents') + ->willReturn([$filters]); + + $filters->expects($this->once()) + ->method('getChildComponents') + ->willReturn([$select]); + + $select->expects($this->any()) + ->method('getName') + ->willReturn($filter); + $select->expects($this->any()) + ->method('getData') + ->with('config/options') + ->willReturn($options); + + $result = $this->model->getOptions(); + $this->assertTrue(is_array($result)); + $this->assertCount(1, $result); + $this->assertEquals($expected, $result); + } + + /** + * @return array + */ + public function getOptionsDataProvider() + { + return [ + [ + 'filter' => 'filter_name', + 'options' => [ + [ + 'value' => 'value_1', + 'label' => 'label_1', + ] + ], + 'expected' => [ + 'filter_name' => [ + 'value_1' => 'label_1', + ], + ], + ], + [ + 'filter' => 'filter_name', + 'options' => [ + [ + 'value' => [ + [ + 'value' => 'value_2', + 'label' => 'label_2', + ], + ], + 'label' => 'label_1', + ] + ], + 'expected' => [ + 'filter_name' => [ + 'value_2' => 'label_1label_2', + ], + ], + ], + [ + 'filter' => 'filter_name', + 'options' => [ + [ + 'value' => [ + [ + 'value' => [ + [ + 'value' => 'value_3', + 'label' => 'label_3', + ] + ], + 'label' => 'label_2', + ], + ], + 'label' => 'label_1', + ] + ], + 'expected' => [ + 'filter_name' => [ + 'value_3' => 'label_1label_2label_3', + ], + ], + ], + ]; + } +} diff --git a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml index 0444e19e30edf..75349c69df7ac 100755 --- a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml +++ b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml @@ -283,6 +283,21 @@ Magento_Ui/js/grid/export + + dataGridActions + + + csv + CSV + mui/export/gridToCsv + + + xml + Excel XML + mui/export/gridToXml + + + diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php index 22b3c02f69289..566c215912993 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressMetadataTest.php @@ -61,23 +61,27 @@ public function getAttributeMetadataDataProvider() Address::POSTCODE => [ Address::POSTCODE, [ - AttributeMetadata::ATTRIBUTE_CODE => 'postcode', AttributeMetadata::FRONTEND_INPUT => 'text', AttributeMetadata::INPUT_FILTER => '', AttributeMetadata::STORE_LABEL => 'Zip/Postal Code', + AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::VALIDATION_RULES => [], AttributeMetadata::VISIBLE => true, AttributeMetadata::REQUIRED => false, - AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::DATA_MODEL => 'Magento\Customer\Model\Attribute\Data\Postcode', AttributeMetadata::OPTIONS => [], AttributeMetadata::FRONTEND_CLASS => '', + AttributeMetadata::USER_DEFINED => false, + AttributeMetadata::SORT_ORDER => 110, AttributeMetadata::FRONTEND_LABEL => 'Zip/Postal Code', AttributeMetadata::NOTE => '', AttributeMetadata::SYSTEM => true, - AttributeMetadata::USER_DEFINED => false, AttributeMetadata::BACKEND_TYPE => 'static', - AttributeMetadata::SORT_ORDER => 110 + AttributeMetadata::IS_USED_IN_GRID => true, + AttributeMetadata::IS_VISIBLE_IN_GRID => true, + AttributeMetadata::IS_FILTERABLE_IN_GRID => true, + AttributeMetadata::IS_SEARCHABLE_IN_GRID => true, + AttributeMetadata::ATTRIBUTE_CODE => 'postcode', ], ] ]; diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php index 21a80b605d33b..02f0f13f95d34 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php @@ -62,39 +62,43 @@ public function getAttributeMetadataDataProvider() Customer::FIRSTNAME => [ Customer::FIRSTNAME, [ - AttributeMetadata::ATTRIBUTE_CODE => 'firstname', AttributeMetadata::FRONTEND_INPUT => 'text', AttributeMetadata::INPUT_FILTER => '', AttributeMetadata::STORE_LABEL => 'First Name', + AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::VALIDATION_RULES => [ ['name' => 'min_text_length', 'value' => 1], ['name' => 'max_text_length', 'value' => 255], ], AttributeMetadata::VISIBLE => true, AttributeMetadata::REQUIRED => true, - AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::DATA_MODEL => '', AttributeMetadata::OPTIONS => [], AttributeMetadata::FRONTEND_CLASS => ' required-entry', + AttributeMetadata::USER_DEFINED => false, + AttributeMetadata::SORT_ORDER => 40, AttributeMetadata::FRONTEND_LABEL => 'First Name', AttributeMetadata::NOTE => '', AttributeMetadata::SYSTEM => true, - AttributeMetadata::USER_DEFINED => false, AttributeMetadata::BACKEND_TYPE => 'static', - AttributeMetadata::SORT_ORDER => 40 + AttributeMetadata::IS_USED_IN_GRID => '', + AttributeMetadata::IS_VISIBLE_IN_GRID => '', + AttributeMetadata::IS_FILTERABLE_IN_GRID => '', + AttributeMetadata::IS_SEARCHABLE_IN_GRID => '', + AttributeMetadata::ATTRIBUTE_CODE => 'firstname', + ], ], Customer::GENDER => [ Customer::GENDER, [ - AttributeMetadata::ATTRIBUTE_CODE => 'gender', AttributeMetadata::FRONTEND_INPUT => 'select', AttributeMetadata::INPUT_FILTER => '', AttributeMetadata::STORE_LABEL => 'Gender', + AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::VALIDATION_RULES => [], AttributeMetadata::VISIBLE => false, AttributeMetadata::REQUIRED => false, - AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::DATA_MODEL => '', AttributeMetadata::OPTIONS => [ ['label' => '', 'value' => ''], @@ -102,37 +106,46 @@ public function getAttributeMetadataDataProvider() ['label' => 'Female', 'value' => '2'], ], AttributeMetadata::FRONTEND_CLASS => '', + AttributeMetadata::USER_DEFINED => false, + AttributeMetadata::SORT_ORDER => 110, AttributeMetadata::FRONTEND_LABEL => 'Gender', AttributeMetadata::NOTE => '', AttributeMetadata::SYSTEM => false, - AttributeMetadata::USER_DEFINED => false, AttributeMetadata::BACKEND_TYPE => 'static', - AttributeMetadata::SORT_ORDER => 110 + AttributeMetadata::IS_USED_IN_GRID => true, + AttributeMetadata::IS_VISIBLE_IN_GRID => true, + AttributeMetadata::IS_FILTERABLE_IN_GRID => true, + AttributeMetadata::IS_SEARCHABLE_IN_GRID => '', + AttributeMetadata::ATTRIBUTE_CODE => 'gender', ], ], Customer::WEBSITE_ID => [ Customer::WEBSITE_ID, [ - AttributeMetadata::ATTRIBUTE_CODE => 'website_id', AttributeMetadata::FRONTEND_INPUT => 'select', AttributeMetadata::INPUT_FILTER => '', AttributeMetadata::STORE_LABEL => 'Associate to Website', + AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::VALIDATION_RULES => [], AttributeMetadata::VISIBLE => true, AttributeMetadata::REQUIRED => true, - AttributeMetadata::MULTILINE_COUNT => 0, AttributeMetadata::DATA_MODEL => '', AttributeMetadata::OPTIONS => [ ['label' => 'Admin', 'value' => '0'], ['label' => 'Main Website', 'value' => '1'], ], AttributeMetadata::FRONTEND_CLASS => ' required-entry', + AttributeMetadata::USER_DEFINED => false, + AttributeMetadata::SORT_ORDER => 10, AttributeMetadata::FRONTEND_LABEL => 'Associate to Website', AttributeMetadata::NOTE => '', AttributeMetadata::SYSTEM => true, - AttributeMetadata::USER_DEFINED => false, AttributeMetadata::BACKEND_TYPE => 'static', - AttributeMetadata::SORT_ORDER => 10 + AttributeMetadata::IS_USED_IN_GRID => true, + AttributeMetadata::IS_VISIBLE_IN_GRID => true, + AttributeMetadata::IS_FILTERABLE_IN_GRID => true, + AttributeMetadata::IS_SEARCHABLE_IN_GRID => '', + AttributeMetadata::ATTRIBUTE_CODE => 'website_id', ], ] ]; diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php index 4db5cf7a13f08..143aea42acbd0 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php @@ -6,14 +6,14 @@ namespace Magento\Customer\Test\Block\Adminhtml; -use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; /** * Class CustomerGrid * Backend customer grid * */ -class CustomerGrid extends AbstractGrid +class CustomerGrid extends DataGrid { /** * Selector for action option select @@ -29,13 +29,13 @@ class CustomerGrid extends AbstractGrid */ protected $filters = [ 'name' => [ - 'selector' => '#customerGrid_filter_name', + 'selector' => '.admin__data-grid-filters input[name*=name]', ], 'email' => [ - 'selector' => '#customerGrid_filter_email', + 'selector' => '.admin__data-grid-filters input[name*=email]', ], 'group' => [ - 'selector' => '#customerGrid_filter_group', + 'selector' => '.admin__data-grid-filters select[name*=group_id]', 'input' => 'select', ], ]; 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 2d8f5faf09f88..0d8ca0ccb63bb 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 @@ -120,14 +120,22 @@ public function persist(FixtureInterface $customer = null) */ protected function getCustomerId($email) { - $url = $_ENV['app_backend_url'] . 'customer/index/grid/filter/' . $this->encodeFilter(['email' => $email]); + $url = $_ENV['app_backend_url'] . 'mui/index/render/'; + $data = [ + 'namespace' => 'customer_listing', + 'filters' => [ + 'placeholder' => true, + 'email' => $email + ], + 'isAjax' => true + ]; $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); - $curl->write(CurlInterface::GET, $url, '1.0'); + $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $curl->read(); $curl->close(); - preg_match('/data-column="entity_id"[^>]*>\s*([0-9]+)\s* - + diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/TypeTest.php b/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/TypeTest.php index fbf6e31bde66e..d58a2c767a30c 100644 --- a/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/TypeTest.php +++ b/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/TypeTest.php @@ -19,7 +19,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase /** * Full reindex * - * @var \Magento\Indexer\Model\IndexerInterface + * @var \Magento\Framework\Indexer\IndexerInterface */ protected $indexer; @@ -39,8 +39,8 @@ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ - $indexerRegistry = $this->objectManager->create('\Magento\Indexer\Model\IndexerRegistry'); + /** @var \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ + $indexerRegistry = $this->objectManager->create('\Magento\Framework\Indexer\IndexerRegistry'); $this->indexer = $indexerRegistry->get('catalogsearch_fulltext'); $this->resource = $this->objectManager->get('Magento\Framework\App\Resource'); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php index c00277e7a8678..d95e25740a060 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php @@ -17,7 +17,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase const DEFAULT_ROOT_CATEGORY = 2; /** - * @var \Magento\Indexer\Model\IndexerInterface + * @var \Magento\Framework\Indexer\IndexerInterface */ protected $indexer; @@ -28,7 +28,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { - /** @var \Magento\Indexer\Model\IndexerInterface indexer */ + /** @var \Magento\Framework\Indexer\IndexerInterface indexer */ $this->indexer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Indexer\Model\Indexer' ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php index f1a3d2ae59800..0cd782e244401 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php @@ -78,7 +78,7 @@ public function testEntityItemsBefore() */ public function testReindexAll() { - /** @var $indexer \Magento\Indexer\Model\IndexerInterface */ + /** @var $indexer \Magento\Framework\Indexer\IndexerInterface */ $indexer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Indexer\Model\Indexer' ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule.php index bd3446ce56de4..cc06391fd1f96 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -/* @var \Magento\Indexer\Model\IndexerInterface $model */ -$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Indexer\Model\IndexerRegistry') +/* @var \Magento\Framework\Indexer\IndexerInterface $model */ +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Indexer\IndexerRegistry') ->get('catalogsearch_fulltext'); $model->setScheduled(true); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule_rollback.php index 7990287681a48..77aefe8f867b6 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/enable_reindex_schedule_rollback.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -/* @var \Magento\Indexer\Model\IndexerInterface $model */ -$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Indexer\Model\IndexerRegistry') +/* @var \Magento\Framework\Indexer\IndexerInterface $model */ +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Indexer\IndexerRegistry') ->get('catalogsearch_fulltext'); $model->setScheduled(false); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php index f0dd6a8901dd0..d74e750cf109e 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php @@ -16,7 +16,7 @@ class FulltextTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\IndexerInterface + * @var \Magento\Framework\Indexer\IndexerInterface */ protected $indexer; @@ -72,7 +72,7 @@ class FulltextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - /** @var \Magento\Indexer\Model\IndexerInterface indexer */ + /** @var \Magento\Framework\Indexer\IndexerInterface indexer */ $this->indexer = Bootstrap::getObjectManager()->create( 'Magento\Indexer\Model\Indexer' ); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index c92d3bd491c8f..b5e408cacc28a 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -521,21 +521,6 @@ public function testNotExistingCustomerDeleteAction() ); } - /** - * @magentoDataFixture Magento/Customer/_files/customer_sample.php - */ - public function testGridAction() - { - $this->dispatch('backend/customer/index/grid'); - - $body = $this->getResponse()->getBody(); - - $this->assertContains('test firstname test lastname', $body); - $this->assertContains('customer@example.com', $body); - $this->assertContains('+7000000001', $body); - $this->assertContains('United States', $body); - } - /** * @magentoDataFixture Magento/Customer/_files/customer_sample.php */ @@ -569,7 +554,7 @@ public function testMassSubscriberAction() $this->assertNull($subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus()); $this->assertNull($subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus()); // Setup - $this->getRequest()->setParam('customer', [1, 2]); + $this->getRequest()->setPostValue('selected', [1, 2])->setPostValue('namespace', 'customer_listing'); // Test $this->dispatch('backend/customer/index/massSubscribe'); @@ -595,73 +580,22 @@ public function testMassSubscriberAction() */ public function testMassSubscriberActionNoSelection() { + $this->getRequest()->setPostValue('namespace', 'customer_listing'); $this->dispatch('backend/customer/index/massSubscribe'); $this->assertRedirect($this->stringContains('customer/index')); $this->assertSessionMessages( - $this->equalTo(['Please select customer(s).']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); - } - - /** - * @magentoDbIsolation enabled - */ - public function testMassSubscriberActionInvalidId() - { - $this->getRequest()->setParam('customer', [4200]); - - $this->dispatch('backend/customer/index/massSubscribe'); - - $this->assertRedirect($this->stringContains('customer/index')); - $this->assertSessionMessages( - $this->equalTo(['No such entity with customerId = 4200']), + $this->equalTo(['Please select item(s).']), \Magento\Framework\Message\MessageInterface::TYPE_ERROR ); } - /** - * @magentoDataFixture Magento/Customer/_files/two_customers.php - */ - public function testMassSubscriberActionPartialUpdate() - { - // Pre-condition - /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ - $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); - $this->assertNull($subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus()); - $this->assertNull($subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus()); - // Setup - $this->getRequest()->setParam('customer', [1, 4200, 2]); - - // Test - $this->dispatch('backend/customer/index/massSubscribe'); - - // Assertions - $this->assertRedirect($this->stringContains('customer/index')); - $this->assertSessionMessages( - $this->equalTo(['A total of 2 record(s) were updated.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS - ); - $this->assertSessionMessages( - $this->equalTo(['No such entity with customerId = 4200']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); - $this->assertEquals( - Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() - ); - $this->assertEquals( - Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() - ); - } - /** * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testMassDeleteAction() { - $this->getRequest()->setPostValue('customer', [1]); + $this->getRequest()->setPostValue('selected', [1])->setPostValue('namespace', 'customer_listing'); $this->dispatch('backend/customer/index/massDelete'); $this->assertSessionMessages( $this->equalTo(['A total of 1 record(s) were deleted.']), @@ -670,45 +604,16 @@ public function testMassDeleteAction() $this->assertRedirect($this->stringContains('customer/index')); } - /** - * @magentoDbIsolation enabled - */ - public function testInvalidIdMassDeleteAction() - { - $this->getRequest()->setPostValue('customer', [1]); - $this->dispatch('backend/customer/index/massDelete'); - $this->assertSessionMessages( - $this->equalTo(['No such entity with customerId = 1']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); - } - /** * Valid group Id but no customer Ids specified * @magentoDbIsolation enabled */ public function testMassDeleteActionNoCustomerIds() { + $this->getRequest()->setPostValue('namespace', 'customer_listing'); $this->dispatch('backend/customer/index/massDelete'); $this->assertSessionMessages( - $this->equalTo(['Please select customer(s).']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); - } - - /** - * @magentoDataFixture Magento/Customer/_files/two_customers.php - */ - public function testMassDeleteActionPartialUpdate() - { - $this->getRequest()->setPostValue('customer', [1, 999, 2, 9999]); - $this->dispatch('backend/customer/index/massDelete'); - $this->assertSessionMessages( - $this->equalTo(['A total of 2 record(s) were deleted.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS - ); - $this->assertSessionMessages( - $this->equalTo(['No such entity with customerId = 999', 'No such entity with customerId = 9999']), + $this->equalTo(['Please select item(s).']), \Magento\Framework\Message\MessageInterface::TYPE_ERROR ); } @@ -794,7 +699,7 @@ public function testMassUnsubscriberAction() $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); $subscriberFactory->create()->subscribeCustomerById(1); $subscriberFactory->create()->subscribeCustomerById(2); - $this->getRequest()->setParam('customer', [1, 2]); + $this->getRequest()->setPostValue('selected', [1, 2])->setPostValue('namespace', 'customer_listing'); // Ensure secret key is disabled (subscription status notification emails turn it off) $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); @@ -823,69 +728,16 @@ public function testMassUnsubscriberAction() */ public function testMassUnsubscriberActionNoSelection() { + $this->getRequest()->setPostValue('namespace', 'customer_listing'); $this->dispatch('backend/customer/index/massUnsubscribe'); $this->assertRedirect($this->stringContains('customer/index')); $this->assertSessionMessages( - $this->equalTo(['Please select customer(s).']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); - } - - /** - * @magentoDbIsolation enabled - */ - public function testMassUnsubscriberActionInvalidId() - { - $this->getRequest()->setParam('customer', [4200]); - - $this->dispatch('backend/customer/index/massUnsubscribe'); - - $this->assertRedirect($this->stringContains('customer/index')); - $this->assertSessionMessages( - $this->equalTo(['No such entity with customerId = 4200']), + $this->equalTo(['Please select item(s).']), \Magento\Framework\Message\MessageInterface::TYPE_ERROR ); } - /** - * @magentoDataFixture Magento/Customer/_files/two_customers.php - */ - public function testMassUnsubscriberActionPartialUpdate() - { - // Setup - /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ - $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); - $subscriberFactory->create()->subscribeCustomerById(1); - $subscriberFactory->create()->subscribeCustomerById(2); - $this->getRequest()->setParam('customer', [1, 4200, 2]); - - // Ensure secret key is disabled (subscription status notification emails turn it off) - $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); - - // Test - $this->dispatch('backend/customer/index/massUnsubscribe'); - - // Assertions - $this->assertRedirect($this->stringContains('customer/index')); - $this->assertSessionMessages( - $this->equalTo(['A total of 2 record(s) were updated.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS - ); - $this->assertSessionMessages( - $this->equalTo(['No such entity with customerId = 4200']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR - ); - $this->assertEquals( - Subscriber::STATUS_UNSUBSCRIBED, - $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() - ); - $this->assertEquals( - Subscriber::STATUS_UNSUBSCRIBED, - $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() - ); - } - /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/ConverterTest.php b/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/ConverterTest.php index 1bc92eaab653a..ca2af2c25806f 100644 --- a/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/ConverterTest.php +++ b/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/ConverterTest.php @@ -8,14 +8,14 @@ class ConverterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\Config\Converter + * @var \Magento\Framework\Indexer\Config\Converter */ protected $model; protected function setUp() { $this->model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('\Magento\Indexer\Model\Config\Converter'); + ->create('Magento\Framework\Indexer\Config\Converter'); } public function testConverter() diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/indexer.xml b/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/indexer.xml index b83f645c9cd2b..35b252ec984c9 100644 --- a/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/indexer.xml +++ b/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/indexer.xml @@ -6,7 +6,7 @@ */ --> + xsi:noNamespaceSchemaLocation="../../../../../../../../../lib/internal/Magento/Framework/Indexer/etc/indexer.xsd"> @@ -16,21 +16,15 @@
- -
- - - -
diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/result.php b/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/result.php index 4c3adbe825801..1ea56303ff15a 100644 --- a/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/result.php +++ b/dev/tests/integration/testsuite/Magento/Indexer/Model/Config/_files/result.php @@ -66,19 +66,10 @@ [ 'first' => [ - 0 => - [ - 'fieldset' => 'first', - 'from' => 'id_field', - 'to' => 'second_entity_id', - ], - 1 => - [ - 'fieldset' => 'first', - 'from' => 'id_field2', - 'to' => 'second_entity_id2', - ], - ], + 'fieldset' => 'first', + 'from' => 'id_field', + 'to' => 'second_entity_id', + ] ], ], ], diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php index 525fc6af48d6f..944cf84501454 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php @@ -30,8 +30,8 @@ protected function setUp() $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\Filesystem' ); - $this->schemeFile = $filesystem->getDirectoryRead(DirectoryList::APP) - ->getAbsolutePath('code/Magento/Indexer/etc/indexer.xsd'); + $this->schemeFile = $filesystem->getDirectoryRead(DirectoryList::ROOT) + ->getAbsolutePath('lib/internal/Magento/Framework/Indexer/etc/indexer.xsd'); } /** diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/ConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/ConfigTest.php index 6c1aed921ece0..7b8c37e437e2f 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/ConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/ConfigTest.php @@ -19,7 +19,7 @@ class ConfigTest extends \Magento\TestFramework\Integrity\AbstractConfig */ protected function _getXsd() { - return '/app/code/Magento/Indexer/etc/indexer_merged.xsd'; + return '/lib/internal/Magento/Framework/Indexer/etc/indexer_merged.xsd'; } /** @@ -69,7 +69,7 @@ protected function _getKnownInvalidPartialXml() */ protected function _getFileXsd() { - return '/app/code/Magento/Indexer/etc/indexer.xsd'; + return '/lib/internal/Magento/Framework/Indexer/etc/indexer.xsd'; } /** @@ -79,6 +79,6 @@ protected function _getFileXsd() */ protected function _getXmlName() { - return '/app/code/Magento/Indexer/etc/indexer.xml'; + return '/lib/internal/Magento/Framework/Indexer/etc/indexer.xml'; } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/invalid.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/invalid.xml index c7095a028730b..5479440317f6f 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/invalid.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/invalid.xml @@ -7,7 +7,7 @@ * See COPYING.txt for license details. */ --> - + Test Indexer Declaration Invalid provider attribute value @@ -23,19 +23,19 @@ Test Indexer Declaration Empty fields -
+
Test Indexer Declaration Invalid handler attribute value -
+
Test Indexer Declaration Duplicate field declaration -
+
@@ -45,42 +45,42 @@ Test Indexer Declaration Invalid source attribute value -
+
Test Indexer Declaration Invalid field handler attribute value -
+
Test Indexer Declaration Invalid field type -
+
Test Indexer Declaration No dataType attribute for 'filterable' type field -
+
Test Indexer Declaration Invalid field dataType attribute value -
+
Test Indexer Declaration No dataType attribute for 'filterable' type field -
+
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid.xml index 3d9143fbfbcef..0bd5f82c64f23 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Test Indexer Declaration 1 Test Indexer Declaration 1 diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid_partial.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid_partial.xml index 913bf102f90cf..3945fb13a058b 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid_partial.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Indexer/_files/valid_partial.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Test Indexer Declaration 1 Test Indexer Declaration 1 diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 6c134ffed5ebf..d0a34092894b3 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2433,6 +2433,14 @@ ['getThumbnailSize', 'Magento\ProductAlert\Block\Email\AbstractEmail'], ['getThumbnailUrl', 'Magento\ProductAlert\Block\Email\AbstractEmail'], ['getProductThumbnail', 'Magento\Checkout\Block\Cart\Item\Renderer'], + ['getColumnsComponent', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getColumnsComponent'], + ['getColumns', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getColumns'], + ['getHeaders', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getHeaders'], + ['getFields', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getFields'], + ['getRowData', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getRowData'], + ['getComplexLabel', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getComplexLabel'], + ['getFilterOptions', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getFilterOptions'], + ['getOptions', 'Magento\Ui\Model\Export\ConvertToCsv', 'Magento\Ui\Model\Export\MetadataProvider::getOptions'], [ 'generateSimpleProducts', 'Magento\ConfigurableProduct\Model\Product\Type\Configurable', diff --git a/lib/internal/Magento/Framework/Api/Search/SearchCriteriaBuilder.php b/lib/internal/Magento/Framework/Api/Search/SearchCriteriaBuilder.php index 7d7d1f5bd2baf..a81600418ad77 100644 --- a/lib/internal/Magento/Framework/Api/Search/SearchCriteriaBuilder.php +++ b/lib/internal/Magento/Framework/Api/Search/SearchCriteriaBuilder.php @@ -8,7 +8,6 @@ use Magento\Framework\Api\AbstractSimpleObjectBuilder; use Magento\Framework\Api\ObjectFactory; -use Magento\Framework\Api\SortOrder; use Magento\Framework\Api\SortOrderBuilder; /** diff --git a/lib/internal/Magento/Framework/App/Resource/SourcePool.php b/lib/internal/Magento/Framework/App/Resource/SourceFactory.php similarity index 88% rename from lib/internal/Magento/Framework/App/Resource/SourcePool.php rename to lib/internal/Magento/Framework/App/Resource/SourceFactory.php index f4ef9edecbfe7..bfc9da15dcb8e 100644 --- a/lib/internal/Magento/Framework/App/Resource/SourcePool.php +++ b/lib/internal/Magento/Framework/App/Resource/SourceFactory.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\App\Resource; -class SourcePool +class SourceFactory { /** * @var \Magento\Framework\ObjectManagerInterface @@ -27,9 +27,9 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan * @throws \InvalidArgumentException * @return SourceProviderInterface */ - public function get($className) + public function create($className) { - $source = $this->objectManager->get($className); + $source = $this->objectManager->create($className); if (!$source instanceof SourceProviderInterface) { throw new \InvalidArgumentException( $className . ' doesn\'t implement \Magento\Framework\App\Resource\SourceProviderInterface' diff --git a/lib/internal/Magento/Framework/Convert/ExcelFactory.php b/lib/internal/Magento/Framework/Convert/ExcelFactory.php new file mode 100644 index 0000000000000..116da10310962 --- /dev/null +++ b/lib/internal/Magento/Framework/Convert/ExcelFactory.php @@ -0,0 +1,44 @@ +objectManager = $objectManager; + $this->instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\Framework\Convert\Excel + */ + public function create(array $data = []) + { + return $this->objectManager->create($this->instanceName, $data); + } +} diff --git a/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php b/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php new file mode 100644 index 0000000000000..de7e50558b329 --- /dev/null +++ b/lib/internal/Magento/Framework/Convert/Test/Unit/ExcelFactoryTest.php @@ -0,0 +1,47 @@ +objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->setMethods(['create']) + ->getMockForAbstractClass(); + + $this->model = new ExcelFactory( + $this->objectManager + ); + } + + public function testCreate() + { + $excel = $this->getMockBuilder('Magento\Framework\Convert\Excel') + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager->expects($this->once()) + ->method('create') + ->with('\\Magento\\Framework\\Convert\\Excel', []) + ->willReturn($excel); + + $this->assertInstanceOf('Magento\Framework\Convert\Excel', $this->model->create()); + } +} diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index 2ab2fdf21be1b..041d7d35b977f 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -1973,8 +1973,10 @@ public function createTable(Table $table) implode(",\n", $sqlFragment), implode(" ", $tableOptions) ); + $result = $this->query($sql); + $this->resetDdlCache($table->getName(), $table->getSchema()); - return $this->query($sql); + return $result; } /** @@ -2379,7 +2381,7 @@ public function dropTable($tableName, $schemaName = null) $table = $this->quoteIdentifier($this->_getTableName($tableName, $schemaName)); $query = 'DROP TABLE IF EXISTS ' . $table; $this->query($query); - + $this->resetDdlCache($tableName, $schemaName); return true; } diff --git a/lib/internal/Magento/Framework/DB/SubSelect.php b/lib/internal/Magento/Framework/DB/SubSelect.php new file mode 100644 index 0000000000000..7f23f9eb4a368 --- /dev/null +++ b/lib/internal/Magento/Framework/DB/SubSelect.php @@ -0,0 +1,105 @@ +resource = $resource; + $this->connectionName = $connectionName; + $this->table = $table; + $this->columns = $columns; + $this->originColumn = $originColumn; + $this->targetColumn = $targetColumn; + } + + /** + * @return string + */ + public function __toString() + { + $select = $this->getConnection()->select()->from( + $this->resource->getTableName($this->table), + array_values($this->columns) + )->where( + sprintf( + '%s = %s', + $this->getConnection()->quoteIdentifier($this->originColumn), + $this->getConnection()->quoteIdentifier($this->targetColumn) + ) + )->limit(1); + return sprintf('(%s)', $select); + } + + /** + * Returns connection + * + * @return AdapterInterface + */ + protected function getConnection() + { + if (!$this->connection) { + $this->connection = $this->resource->getConnection($this->connectionName); + } + return $this->connection; + } +} diff --git a/app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php b/lib/internal/Magento/Framework/Indexer/AbstractProcessor.php similarity index 85% rename from app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php rename to lib/internal/Magento/Framework/Indexer/AbstractProcessor.php index 1a00ab15aa0bd..f9bfebb770026 100644 --- a/app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php +++ b/lib/internal/Magento/Framework/Indexer/AbstractProcessor.php @@ -6,7 +6,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\Indexer; +namespace Magento\Framework\Indexer; abstract class AbstractProcessor { @@ -15,14 +15,14 @@ abstract class AbstractProcessor */ const INDEXER_ID = ''; - /** @var \Magento\Indexer\Model\IndexerRegistry */ + /** @var \Magento\Framework\Indexer\IndexerRegistry */ protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry */ public function __construct( - \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry ) { $this->indexerRegistry = $indexerRegistry; } @@ -30,7 +30,7 @@ public function __construct( /** * Get indexer * - * @return \Magento\Indexer\Model\IndexerInterface + * @return \Magento\Framework\Indexer\IndexerInterface */ public function getIndexer() { diff --git a/app/code/Magento/Indexer/Model/Action/Base.php b/lib/internal/Magento/Framework/Indexer/Action/Base.php similarity index 69% rename from app/code/Magento/Indexer/Model/Action/Base.php rename to lib/internal/Magento/Framework/Indexer/Action/Base.php index 1ea7dc7fdf956..44628589c4c5b 100644 --- a/app/code/Magento/Indexer/Model/Action/Base.php +++ b/lib/internal/Magento/Framework/Indexer/Action/Base.php @@ -3,21 +3,21 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\Action; +namespace Magento\Framework\Indexer\Action; use Magento\Framework\App\Resource as AppResource; use Magento\Framework\App\Resource\SourceProviderInterface; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Ddl\Table; -use Magento\Framework\IndexerInterface; +use Magento\Framework\Indexer\SaveHandler\IndexerInterface; use Magento\Framework\Stdlib\StringUtils as StdString; -use Magento\Indexer\Model\ActionInterface; -use Magento\Indexer\Model\FieldsetPool; -use Magento\Indexer\Model\HandlerPool; -use Magento\Indexer\Model\IndexStructure; -use Magento\Indexer\Model\SaveHandlerFactory; -use Magento\Framework\App\Resource\SourcePool; -use Magento\Indexer\Model\HandlerInterface; +use Magento\Framework\Indexer\ActionInterface; +use Magento\Framework\Indexer\FieldsetPool; +use Magento\Framework\Indexer\HandlerPool; +use Magento\Framework\Indexer\IndexStructureInterface; +use Magento\Framework\Indexer\SaveHandlerFactory; +use Magento\Framework\App\Resource\SourceFactory; +use Magento\Framework\Indexer\HandlerInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -80,9 +80,9 @@ class Base implements ActionInterface protected $searchColumns; /** - * @var SourcePool + * @var SourceFactory */ - protected $sourcePool; + protected $sourceFactory; /** * @var HandlerPool @@ -100,7 +100,7 @@ class Base implements ActionInterface protected $string; /** - * @var IndexStructure + * @var IndexStructureInterface */ protected $indexStructure; @@ -119,30 +119,35 @@ class Base implements ActionInterface */ protected $saveHandler; + /** + * @var string + */ + protected $tableAlias = 'main_table'; + /** * @param AppResource $resource - * @param SourcePool $sourcePool + * @param SourceFactory $sourceFactory * @param HandlerPool $handlerPool * @param SaveHandlerFactory $saveHandlerFactory * @param FieldsetPool $fieldsetPool * @param StdString $string - * @param IndexStructure $indexStructure + * @param IndexStructureInterface $indexStructure * @param array $data */ public function __construct( AppResource $resource, - SourcePool $sourcePool, + SourceFactory $sourceFactory, HandlerPool $handlerPool, SaveHandlerFactory $saveHandlerFactory, FieldsetPool $fieldsetPool, StdString $string, - IndexStructure $indexStructure, + IndexStructureInterface $indexStructure, $data = [] ) { $this->connection = $resource->getConnection(); $this->fieldsetPool = $fieldsetPool; $this->data = $data; - $this->sourcePool = $sourcePool; + $this->sourceFactory = $sourceFactory; $this->handlerPool = $handlerPool; $this->saveHandlerFactory = $saveHandlerFactory; $this->string = $string; @@ -155,12 +160,13 @@ public function __construct( * @param null|int|array $ids * @return void */ - protected function execute($ids = null) + protected function execute(array $ids = []) { $this->prepareFields(); - $this->indexStructure->delete($this->getTableName()); - $this->indexStructure->create($this->getTableName(), $this->filterable); - $this->getSaveHandler()->cleanIndex([]); + if (!count($ids)) { + $this->getSaveHandler()->cleanIndex([]); + } + $this->getSaveHandler()->deleteIndex([], new \ArrayObject($ids)); $this->getSaveHandler()->saveIndex([], $this->prepareDataSource($ids)); } @@ -193,7 +199,7 @@ public function executeList(array $ids) */ public function executeRow($id) { - $this->execute($id); + $this->execute([$id]); } /** @@ -202,9 +208,9 @@ public function executeRow($id) * @param array|int|null $ids * @return SourceProviderInterface */ - protected function prepareDataSource($ids = null) + protected function prepareDataSource(array $ids = []) { - return $ids === null + return !count($ids) ? $this->createResultCollection() : $this->createResultCollection()->addFieldToFilter($this->getPrimaryResource()->getIdFieldname(), $ids); } @@ -227,7 +233,13 @@ protected function getTableName() protected function getSaveHandler() { if ($this->saveHandler === null) { - $this->saveHandler = $this->saveHandlerFactory->create($this->data['saveHandler'], ['data' => $this->data]); + $this->saveHandler = $this->saveHandlerFactory->create( + $this->data['saveHandler'], + [ + 'indexStructure' => $this->indexStructure, + 'data' => $this->data, + ] + ); } return $this->saveHandler; } @@ -265,15 +277,15 @@ protected function createResultCollection() if (isset($fieldset['references'])) { foreach ($fieldset['references'] as $reference) { $source = $fieldset['source']; - $referenceSource = $this->data['fieldsets'][$reference['fieldset']]['source']; /** @var SourceProviderInterface $source */ - /** @var SourceProviderInterface $referenceSource */ $currentEntityName = $source->getMainTable(); - $select->joinInner( - $currentEntityName, + $alias = $this->getPrimaryFieldset()['name'] == $reference['fieldset'] + ? $this->tableAlias + : $reference['fieldset']; + $select->joinLeft( + [$fieldset['name'] => $currentEntityName], new \Zend_Db_Expr( - $referenceSource->getMainTable() . '.' . $reference['from'] - . '=' . $currentEntityName . '.' . $reference['to'] + $fieldset['name'] . '.' . $reference['from'] . '=' . $alias . '.' . $reference['to'] ), null ); @@ -282,7 +294,11 @@ protected function createResultCollection() foreach ($fieldset['fields'] as $field) { $handler = $field['handler']; /** @var HandlerInterface $handler */ - $handler->prepareSql($fieldset['source'], $field); + $handler->prepareSql( + $this->getPrimaryResource(), + $this->getPrimaryFieldset()['name'] == $fieldset['name'] ? $this->tableAlias : $fieldset['name'], + $field + ); } } @@ -297,12 +313,21 @@ protected function createResultCollection() protected function prepareFields() { foreach ($this->data['fieldsets'] as $fieldsetName => $fieldset) { - $this->data['fieldsets'][$fieldsetName]['source'] = $this->sourcePool->get($fieldset['source']); - if (isset($fieldset['class'])) { - $fieldsetObject = $this->fieldsetPool->get($fieldset['class']); - $this->data['fieldsets'][$fieldsetName] = $fieldsetObject->addDynamicData($fieldset); + $this->data['fieldsets'][$fieldsetName]['source'] = $this->sourceFactory->create($fieldset['source']); + if (isset($fieldset['provider'])) { + $fieldsetObject = $this->fieldsetPool->get($fieldset['provider']); + $this->data['fieldsets'][$fieldsetName] = + $fieldsetObject->addDynamicData($this->data['fieldsets'][$fieldsetName]); } - foreach ($fieldset['fields'] as $fieldName => $field) { + foreach ($this->data['fieldsets'][$fieldsetName]['fields'] as $fieldName => $field) { + $this->data['fieldsets'][$fieldsetName]['fields'][$fieldName]['origin'] = + $this->data['fieldsets'][$fieldsetName]['fields'][$fieldName]['origin'] + ?: $this->data['fieldsets'][$fieldsetName]['fields'][$fieldName]['name']; + if ($fieldsetName != 0) { + $this->data['fieldsets'][$fieldsetName]['fields'][$fieldName]['name'] = + $this->data['fieldsets'][$fieldsetName]['name'] . '_' + . $this->data['fieldsets'][$fieldsetName]['fields'][$fieldName]['name']; + } $this->saveFieldByType($field); $this->data['fieldsets'][$fieldsetName]['fields'][$fieldName]['handler'] = $this->handlerPool->get($field['handler']); diff --git a/lib/internal/Magento/Framework/Indexer/Action/Dummy.php b/lib/internal/Magento/Framework/Indexer/Action/Dummy.php new file mode 100644 index 0000000000000..ca29e99d07fab --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Action/Dummy.php @@ -0,0 +1,54 @@ +createResultCollection() + : $this->createResultCollection()->addFieldToFilter($this->getPrimaryResource()->getRowIdFieldName(), $ids); + } +} diff --git a/app/code/Magento/Indexer/Model/ActionFactory.php b/lib/internal/Magento/Framework/Indexer/ActionFactory.php similarity index 84% rename from app/code/Magento/Indexer/Model/ActionFactory.php rename to lib/internal/Magento/Framework/Indexer/ActionFactory.php index d0c703a3ee482..38e61d5dc3fd7 100644 --- a/app/code/Magento/Indexer/Model/ActionFactory.php +++ b/lib/internal/Magento/Framework/Indexer/ActionFactory.php @@ -3,7 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; + +use Magento\Framework\Indexer\ActionInterface; class ActionFactory { @@ -33,7 +35,7 @@ public function create($className, $arguments = []) $action = $this->objectManager->create($className, $arguments); if (!$action instanceof ActionInterface) { throw new \InvalidArgumentException( - $className . ' doesn\'t implement \Magento\Indexer\Model\ActionInterface' + $className . ' doesn\'t implement \Magento\Framework\Indexer\ActionInterface' ); } diff --git a/app/code/Magento/Indexer/Model/ActionInterface.php b/lib/internal/Magento/Framework/Indexer/ActionInterface.php similarity index 93% rename from app/code/Magento/Indexer/Model/ActionInterface.php rename to lib/internal/Magento/Framework/Indexer/ActionInterface.php index a26fcf1ff2925..b62bb11d37226 100644 --- a/app/code/Magento/Indexer/Model/ActionInterface.php +++ b/lib/internal/Magento/Framework/Indexer/ActionInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; /** * @api diff --git a/app/code/Magento/Indexer/Model/CacheContext.php b/lib/internal/Magento/Framework/Indexer/CacheContext.php similarity index 97% rename from app/code/Magento/Indexer/Model/CacheContext.php rename to lib/internal/Magento/Framework/Indexer/CacheContext.php index fa82505a090c9..54ead2476ddd6 100644 --- a/app/code/Magento/Indexer/Model/CacheContext.php +++ b/lib/internal/Magento/Framework/Indexer/CacheContext.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; /** * Class Context diff --git a/app/code/Magento/Indexer/Model/Config/Converter.php b/lib/internal/Magento/Framework/Indexer/Config/Converter.php similarity index 94% rename from app/code/Magento/Indexer/Model/Config/Converter.php rename to lib/internal/Magento/Framework/Indexer/Config/Converter.php index 59aab2ae5688b..5b441b97b3ee4 100644 --- a/app/code/Magento/Indexer/Model/Config/Converter.php +++ b/lib/internal/Magento/Framework/Indexer/Config/Converter.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\Config; +namespace Magento\Framework\Indexer\Config; use Magento\Framework\Config\ConverterInterface; @@ -133,7 +133,7 @@ protected function convertFieldset(\DOMElement $node, $data) ['references'][$this->getAttributeValue($childNode, 'fieldset')] : []; $data['fieldsets'][$this->getAttributeValue($node, 'name')]['references'] - [$this->getAttributeValue($childNode, 'fieldset')][] = [ + [$this->getAttributeValue($childNode, 'fieldset')] = [ 'fieldset' => $this->getAttributeValue($childNode, 'fieldset'), 'from' => $this->getAttributeValue($childNode, 'from'), 'to' => $this->getAttributeValue($childNode, 'to'), @@ -211,7 +211,7 @@ protected function getTranslatedNodeValue(\DOMNode $node) { $value = $node->nodeValue; if ($this->getAttributeValue($node, 'translate') == 'true') { - $value = __($value); + $value = new \Magento\Framework\Phrase($value); } return $value; } @@ -224,14 +224,16 @@ protected function getTranslatedNodeValue(\DOMNode $node) */ protected function sorting($data) { - usort($data['fieldsets'], function ($current, $parent) { - if (!isset($current['references']) || isset($parent['references'][$current['name']])) { + usort($data['fieldsets'], function ($current, $parent) use ($data) { + if (!isset($current['references']) && $data['primary'] == $current['name'] + || isset($parent['references'][$current['name']]) + ) { return -1; - } - if (!isset($parent['references']) || isset($current['references'][$parent['name']])) { + } elseif (!isset($parent['references']) || isset($current['references'][$parent['name']])) { return 1; + } else { + return 0; } - return 0; }); return $data; } diff --git a/app/code/Magento/Indexer/Model/Config/Reader.php b/lib/internal/Magento/Framework/Indexer/Config/Reader.php similarity index 87% rename from app/code/Magento/Indexer/Model/Config/Reader.php rename to lib/internal/Magento/Framework/Indexer/Config/Reader.php index 93e337ba4903e..85eaa19c6de46 100644 --- a/app/code/Magento/Indexer/Model/Config/Reader.php +++ b/lib/internal/Magento/Framework/Indexer/Config/Reader.php @@ -3,11 +3,8 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\Config; +namespace Magento\Framework\Indexer\Config; -/** - * @codeCoverageIgnore - */ class Reader extends \Magento\Framework\Config\Reader\Filesystem { /** @@ -32,11 +29,13 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem * @param array $idAttributes * @param string $domDocumentClass * @param string $defaultScope + * + * @codeCoverageIgnore */ public function __construct( \Magento\Framework\Config\FileResolverInterface $fileResolver, - \Magento\Indexer\Model\Config\Converter $converter, - \Magento\Indexer\Model\Config\SchemaLocator $schemaLocator, + \Magento\Framework\Indexer\Config\Converter $converter, + \Magento\Framework\Indexer\Config\SchemaLocator $schemaLocator, \Magento\Framework\Config\ValidationStateInterface $validationState, $fileName = 'indexer.xml', $idAttributes = [], diff --git a/lib/internal/Magento/Framework/Indexer/Config/SchemaLocator.php b/lib/internal/Magento/Framework/Indexer/Config/SchemaLocator.php new file mode 100644 index 0000000000000..e6fffe6aa191f --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Config/SchemaLocator.php @@ -0,0 +1,31 @@ +objectManager->get($fieldsetClass); if (!$handler instanceof FieldsetInterface) { throw new \InvalidArgumentException( - $fieldsetClass . ' doesn\'t implement \Magento\Indexer\Model\FieldsetInterface' + $fieldsetClass . ' doesn\'t implement \Magento\Framework\Indexer\FieldsetInterface' ); } return $handler; diff --git a/app/code/Magento/Indexer/Model/FilterInterface.php b/lib/internal/Magento/Framework/Indexer/FilterInterface.php similarity index 84% rename from app/code/Magento/Indexer/Model/FilterInterface.php rename to lib/internal/Magento/Framework/Indexer/FilterInterface.php index b2d5e39abcc36..e7d7cfd98b34b 100644 --- a/app/code/Magento/Indexer/Model/FilterInterface.php +++ b/lib/internal/Magento/Framework/Indexer/FilterInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; interface FilterInterface { diff --git a/lib/internal/Magento/Framework/Indexer/GridStructure.php b/lib/internal/Magento/Framework/Indexer/GridStructure.php new file mode 100644 index 0000000000000..e7116fe3f0ef6 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/GridStructure.php @@ -0,0 +1,136 @@ + ['type' => Table::TYPE_TEXT, 'size' => 255], + 'mediumtext' => ['type' => Table::TYPE_TEXT, 'size' => 16777216], + 'text' => ['type' => Table::TYPE_TEXT, 'size' => 65536], + 'int' => ['type' => Table::TYPE_INTEGER, 'size' => null], + 'date' => ['type' => Table::TYPE_DATE, 'size' => null], + 'datetime' => ['type' => Table::TYPE_DATETIME, 'size' => null], + 'timestamp' => ['type' => Table::TYPE_TIMESTAMP, 'size' => null], + ]; + + /** + * @param Resource|Resource $resource + * @param FlatScopeResolver $flatScopeResolver + * @param array $columnTypesMap + */ + public function __construct( + Resource $resource, + FlatScopeResolver $flatScopeResolver, + array $columnTypesMap = [] + ) { + $this->resource = $resource; + $this->flatScopeResolver = $flatScopeResolver; + $this->columnTypesMap = array_merge($this->columnTypesMap, $columnTypesMap); + } + + /** + * @param string $index + * @param Dimension[] $dimensions + * @return void + */ + public function delete($index, array $dimensions = []) + { + $adapter = $this->getAdapter(); + $tableName = $this->flatScopeResolver->resolve($index, $dimensions); + if ($adapter->isTableExists($tableName)) { + $adapter->dropTable($tableName); + } + } + + /** + * @param string $index + * @param array $fields + * @param Dimension[] $dimensions + * @return void + */ + public function create($index, array $fields, array $dimensions = []) + { + $this->createFlatTable($this->flatScopeResolver->resolve($index, $dimensions), $fields); + } + + /** + * @param string $tableName + * @param array $fields + * @throws \Zend_Db_Exception + * @return void + */ + protected function createFlatTable($tableName, array $fields) + { + $adapter = $this->getAdapter(); + $table = $adapter->newTable($tableName); + $table->addColumn( + 'entity_id', + Table::TYPE_INTEGER, + 10, + ['unsigned' => true, 'nullable' => false, 'primary' => true], + 'Entity ID' + ); + $searchableFields = []; + foreach ($fields as $field) { + if ($field['type'] === 'searchable') { + $searchableFields[] = $field['name']; + } + $columnMap = isset($field['dataType']) && isset($this->columnTypesMap[$field['dataType']]) + ? $this->columnTypesMap[$field['dataType']] + : ['type' => $field['dataType'], 'size' => isset($field['size']) ? $field['size'] : null]; + $name = $field['name']; + $type = $columnMap['type']; + $size = $columnMap['size']; + if ($field['type'] === 'filterable') { + $table->addIndex( + $this->resource->getIdxName($tableName, $name, AdapterInterface::INDEX_TYPE_INDEX), + $name, + AdapterInterface::INDEX_TYPE_INDEX + ); + } + $table->addColumn($name, $type, $size); + } + $adapter->createTable($table); + $adapter->addIndex( + $tableName, + $this->resource->getIdxName( + $tableName, + $searchableFields, + AdapterInterface::INDEX_TYPE_FULLTEXT + ), + $searchableFields, + AdapterInterface::INDEX_TYPE_FULLTEXT + ); + } + + /** + * @return false|AdapterInterface + */ + private function getAdapter() + { + $adapter = $this->resource->getConnection('write'); + return $adapter; + } +} diff --git a/lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler.php b/lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler.php new file mode 100644 index 0000000000000..602c264ad7a1d --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler.php @@ -0,0 +1,37 @@ +joinAttribute( + $fieldInfo['name'], + $fieldInfo['entity'] . '/' . $fieldInfo['origin'], + $fieldInfo['bind'], + null, + 'left' + ); + } else { + $source->addAttributeToSelect($fieldInfo['origin'], 'left'); + } + } +} diff --git a/lib/internal/Magento/Framework/Indexer/Handler/ConcatHandler.php b/lib/internal/Magento/Framework/Indexer/Handler/ConcatHandler.php new file mode 100644 index 0000000000000..18f1db4d7663d --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Handler/ConcatHandler.php @@ -0,0 +1,39 @@ +concatExpression = $concatExpression; + } + + /** + * Prepare SQL for field and add it to collection + * + * @param SourceProviderInterface $source + * @param string $alias + * @param array $fieldInfo + * @return void + */ + public function prepareSql(SourceProviderInterface $source, $alias, $fieldInfo) + { + $source->getSelect()->columns([$fieldInfo['name'] => $this->concatExpression]); + } +} diff --git a/lib/internal/Magento/Framework/Indexer/Handler/DefaultHandler.php b/lib/internal/Magento/Framework/Indexer/Handler/DefaultHandler.php new file mode 100644 index 0000000000000..a053db4bef817 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Handler/DefaultHandler.php @@ -0,0 +1,23 @@ +getSelect()->columns($fieldInfo['origin'] . ' AS ' . $fieldInfo['name'], $alias); + } +} diff --git a/app/code/Magento/Indexer/Model/HandlerInterface.php b/lib/internal/Magento/Framework/Indexer/HandlerInterface.php similarity index 61% rename from app/code/Magento/Indexer/Model/HandlerInterface.php rename to lib/internal/Magento/Framework/Indexer/HandlerInterface.php index 72d2a39c9e434..05a334c788f58 100644 --- a/app/code/Magento/Indexer/Model/HandlerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/HandlerInterface.php @@ -3,23 +3,19 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; use Magento\Framework\App\Resource\SourceProviderInterface; interface HandlerInterface { /** + * Prepare SQL for field and add it to collection + * * @param SourceProviderInterface $source + * @param string $alias * @param array $fieldInfo * @return void */ - public function prepareSql(SourceProviderInterface $source, $fieldInfo); - - /** - * @param SourceProviderInterface $source - * @param array $fieldInfo - * @return void - */ - public function prepareData(SourceProviderInterface $source, $fieldInfo); + public function prepareSql(SourceProviderInterface $source, $alias, $fieldInfo); } diff --git a/app/code/Magento/Indexer/Model/HandlerPool.php b/lib/internal/Magento/Framework/Indexer/HandlerPool.php similarity index 80% rename from app/code/Magento/Indexer/Model/HandlerPool.php rename to lib/internal/Magento/Framework/Indexer/HandlerPool.php index f26301c87df50..97cd9787d8fe1 100644 --- a/app/code/Magento/Indexer/Model/HandlerPool.php +++ b/lib/internal/Magento/Framework/Indexer/HandlerPool.php @@ -3,8 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; +use Magento\Framework\Indexer\Handler\DefaultHandler; use Magento\Framework\ObjectManagerInterface; class HandlerPool @@ -21,11 +22,11 @@ class HandlerPool /** * @param ObjectManagerInterface $objectManager - * @param HandlerInterface $defaultHandler + * @param DefaultHandler $defaultHandler */ public function __construct( ObjectManagerInterface $objectManager, - HandlerInterface $defaultHandler + DefaultHandler $defaultHandler ) { $this->defaultHandler = $defaultHandler; $this->objectManager = $objectManager; @@ -47,7 +48,7 @@ public function get($handlerClass = null) $handler = $this->objectManager->get($handlerClass); if (!$handler instanceof HandlerInterface) { throw new \InvalidArgumentException( - $handlerClass . ' doesn\'t implement \Magento\Indexer\Model\HandlerInterface' + $handlerClass . ' doesn\'t implement \Magento\Framework\Indexer\HandlerInterface' ); } diff --git a/app/code/Magento/Indexer/Model/IndexStructure.php b/lib/internal/Magento/Framework/Indexer/IndexStructure.php similarity index 89% rename from app/code/Magento/Indexer/Model/IndexStructure.php rename to lib/internal/Magento/Framework/Indexer/IndexStructure.php index ca65108f330f1..f07090e5e821a 100644 --- a/app/code/Magento/Indexer/Model/IndexStructure.php +++ b/lib/internal/Magento/Framework/Indexer/IndexStructure.php @@ -4,24 +4,23 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; - +namespace Magento\Framework\Indexer; use Magento\Framework\App\Resource; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\Search\Request\Dimension; -use Magento\Indexer\Model\ScopeResolver\FlatScopeResolver; -use Magento\Indexer\Model\ScopeResolver\IndexScopeResolver; +use Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver; +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; -class IndexStructure +class IndexStructure implements IndexStructureInterface { /** * @var Resource */ private $resource; /** - * @var \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver + * @var \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver */ private $indexScopeResolver; /** @@ -41,7 +40,7 @@ class IndexStructure /** * @param Resource|Resource $resource * @param IndexScopeResolver $indexScopeResolver - * @param \Magento\Indexer\Model\ScopeResolver\FlatScopeResolver $flatScopeResolver + * @param \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver $flatScopeResolver * @param array $columnTypesMap */ public function __construct( @@ -69,15 +68,15 @@ public function delete($index, array $dimensions = []) /** * @param string $index - * @param array $filterFields + * @param array $fields * @param Dimension[] $dimensions * @return void */ - public function create($index, array $filterFields, array $dimensions = []) + public function create($index, array $fields, array $dimensions = []) { $this->createFulltextIndex($this->indexScopeResolver->resolve($index, $dimensions)); - if ($filterFields) { - $this->createFlatIndex($this->flatScopeResolver->resolve($index, $dimensions), $filterFields); + if ($fields) { + $this->createFlatIndex($this->flatScopeResolver->resolve($index, $dimensions), $fields); } } diff --git a/lib/internal/Magento/Framework/Indexer/IndexStructureInterface.php b/lib/internal/Magento/Framework/Indexer/IndexStructureInterface.php new file mode 100644 index 0000000000000..0afff912eba27 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/IndexStructureInterface.php @@ -0,0 +1,26 @@ +indexers[$indexerId])) { - $this->indexers[$indexerId] = $this->objectManager->create('Magento\Indexer\Model\IndexerInterface') + $this->indexers[$indexerId] = $this->objectManager->create('Magento\Framework\Indexer\IndexerInterface') ->load($indexerId); } return $this->indexers[$indexerId]; diff --git a/lib/internal/Magento/Framework/Indexer/README.md b/lib/internal/Magento/Framework/Indexer/README.md new file mode 100644 index 0000000000000..aa392d2facdbf --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/README.md @@ -0,0 +1 @@ +A library for indexing processing diff --git a/app/code/Magento/Indexer/Model/SaveHandler/Batch.php b/lib/internal/Magento/Framework/Indexer/SaveHandler/Batch.php similarity index 93% rename from app/code/Magento/Indexer/Model/SaveHandler/Batch.php rename to lib/internal/Magento/Framework/Indexer/SaveHandler/Batch.php index 68c3d20bda20c..5f432356d3d1b 100644 --- a/app/code/Magento/Indexer/Model/SaveHandler/Batch.php +++ b/lib/internal/Magento/Framework/Indexer/SaveHandler/Batch.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\SaveHandler; +namespace Magento\Framework\Indexer\SaveHandler; class Batch { diff --git a/lib/internal/Magento/Framework/Indexer/SaveHandler/Grid.php b/lib/internal/Magento/Framework/Indexer/SaveHandler/Grid.php new file mode 100644 index 0000000000000..2f7136cb812ab --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/SaveHandler/Grid.php @@ -0,0 +1,79 @@ +batch->getItems($documents, $this->batchSize) as $batchDocuments) { + $this->insertDocumentsForFilterable($batchDocuments, $dimensions); + } + } + + /** + * @param array $documents + * @param Dimension[] $dimensions + * @return void + */ + protected function insertDocumentsForFilterable(array $documents, array $dimensions) + { + $onDuplicate = []; + foreach ($this->fields as $field) { + if (in_array($field['type'], $this->dataTypes)) { + $onDuplicate[] = $field['name']; + } + } + + $this->connection->insertOnDuplicate( + $this->getTableName($this->dataTypes[1], $dimensions), + $this->prepareFilterableFields($documents), + $onDuplicate + ); + } + + /** + * @param array $documents + * @return array + */ + protected function prepareFilterableFields(array $documents) + { + $insertDocuments = []; + foreach ($documents as $entityId => $document) { + $documentFlat = ['entity_id' => $entityId]; + foreach ($this->fields as $field) { + if (in_array($field['type'], $this->dataTypes)) { + $documentFlat[$field['name']] = $document[$field['name']]; + } + } + $insertDocuments[] = $documentFlat; + } + return $insertDocuments; + } + + /** + * {@inheritdoc} + */ + public function deleteIndex($dimensions, \Traversable $ids) + { + foreach ($this->batch->getItems($ids, $this->batchSize) as $batchIds) { + $this->connection->delete( + $this->getTableName('filterable', $dimensions), + ['entity_id IN(?)' => $batchIds] + ); + } + } +} diff --git a/app/code/Magento/Indexer/Model/SaveHandler/IndexerHandler.php b/lib/internal/Magento/Framework/Indexer/SaveHandler/IndexerHandler.php similarity index 80% rename from app/code/Magento/Indexer/Model/SaveHandler/IndexerHandler.php rename to lib/internal/Magento/Framework/Indexer/SaveHandler/IndexerHandler.php index 235a9548fbf2a..cabda6c830c61 100644 --- a/app/code/Magento/Indexer/Model/SaveHandler/IndexerHandler.php +++ b/lib/internal/Magento/Framework/Indexer/SaveHandler/IndexerHandler.php @@ -3,75 +3,76 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\SaveHandler; +namespace Magento\Framework\Indexer\SaveHandler; use Magento\Framework\App\Resource; use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\IndexerInterface; -use Magento\Indexer\Model\IndexStructure; use Magento\Framework\Search\Request\Dimension; use Magento\Framework\Search\Request\IndexScopeResolverInterface; -use Magento\Indexer\Model\ScopeResolver\FlatScopeResolver; -use Magento\Indexer\Model\ScopeResolver\IndexScopeResolver; +use Magento\Framework\Indexer\IndexStructureInterface; +use Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver; +use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; +use Magento\Framework\Indexer\SaveHandler\Batch; class IndexerHandler implements IndexerInterface { /** * @var string[] */ - private $dataTypes = ['searchable', 'filterable']; + protected $dataTypes = ['searchable', 'filterable']; /** - * @var IndexStructure + * @var IndexStructureInterface */ - private $indexStructure; + protected $indexStructure; /** * @var array */ - private $data; + protected $data; /** * @var array */ - private $fields; + protected $fields; /** * @var Resource|Resource */ - private $resource; + protected $resource; /** * @var Batch */ - private $batch; + protected $batch; /** * @var int */ - private $batchSize; + protected $batchSize; /** * @var IndexScopeResolverInterface[] */ - private $scopeResolvers; + protected $scopeResolvers; /** + * @param IndexStructureInterface $indexStructure * @var AdapterInterface */ - private $connection; + protected $connection; /** - * @param IndexStructure $indexStructure + * @param IndexStructureInterface $indexStructure * @param Resource $resource * @param Batch $batch - * @param \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver $indexScopeResolver - * @param \Magento\Indexer\Model\ScopeResolver\FlatScopeResolver $flatScopeResolver + * @param \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver $indexScopeResolver + * @param \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver $flatScopeResolver * @param array $data * @param int $batchSize */ public function __construct( - IndexStructure $indexStructure, + IndexStructureInterface $indexStructure, Resource $resource, Batch $batch, IndexScopeResolver $indexScopeResolver, @@ -138,7 +139,7 @@ public function isAvailable() * @param Dimension[] $dimensions * @return string */ - private function getTableName($dataType, $dimensions) + protected function getTableName($dataType, $dimensions) { return $this->scopeResolvers[$dataType]->resolve($this->getIndexName(), $dimensions); } @@ -146,7 +147,7 @@ private function getTableName($dataType, $dimensions) /** * @return string */ - private function getIndexName() + protected function getIndexName() { return $this->data['indexer_id']; } @@ -170,7 +171,7 @@ private function insertDocumentsForSearchable(array $documents, array $dimension * @param Dimension[] $dimensions * @return void */ - private function insertDocumentsForFilterable(array $documents, array $dimensions) + protected function insertDocumentsForFilterable(array $documents, array $dimensions) { $onDuplicate = []; foreach ($this->fields as $field) { @@ -190,7 +191,7 @@ private function insertDocumentsForFilterable(array $documents, array $dimension * @param array $documents * @return array */ - private function prepareFilterableFields(array $documents) + protected function prepareFilterableFields(array $documents) { $insertDocuments = []; foreach ($documents as $entityId => $document) { @@ -233,7 +234,7 @@ private function prepareSearchableFields(array $documents) private function prepareFields() { foreach ($this->data['fieldsets'] as $fieldset) { - $this->fields = array_merge($this->fields, $fieldset['fields']); + $this->fields = array_merge($this->fields, array_values($fieldset['fields'])); } } } diff --git a/lib/internal/Magento/Framework/IndexerInterface.php b/lib/internal/Magento/Framework/Indexer/SaveHandler/IndexerInterface.php similarity index 95% rename from lib/internal/Magento/Framework/IndexerInterface.php rename to lib/internal/Magento/Framework/Indexer/SaveHandler/IndexerInterface.php index b321e7693feaf..457ce3374d9ed 100644 --- a/lib/internal/Magento/Framework/IndexerInterface.php +++ b/lib/internal/Magento/Framework/Indexer/SaveHandler/IndexerInterface.php @@ -7,7 +7,7 @@ /** * Index Engine Interface */ -namespace Magento\Framework; +namespace Magento\Framework\Indexer\SaveHandler; use Magento\Framework\Search\Request\Dimension; diff --git a/app/code/Magento/Indexer/Model/SaveHandlerFactory.php b/lib/internal/Magento/Framework/Indexer/SaveHandlerFactory.php similarity index 86% rename from app/code/Magento/Indexer/Model/SaveHandlerFactory.php rename to lib/internal/Magento/Framework/Indexer/SaveHandlerFactory.php index e9a215eb86880..c8e490a87fa63 100644 --- a/app/code/Magento/Indexer/Model/SaveHandlerFactory.php +++ b/lib/internal/Magento/Framework/Indexer/SaveHandlerFactory.php @@ -3,10 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model; +namespace Magento\Framework\Indexer; +use Magento\Framework\Indexer\IndexerInterface; use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\IndexerInterface as SaveHandlerInterface; +use Magento\Framework\Indexer\SaveHandler\IndexerInterface as SaveHandlerInterface; class SaveHandlerFactory { diff --git a/app/code/Magento/Indexer/Model/ScopeResolver/FlatScopeResolver.php b/lib/internal/Magento/Framework/Indexer/ScopeResolver/FlatScopeResolver.php similarity index 89% rename from app/code/Magento/Indexer/Model/ScopeResolver/FlatScopeResolver.php rename to lib/internal/Magento/Framework/Indexer/ScopeResolver/FlatScopeResolver.php index 8e415be17131e..dfa7fd69d498e 100644 --- a/app/code/Magento/Indexer/Model/ScopeResolver/FlatScopeResolver.php +++ b/lib/internal/Magento/Framework/Indexer/ScopeResolver/FlatScopeResolver.php @@ -4,11 +4,10 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\ScopeResolver; +namespace Magento\Framework\Indexer\ScopeResolver; use Magento\Framework\Search\Request\Dimension; use Magento\Framework\Search\Request\IndexScopeResolverInterface; -use Magento\Indexer\Model\ScopeResolver\IndexScopeResolver; class FlatScopeResolver implements IndexScopeResolverInterface { diff --git a/app/code/Magento/Indexer/Model/ScopeResolver/IndexScopeResolver.php b/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php similarity index 97% rename from app/code/Magento/Indexer/Model/ScopeResolver/IndexScopeResolver.php rename to lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php index 696d6af0041b2..a5f1a4657670b 100644 --- a/app/code/Magento/Indexer/Model/ScopeResolver/IndexScopeResolver.php +++ b/lib/internal/Magento/Framework/Indexer/ScopeResolver/IndexScopeResolver.php @@ -4,8 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\ScopeResolver; - +namespace Magento\Framework\Indexer\ScopeResolver; use Magento\Framework\App\Resource; use Magento\Framework\App\ScopeResolverInterface; diff --git a/lib/internal/Magento/Framework/Indexer/StateInterface.php b/lib/internal/Magento/Framework/Indexer/StateInterface.php new file mode 100644 index 0000000000000..cb755ed978188 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/StateInterface.php @@ -0,0 +1,69 @@ +objectManager = $objectManager; + } + + /** + * Get structure class instance by class name + * + * @param string $className + * @param [] $arguments + * @throws \InvalidArgumentException + * @return IndexStructureInterface + */ + public function create($className, $arguments = []) + { + $structure = $this->objectManager->create($className, $arguments); + if (!$structure instanceof IndexStructureInterface) { + throw new \InvalidArgumentException( + $className . ' doesn\'t implement \Magento\Framework\Indexer\IndexStructureInterface' + ); + } + + return $structure; + } +} diff --git a/app/code/Magento/Indexer/Model/Indexer/Table/Strategy.php b/lib/internal/Magento/Framework/Indexer/Table/Strategy.php similarity index 96% rename from app/code/Magento/Indexer/Model/Indexer/Table/Strategy.php rename to lib/internal/Magento/Framework/Indexer/Table/Strategy.php index 2d6c154a2a707..6abcfb1c6afdc 100644 --- a/app/code/Magento/Indexer/Model/Indexer/Table/Strategy.php +++ b/lib/internal/Magento/Framework/Indexer/Table/Strategy.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\Indexer\Table; +namespace Magento\Framework\Indexer\Table; /** * Class Strategy diff --git a/app/code/Magento/Indexer/Model/Indexer/Table/StrategyInterface.php b/lib/internal/Magento/Framework/Indexer/Table/StrategyInterface.php similarity index 95% rename from app/code/Magento/Indexer/Model/Indexer/Table/StrategyInterface.php rename to lib/internal/Magento/Framework/Indexer/Table/StrategyInterface.php index c1693ceb44cd4..842a811034b65 100644 --- a/app/code/Magento/Indexer/Model/Indexer/Table/StrategyInterface.php +++ b/lib/internal/Magento/Framework/Indexer/Table/StrategyInterface.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Model\Indexer\Table; +namespace Magento\Framework\Indexer\Table; /** * Interface StrategyInterface diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ActionFactoryTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php similarity index 69% rename from app/code/Magento/Indexer/Test/Unit/Model/ActionFactoryTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php index 0aa4997661a3c..d8dd5d817a0f1 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ActionFactoryTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/ActionFactoryTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model; +namespace Magento\Framework\Indexer\Test\Unit; class ActionFactoryTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\ActionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ActionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $model; @@ -20,12 +20,12 @@ class ActionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); - $this->model = new \Magento\Indexer\Model\ActionFactory($this->objectManagerMock); + $this->model = new \Magento\Framework\Indexer\ActionFactory($this->objectManagerMock); } /** * @expectedException \InvalidArgumentException - * @expectedExceptionMessage NotAction doesn't implement \Magento\Indexer\Model\ActionInterface + * @expectedExceptionMessage NotAction doesn't implement \Magento\Framework\Indexer\ActionInterface */ public function testGetWithException() { @@ -40,16 +40,16 @@ public function testGetWithException() public function testCreate() { $actionInterfaceMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\ActionInterface', + 'Magento\Framework\Indexer\ActionInterface', [], '', false ); $this->objectManagerMock->expects($this->once()) ->method('create') - ->with('Magento\Indexer\Model\ActionInterface', []) + ->with('Magento\Framework\Indexer\ActionInterface', []) ->willReturn($actionInterfaceMock); - $this->model->create('Magento\Indexer\Model\ActionInterface'); - $this->assertInstanceOf('Magento\Indexer\Model\ActionInterface', $actionInterfaceMock); + $this->model->create('Magento\Framework\Indexer\ActionInterface'); + $this->assertInstanceOf('Magento\Framework\Indexer\ActionInterface', $actionInterfaceMock); } } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ConverterTest.php similarity index 60% rename from app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ConverterTest.php index 3be90c1459b5a..ac0061f255798 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ConverterTest.php @@ -3,23 +3,23 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model\Config; +namespace Magento\Framework\Indexer\Test\Unit\Config; class ConverterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\Config\Converter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\Config\Converter|\PHPUnit_Framework_MockObject_MockObject */ protected $_model; protected function setUp() { - $this->_model = new \Magento\Indexer\Model\Config\Converter(); + $this->_model = new \Magento\Framework\Indexer\Config\Converter(); } public function testConvert() { - $data = include __DIR__ . '/../../_files/indexer_config.php'; + $data = include __DIR__ . '/../_files/indexer_config.php'; $dom = new \DOMDocument(); $dom->loadXML($data['inputXML']); diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/ReaderTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php similarity index 69% rename from app/code/Magento/Indexer/Test/Unit/Model/Config/ReaderTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php index 15125405ac002..266ddc2ae61ce 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php @@ -3,17 +3,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model\Config; +namespace Magento\Framework\Indexer\Test\Unit\Config; class ReaderTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\Config\Reader + * @var \Magento\Framework\Indexer\Config\Reader */ protected $_model; /** - * @var \Magento\Indexer\Model\Config\Converter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\Config\Converter|\PHPUnit_Framework_MockObject_MockObject */ protected $_converter; @@ -32,34 +32,14 @@ protected function setUp() false ); - $this->_converter = $this->getMock('Magento\Indexer\Model\Config\Converter', ['convert']); - - $moduleReader = $this->getMock( - 'Magento\Framework\Module\Dir\Reader', - ['getModuleDir'], - [], - '', - false - ); - $moduleReader->expects( - $this->once() - )->method( - 'getModuleDir' - )->with( - 'etc', - 'Magento_Indexer' - )->will( - $this->returnValue('stub') - ); - $schemaLocator = new \Magento\Indexer\Model\Config\SchemaLocator($moduleReader); - + $this->_converter = $this->getMock('Magento\Framework\Indexer\Config\Converter', ['convert']); $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); - $this->_model = new \Magento\Indexer\Model\Config\Reader( + $this->_model = new \Magento\Framework\Indexer\Config\Reader( $this->_fileResolverMock, $this->_converter, - $schemaLocator, + new \Magento\Framework\Indexer\Config\SchemaLocator(), $validationState ); } @@ -82,7 +62,7 @@ public function testReadValidConfig($files, $expectedFile) $constraint = function (\DOMDocument $actual) use ($expectedFile) { try { - $expected = file_get_contents(__DIR__ . '/../../_files/' . $expectedFile); + $expected = file_get_contents(__DIR__ . '/../_files/' . $expectedFile); \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML()); return true; } catch (\PHPUnit_Framework_AssertionFailedError $e) { @@ -111,15 +91,15 @@ public function readerDataProvider() return [ [ [ - 'indexer_one.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_one.xml'), - 'indexer_two.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_two.xml'), + 'indexer_one.xml' => file_get_contents(__DIR__ . '/../_files/indexer_one.xml'), + 'indexer_two.xml' => file_get_contents(__DIR__ . '/../_files/indexer_two.xml'), ], 'indexer_merged_one.xml', ], [ [ - 'indexer_one.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_one.xml'), - 'indexer_three.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_three.xml'), + 'indexer_one.xml' => file_get_contents(__DIR__ . '/../_files/indexer_one.xml'), + 'indexer_three.xml' => file_get_contents(__DIR__ . '/../_files/indexer_three.xml'), ], 'indexer_merged_two.xml' ] diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php new file mode 100644 index 0000000000000..bf1ea53a8e9e4 --- /dev/null +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/GridStructureTest.php @@ -0,0 +1,118 @@ +connection = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->getMock(); + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->getMock(); + $this->flatScopeResolver = $this->getMockBuilder('Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver') + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->any()) + ->method('getConnection') + ->with('write') + ->willReturn($this->connection); + $this->object = new GridStructure( + $this->resource, + $this->flatScopeResolver + ); + } + + public function testDelete() + { + $index = 'index'; + $table = 'index_table'; + + $this->flatScopeResolver->expects($this->once()) + ->method('resolve') + ->with($index, []) + ->willReturn($table); + $this->connection->expects($this->once()) + ->method('isTableExists') + ->with($table) + ->willReturn(true); + $this->connection->expects($this->once()) + ->method('dropTable') + ->with($table); + + $this->object->delete($index); + } + + public function testCreate() + { + $index = 'index'; + $fields = [ + [ + 'type' => 'searchable', + 'name' => 'field', + 'dataType' => 'int' + ] + ]; + $tableName = 'index_table'; + $idxName = 'idxName'; + + $table = $this->getMockBuilder('Magento\Framework\DB\Ddl\Table') + ->disableOriginalConstructor() + ->getMock(); + $this->flatScopeResolver->expects($this->once()) + ->method('resolve') + ->with($index, []) + ->willReturn($tableName); + $this->connection->expects($this->once()) + ->method('newTable') + ->with($tableName) + ->willReturn($table); + $table->expects($this->any()) + ->method('addColumn') + ->willReturnMap( + [ + ['entity_id', Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false], 'Entity ID'], + ['field', Table::TYPE_INTEGER, null] + ] + ); + $this->connection->expects($this->once()) + ->method('createTable') + ->with($table); + $this->resource->expects($this->once()) + ->method('getIdxName') + ->with($tableName, ['field'], AdapterInterface::INDEX_TYPE_FULLTEXT) + ->willReturn($idxName); + $this->connection->expects($this->once()) + ->method('addIndex') + ->with($tableName, $idxName, ['field'], AdapterInterface::INDEX_TYPE_FULLTEXT); + $this->object->create($index, $fields); + } +} diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexStructureTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php similarity index 94% rename from app/code/Magento/Indexer/Test/Unit/Model/IndexStructureTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php index f29bee9349055..2325db5c326f2 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexStructureTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexStructureTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model; +namespace Magento\Framework\Indexer\Test\Unit; use Magento\Framework\App\Resource; use Magento\Framework\DB\Adapter\AdapterInterface; @@ -12,17 +12,17 @@ use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** - * Test for \Magento\Indexer\Model\IndexStructure + * Test for \Magento\Framework\Indexer\IndexStructure */ class IndexStructureTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject */ private $indexScopeResolver; /** - * @var \Magento\Indexer\Model\ScopeResolver\FlatScopeResolver|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver|\PHPUnit_Framework_MockObject_MockObject */ private $flatScopeResolver; @@ -37,7 +37,7 @@ class IndexStructureTest extends \PHPUnit_Framework_TestCase private $connectionInterface; /** - * @var \Magento\Indexer\Model\IndexStructure + * @var \Magento\Framework\Indexer\IndexStructure */ private $target; @@ -53,11 +53,11 @@ protected function setUp() $this->resource->expects($this->atLeastOnce()) ->method('getConnection') ->willReturn($this->connectionInterface); - $this->indexScopeResolver = $this->getMockBuilder('\Magento\Indexer\Model\ScopeResolver\IndexScopeResolver') + $this->indexScopeResolver = $this->getMockBuilder('\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver') ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMock(); - $this->flatScopeResolver = $this->getMockBuilder('\Magento\Indexer\Model\ScopeResolver\FlatScopeResolver') + $this->flatScopeResolver = $this->getMockBuilder('\Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver') ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMock(); @@ -65,7 +65,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->target = $objectManager->getObject( - '\Magento\Indexer\Model\IndexStructure', + '\Magento\Framework\Indexer\IndexStructure', [ 'resource' => $this->resource, 'indexScopeResolver' => $this->indexScopeResolver, diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerRegistryTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php similarity index 76% rename from app/code/Magento/Indexer/Test/Unit/Model/IndexerRegistryTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php index 5d2c8c278b75a..f9794eae4b467 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerRegistryTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/IndexerRegistryTest.php @@ -3,23 +3,23 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model; +namespace Magento\Framework\Indexer\Test\Unit; class IndexerRegistryTest extends \PHPUnit_Framework_TestCase { public function testGetCreatesIndexerInstancesAndReusesExistingOnes() { - $firstIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); + $firstIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); $firstIndexer->expects($this->once())->method('load')->with('first-indexer')->willReturnSelf(); - $secondIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); + $secondIndexer = $this->getMock('Magento\Framework\Indexer\IndexerInterface'); $secondIndexer->expects($this->once())->method('load')->with('second-indexer')->willReturnSelf(); $objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); $objectManager->expects($this->at(0))->method('create')->willReturn($firstIndexer); $objectManager->expects($this->at(1))->method('create')->willReturn($secondIndexer); - $unit = new \Magento\Indexer\Model\IndexerRegistry($objectManager); + $unit = new \Magento\Framework\Indexer\IndexerRegistry($objectManager); $this->assertSame($firstIndexer, $unit->get('first-indexer')); $this->assertSame($secondIndexer, $unit->get('second-indexer')); $this->assertSame($firstIndexer, $unit->get('first-indexer')); diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ScopeResolver/IndexScopeResolverTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php similarity index 93% rename from app/code/Magento/Indexer/Test/Unit/Model/ScopeResolver/IndexScopeResolverTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php index a64005d658eba..b34a4e1bd47f7 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ScopeResolver/IndexScopeResolverTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/ScopeResolver/IndexScopeResolverTest.php @@ -4,13 +4,13 @@ * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model\ScopeResolver; +namespace Magento\Framework\Indexer\Test\Unit\ScopeResolver; use Magento\Framework\Search\Request\Dimension; use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** - * Test for \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver + * Test for \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver */ class IndexScopeResolverTest extends \PHPUnit_Framework_TestCase { @@ -25,7 +25,7 @@ class IndexScopeResolverTest extends \PHPUnit_Framework_TestCase private $resource; /** - * @var \Magento\Indexer\Model\ScopeResolver\IndexScopeResolver + * @var \Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver */ private $target; @@ -45,7 +45,7 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->target = $objectManager->getObject( - '\Magento\Indexer\Model\ScopeResolver\IndexScopeResolver', + '\Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver', [ 'resource' => $this->resource, 'scopeResolver' => $this->scopeResolver diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php similarity index 92% rename from app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php index 6aed194580dc6..fd4f9a1da1300 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit\Model\Indexer\Table; +namespace Magento\Framework\Indexer\Test\Unit; /** * Class StrategyTest @@ -14,7 +14,7 @@ class StrategyTest extends \PHPUnit_Framework_TestCase /** * Strategy object * - * @var \Magento\Indexer\Model\Indexer\Table\Strategy + * @var \Magento\Framework\Indexer\Table\Strategy */ protected $_model; @@ -37,7 +37,7 @@ protected function setUp() '', false ); - $this->_model = new \Magento\Indexer\Model\Indexer\Table\Strategy( + $this->_model = new \Magento\Framework\Indexer\Table\Strategy( $this->_resourceMock ); } diff --git a/app/code/Magento/Indexer/Test/Unit/XsdTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/XsdTest.php similarity index 86% rename from app/code/Magento/Indexer/Test/Unit/XsdTest.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/XsdTest.php index a72ab7f201444..8f94183c530f7 100644 --- a/app/code/Magento/Indexer/Test/Unit/XsdTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/XsdTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Indexer\Test\Unit; +namespace Magento\Framework\Indexer\Test\Unit; class XsdTest extends \PHPUnit_Framework_TestCase { @@ -20,7 +20,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_xsdSchema = BP . '/app/code/Magento/Indexer/etc/indexer.xsd'; + $this->_xsdSchema = BP . '/lib/internal/Magento/Framework/Indexer/etc/indexer.xsd'; $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator(); } @@ -32,7 +32,7 @@ protected function setUp() public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError) { $actualError = $this->_xsdValidator->validate( - BP . '/app/code/Magento/Indexer/etc/indexer_merged.xsd', + BP . '/lib/internal/Magento/Framework/Indexer/etc/indexer_merged.xsd', $xmlString ); $this->assertEquals($expectedError, $actualError); diff --git a/app/code/Magento/Indexer/Test/Unit/_files/indexer_config.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_config.php similarity index 100% rename from app/code/Magento/Indexer/Test/Unit/_files/indexer_config.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_config.php diff --git a/app/code/Magento/Indexer/Test/Unit/_files/indexer_merged_one.xml b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_merged_one.xml similarity index 91% rename from app/code/Magento/Indexer/Test/Unit/_files/indexer_merged_one.xml rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_merged_one.xml index cd39a7d6866c2..d886f7bfb04f9 100644 --- a/app/code/Magento/Indexer/Test/Unit/_files/indexer_merged_one.xml +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_merged_one.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Indexer public name one Indexer public description one diff --git a/app/code/Magento/Indexer/Test/Unit/_files/indexer_merged_two.xml b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_merged_two.xml similarity index 88% rename from app/code/Magento/Indexer/Test/Unit/_files/indexer_merged_two.xml rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_merged_two.xml index a5061cce1c00f..546d8a46627c3 100644 --- a/app/code/Magento/Indexer/Test/Unit/_files/indexer_merged_two.xml +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_merged_two.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Indexer public name two Indexer public description two diff --git a/app/code/Magento/Indexer/Test/Unit/_files/indexer_one.xml b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_one.xml similarity index 83% rename from app/code/Magento/Indexer/Test/Unit/_files/indexer_one.xml rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_one.xml index 734fe4b11352d..eff97c9480a84 100644 --- a/app/code/Magento/Indexer/Test/Unit/_files/indexer_one.xml +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_one.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Indexer public name one Indexer public description one diff --git a/app/code/Magento/Indexer/Test/Unit/_files/indexer_three.xml b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_three.xml similarity index 88% rename from app/code/Magento/Indexer/Test/Unit/_files/indexer_three.xml rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_three.xml index a5061cce1c00f..546d8a46627c3 100644 --- a/app/code/Magento/Indexer/Test/Unit/_files/indexer_three.xml +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_three.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Indexer public name two Indexer public description two diff --git a/app/code/Magento/Indexer/Test/Unit/_files/indexer_two.xml b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_two.xml similarity index 88% rename from app/code/Magento/Indexer/Test/Unit/_files/indexer_two.xml rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_two.xml index 879b5bc8d0d11..80e8743d1a23e 100644 --- a/app/code/Magento/Indexer/Test/Unit/_files/indexer_two.xml +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/indexer_two.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Indexer public name two Indexer public description two diff --git a/app/code/Magento/Indexer/Test/Unit/_files/invalidIndexerXmlArray.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/invalidIndexerXmlArray.php similarity index 100% rename from app/code/Magento/Indexer/Test/Unit/_files/invalidIndexerXmlArray.php rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/invalidIndexerXmlArray.php diff --git a/app/code/Magento/Indexer/Test/Unit/_files/valid_indexer.xml b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/valid_indexer.xml similarity index 88% rename from app/code/Magento/Indexer/Test/Unit/_files/valid_indexer.xml rename to lib/internal/Magento/Framework/Indexer/Test/Unit/_files/valid_indexer.xml index 135e59783b6a0..904ba16ef833f 100644 --- a/app/code/Magento/Indexer/Test/Unit/_files/valid_indexer.xml +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/_files/valid_indexer.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + Indexer public name Indexer public description diff --git a/app/code/Magento/Indexer/etc/indexer.xsd b/lib/internal/Magento/Framework/Indexer/etc/indexer.xsd similarity index 92% rename from app/code/Magento/Indexer/etc/indexer.xsd rename to lib/internal/Magento/Framework/Indexer/etc/indexer.xsd index 05dcaca0008a3..fa6e0f7afd4eb 100644 --- a/app/code/Magento/Indexer/etc/indexer.xsd +++ b/lib/internal/Magento/Framework/Indexer/etc/indexer.xsd @@ -27,7 +27,17 @@ - + + + + + Field name must be unique in one fieldset. + + + + + + @@ -187,6 +197,9 @@ + + + @@ -239,14 +252,5 @@ - - - - Field name must be unique in one fieldset. - - - - - diff --git a/app/code/Magento/Indexer/etc/indexer_merged.xsd b/lib/internal/Magento/Framework/Indexer/etc/indexer_merged.xsd similarity index 97% rename from app/code/Magento/Indexer/etc/indexer_merged.xsd rename to lib/internal/Magento/Framework/Indexer/etc/indexer_merged.xsd index 385a07c884cda..fb60fd6d096e2 100644 --- a/app/code/Magento/Indexer/etc/indexer_merged.xsd +++ b/lib/internal/Magento/Framework/Indexer/etc/indexer_merged.xsd @@ -122,9 +122,9 @@ Fieldset of field declaration. - + - + @@ -187,6 +187,9 @@ + + + diff --git a/lib/internal/Magento/Framework/Mview/etc/mview.xsd b/lib/internal/Magento/Framework/Mview/etc/mview.xsd index e96024d92f2b7..320a57a0af46e 100644 --- a/lib/internal/Magento/Framework/Mview/etc/mview.xsd +++ b/lib/internal/Magento/Framework/Mview/etc/mview.xsd @@ -30,7 +30,7 @@ - + diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php index 847206787efe4..c05969298ef80 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php @@ -15,7 +15,6 @@ */ class FulltextFilter implements FilterApplierInterface { - /** * Returns list of columns from fulltext index (doesn't support more then one FTI per table) * diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php index 9fa1308c4acbb..48f6384aa2117 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php @@ -93,6 +93,7 @@ public function getSearchCriteria() /** * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php index 2c1888d848eab..f7267a3cb002a 100755 --- a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php @@ -144,7 +144,7 @@ public function create($identifier, $name = null, array $arguments = []) $identifier, $bundleComponents[$identifier] ); - $componentArguments = array_merge($componentArguments, $arguments); + $componentArguments = array_replace_recursive($componentArguments, $arguments); if (!isset($componentArguments['context'])) { $componentArguments['context'] = $this->contextFactory->create([ 'namespace' => $identifier @@ -164,7 +164,10 @@ public function create($identifier, $name = null, array $arguments = []) $componentArguments['components'] = $components; /** @var \Magento\Framework\View\Element\UiComponentInterface $component */ - $component = $this->objectManager->create($className, array_merge($componentArguments, $arguments)); + $component = $this->objectManager->create( + $className, + array_replace_recursive($componentArguments, $arguments) + ); return $component; } else { diff --git a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php index e61ca8a3c7df0..83efcb06b178d 100644 --- a/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php +++ b/setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php @@ -84,8 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output) /** @var $config \Magento\Indexer\Model\Config */ $config = $fixtureModel->getObjectManager()->get('Magento\Indexer\Model\Config'); $indexerListIds = $config->getIndexers(); - /** @var $indexerRegistry \Magento\Indexer\Model\IndexerRegistry */ - $indexerRegistry = $fixtureModel->getObjectManager()->create('Magento\Indexer\Model\IndexerRegistry'); + /** @var $indexerRegistry \Magento\Framework\Indexer\IndexerRegistry */ + $indexerRegistry = $fixtureModel->getObjectManager()->create('Magento\Framework\Indexer\IndexerRegistry'); $indexersState = []; foreach ($indexerListIds as $indexerId) { $indexer = $indexerRegistry->get($indexerId['indexer_id']); diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/Type.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/Type.php index a2ea1d3bf1df1..f4dfb16ad65da 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Reader/Type.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/Type.php @@ -17,7 +17,11 @@ class Type */ public function isConcrete($type) { - $instance = new \ReflectionClass($type); + try { + $instance = new \ReflectionClass($type); + } catch (\ReflectionException $e) { + return false; + } return !$instance->isAbstract() && !$instance->isInterface(); } }