@@ -856,7 +856,7 @@ public function testProductsWithMultipleStores()
856
856
$ this ->_model ->importData ();
857
857
858
858
/** @var \Magento\Catalog\Model\Product $product */
859
- $ product = $ objectManager ->create (' Magento\Catalog\Model\Product ' );
859
+ $ product = $ objectManager ->create (\ Magento \Catalog \Model \Product::class );
860
860
$ id = $ product ->getIdBySku ('Configurable 03 ' );
861
861
$ product ->load ($ id );
862
862
$ this ->assertEquals ('1 ' , $ product ->getHasOptions ());
@@ -1142,6 +1142,47 @@ public function testValidateUrlKeys($importFile, $errorsCount)
1142
1142
}
1143
1143
}
1144
1144
1145
+ /**
1146
+ * Test import products without url keys will auto generate ones.
1147
+ *
1148
+ * @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
1149
+ * @magentoAppIsolation enabled
1150
+ */
1151
+ public function testImportWithoutUrlKeys ()
1152
+ {
1153
+ $ products = [
1154
+ 'simple1 ' => 'simple-1 ' ,
1155
+ 'simple2 ' => 'simple-2 ' ,
1156
+ 'simple3 ' => 'simple-3 '
1157
+ ];
1158
+ $ filesystem = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
1159
+ ->create (\Magento \Framework \Filesystem::class);
1160
+ $ directory = $ filesystem ->getDirectoryWrite (DirectoryList::ROOT );
1161
+ $ source = $ this ->objectManager ->create (
1162
+ \Magento \ImportExport \Model \Import \Source \Csv::class,
1163
+ [
1164
+ 'file ' => __DIR__ . '/_files/products_to_import_without_url_keys.csv ' ,
1165
+ 'directory ' => $ directory
1166
+ ]
1167
+ );
1168
+
1169
+ $ errors = $ this ->_model ->setParameters (
1170
+ ['behavior ' => \Magento \ImportExport \Model \Import::BEHAVIOR_APPEND , 'entity ' => 'catalog_product ' ]
1171
+ )
1172
+ ->setSource ($ source )
1173
+ ->validateData ();
1174
+
1175
+ $ this ->assertTrue ($ errors ->getErrorsCount () == 0 );
1176
+ $ this ->_model ->importData ();
1177
+
1178
+ $ productRepository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
1179
+ \Magento \Catalog \Api \ProductRepositoryInterface::class
1180
+ );
1181
+ foreach ($ products as $ productSku => $ productUrlKey ) {
1182
+ $ this ->assertEquals ($ productUrlKey , $ productRepository ->get ($ productSku )->getUrlKey ());
1183
+ }
1184
+ }
1185
+
1145
1186
/**
1146
1187
* @return array
1147
1188
*/
@@ -1235,7 +1276,7 @@ public function testProductWithLinks()
1235
1276
$ productId = $ resource ->getIdBySku ('simple4 ' );
1236
1277
/** @var \Magento\Catalog\Model\Product $product */
1237
1278
$ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
1238
- ' Magento\Catalog\Model\Product '
1279
+ \ Magento \Catalog \Model \Product::class
1239
1280
);
1240
1281
$ product ->load ($ productId );
1241
1282
$ productLinks = [
@@ -1285,7 +1326,7 @@ public function testExistingProductWithUrlKeys()
1285
1326
$ this ->_model ->importData ();
1286
1327
1287
1328
$ productRepository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
1288
- ' Magento\Catalog\Api\ProductRepositoryInterface '
1329
+ \ Magento \Catalog \Api \ProductRepositoryInterface::class
1289
1330
);
1290
1331
foreach ($ products as $ productSku => $ productUrlKey ) {
1291
1332
$ this ->assertEquals ($ productUrlKey , $ productRepository ->get ($ productSku )->getUrlKey ());
@@ -1325,7 +1366,7 @@ public function testProductWithUseConfigSettings()
1325
1366
foreach ($ products as $ sku => $ manageStockUseConfig ) {
1326
1367
/** @var \Magento\CatalogInventory\Model\StockRegistry $stockRegistry */
1327
1368
$ stockRegistry = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
1328
- ' Magento\CatalogInventory\Model\StockRegistry '
1369
+ \ Magento \CatalogInventory \Model \StockRegistry::class
1329
1370
);
1330
1371
$ stockItem = $ stockRegistry ->getStockItemBySku ($ sku );
1331
1372
$ this ->assertEquals ($ manageStockUseConfig , $ stockItem ->getUseConfigManageStock ());
0 commit comments