@@ -61,6 +61,8 @@ protected function setUp()
6161 {
6262 $ objectManager = new ObjectManager ($ this );
6363
64+ $ attributeTable = 'catalog_product_entity_int ' ;
65+ $ statusId = 22 ;
6466 $ this ->connection = $ this ->createMock (\Magento \Framework \DB \Adapter \AdapterInterface::class);
6567 $ this ->resource = $ this ->createMock (\Magento \Framework \App \ResourceConnection::class);
6668 $ this ->resource ->expects ($ this ->any ())->method ('getConnection ' )
@@ -70,10 +72,36 @@ protected function setUp()
7072 $ this ->store = $ this ->createMock (\Magento \Store \Model \Store::class);
7173 $ this ->store ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue ('store_id_1 ' ));
7274 $ this ->storeManager ->expects ($ this ->any ())->method ('getStores ' )->will ($ this ->returnValue ([$ this ->store ]));
73- $ this ->productIndexerHelper = $ this ->createMock (\Magento \Catalog \Helper \Product \Flat \Indexer::class);
7475 $ this ->flatItemEraser = $ this ->createMock (\Magento \Catalog \Model \Indexer \Product \Flat \Action \Eraser::class);
7576 $ this ->flatItemWriter = $ this ->createMock (\Magento \Catalog \Model \Indexer \Product \Flat \Action \Indexer::class);
7677 $ this ->flatTableBuilder = $ this ->createMock (\Magento \Catalog \Model \Indexer \Product \Flat \FlatTableBuilder::class);
78+ $ this ->productIndexerHelper = $ this ->createMock (\Magento \Catalog \Helper \Product \Flat \Indexer::class);
79+ $ statusAttributeMock = $ this ->getMockBuilder (\Magento \Eav \Model \Entity \Attribute::class)
80+ ->disableOriginalConstructor ()
81+ ->getMock ();
82+ $ this ->productIndexerHelper ->expects ($ this ->any ())->method ('getAttribute ' )
83+ ->with ('status ' )
84+ ->willReturn ($ statusAttributeMock );
85+ $ backendMock = $ this ->getMockBuilder (\Magento \Eav \Model \Entity \Attribute \Backend \AbstractBackend::class)
86+ ->disableOriginalConstructor ()
87+ ->getMock ();
88+ $ backendMock ->expects ($ this ->any ())->method ('getTable ' )->willReturn ($ attributeTable );
89+ $ statusAttributeMock ->expects ($ this ->any ())->method ('getBackend ' )->willReturn (
90+ $ backendMock
91+ );
92+ $ statusAttributeMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ statusId );
93+ $ selectMock = $ this ->getMockBuilder (\Magento \Framework \DB \Select::class)
94+ ->disableOriginalConstructor ()
95+ ->getMock ();
96+ $ this ->connection ->expects ($ this ->any ())->method ('select ' )->willReturn ($ selectMock );
97+ $ selectMock ->expects ($ this ->any ())->method ('from ' )->with (
98+ $ attributeTable ,
99+ ['value ' ]
100+ )->willReturnSelf ();
101+ $ selectMock ->expects ($ this ->any ())->method ('where ' )->willReturnSelf ();
102+ $ pdoMock = $ this ->createMock (\Zend_Db_Statement_Pdo::class);
103+ $ this ->connection ->expects ($ this ->any ())->method ('query ' )->with ($ selectMock )->will ($ this ->returnValue ($ pdoMock ));
104+ $ pdoMock ->expects ($ this ->any ())->method ('fetch ' )->will ($ this ->returnValue (['value ' => 1 ]));
77105
78106 $ this ->model = $ objectManager ->getObject (
79107 \Magento \Catalog \Model \Indexer \Product \Flat \Action \Row::class, [
@@ -82,7 +110,7 @@ protected function setUp()
82110 'productHelper ' => $ this ->productIndexerHelper ,
83111 'flatItemEraser ' => $ this ->flatItemEraser ,
84112 'flatItemWriter ' => $ this ->flatItemWriter ,
85- 'flatTableBuilder ' => $ this ->flatTableBuilder
113+ 'flatTableBuilder ' => $ this ->flatTableBuilder ,
86114 ]);
87115 }
88116
0 commit comments