99use Magento \Customer \Api \CustomerRepositoryInterface ;
1010use Magento \Customer \Api \Data \CustomerInterface ;
1111use Magento \Customer \Model \Indexer \Processor ;
12+ use Magento \Customer \Model \ResourceModel \Customer \Collection as CustomerCollection ;
1213use Magento \Framework \App \Filesystem \DirectoryList ;
1314use Magento \Framework \Exception \NoSuchEntityException ;
1415use Magento \Framework \Filesystem \Directory \Write as DirectoryWrite ;
1516use Magento \Framework \Filesystem \File \WriteFactory ;
1617use Magento \Framework \Indexer \StateInterface ;
1718use Magento \Framework \ObjectManagerInterface ;
19+ use Magento \Framework \Registry ;
1820use Magento \ImportExport \Model \Import ;
1921use Magento \ImportExport \Model \Import \Source \CsvFactory ;
2022use Magento \TestFramework \Helper \Bootstrap ;
@@ -95,6 +97,24 @@ protected function setUp(): void
9597 $ this ->csvFactory = $ this ->objectManager ->get (CsvFactory::class);
9698 }
9799
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+
98118 /**
99119 * Test importData() method
100120 *
@@ -113,9 +133,9 @@ public function testImportData()
113133
114134 $ existingCustomer = $ this ->getCustomer ('CharlesTAlston@teleworm.us ' , 1 );
115135
116- /** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
136+ /** @var $customersCollection CustomerCollection */
117137 $ customersCollection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
118- \ Magento \ Customer \ Model \ ResourceModel \ Customer \Collection ::class
138+ CustomerCollection ::class
119139 );
120140 $ customersCollection ->addAttributeToSelect ('firstname ' , 'inner ' )->addAttributeToSelect ('lastname ' , 'inner ' );
121141
@@ -276,9 +296,9 @@ public function testImportDataWithOneAdditionalColumn(): void
276296 $ existingCustomer ->setWebsiteId (1 );
277297 $ existingCustomer = $ existingCustomer ->loadByEmail ('CharlesTAlston@teleworm.us ' );
278298
279- /** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
299+ /** @var $customersCollection CustomerCollection */
280300 $ customersCollection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
281- \ Magento \ Customer \ Model \ ResourceModel \ Customer \Collection ::class
301+ CustomerCollection ::class
282302 );
283303 $ customersCollection ->resetData ();
284304 $ customersCollection ->clear ();
@@ -346,9 +366,9 @@ public function testDeleteData()
346366 $ this ->directoryWrite
347367 );
348368
349- /** @var $customerCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
369+ /** @var $customerCollection CustomerCollection */
350370 $ customerCollection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
351- \ Magento \ Customer \ Model \ ResourceModel \ Customer \Collection ::class
371+ CustomerCollection ::class
352372 );
353373 $ this ->assertEquals (3 , $ customerCollection ->count (), 'Count of existing customers are invalid ' );
354374
0 commit comments