9
9
use Magento \Customer \Api \CustomerRepositoryInterface ;
10
10
use Magento \Customer \Api \Data \CustomerInterface ;
11
11
use Magento \Customer \Model \Indexer \Processor ;
12
+ use Magento \Customer \Model \ResourceModel \Customer \Collection as CustomerCollection ;
12
13
use Magento \Framework \App \Filesystem \DirectoryList ;
13
14
use Magento \Framework \Exception \NoSuchEntityException ;
14
15
use Magento \Framework \Filesystem \Directory \Write as DirectoryWrite ;
15
16
use Magento \Framework \Filesystem \File \WriteFactory ;
16
17
use Magento \Framework \Indexer \StateInterface ;
17
18
use Magento \Framework \ObjectManagerInterface ;
19
+ use Magento \Framework \Registry ;
18
20
use Magento \ImportExport \Model \Import ;
19
21
use Magento \ImportExport \Model \Import \Source \CsvFactory ;
20
22
use Magento \TestFramework \Helper \Bootstrap ;
@@ -95,6 +97,24 @@ protected function setUp(): void
95
97
$ this ->csvFactory = $ this ->objectManager ->get (CsvFactory::class);
96
98
}
97
99
100
+ /**
101
+ * @inheritdoc
102
+ */
103
+ protected function tearDown (): void
104
+ {
105
+ $ registry = $ this ->objectManager ->get (Registry::class);
106
+ $ registry ->unregister ('isSecureArea ' );
107
+ $ registry ->register ('isSecureArea ' , true );
108
+ try {
109
+ $ customerCollection = $ this ->objectManager ->create (CustomerCollection::class);
110
+ $ customerCollection ->delete ();
111
+ } finally {
112
+ $ registry ->unregister ('isSecureArea ' );
113
+ $ registry ->register ('isSecureArea ' , false );
114
+ }
115
+ parent ::tearDown ();
116
+ }
117
+
98
118
/**
99
119
* Test importData() method
100
120
*
@@ -113,9 +133,9 @@ public function testImportData()
113
133
114
134
$ existingCustomer =
$ this ->
getCustomer (
'[email protected] ' ,
1 );
115
135
116
- /** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
136
+ /** @var $customersCollection CustomerCollection */
117
137
$ customersCollection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
118
- \ Magento \ Customer \ Model \ ResourceModel \ Customer \Collection ::class
138
+ CustomerCollection ::class
119
139
);
120
140
$ customersCollection ->addAttributeToSelect ('firstname ' , 'inner ' )->addAttributeToSelect ('lastname ' , 'inner ' );
121
141
@@ -276,9 +296,9 @@ public function testImportDataWithOneAdditionalColumn(): void
276
296
$ existingCustomer ->setWebsiteId (1 );
277
297
$ existingCustomer =
$ existingCustomer->
loadByEmail (
'[email protected] ' );
278
298
279
- /** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
299
+ /** @var $customersCollection CustomerCollection */
280
300
$ customersCollection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
281
- \ Magento \ Customer \ Model \ ResourceModel \ Customer \Collection ::class
301
+ CustomerCollection ::class
282
302
);
283
303
$ customersCollection ->resetData ();
284
304
$ customersCollection ->clear ();
@@ -346,9 +366,9 @@ public function testDeleteData()
346
366
$ this ->directoryWrite
347
367
);
348
368
349
- /** @var $customerCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
369
+ /** @var $customerCollection CustomerCollection */
350
370
$ customerCollection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
351
- \ Magento \ Customer \ Model \ ResourceModel \ Customer \Collection ::class
371
+ CustomerCollection ::class
352
372
);
353
373
$ this ->assertEquals (3 , $ customerCollection ->count (), 'Count of existing customers are invalid ' );
354
374
0 commit comments