本文整理匯總了PHP中Magento\CatalogImportExport\Model\Import\Product::method方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::method方法的具體用法?PHP Product::method怎麽用?PHP Product::method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\CatalogImportExport\Model\Import\Product
的用法示例。
在下文中一共展示了Product::method方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
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]);
}
示例2: setUp
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]);
}
示例3: setUp
/**
* @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]);
}
示例4: setUp
/**
* @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);
}
示例5: setUp
/**
* 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);
}
示例6: _getSourceDataMocks
/**
* Get source data mocks
*
* @param bool $addExpectations
* @param bool $doubleOptions
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _getSourceDataMocks($addExpectations, $doubleOptions)
{
$csvData = $this->_loadCsvFile();
$dataSourceModel = $this->getMock('stdClass', ['getNextBunch']);
if ($addExpectations) {
$dataSourceModel->expects($this->at(0))->method('getNextBunch')->will($this->returnValue($csvData['data']));
$dataSourceModel->expects($this->at(1))->method('getNextBunch')->will($this->returnValue(null));
}
$products = [];
$elementIndex = 0;
foreach ($csvData['data'] as $rowIndex => $csvDataRow) {
if (!empty($csvDataRow['sku']) && !array_key_exists($csvDataRow['sku'], $products)) {
$elementIndex = $rowIndex + 1;
$products[$csvDataRow['sku']] = ['sku' => $csvDataRow['sku'], 'id' => $elementIndex, 'entity_id' => $elementIndex, 'product_id' => $elementIndex, 'type' => $csvDataRow[\Magento\CatalogImportExport\Model\Import\Product::COL_TYPE], 'title' => $csvDataRow[\Magento\CatalogImportExport\Model\Import\Product::COL_NAME]];
}
}
$this->productEntity = $this->getMock(\Magento\CatalogImportExport\Model\Import\Product::class, ['getErrorAggregator'], [], '', false);
$this->productEntity->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
$reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product::class);
$reflectionProperty = $reflection->getProperty('metadataPool');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->productEntity, $this->metadataPoolMock);
$productModelMock = $this->getMock('stdClass', ['getProductEntitiesInfo']);
$productModelMock->expects($this->any())->method('getProductEntitiesInfo')->will($this->returnValue($products));
$fetchStrategy = $this->getMockForAbstractClass(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class, ['fetchAll']);
$logger = $this->getMock(\Psr\Log\LoggerInterface::class);
$entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false);
$optionCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class)->setConstructorArgs([$entityFactory, $logger, $fetchStrategy])->setMethods(['reset', 'addProductToFilter', 'getSelect', 'getNewEmptyItem'])->getMockForAbstractClass();
$select = $this->getMock(\Magento\Framework\DB\Select::class, ['join', 'where'], [], '', false);
$select->expects($this->any())->method('join')->will($this->returnSelf());
$select->expects($this->any())->method('where')->will($this->returnSelf());
$optionCollection->expects($this->any())->method('getNewEmptyItem')->will($this->returnCallback([$this, 'getNewOptionMock']));
$optionCollection->expects($this->any())->method('reset')->will($this->returnSelf());
$optionCollection->expects($this->any())->method('addProductToFilter')->will($this->returnSelf());
$optionCollection->expects($this->any())->method('getSelect')->will($this->returnValue($select));
$optionsData = array_values($products);
if ($doubleOptions) {
foreach ($products as $product) {
$elementIndex++;
$product['id'] = $elementIndex;
$optionsData[] = $product;
}
}
$fetchStrategy->expects($this->any())->method('fetchAll')->will($this->returnValue($optionsData));
$collectionIterator = $this->getMock('stdClass', ['iterate']);
$collectionIterator->expects($this->any())->method('iterate')->will($this->returnCallback([$this, 'iterate']));
$data = ['data_source_model' => $dataSourceModel, 'product_model' => $productModelMock, 'product_entity' => $this->productEntity, 'option_collection' => $optionCollection, 'collection_by_pages_iterator' => $collectionIterator, 'page_size' => $this->_iteratorPageSize];
return $data;
}