Skip to content

Commit 13595a3

Browse files
lewisvonckengelanivishal
authored andcommitted
Updated the Unit Test according to issue-14966
1 parent 80fbc9e commit 13595a3

File tree

2 files changed

+44
-2
lines changed
  • app/code/Magento/Catalog
    • Model/Indexer/Product/Flat/Action
    • Test/Unit/Model/Indexer/Product/Flat/Action

2 files changed

+44
-2
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function execute($id = null)
7979

8080
/* @var $status \Magento\Eav\Model\Entity\Attribute */
8181
$status = $this->_productIndexerHelper->getAttribute('status');
82-
$statusTable = $status->getBackendTable();
82+
$statusTable = $status->getBackend()->getTable();
8383
$statusConditions = [
8484
'store_id IN(0,' . (int)$store->getId() . ')',
8585
'attribute_id = ' . (int)$status->getId(),

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/Action/RowTest.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ protected function setUp()
5959
{
6060
$objectManager = new ObjectManager($this);
6161

62+
$attributeTable = 'catalog_product_entity_int';
63+
$statusId = 22;
6264
$this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
6365
$this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
6466
$this->resource->expects($this->any())->method('getConnection')
@@ -68,9 +70,9 @@ protected function setUp()
6870
$this->store = $this->createMock(\Magento\Store\Model\Store::class);
6971
$this->store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1'));
7072
$this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$this->store]));
71-
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
7273
$this->flatItemEraser = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser::class);
7374
$this->flatItemWriter = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer::class);
75+
<<<<<<< HEAD
7476
$this->flatTableBuilder = $this->createMock(
7577
\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class
7678
);
@@ -86,6 +88,46 @@ protected function setUp()
8688
'flatTableBuilder' => $this->flatTableBuilder
8789
]
8890
);
91+
=======
92+
$this->flatTableBuilder = $this->createMock(\Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder::class);
93+
$this->productIndexerHelper = $this->createMock(\Magento\Catalog\Helper\Product\Flat\Indexer::class);
94+
$statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
95+
->disableOriginalConstructor()
96+
->getMock();
97+
$this->productIndexerHelper->expects($this->any())->method('getAttribute')
98+
->with('status')
99+
->willReturn($statusAttributeMock);
100+
$backendMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class)
101+
->disableOriginalConstructor()
102+
->getMock();
103+
$backendMock->expects($this->any())->method('getTable')->willReturn($attributeTable);
104+
$statusAttributeMock->expects($this->any())->method('getBackend')->willReturn(
105+
$backendMock
106+
);
107+
$statusAttributeMock->expects($this->any())->method('getId')->willReturn($statusId);
108+
$selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
109+
->disableOriginalConstructor()
110+
->getMock();
111+
$this->connection->expects($this->any())->method('select')->willReturn($selectMock);
112+
$selectMock->expects($this->any())->method('from')->with(
113+
$attributeTable,
114+
['value']
115+
)->willReturnSelf();
116+
$selectMock->expects($this->any())->method('where')->willReturnSelf();
117+
$pdoMock = $this->createMock(\Zend_Db_Statement_Pdo::class);
118+
$this->connection->expects($this->any())->method('query')->with($selectMock)->will($this->returnValue($pdoMock));
119+
$pdoMock->expects($this->any())->method('fetch')->will($this->returnValue(['value' => 1]));
120+
121+
$this->model = $objectManager->getObject(
122+
\Magento\Catalog\Model\Indexer\Product\Flat\Action\Row::class, [
123+
'resource' => $this->resource,
124+
'storeManager' => $this->storeManager,
125+
'productHelper' => $this->productIndexerHelper,
126+
'flatItemEraser' => $this->flatItemEraser,
127+
'flatItemWriter' => $this->flatItemWriter,
128+
'flatTableBuilder' => $this->flatTableBuilder,
129+
]);
130+
>>>>>>> 38bd9d381bc... [TASK] Updated the Unit Test according to issue-14966
89131
}
90132

91133
/**

0 commit comments

Comments
 (0)