@@ -1290,18 +1290,14 @@ public function testProductPositionInCategory()
1290
1290
*/
1291
1291
public function testNewProductPositionInCategory ()
1292
1292
{
1293
- $ categoryId = 333 ;
1294
-
1295
- $ filesystem = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
1296
- \Magento \Framework \Filesystem::class
1297
- );
1293
+ $ filesystem = $ this ->objectManager ->create (\Magento \Framework \Filesystem::class);
1298
1294
1299
1295
$ directory = $ filesystem ->getDirectoryWrite (DirectoryList::ROOT );
1300
1296
$ source = $ this ->objectManager ->create (
1301
1297
\Magento \ImportExport \Model \Import \Source \Csv::class,
1302
1298
[
1303
1299
'file ' => __DIR__ . '/_files/product_to_import_with_category.csv ' ,
1304
- 'directory ' => $ directory
1300
+ 'directory ' => $ directory,
1305
1301
]
1306
1302
);
1307
1303
$ errors = $ this ->_model ->setSource (
@@ -1313,29 +1309,17 @@ public function testNewProductPositionInCategory()
1313
1309
]
1314
1310
)->validateData ();
1315
1311
1316
- $ this ->assertTrue ($ errors ->getErrorsCount () == 0 );
1312
+ $ this ->assertTrue ($ errors ->getErrorsCount () === 0 );
1317
1313
$ this ->_model ->importData ();
1318
1314
1319
- /** @var \Magento\Framework\App\ResourceConnection $resourceConnection */
1320
- $ resourceConnection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
1321
- \Magento \Framework \App \ResourceConnection::class
1322
- );
1323
- $ categoryProductstableName = $ resourceConnection ->getTableName ('catalog_category_product ' );
1324
- $ productEntitiesTableName = $ resourceConnection ->getTableName ('catalog_product_entity ' );
1325
- $ select = $ resourceConnection ->getConnection ()
1326
- ->select ()
1327
- ->from (['category_products ' => $ categoryProductstableName ])
1328
- ->join (
1329
- ['product_entities ' => $ productEntitiesTableName ],
1330
- 'product_entities.entity_id = category_products.product_id ' ,
1331
- ''
1332
- )
1333
- ->where ('category_products.category_id = ? ' , $ categoryId )
1334
- ->where ('product_entities.sku = "simpleImported" ' );
1335
- $ importedItem = $ resourceConnection ->getConnection ()->fetchRow ($ select );
1336
- $ this ->assertTrue (is_array ($ importedItem ));
1337
- $ this ->assertNotEmpty ($ importedItem );
1338
- $ this ->assertEquals (0 , $ importedItem ['position ' ]);
1315
+ /** @var ProductRepositoryInterface $productRepository */
1316
+ $ productRepository = $ this ->objectManager ->create (ProductRepositoryInterface::class);
1317
+ /** @var ProductInterface $product */
1318
+ $ product = $ productRepository ->get ('simpleImported ' );
1319
+ $ categoryLinks = $ product ->getExtensionAttributes ('category_links ' )->getCategoryLinks ();
1320
+ $ position = $ categoryLinks [0 ]->getPosition ();
1321
+
1322
+ $ this ->assertEquals (0 , $ position );
1339
1323
}
1340
1324
1341
1325
/**
0 commit comments