@@ -924,6 +924,140 @@ public static function validateRowStoreViewCodeFieldDataProvider(): array
924924 ];
925925 }
926926
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+ 'field ' => [
998+ '$rowData ' => [
999+ 'custom_options ' => 'name=Test Field Title,type=field,required=1 '
1000+ . ';sku=1-text,price=0,price_type=fixed '
1001+ ],
1002+ '$responseData ' => [
1003+ 'custom_options ' => [
1004+ 'Test Field Title ' => [
1005+ [
1006+ 'name ' => 'Test Field Title ' ,
1007+ 'type ' => 'field ' ,
1008+ 'required ' => '1 ' ,
1009+ 'sku ' => '1-text ' ,
1010+ 'price ' => '0 ' ,
1011+ 'price_type ' => 'fixed '
1012+ ]
1013+ ]
1014+ ]
1015+ ]
1016+ ],
1017+ 'area ' => [
1018+ '$rowData ' => [
1019+ 'custom_options ' => 'name=Test Field Title,type=area,required=1, '
1020+ . 'sku=1-text,price=20,max_characters=150,price_type=fixed '
1021+ ],
1022+ '$responseData ' => [
1023+ 'custom_options ' => [
1024+ 'Test Field Title ' => [
1025+ [
1026+ 'name ' => 'Test Field Title ' ,
1027+ 'type ' => 'area ' ,
1028+ 'required ' => '1 ' ,
1029+ 'sku ' => '1-text ' ,
1030+ 'price ' => '20 ' ,
1031+ 'max_characters ' => '150 ' ,
1032+ 'price_type ' => 'fixed '
1033+ ]
1034+ ]
1035+ ]
1036+ ]
1037+ ],
1038+ 'date_time ' => [
1039+ '$rowData ' => [
1040+ 'custom_options ' => 'name=Test Field Title,type=date_time,required=0, '
1041+ . 'sku=1-text,price=30,price_type=fixed '
1042+ ],
1043+ '$responseData ' => [
1044+ 'custom_options ' => [
1045+ 'Test Field Title ' => [
1046+ [
1047+ 'name ' => 'Test Field Title ' ,
1048+ 'type ' => 'date_time ' ,
1049+ 'required ' => '0 ' ,
1050+ 'sku ' => '1-text ' ,
1051+ 'price ' => '30 ' ,
1052+ 'price_type ' => 'fixed '
1053+ ]
1054+ ]
1055+ ]
1056+ ]
1057+ ]
1058+ ];
1059+ }
1060+
9271061 /**
9281062 * Data provider of row data and errors.
9291063 *
0 commit comments