@@ -125,4 +125,50 @@ public function verifyRow(array $rowData)
125
125
);
126
126
}
127
127
}
128
+
129
+ /**
130
+ * Verifies if exception processing works properly
131
+ *
132
+ * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php
133
+ */
134
+ public function testExceptionInGetExportData ()
135
+ {
136
+ $ exception = new \Exception ('Error ' );
137
+
138
+ $ rowCustomizerMock = $ this ->getMockBuilder ('Magento\CatalogImportExport\Model\Export\RowCustomizerInterface ' )
139
+ ->disableOriginalConstructor ()
140
+ ->getMock ();
141
+
142
+ $ loggerMock = $ this ->getMockBuilder ('\Psr\Log\LoggerInterface ' )->getMock ();
143
+
144
+ $ directoryMock = $ this ->getMock ('Magento\Framework\Filesystem\Directory\Write ' , [], [], '' , false );
145
+ $ directoryMock ->expects ($ this ->any ())->method ('getParentDirectory ' )->will ($ this ->returnValue ('some#path ' ));
146
+ $ directoryMock ->expects ($ this ->any ())->method ('isWritable ' )->will ($ this ->returnValue (true ));
147
+
148
+ $ filesystemMock = $ this ->getMock ('Magento\Framework\Filesystem ' , [], [], '' , false );
149
+ $ filesystemMock ->expects ($ this ->once ())->method ('getDirectoryWrite ' )->will ($ this ->returnValue ($ directoryMock ));
150
+
151
+ $ exportAdapter = new \Magento \ImportExport \Model \Export \Adapter \Csv ($ filesystemMock );
152
+
153
+ $ rowCustomizerMock ->expects ($ this ->once ())->method ('prepareData ' )->willThrowException ($ exception );
154
+ $ loggerMock ->expects ($ this ->once ())->method ('critical ' )->with ($ exception );
155
+
156
+ $ collection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
157
+ '\Magento\Catalog\Model\Resource\Product\Collection '
158
+ );
159
+
160
+ /** @var \Magento\CatalogImportExport\Model\Export\Product $model */
161
+ $ model = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
162
+ 'Magento\CatalogImportExport\Model\Export\Product ' ,
163
+ [
164
+ 'rowCustomizer ' => $ rowCustomizerMock ,
165
+ 'logger ' => $ loggerMock ,
166
+ 'collection ' => $ collection
167
+ ]
168
+ );
169
+
170
+
171
+ $ data = $ model ->setWriter ($ exportAdapter )->export ();
172
+ $ this ->assertEmpty ($ data );
173
+ }
128
174
}
0 commit comments