@@ -61,6 +61,8 @@ protected function setUp()
61
61
{
62
62
$ objectManager = new ObjectManager ($ this );
63
63
64
+ $ attributeTable = 'catalog_product_entity_int ' ;
65
+ $ statusId = 22 ;
64
66
$ this ->connection = $ this ->createMock (\Magento \Framework \DB \Adapter \AdapterInterface::class);
65
67
$ this ->resource = $ this ->createMock (\Magento \Framework \App \ResourceConnection::class);
66
68
$ this ->resource ->expects ($ this ->any ())->method ('getConnection ' )
@@ -70,10 +72,36 @@ protected function setUp()
70
72
$ this ->store = $ this ->createMock (\Magento \Store \Model \Store::class);
71
73
$ this ->store ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue ('store_id_1 ' ));
72
74
$ this ->storeManager ->expects ($ this ->any ())->method ('getStores ' )->will ($ this ->returnValue ([$ this ->store ]));
73
- $ this ->productIndexerHelper = $ this ->createMock (\Magento \Catalog \Helper \Product \Flat \Indexer::class);
74
75
$ this ->flatItemEraser = $ this ->createMock (\Magento \Catalog \Model \Indexer \Product \Flat \Action \Eraser::class);
75
76
$ this ->flatItemWriter = $ this ->createMock (\Magento \Catalog \Model \Indexer \Product \Flat \Action \Indexer::class);
76
77
$ 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 ]));
77
105
78
106
$ this ->model = $ objectManager ->getObject (
79
107
\Magento \Catalog \Model \Indexer \Product \Flat \Action \Row::class, [
@@ -82,7 +110,7 @@ protected function setUp()
82
110
'productHelper ' => $ this ->productIndexerHelper ,
83
111
'flatItemEraser ' => $ this ->flatItemEraser ,
84
112
'flatItemWriter ' => $ this ->flatItemWriter ,
85
- 'flatTableBuilder ' => $ this ->flatTableBuilder
113
+ 'flatTableBuilder ' => $ this ->flatTableBuilder ,
86
114
]);
87
115
}
88
116
0 commit comments