File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
dev/tests/integration/testsuite/Magento/Customer/_files/import_export Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 21
21
/** @var $customer Customer */
22
22
$ customer = $ objectManager ->create (Customer::class);
23
23
24
- $ emailsToDelete = [
24
+ $ customersToRemove = [
25
25
'customer@example.com ' ,
26
26
'julie.worrell@example.com ' ,
27
27
'david.lamar@example.com ' ,
28
28
];
29
- foreach ($ emailsToDelete as $ email ) {
29
+
30
+ /**
31
+ * @var Magento\Customer\Api\CustomerRepositoryInterface
32
+ */
33
+ $ customerRepository = $ objectManager ->create (\Magento \Customer \Api \CustomerRepositoryInterface::class);
34
+
35
+ foreach ($ customersToRemove as $ customerEmail ) {
30
36
try {
31
- $ customer ->loadByEmail ($ email )->delete ();
32
- } catch (\Exception $ e ) {
37
+ $ customer = $ customerRepository ->get ($ customerEmail );
38
+ $ customerRepository ->delete ($ customer );
39
+ } catch (\Magento \Framework \Exception \NoSuchEntityException $ exception ) {
40
+ /**
41
+ * Tests which are wrapped with MySQL transaction clear all data by transaction rollback.
42
+ */
43
+ continue ;
33
44
}
34
45
}
46
+
35
47
$ registry ->unregister ('isSecureArea ' );
36
48
$ registry ->register ('isSecureArea ' , false );
37
49
$ registry ->unregister ('_fixture/Magento_ImportExport_Customer_Collection ' );
You can’t perform that action at this time.
0 commit comments