Example #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->setCollectionFactory = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->attrCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create', 'addFieldToFilter'], [], '', false);
     $this->attrCollectionFactory->expects($this->any())->method('create')->will($this->returnSelf());
     $this->attrCollectionFactory->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getErrorAggregator', 'getNewSku', 'getOldSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope'], [], '', false);
     $this->entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->params = [0 => $this->entityModel, 1 => 'grouped'];
     $this->links = $this->getMock('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped\\Links', [], [], '', false);
     $entityAttributes = [['attribute_set_name' => 'attribute_id', 'attribute_id' => 'attributeSetName']];
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', ['from', 'where', 'joinLeft', 'getConnection'], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $connectionMock->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getConnection')->willReturn($connectionMock);
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->connection->expects($this->any())->method('fetchAll')->will($this->returnValue($entityAttributes));
     $this->resource = $this->getMock('\\Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->grouped = $this->objectManagerHelper->getObject('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped', ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'resource' => $this->resource, 'params' => $this->params, 'links' => $this->links]);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getErrorAggregator', 'getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope', 'getConnection'], [], '', false);
     $this->entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->select->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->initFetchAllCalls();
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->resource = $this->getMock('Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->attrSetColFac = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColFac->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->prodAttrColFac = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFac->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     $this->params = [0 => $this->entityModel, 1 => 'bundle'];
     $this->bundle = $this->objectManagerHelper->getObject('Magento\\BundleImportExport\\Model\\Import\\Product\\Type\\Bundle', ['attrSetColFac' => $this->attrSetColFac, 'prodAttrColFac' => $this->prodAttrColFac, 'resource' => $this->resource, 'params' => $this->params]);
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setCollectionFactory = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $item = new \Magento\Framework\DataObject(['id' => 1, 'attribute_set_name' => 'Default', '_attribute_set' => 'Default']);
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([$item]));
     $this->attrCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $this->attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', ['setAttributeSetFilter'], [], '', false);
     $superAttributes = [];
     foreach ($this->_getSuperAttributes() as $superAttribute) {
         $item = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', ['isStatic'], $superAttribute, '', false);
         $item->setData($superAttribute);
         $item->method('isStatic')->will($this->returnValue(false));
         $superAttributes[] = $item;
     }
     $this->attrCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->attrCollection));
     $this->attrCollection->expects($this->any())->method('setAttributeSetFilter')->will($this->returnValue($superAttributes));
     $this->_entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getNewSku', 'getOldSku', 'getNextBunch', 'isRowAllowedToImport', 'getConnection', 'getAttrSetIdToName', 'getErrorAggregator', 'getAttributeOptions'], [], '', false);
     $this->_entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->params = [0 => $this->_entityModel, 1 => 'configurable'];
     $this->_connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', ['from', 'where', 'joinLeft', 'getConnection'], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->_connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $connectionMock->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getConnection')->willReturn($connectionMock);
     $this->_connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->_connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->_connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->_connection->expects($this->any())->method('fetchAll')->will($this->returnValue([]));
     $this->resource = $this->getMock('\\Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->_entityModel->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connection));
     $this->productCollectionFactory = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory', ['create'], [], '', false);
     $this->productCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', ['addFieldToFilter', 'addAttributeToSelect'], [], '', false);
     $products = [];
     $testProducts = [['id' => 1, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1], ['id' => 2, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1], ['id' => 20, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1]];
     foreach ($testProducts as $product) {
         $item = $this->getMock('\\Magento\\Framework\\DataObject', ['getAttributeSetId'], [], '', false);
         $item->setData($product);
         $item->expects($this->any())->method('getAttributeSetId')->willReturn(4);
         $products[] = $item;
     }
     $this->productCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->productCollection));
     $this->productCollection->expects($this->any())->method('addFieldToFilter')->will($this->returnValue($this->productCollection));
     $this->productCollection->expects($this->any())->method('addAttributeToSelect')->will($this->returnValue($products));
     $this->_entityModel->expects($this->any())->method('getAttributeOptions')->will($this->returnValue(['attr2val1' => '1', 'attr2val2' => '2', 'attr2val3' => '3', 'testattr3v1' => '4', 'testattr30v1' => '4', 'testattr3v2' => '5', 'testattr3v3' => '6']));
     $this->configurable = $this->objectManagerHelper->getObject('Magento\\ConfigurableImportExport\\Model\\Import\\Product\\Type\\Configurable', ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'params' => $this->params, 'resource' => $this->resource, 'productColFac' => $this->productCollectionFactory]);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->_string = new \Magento\Framework\Stdlib\StringUtils();
     $scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->_importFactory = $this->getMock('Magento\\ImportExport\\Model\\ImportFactory', [], [], '', false);
     $this->_resource = $this->getMock('Magento\\Framework\\App\\ResourceConnection', [], [], '', false);
     $this->_resourceHelper = $this->getMock('Magento\\ImportExport\\Model\\ResourceModel\\Helper', [], [], '', false);
     $this->_storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $this->_collectionFactory = $this->getMock('Magento\\ImportExport\\Model\\Export\\Factory', [], [], '', false);
     $this->_eavConfig = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->_model = $this->getMockForAbstractClass('Magento\\ImportExport\\Model\\Import\\Entity\\AbstractEav', [$this->_string, $scopeConfig, $this->_importFactory, $this->_resourceHelper, $this->_resource, $this->getErrorAggregatorObject(), $this->_storeManager, $this->_collectionFactory, $this->_eavConfig, $this->_getModelDependencies()]);
 }
 /**
  * Set up
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setUp()
 {
     parent::setUp();
     //connection and sql query results
     $this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->connectionMock->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->connectionMock->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('delete')->willReturnSelf();
     $this->connectionMock->expects($this->any())->method('quoteInto')->willReturn('');
     //constructor arguments:
     // 1. $attrSetColFac
     $this->attrSetColFacMock = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->attrSetColMock = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColMock->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     // 2. $prodAttrColFac
     $this->prodAttrColFacMock = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFacMock->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     // 3. $resource
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->connectionMock));
     $this->resourceMock->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     // 4. $params
     $this->entityModelMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', ['addMessageTemplate', 'getEntityTypeId', 'getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getParameters', 'addRowError'], [], '', false);
     $this->entityModelMock->expects($this->any())->method('addMessageTemplate')->will($this->returnSelf());
     $this->entityModelMock->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(5));
     $this->entityModelMock->expects($this->any())->method('getParameters')->will($this->returnValue([]));
     $this->paramsArray = [$this->entityModelMock, 'downloadable'];
     $this->uploaderMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Uploader', ['move'], [], '', false);
     // 6. $filesystem
     $this->directoryWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     // 7. $fileHelper
     $this->uploaderHelper = $this->getMock('\\Magento\\DownloadableImportExport\\Helper\\Uploader', ['getUploader'], [], '', false);
     $this->uploaderHelper->expects($this->any())->method('getUploader')->willReturn($this->uploaderMock);
     $this->downloadableHelper = $this->getMock('\\Magento\\DownloadableImportExport\\Helper\\Data', ['prepareDataForSave'], [], '', false);
     $this->downloadableHelper->expects($this->any())->method('prepareDataForSave')->willReturn([]);
 }
Example #6
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setCollectionFactory = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, ['create'], [], '', false);
     $this->setCollection = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class, ['setEntityTypeFilter'], [], '', false);
     $this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->attrCollectionFactory = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, ['create', 'addFieldToFilter'], [], '', false);
     $this->attrCollectionFactory->expects($this->any())->method('create')->will($this->returnSelf());
     $this->attrCollectionFactory->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->entityModel = $this->getMock(\Magento\CatalogImportExport\Model\Import\Product::class, ['getErrorAggregator', 'getNewSku', 'getOldSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope'], [], '', false);
     $this->entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->params = [0 => $this->entityModel, 1 => 'grouped'];
     $this->links = $this->getMock(\Magento\GroupedImportExport\Model\Import\Product\Type\Grouped\Links::class, [], [], '', false);
     $entityAttributes = [['attribute_set_name' => 'attribute_id', 'attribute_id' => 'attributeSetName']];
     $this->connection = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', ['from', 'where', 'joinLeft', 'getConnection'], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false);
     $connectionMock->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getConnection')->willReturn($connectionMock);
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->connection->expects($this->any())->method('fetchAll')->will($this->returnValue($entityAttributes));
     $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->grouped = $this->objectManagerHelper->getObject(\Magento\GroupedImportExport\Model\Import\Product\Type\Grouped::class, ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'resource' => $this->resource, 'params' => $this->params, 'links' => $this->links]);
     $metadataPoolMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false);
     $entityMetadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false);
     $metadataPoolMock->expects($this->any())->method('getMetadata')->with(\Magento\Catalog\Api\Data\ProductInterface::class)->willReturn($entityMetadataMock);
     $entityMetadataMock->expects($this->any())->method('getLinkField')->willReturn('entity_id');
     $entityMetadataMock->expects($this->any())->method('getIdentifierField')->willReturn('entity_id');
     $reflection = new \ReflectionClass(\Magento\GroupedImportExport\Model\Import\Product\Type\Grouped::class);
     $reflectionProperty = $reflection->getProperty('metadataPool');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->grouped, $metadataPoolMock);
 }
 /**
  * Set up
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityModel = $this->getMock(\Magento\CatalogImportExport\Model\Import\Product::class, ['getErrorAggregator', 'getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope', 'getConnection'], [], '', false);
     $this->entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->connection = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $this->select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->select->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->initFetchAllCalls();
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->attrSetColFac = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, ['create'], [], '', false);
     $this->setCollection = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class, ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColFac->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->prodAttrColFac = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, ['create'], [], '', false);
     $attrCollection = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFac->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     $this->params = [0 => $this->entityModel, 1 => 'bundle'];
     $this->bundle = $this->objectManagerHelper->getObject(\Magento\BundleImportExport\Model\Import\Product\Type\Bundle::class, ['attrSetColFac' => $this->attrSetColFac, 'prodAttrColFac' => $this->prodAttrColFac, 'resource' => $this->resource, 'params' => $this->params]);
     $metadataMock = $this->getMock(\Magento\Framework\Model\Entity\EntityMetadata::class, [], [], '', false);
     $metadataMock->expects($this->any())->method('getLinkField')->willReturn('entity_id');
     $metadataPoolMock = $this->getMock(\Magento\Framework\Model\Entity\MetadataPool::class, [], [], '', false);
     $metadataPoolMock->expects($this->any())->method('getMetadata')->with(\Magento\Catalog\Api\Data\ProductInterface::class)->willReturn($metadataMock);
     $reflection = new \ReflectionClass(\Magento\BundleImportExport\Model\Import\Product\Type\Bundle::class);
     $reflectionProperty = $reflection->getProperty('metadataPool');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->bundle, $metadataPoolMock);
 }
Example #8
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     parent::setUp();
     /* For parent object construct */
     $this->jsonHelper = $this->getMockBuilder('\\Magento\\Framework\\Json\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->importExportData = $this->getMockBuilder('\\Magento\\ImportExport\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->_dataSourceModel = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data')->disableOriginalConstructor()->getMock();
     $this->config = $this->getMockBuilder('\\Magento\\Eav\\Model\\Config')->disableOriginalConstructor()->getMock();
     $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\ResourceConnection')->disableOriginalConstructor()->getMock();
     $this->resourceHelper = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\ResourceModel\\Helper')->disableOriginalConstructor()->getMock();
     $this->string = $this->getMockBuilder('\\Magento\\Framework\\Stdlib\\StringUtils')->disableOriginalConstructor()->getMock();
     /* For object construct */
     $this->_eventManager = $this->getMockBuilder('\\Magento\\Framework\\Event\\ManagerInterface')->getMock();
     $this->stockRegistry = $this->getMockBuilder('\\Magento\\CatalogInventory\\Api\\StockRegistryInterface')->getMock();
     $this->stockConfiguration = $this->getMockBuilder('\\Magento\\CatalogInventory\\Api\\StockConfigurationInterface')->getMock();
     $this->stockStateProvider = $this->getMockBuilder('\\Magento\\CatalogInventory\\Model\\Spi\\StockStateProviderInterface')->getMock();
     $this->_catalogData = $this->getMockBuilder('\\Magento\\Catalog\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->_importConfig = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Import\\Config')->disableOriginalConstructor()->getMock();
     $this->_resourceFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Proxy\\Product\\ResourceModelFactory', ['create'], [], '', false);
     $this->_setColFactory = $this->getMock('\\Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->_productTypeFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\Type\\Factory', ['create'], [], '', false);
     $this->_linkFactory = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\LinkFactory', ['create'], [], '', false);
     $this->_proxyProdFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Proxy\\ProductFactory', ['create'], [], '', false);
     $this->_uploaderFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\UploaderFactory', ['create'], [], '', false);
     $this->_filesystem = $this->getMockBuilder('\\Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->_mediaDirectory = $this->getMockBuilder('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface')->getMock();
     $this->_stockResItemFac = $this->getMock('\\Magento\\CatalogInventory\\Model\\ResourceModel\\Stock\\ItemFactory', ['create'], [], '', false);
     $this->_localeDate = $this->getMockBuilder('\\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->getMock();
     $this->dateTime = $this->getMockBuilder('\\Magento\\Framework\\Stdlib\\DateTime')->disableOriginalConstructor()->getMock();
     $this->indexerRegistry = $this->getMockBuilder('\\Magento\\Framework\\Indexer\\IndexerRegistry')->disableOriginalConstructor()->getMock();
     $this->_logger = $this->getMockBuilder('\\Psr\\Log\\LoggerInterface')->getMock();
     $this->storeResolver = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\StoreResolver')->setMethods(['getStoreCodeToId'])->disableOriginalConstructor()->getMock();
     $this->skuProcessor = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\SkuProcessor')->disableOriginalConstructor()->getMock();
     $this->categoryProcessor = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\CategoryProcessor')->disableOriginalConstructor()->getMock();
     $this->validator = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\Validator')->setMethods(['isAttributeValid', 'getMessages', 'isValid'])->disableOriginalConstructor()->getMock();
     $this->objectRelationProcessor = $this->getMockBuilder('\\Magento\\Framework\\Model\\ResourceModel\\Db\\ObjectRelationProcessor')->disableOriginalConstructor()->getMock();
     $this->transactionManager = $this->getMockBuilder('\\Magento\\Framework\\Model\\ResourceModel\\Db\\TransactionManagerInterface')->getMock();
     $this->taxClassProcessor = $this->getMockBuilder('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\TaxClassProcessor')->disableOriginalConstructor()->getMock();
     $this->scopeConfig = $this->getMockBuilder('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->productUrl = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product\\Url')->disableOriginalConstructor()->getMock();
     $this->errorAggregator = $this->getErrorAggregatorObject();
     $this->data = [];
     $this->_objectConstructor()->_parentObjectConstructor()->_initAttributeSets()->_initTypeModels()->_initSkus();
     $this->importProduct = new Product($this->jsonHelper, $this->importExportData, $this->_dataSourceModel, $this->config, $this->resource, $this->resourceHelper, $this->string, $this->errorAggregator, $this->_eventManager, $this->stockRegistry, $this->stockConfiguration, $this->stockStateProvider, $this->_catalogData, $this->_importConfig, $this->_resourceFactory, $this->optionFactory, $this->_setColFactory, $this->_productTypeFactory, $this->_linkFactory, $this->_proxyProdFactory, $this->_uploaderFactory, $this->_filesystem, $this->_stockResItemFac, $this->_localeDate, $this->dateTime, $this->_logger, $this->indexerRegistry, $this->storeResolver, $this->skuProcessor, $this->categoryProcessor, $this->validator, $this->objectRelationProcessor, $this->transactionManager, $this->taxClassProcessor, $this->scopeConfig, $this->productUrl, $this->data);
 }
 /**
  * Set up
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setUp()
 {
     parent::setUp();
     $logger = $this->getMockBuilder('\\Psr\\Log\\LoggerInterface')->disableOriginalConstructor()->getMock();
     $this->_filesystem = $this->getMockBuilder('\\Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->_importExportData = $this->getMockBuilder('\\Magento\\ImportExport\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->_coreConfig = $this->getMockBuilder('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')->disableOriginalConstructor()->getMock();
     $this->_importConfig = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Import\\Config')->disableOriginalConstructor()->setMethods(['getEntityTypeCode', 'getBehavior', 'getEntities'])->getMockForAbstractClass();
     $this->_entityFactory = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Import\\Entity\\Factory')->disableOriginalConstructor()->getMock();
     $this->_entityAdapter = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Import\\Entity\\AbstractEntity')->disableOriginalConstructor()->setMethods(['importData', '_saveValidatedBunches', 'getErrorAggregator'])->getMockForAbstractClass();
     $this->_entityAdapter->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject(['initValidationStrategy']));
     $this->_entityFactory->method('create')->willReturn($this->_entityAdapter);
     $this->_importData = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data')->disableOriginalConstructor()->getMock();
     $this->_csvFactory = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Export\\Adapter\\CsvFactory')->disableOriginalConstructor()->getMock();
     $this->_httpFactory = $this->getMockBuilder('\\Magento\\Framework\\HTTP\\Adapter\\FileTransferFactory')->disableOriginalConstructor()->getMock();
     $this->_uploaderFactory = $this->getMockBuilder('\\Magento\\MediaStorage\\Model\\File\\UploaderFactory')->disableOriginalConstructor()->getMock();
     $this->_behaviorFactory = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Source\\Import\\Behavior\\Factory')->disableOriginalConstructor()->getMock();
     $this->indexerRegistry = $this->getMockBuilder('\\Magento\\Framework\\Indexer\\IndexerRegistry')->disableOriginalConstructor()->getMock();
     $this->historyModel = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\History')->disableOriginalConstructor()->setMethods(['updateReport', 'invalidateReport', 'addReport'])->getMock();
     $this->historyModel->expects($this->any())->method('updateReport')->willReturnSelf();
     $this->dateTime = $this->getMockBuilder('\\Magento\\Framework\\Stdlib\\DateTime\\DateTime')->disableOriginalConstructor()->getMock();
     $this->_varDirectory = $this->getMockBuilder('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->_driver = $this->getMockBuilder('\\Magento\\Framework\\Filesystem\\DriverInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->_driver->expects($this->any())->method('fileGetContents')->willReturn('');
     $this->_varDirectory->expects($this->any())->method('getDriver')->willReturn($this->_driver);
     $this->import = $this->getMockBuilder('\\Magento\\ImportExport\\Model\\Import')->setConstructorArgs([$logger, $this->_filesystem, $this->_importExportData, $this->_coreConfig, $this->_importConfig, $this->_entityFactory, $this->_importData, $this->_csvFactory, $this->_httpFactory, $this->_uploaderFactory, $this->_behaviorFactory, $this->indexerRegistry, $this->historyModel, $this->dateTime])->setMethods(['getDataSourceModel', 'setData', 'getProcessedEntitiesCount', 'getProcessedRowsCount', 'getEntity', 'getBehavior', 'isReportEntityType', '_getEntityAdapter'])->getMock();
     $this->setPropertyValue($this->import, '_varDirectory', $this->_varDirectory);
 }
 protected function tearDown()
 {
     unset($this->_model);
     parent::tearDown();
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     parent::setUp();
     $metadataPoolMock = $this->getMock(\Magento\Framework\Model\Entity\MetadataPool::class, [], [], '', false);
     $entityMetadataMock = $this->getMock(\Magento\Framework\Model\Entity\EntityMetadata::class, [], [], '', false);
     $metadataPoolMock->expects($this->any())->method('getMetadata')->with(\Magento\Catalog\Api\Data\ProductInterface::class)->willReturn($entityMetadataMock);
     $entityMetadataMock->expects($this->any())->method('getLinkField')->willReturn('entity_id');
     /* For parent object construct */
     $this->jsonHelper = $this->getMockBuilder(\Magento\Framework\Json\Helper\Data::class)->disableOriginalConstructor()->getMock();
     $this->importExportData = $this->getMockBuilder(\Magento\ImportExport\Helper\Data::class)->disableOriginalConstructor()->getMock();
     $this->_dataSourceModel = $this->getMockBuilder(\Magento\ImportExport\Model\ResourceModel\Import\Data::class)->disableOriginalConstructor()->getMock();
     $this->config = $this->getMockBuilder(\Magento\Eav\Model\Config::class)->disableOriginalConstructor()->getMock();
     $this->resource = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)->disableOriginalConstructor()->getMock();
     $this->resourceHelper = $this->getMockBuilder(\Magento\ImportExport\Model\ResourceModel\Helper::class)->disableOriginalConstructor()->getMock();
     $this->string = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class)->disableOriginalConstructor()->getMock();
     /* For object construct */
     $this->_eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)->getMock();
     $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockRegistryInterface::class)->getMock();
     $this->stockConfiguration = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockConfigurationInterface::class)->getMock();
     $this->stockStateProvider = $this->getMockBuilder(\Magento\CatalogInventory\Model\Spi\StockStateProviderInterface::class)->getMock();
     $this->_catalogData = $this->getMockBuilder(\Magento\Catalog\Helper\Data::class)->disableOriginalConstructor()->getMock();
     $this->_importConfig = $this->getMockBuilder(\Magento\ImportExport\Model\Import\Config::class)->disableOriginalConstructor()->getMock();
     $this->_resourceFactory = $this->getMock(\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory::class, ['create'], [], '', false);
     $this->_setColFactory = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, ['create'], [], '', false);
     $this->_productTypeFactory = $this->getMock(\Magento\CatalogImportExport\Model\Import\Product\Type\Factory::class, ['create'], [], '', false);
     $this->_linkFactory = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\LinkFactory::class, ['create'], [], '', false);
     $this->_proxyProdFactory = $this->getMock(\Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory::class, ['create'], [], '', false);
     $this->_uploaderFactory = $this->getMock(\Magento\CatalogImportExport\Model\Import\UploaderFactory::class, ['create'], [], '', false);
     $this->_filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class)->disableOriginalConstructor()->getMock();
     $this->_mediaDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class)->getMock();
     $this->_stockResItemFac = $this->getMock(\Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class, ['create'], [], '', false);
     $this->_localeDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)->getMock();
     $this->dateTime = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime::class)->disableOriginalConstructor()->getMock();
     $this->indexerRegistry = $this->getMockBuilder(\Magento\Framework\Indexer\IndexerRegistry::class)->disableOriginalConstructor()->getMock();
     $this->_logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
     $this->storeResolver = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class)->setMethods(['getStoreCodeToId'])->disableOriginalConstructor()->getMock();
     $this->skuProcessor = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class)->disableOriginalConstructor()->getMock();
     $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class);
     $reflectionProperty = $reflection->getProperty('metadataPool');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->skuProcessor, $metadataPoolMock);
     $this->categoryProcessor = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor::class)->disableOriginalConstructor()->getMock();
     $this->validator = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Validator::class)->setMethods(['isAttributeValid', 'getMessages', 'isValid'])->disableOriginalConstructor()->getMock();
     $this->objectRelationProcessor = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class)->disableOriginalConstructor()->getMock();
     $this->transactionManager = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface::class)->getMock();
     $this->taxClassProcessor = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\TaxClassProcessor::class)->disableOriginalConstructor()->getMock();
     $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)->disableOriginalConstructor()->getMockForAbstractClass();
     $this->productUrl = $this->getMockBuilder(\Magento\Catalog\Model\Product\Url::class)->disableOriginalConstructor()->getMock();
     $this->errorAggregator = $this->getErrorAggregatorObject();
     $this->data = [];
     $this->_objectConstructor()->_parentObjectConstructor()->_initAttributeSets()->_initTypeModels()->_initSkus();
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->importProduct = $objectManager->getObject(\Magento\CatalogImportExport\Model\Import\Product::class, ['jsonHelper' => $this->jsonHelper, 'importExportData' => $this->importExportData, 'importData' => $this->_dataSourceModel, 'config' => $this->config, 'resource' => $this->resource, 'resourceHelper' => $this->resourceHelper, 'string' => $this->string, 'errorAggregator' => $this->errorAggregator, 'eventManager' => $this->_eventManager, 'stockRegistry' => $this->stockRegistry, 'stockConfiguration' => $this->stockConfiguration, 'stockStateProvider' => $this->stockStateProvider, 'catalogData' => $this->_catalogData, 'importConfig' => $this->_importConfig, 'resourceFactory' => $this->_resourceFactory, 'optionFactory' => $this->optionFactory, 'setColFactory' => $this->_setColFactory, 'productTypeFactory' => $this->_productTypeFactory, 'linkFactory' => $this->_linkFactory, 'proxyProdFactory' => $this->_proxyProdFactory, 'uploaderFactory' => $this->_uploaderFactory, 'filesystem' => $this->_filesystem, 'stockResItemFac' => $this->_stockResItemFac, 'localeDate' => $this->_localeDate, 'dateTime' => $this->dateTime, 'logger' => $this->_logger, 'indexerRegistry' => $this->indexerRegistry, 'storeResolver' => $this->storeResolver, 'skuProcessor' => $this->skuProcessor, 'categoryProcessor' => $this->categoryProcessor, 'validator' => $this->validator, 'objectRelationProcessor' => $this->objectRelationProcessor, 'transactionManager' => $this->transactionManager, 'taxClassProcessor' => $this->taxClassProcessor, 'scopeConfig' => $this->scopeConfig, 'productUrl' => $this->productUrl, 'data' => $this->data]);
     $reflection = new \ReflectionClass('\\Magento\\CatalogImportExport\\Model\\Import\\Product');
     $reflectionProperty = $reflection->getProperty('metadataPool');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->importProduct, $metadataPoolMock);
 }
 /**
  * Init entity adapter model
  */
 protected function setUp()
 {
     parent::setUp();
     $addExpectations = false;
     $deleteBehavior = false;
     $testName = $this->getName(true);
     if ($testName == 'testImportDataAppendBehavior' || $testName == 'testImportDataDeleteBehavior') {
         $addExpectations = true;
         $deleteBehavior = $this->getName() == 'testImportDataDeleteBehavior' ? true : false;
     }
     $doubleOptions = false;
     if ($testName == 'testValidateAmbiguousData with data set "ambiguity_several_db_rows"') {
         $doubleOptions = true;
     }
     $catalogDataMock = $this->getMock('Magento\\Catalog\\Helper\\Data', ['__construct'], [], '', false);
     $scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $timezoneInterface = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface');
     $date = new \DateTime();
     $timezoneInterface->expects($this->any())->method('date')->willReturn($date);
     $modelClassArgs = [$this->getMock('Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data', [], [], '', false), $this->getMock('Magento\\Framework\\App\\ResourceConnection', [], [], '', false), $this->getMock('Magento\\ImportExport\\Model\\ResourceModel\\Helper', [], [], '', false), $this->getMock('Magento\\Store\\Model\\StoreManagerInterface', [], [], '', false), $this->getMock('Magento\\Catalog\\Model\\ProductFactory', [], [], '', false), $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Option\\CollectionFactory', [], [], '', false), $this->getMock('Magento\\ImportExport\\Model\\ResourceModel\\CollectionByPagesIteratorFactory', [], [], '', false), $catalogDataMock, $scopeConfig, $timezoneInterface, $this->getMock('Magento\\ImportExport\\Model\\Import\\ErrorProcessing\\ProcessingErrorAggregatorInterface', [], [], '', false), $this->_getModelDependencies($addExpectations, $deleteBehavior, $doubleOptions)];
     $modelClassName = '\\Magento\\CatalogImportExport\\Model\\Import\\Product\\Option';
     $class = new \ReflectionClass($modelClassName);
     $this->_model = $class->newInstanceArgs($modelClassArgs);
     // Create model mock with rewritten _getMultiRowFormat method to support test data with the old format.
     $this->_modelMock = $this->getMockBuilder($modelClassName)->setConstructorArgs($modelClassArgs)->setMethods(['_getMultiRowFormat'])->getMock();
 }
Example #13
0
 /**
  * Init entity adapter model
  */
 protected function setUp()
 {
     parent::setUp();
     $addExpectations = false;
     $deleteBehavior = false;
     $testName = $this->getName(true);
     if ($testName == 'testImportDataAppendBehavior' || $testName == 'testImportDataDeleteBehavior') {
         $addExpectations = true;
         $deleteBehavior = $this->getName() == 'testImportDataDeleteBehavior' ? true : false;
     }
     $doubleOptions = false;
     if ($testName == 'testValidateAmbiguousData with data set "ambiguity_several_db_rows"') {
         $doubleOptions = true;
     }
     $catalogDataMock = $this->getMock(\Magento\Catalog\Helper\Data::class, ['__construct'], [], '', false);
     $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
     $timezoneInterface = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
     $date = new \DateTime();
     $timezoneInterface->expects($this->any())->method('date')->willReturn($date);
     $this->metadataPoolMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false);
     $entityMetadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false);
     $this->metadataPoolMock->expects($this->any())->method('getMetadata')->with(\Magento\Catalog\Api\Data\ProductInterface::class)->willReturn($entityMetadataMock);
     $entityMetadataMock->expects($this->any())->method('getLinkField')->willReturn('entity_id');
     $modelClassArgs = [$this->getMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class, [], [], '', false), $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false), $this->getMock(\Magento\ImportExport\Model\ResourceModel\Helper::class, [], [], '', false), $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false), $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false), $this->getMock(\Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class, [], [], '', false), $this->getMock(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class, [], [], '', false), $catalogDataMock, $scopeConfig, $timezoneInterface, $this->getMock(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface::class, [], [], '', false), $this->_getModelDependencies($addExpectations, $deleteBehavior, $doubleOptions)];
     $modelClassName = \Magento\CatalogImportExport\Model\Import\Product\Option::class;
     $class = new \ReflectionClass($modelClassName);
     $this->model = $class->newInstanceArgs($modelClassArgs);
     // Create model mock with rewritten _getMultiRowFormat method to support test data with the old format.
     $this->modelMock = $this->getMockBuilder($modelClassName)->setConstructorArgs($modelClassArgs)->setMethods(['_getMultiRowFormat'])->getMock();
     $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
     $reflectionProperty = $reflection->getProperty('metadataPool');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->modelMock, $this->metadataPoolMock);
 }
 public function setUp()
 {
     parent::setUp();
     $this->jsonHelper = $this->getMock('\\Magento\\Framework\\Json\\Helper\\Data', [], [], '', false);
     $this->importExportData = $this->getMock('\\Magento\\ImportExport\\Helper\\Data', [], [], '', false);
     $this->resourceHelper = $this->getMock('\\Magento\\ImportExport\\Model\\ResourceModel\\Helper', [], [], '', false);
     $this->resource = $this->getMock('\\Magento\\Framework\\App\\ResourceConnection', ['getConnection'], [], '', false);
     $this->connection = $this->getMockForAbstractClass('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->dataSourceModel = $this->getMock('\\Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data', [], [], '', false);
     $this->eavConfig = $this->getMock('\\Magento\\Eav\\Model\\Config', [], [], '', false);
     $entityType = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $entityType->method('getEntityTypeId')->willReturn('');
     $this->eavConfig->method('getEntityType')->willReturn($entityType);
     $this->resourceFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Proxy\\Product\\ResourceModelFactory', ['create', 'getTable'], [], '', false);
     $this->resourceFactory->expects($this->any())->method('create')->willReturnSelf();
     $this->resourceFactory->expects($this->any())->method('getTable')->willReturnSelf();
     $this->catalogData = $this->getMock('\\Magento\\Catalog\\Helper\\Data', [], [], '', false);
     $this->storeResolver = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\StoreResolver', [], [], '', false);
     $this->importProduct = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', [], [], '', false);
     $this->productModel = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->validator = $this->getMock('\\Magento\\AdvancedPricingImportExport\\Model\\Import\\AdvancedPricing\\Validator', ['isValid', 'getMessages'], [], '', false);
     $this->websiteValidator = $this->getMock('\\Magento\\AdvancedPricingImportExport\\Model\\Import\\AdvancedPricing\\Validator\\Website', [], [], '', false);
     $this->tierPriceValidator = $this->getMock('\\Magento\\AdvancedPricingImportExport\\Model\\Import\\AdvancedPricing\\Validator\\TierPrice', [], [], '', false);
     $this->stringObject = $this->getMock('\\Magento\\Framework\\Stdlib\\StringUtils', [], [], '', false);
     $this->errorAggregator = $this->getErrorAggregatorObject();
     $this->dateTime = $this->getMock('\\Magento\\Framework\\Stdlib\\DateTime\\DateTime', ['date', 'format'], [], '', false);
     $this->dateTime->expects($this->any())->method('date')->willReturnSelf();
     $this->advancedPricing = $this->getAdvancedPricingMock(['retrieveOldSkus', 'validateRow', 'addRowError', 'saveProductPrices', 'getCustomerGroupId', 'getWebSiteId', 'deleteProductTierPrices', 'getBehavior', 'saveAndReplaceAdvancedPrices', 'processCountExistingPrices', 'processCountNewPrices']);
     $this->advancedPricing->expects($this->any())->method('retrieveOldSkus')->willReturn([]);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->_model = $this->getMockBuilder('Magento\\ImportExport\\Model\\Import\\AbstractEntity')->setConstructorArgs($this->_getModelDependencies())->setMethods(['_saveValidatedBunches'])->getMockForAbstractClass();
 }