41
41
use Magento \Store \Model \StoreManager ;
42
42
use PHPUnit \Framework \MockObject \MockObject ;
43
43
use PHPUnit \Framework \TestCase ;
44
+ use ReflectionException ;
44
45
45
46
/**
46
47
* Tests Magento\CustomerImportExport\Model\Import\Address.
@@ -587,64 +588,45 @@ public function validateDeleteAddressEntities(array $deleteRowIds)
587
588
}
588
589
589
590
/**
590
- * @dataProvider importDataProvider
591
- * @param $data
592
591
* @return void
593
- * @throws \ ReflectionException
592
+ * @throws ReflectionException
594
593
*/
595
- public function testImportData ($ data ): void
594
+ public function testImportData (): void
596
595
{
597
- $ this ->dataSourceModel ->expects ($ this ->atLeastOnce ())
596
+ $ this ->dataSourceModel ->expects ($ this ->any ())
598
597
->method ('getNextUniqueBunch ' )
599
- ->willReturnOnConsecutiveCalls ($ data );
600
-
598
+ ->willReturnOnConsecutiveCalls (
599
+ [
'_email ' =>
'[email protected] ' ],
600
+ ['_website ' => 'base ' ],
601
+ ['_store ' => 'admin ' ],
602
+ ['_entity_id ' => 'abc ' ],
603
+ null ,
604
+ [
'_email ' =>
'[email protected] ' ],
605
+ ['_store ' => 'admin ' ],
606
+ ['_entity_id ' => 'abc ' ]
607
+ );
601
608
$ this ->dataSourceModel ->method ('getIterator ' )->willReturnSelf ();
602
609
$ this ->setProtectedProperty ($ this ->_model , '_websiteCodeToId ' , [
603
610
'base ' => 1 ,
604
611
]);
605
612
$ method = $ this ->setMethodAccessible ('_importData ' );
606
613
$ 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
-
619
- '_website ' => 'base ' ,
620
- '_store ' => 'admin ' ,
621
- '_entity_id ' => 'abc '
622
- ]
623
- ],
624
- [
625
- [
626
-
627
- '_store ' => 'admin ' ,
628
- '_entity_id ' => 'abc '
629
- ]
630
- ]
631
- ];
614
+ $ result = $ method ->invokeArgs ($ this ->_model , []);
615
+ $ this ->assertTrue ($ result );
632
616
}
633
617
634
618
/**
635
- * Invoke any method of class AdvancedPricing .
619
+ * Invoke any method of class.
636
620
*
637
621
* @param string $method
638
622
*
639
623
* @return mixed
640
- * @throws \ ReflectionException
624
+ * @throws ReflectionException
641
625
*/
642
- private function setMethodAccessible ($ method )
626
+ private function setMethodAccessible (string $ method ): mixed
643
627
{
644
628
$ class = new \ReflectionClass (Address::class);
645
- $ method = $ class ->getMethod ($ method );
646
- $ method ->setAccessible (true );
647
- return $ method ;
629
+ return $ class ->getMethod ($ method );
648
630
}
649
631
650
632
/**
@@ -655,13 +637,12 @@ private function setMethodAccessible($method)
655
637
* @param $value - new value of the property being modified
656
638
*
657
639
* @return void
658
- * @throws \ ReflectionException
640
+ * @throws ReflectionException
659
641
*/
660
- private function setProtectedProperty ($ object , $ property , $ value )
642
+ private function setProtectedProperty ($ object , $ property , $ value ): void
661
643
{
662
644
$ reflection = new \ReflectionClass ($ object );
663
645
$ reflection_property = $ reflection ->getProperty ($ property );
664
- $ reflection_property ->setAccessible (true );
665
646
$ reflection_property ->setValue ($ object , $ value );
666
647
}
667
648
}
0 commit comments