@@ -924,6 +924,120 @@ public static function validateRowStoreViewCodeFieldDataProvider(): array
924
924
];
925
925
}
926
926
927
+ /**
928
+ * Test parsing different option's type with _parseCustomOptions() method.
929
+ *
930
+ * @param array $rowData
931
+ * @param array $responseData
932
+ *
933
+ * @return void
934
+ * @dataProvider validateParseCustomOptionsDataProvider
935
+ * @throws \ReflectionException
936
+ */
937
+ public function testValidateParseCustomOptions (array $ rowData , array $ responseData ): void
938
+ {
939
+ $ reflection = new \ReflectionClass (Option::class);
940
+ $ reflectionMethod = $ reflection ->getMethod ('_parseCustomOptions ' );
941
+ $ result = $ reflectionMethod ->invoke ($ this ->model , $ rowData );
942
+ $ this ->assertEquals ($ responseData , $ result );
943
+ }
944
+
945
+ /**
946
+ * Data provider for testValidateParseCustomOptions.
947
+ *
948
+ * @return array
949
+ */
950
+ public static function validateParseCustomOptionsDataProvider (): array
951
+ {
952
+ return [
953
+ 'file_type ' => [
954
+ '$rowData ' => [
955
+ 'custom_options ' => 'name=Test Field Title,type=file,required=1, '
956
+ . 'sku=1-text,price=12,file_extension=png,jpeg,jpg,gif,image_size_x=1024, '
957
+ . 'image_size_y=1024,price_type=fixed '
958
+ ],
959
+ '$responseData ' => [
960
+ 'custom_options ' => [
961
+ 'Test Field Title ' => [
962
+ [
963
+ 'name ' => 'Test Field Title ' ,
964
+ 'type ' => 'file ' ,
965
+ 'required ' => '1 ' ,
966
+ 'sku ' => '1-text ' ,
967
+ 'price ' => '12 ' ,
968
+ 'file_extension ' => 'png,jpeg,jpg,gif ' ,
969
+ 'image_size_x ' => '1024 ' ,
970
+ 'image_size_y ' => '1024 ' ,
971
+ 'price_type ' => 'fixed '
972
+ ]
973
+ ]
974
+ ]
975
+ ]
976
+ ],
977
+ 'drop_down ' => [
978
+ '$rowData ' => [
979
+ 'custom_options ' => 'name=Test Field Title,type=drop_down,required=0, '
980
+ . 'sku=1-text,price=10,price_type=fixed '
981
+ ],
982
+ '$responseData ' => [
983
+ 'custom_options ' => [
984
+ 'Test Field Title ' => [
985
+ [
986
+ 'name ' => 'Test Field Title ' ,
987
+ 'type ' => 'drop_down ' ,
988
+ 'required ' => '0 ' ,
989
+ 'sku ' => '1-text ' ,
990
+ 'price ' => '10 ' ,
991
+ 'price_type ' => 'fixed '
992
+ ]
993
+ ]
994
+ ]
995
+ ]
996
+ ],
997
+ 'area ' => [
998
+ '$rowData ' => [
999
+ 'custom_options ' => 'name=Test Field Title,type=area,required=1, '
1000
+ . 'sku=1-text,price=20,max_characters=150,price_type=fixed '
1001
+ ],
1002
+ '$responseData ' => [
1003
+ 'custom_options ' => [
1004
+ 'Test Field Title ' => [
1005
+ [
1006
+ 'name ' => 'Test Field Title ' ,
1007
+ 'type ' => 'area ' ,
1008
+ 'required ' => '1 ' ,
1009
+ 'sku ' => '1-text ' ,
1010
+ 'price ' => '20 ' ,
1011
+ 'max_characters ' => '150 ' ,
1012
+ 'price_type ' => 'fixed '
1013
+ ]
1014
+ ]
1015
+ ]
1016
+ ]
1017
+ ],
1018
+ 'date_time ' => [
1019
+ '$rowData ' => [
1020
+ 'custom_options ' => 'name=Test Field Title,type=date_time,required=0, '
1021
+ . 'sku=1-text,price=30,price_type=fixed '
1022
+ ],
1023
+ '$responseData ' => [
1024
+ 'custom_options ' => [
1025
+ 'Test Field Title ' => [
1026
+ [
1027
+ 'name ' => 'Test Field Title ' ,
1028
+ 'type ' => 'date_time ' ,
1029
+ 'required ' => '0 ' ,
1030
+ 'sku ' => '1-text ' ,
1031
+ 'price ' => '30 ' ,
1032
+ 'price_type ' => 'fixed '
1033
+ ]
1034
+ ]
1035
+ ]
1036
+ ]
1037
+ ]
1038
+ ];
1039
+ }
1040
+
927
1041
/**
928
1042
* Data provider of row data and errors.
929
1043
*
0 commit comments