35 $this->connection = $this->createMock(\
Magento\Framework\DB\Adapter\AdapterInterface::class);
36 $resource->expects($this->any())->method(
'getConnection')->will($this->returnValue($this->connection));
38 $this->indexerHelper->expects($this->any())->method(
'getTable')->will($this->returnArgument(0));
39 $this->indexerHelper->expects($this->any())->method(
'getFlatTableName')->will($this->returnValueMap([
44 $this->storeManager = $this->createMock(\
Magento\
Store\Model\StoreManagerInterface::class);
45 $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser(
54 $productsToDeleteIds = [1, 2];
56 $select->expects($this->once())->method(
'from')->with(
'catalog_product_entity')->will($this->returnSelf());
57 $select->expects($this->once())->method(
'where')->with(
'entity_id IN(?)', $productsToDeleteIds)
58 ->will($this->returnSelf());
60 $statement = $this->createMock(\Zend_Db_Statement_Interface::class);
61 $statement->expects($this->once())->method(
'fetchAll')->will($this->returnValue(
$products));
62 $this->connection->expects($this->once())->method(
'query')->with(
$select)
63 ->will($this->returnValue($statement));
64 $this->connection->expects($this->once())->method(
'select')->will($this->returnValue(
$select));
65 $this->connection->expects($this->once())->method(
'delete')
66 ->with(
'store_1_flat', [
'entity_id IN(?)' => [1]]);
68 $this->model->removeDeletedProducts($productsToDeleteIds, 1);
73 $store1 = $this->createMock(\
Magento\
Store\Model\Store::class);
74 $store1->expects($this->any())->method(
'getId')->will($this->returnValue(1));
75 $store2 = $this->createMock(\
Magento\
Store\Model\Store::class);
76 $store2->expects($this->any())->method(
'getId')->will($this->returnValue(2));
77 $this->storeManager->expects($this->once())->method(
'getStores')
78 ->will($this->returnValue([$store1, $store2]));
79 $this->connection->expects($this->at(0))->method(
'delete')
80 ->with(
'store_1_flat', [
'entity_id IN(?)' => [1]]);
81 $this->connection->expects($this->at(1))->method(
'delete')
82 ->with(
'store_2_flat', [
'entity_id IN(?)' => [1]]);
84 $this->model->deleteProductsFromStore(1);
testDeleteProductsFromStoreForAllStores()
testRemoveDeletedProducts()