@@ -313,10 +313,7 @@ protected function setUp(): void
313
313
314
314
$ contextMock = $ this ->createPartialMock (
315
315
Context::class,
316
- ['getEventDispatcher ' , 'getCacheManager ' , 'getAppState ' , 'getActionValidator ' ],
317
- [],
318
- '' ,
319
- false
316
+ ['getEventDispatcher ' , 'getCacheManager ' , 'getAppState ' , 'getActionValidator ' ]
320
317
);
321
318
$ contextMock ->expects ($ this ->any ())->method ('getAppState ' )->willReturn ($ this ->appStateMock );
322
319
$ contextMock ->expects ($ this ->any ())
@@ -541,7 +538,7 @@ public function testGetStoreSingleSiteModelIds(
541
538
/**
542
539
* @return array
543
540
*/
544
- public function getSingleStoreIds ()
541
+ public function getSingleStoreIds (): array
545
542
{
546
543
return [
547
544
[
@@ -619,15 +616,15 @@ public function testGetCategoryCollectionCollectionNull($initCategoryCollection,
619
616
620
617
$ result = $ product ->getCategoryCollection ();
621
618
622
- $ productIdCachedActual = $ this ->getPropertyValue ($ product , '_productIdCached ' , $ productIdCached );
619
+ $ productIdCachedActual = $ this ->getPropertyValue ($ product , '_productIdCached ' );
623
620
$ this ->assertEquals ($ getIdResult , $ productIdCachedActual );
624
621
$ this ->assertEquals ($ initCategoryCollection , $ result );
625
622
}
626
623
627
624
/**
628
625
* @return array
629
626
*/
630
- public function getCategoryCollectionCollectionNullDataProvider ()
627
+ public function getCategoryCollectionCollectionNullDataProvider (): array
631
628
{
632
629
return [
633
630
[
@@ -742,7 +739,7 @@ public function testReindex($productChanged, $isScheduled, $productFlatCount, $c
742
739
/**
743
740
* @return array
744
741
*/
745
- public function getProductReindexProvider ()
742
+ public function getProductReindexProvider (): array
746
743
{
747
744
return [
748
745
'set 1 ' => [true , false , 1 , 1 ],
@@ -774,12 +771,18 @@ public function testPriceReindexCallback()
774
771
/**
775
772
* @dataProvider getIdentitiesProvider
776
773
* @param array $expected
777
- * @param array $origData
774
+ * @param array|null $origData
778
775
* @param array $data
779
776
* @param bool $isDeleted
780
- */
781
- public function testGetIdentities ($ expected , $ origData , $ data , $ isDeleted = false )
782
- {
777
+ * @param bool $isNew
778
+ */
779
+ public function testGetIdentities (
780
+ array $ expected ,
781
+ ?array $ origData ,
782
+ array $ data ,
783
+ bool $ isDeleted = false ,
784
+ bool $ isNew = false
785
+ ) {
783
786
$ this ->model ->setIdFieldName ('id ' );
784
787
if (is_array ($ origData )) {
785
788
foreach ($ origData as $ key => $ value ) {
@@ -790,13 +793,14 @@ public function testGetIdentities($expected, $origData, $data, $isDeleted = fals
790
793
$ this ->model ->setData ($ key , $ value );
791
794
}
792
795
$ this ->model ->isDeleted ($ isDeleted );
796
+ $ this ->model ->isObjectNew ($ isNew );
793
797
$ this ->assertEquals ($ expected , $ this ->model ->getIdentities ());
794
798
}
795
799
796
800
/**
797
801
* @return array
798
802
*/
799
- public function getIdentitiesProvider ()
803
+ public function getIdentitiesProvider (): array
800
804
{
801
805
$ extensionAttributesMock = $ this ->getMockBuilder (ExtensionAttributesInterface::class)
802
806
->disableOriginalConstructor ()
@@ -814,60 +818,61 @@ public function getIdentitiesProvider()
814
818
['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ]],
815
819
],
816
820
'new product ' => $ this ->getNewProductProviderData (),
821
+ 'new disabled product ' => $ this ->getNewDisabledProductProviderData (),
817
822
'status and category change ' => [
818
823
[0 => 'cat_p_1 ' , 1 => 'cat_c_p_1 ' , 2 => 'cat_c_p_2 ' ],
819
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 2 ],
824
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_DISABLED ],
820
825
[
821
826
'id ' => 1 ,
822
827
'name ' => 'value ' ,
823
828
'category_ids ' => [2 ],
824
- 'status ' => 1 ,
829
+ 'status ' => Status:: STATUS_ENABLED ,
825
830
'affected_category_ids ' => [1 , 2 ],
826
831
'is_changed_categories ' => true
827
832
],
828
833
],
829
834
'status change only ' => [
830
835
[0 => 'cat_p_1 ' , 1 => 'cat_c_p_7 ' ],
831
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [7 ], 'status ' => 1 ],
832
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [7 ], 'status ' => 2 ],
836
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [7 ], 'status ' => Status:: STATUS_ENABLED ],
837
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [7 ], 'status ' => Status:: STATUS_DISABLED ],
833
838
],
834
839
'status changed, category unassigned ' => $ this ->getStatusAndCategoryChangesData (),
835
840
'no status changes ' => [
836
841
[0 => 'cat_p_1 ' ],
837
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 1 ],
838
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 1 ],
842
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_ENABLED ],
843
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_ENABLED ],
839
844
],
840
845
'no stock status changes ' => [
841
846
[0 => 'cat_p_1 ' ],
842
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 1 ],
847
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_ENABLED ],
843
848
[
844
849
'id ' => 1 ,
845
850
'name ' => 'value ' ,
846
851
'category_ids ' => [1 ],
847
- 'status ' => 1 ,
852
+ 'status ' => Status:: STATUS_ENABLED ,
848
853
'stock_data ' => ['is_in_stock ' => true ],
849
854
ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => $ extensionAttributesMock ,
850
855
],
851
856
],
852
857
'no stock status data 1 ' => [
853
858
[0 => 'cat_p_1 ' ],
854
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 1 ],
859
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_ENABLED ],
855
860
[
856
861
'id ' => 1 ,
857
862
'name ' => 'value ' ,
858
863
'category_ids ' => [1 ],
859
- 'status ' => 1 ,
864
+ 'status ' => Status:: STATUS_ENABLED ,
860
865
ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => $ extensionAttributesMock ,
861
866
],
862
867
],
863
868
'no stock status data 2 ' => [
864
869
[0 => 'cat_p_1 ' ],
865
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 1 ],
870
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_ENABLED ],
866
871
[
867
872
'id ' => 1 ,
868
873
'name ' => 'value ' ,
869
874
'category_ids ' => [1 ],
870
- 'status ' => 1 ,
875
+ 'status ' => Status:: STATUS_ENABLED ,
871
876
'stock_data ' => ['is_in_stock ' => true ],
872
877
],
873
878
],
@@ -878,16 +883,16 @@ public function getIdentitiesProvider()
878
883
/**
879
884
* @return array
880
885
*/
881
- private function getStatusAndCategoryChangesData ()
886
+ private function getStatusAndCategoryChangesData (): array
882
887
{
883
888
return [
884
889
[0 => 'cat_p_1 ' , 1 => 'cat_c_p_5 ' ],
885
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [5 ], 'status ' => 2 ],
890
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [5 ], 'status ' => Status:: STATUS_DISABLED ],
886
891
[
887
892
'id ' => 1 ,
888
893
'name ' => 'value ' ,
889
894
'category_ids ' => [],
890
- 'status ' => 1 ,
895
+ 'status ' => Status:: STATUS_ENABLED ,
891
896
'is_changed_categories ' => true ,
892
897
'affected_category_ids ' => [5 ]
893
898
],
@@ -897,7 +902,7 @@ private function getStatusAndCategoryChangesData()
897
902
/**
898
903
* @return array
899
904
*/
900
- private function getNewProductProviderData ()
905
+ private function getNewProductProviderData (): array
901
906
{
902
907
return [
903
908
['cat_p_1 ' , 'cat_c_p_1 ' ],
@@ -908,24 +913,47 @@ private function getNewProductProviderData()
908
913
'category_ids ' => [1 ],
909
914
'affected_category_ids ' => [1 ],
910
915
'is_changed_categories ' => true
911
- ]
916
+ ],
917
+ false ,
918
+ true ,
919
+ ];
920
+ }
921
+
922
+ /**
923
+ * @return array
924
+ */
925
+ private function getNewDisabledProductProviderData (): array
926
+ {
927
+ return [
928
+ ['cat_p_1 ' ],
929
+ null ,
930
+ [
931
+ 'id ' => 1 ,
932
+ 'name ' => 'value ' ,
933
+ 'category_ids ' => [1 ],
934
+ 'status ' => Status::STATUS_DISABLED ,
935
+ 'affected_category_ids ' => [1 ],
936
+ 'is_changed_categories ' => true
937
+ ],
938
+ false ,
939
+ true ,
912
940
];
913
941
}
914
942
915
943
/**
916
944
* @param MockObject $extensionAttributesMock
917
945
* @return array
918
946
*/
919
- private function getStatusStockProviderData ($ extensionAttributesMock )
947
+ private function getStatusStockProviderData ($ extensionAttributesMock ): array
920
948
{
921
949
return [
922
950
[0 => 'cat_p_1 ' , 1 => 'cat_c_p_1 ' ],
923
- ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => 1 ],
951
+ ['id ' => 1 , 'name ' => 'value ' , 'category_ids ' => [1 ], 'status ' => Status:: STATUS_ENABLED ],
924
952
[
925
953
'id ' => 1 ,
926
954
'name ' => 'value ' ,
927
955
'category_ids ' => [1 ],
928
- 'status ' => 1 ,
956
+ 'status ' => Status:: STATUS_ENABLED ,
929
957
'stock_data ' => ['is_in_stock ' => false ],
930
958
ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => $ extensionAttributesMock ,
931
959
],
@@ -1440,7 +1468,7 @@ public function testGetCustomAttributes()
1440
1468
/**
1441
1469
* @return array
1442
1470
*/
1443
- public function priceDataProvider ()
1471
+ public function priceDataProvider (): array
1444
1472
{
1445
1473
return [
1446
1474
'receive empty array ' => [[]],
0 commit comments