4141use Magento \Store \Model \StoreManager ;
4242use PHPUnit \Framework \MockObject \MockObject ;
4343use PHPUnit \Framework \TestCase ;
44+ use ReflectionException ;
4445
4546/**
4647 * Tests Magento\CustomerImportExport\Model\Import\Address.
@@ -587,64 +588,45 @@ public function validateDeleteAddressEntities(array $deleteRowIds)
587588 }
588589
589590 /**
590- * @dataProvider importDataProvider
591- * @param $data
592591 * @return void
593- * @throws \ ReflectionException
592+ * @throws ReflectionException
594593 */
595- public function testImportData ($ data ): void
594+ public function testImportData (): void
596595 {
597- $ this ->dataSourceModel ->expects ($ this ->atLeastOnce ())
596+ $ this ->dataSourceModel ->expects ($ this ->any ())
598597 ->method ('getNextUniqueBunch ' )
599- ->willReturnOnConsecutiveCalls ($ data );
600-
598+ ->willReturnOnConsecutiveCalls (
599+ ['_email ' => 'jondoe@example.com ' ],
600+ ['_website ' => 'base ' ],
601+ ['_store ' => 'admin ' ],
602+ ['_entity_id ' => 'abc ' ],
603+ null ,
604+ ['_email ' => 'jondoe@example.com ' ],
605+ ['_store ' => 'admin ' ],
606+ ['_entity_id ' => 'abc ' ]
607+ );
601608 $ this ->dataSourceModel ->method ('getIterator ' )->willReturnSelf ();
602609 $ this ->setProtectedProperty ($ this ->_model , '_websiteCodeToId ' , [
603610 'base ' => 1 ,
604611 ]);
605612 $ method = $ this ->setMethodAccessible ('_importData ' );
606613 $ this ->connection ->method ('insertMultiple ' )->willReturnSelf ();
607- $ method ->invokeArgs ($ this ->_model , []);
608- }
609-
610- /**
611- * @return array
612- */
613- public function importDataProvider (): array
614- {
615- return [
616- [
617- [
618- '_email ' => 'jondoe@example.com ' ,
619- '_website ' => 'base ' ,
620- '_store ' => 'admin ' ,
621- '_entity_id ' => 'abc '
622- ]
623- ],
624- [
625- [
626- '_email ' => 'jondoe@example.com ' ,
627- '_store ' => 'admin ' ,
628- '_entity_id ' => 'abc '
629- ]
630- ]
631- ];
614+ $ result = $ method ->invokeArgs ($ this ->_model , []);
615+ $ this ->assertTrue ($ result );
632616 }
633617
634618 /**
635- * Invoke any method of class AdvancedPricing .
619+ * Invoke any method of class.
636620 *
637621 * @param string $method
638622 *
639623 * @return mixed
640- * @throws \ ReflectionException
624+ * @throws ReflectionException
641625 */
642- private function setMethodAccessible ($ method )
626+ private function setMethodAccessible (string $ method ): mixed
643627 {
644628 $ class = new \ReflectionClass (Address::class);
645- $ method = $ class ->getMethod ($ method );
646- $ method ->setAccessible (true );
647- return $ method ;
629+ return $ class ->getMethod ($ method );
648630 }
649631
650632 /**
@@ -655,13 +637,12 @@ private function setMethodAccessible($method)
655637 * @param $value - new value of the property being modified
656638 *
657639 * @return void
658- * @throws \ ReflectionException
640+ * @throws ReflectionException
659641 */
660- private function setProtectedProperty ($ object , $ property , $ value )
642+ private function setProtectedProperty ($ object , $ property , $ value ): void
661643 {
662644 $ reflection = new \ReflectionClass ($ object );
663645 $ reflection_property = $ reflection ->getProperty ($ property );
664- $ reflection_property ->setAccessible (true );
665646 $ reflection_property ->setValue ($ object , $ value );
666647 }
667648}
0 commit comments