Skip to content

Commit e4ccdbb

Browse files
committed
ACP2E-3793: No store is available after redirecting to home page and checkout
1 parent df92deb commit e4ccdbb

File tree

1 file changed

+35
-0
lines changed
  • dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import

1 file changed

+35
-0
lines changed

dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/CustomerTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ public function testUpdateExistingCustomers(): void
497497
*
498498
* @magentoAppIsolation enabled
499499
* @magentoDbIsolation disabled
500+
* @magentoDataFixture deleteAllCustomers
500501
* @return void
501502
*/
502503
public function testCustomerIndexer(): void
@@ -510,6 +511,40 @@ public function testCustomerIndexer(): void
510511
$this->assertEquals(StateInterface::STATUS_INVALID, $statusAfterImport);
511512
}
512513

514+
public static function deleteAllCustomers(): void
515+
{
516+
//Do nothing. we just need the rollback method to be called
517+
}
518+
519+
public static function deleteAllCustomersRollback(): void
520+
{
521+
static::deleteAllCustomersInCsvFile(__DIR__ . '/_files/customers_with_gender_to_import.csv');
522+
}
523+
524+
private static function deleteAllCustomersInCsvFile(string $file): void
525+
{
526+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
527+
/** @var CustomerRepositoryInterface $repository */
528+
$repository = $objectManager->get(CustomerRepositoryInterface::class);
529+
$rows = $objectManager->get(\Magento\Framework\File\Csv::class)->getData($file);
530+
$header = array_shift($rows);
531+
if ($header === false) {
532+
return;
533+
}
534+
$emailIndex = array_search('email', $header);
535+
if ($emailIndex === false) {
536+
return;
537+
}
538+
foreach (array_column($rows, $emailIndex) as $email) {
539+
try {
540+
$customer = $repository->get(strtolower(trim($email)));
541+
$repository->delete($customer);
542+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
543+
continue;
544+
}
545+
}
546+
}
547+
513548
/**
514549
* Gets customer entity.
515550
*

0 commit comments

Comments
 (0)