@@ -671,63 +671,6 @@ public function getInvalidNumberOfDownloads()
671
671
];
672
672
}
673
673
674
- /**
675
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
676
- */
677
- public function testCreateThrowsExceptionIfTargetProductTypeIsNotDownloadable ()
678
- {
679
- $ this ->expectException (\Exception::class);
680
- $ this ->expectExceptionMessage (
681
- 'The product needs to be the downloadable type. Verify the product and try again. '
682
- );
683
-
684
- $ this ->createServiceInfo ['rest ' ]['resourcePath ' ] = '/V1/products/simple/downloadable-links ' ;
685
- $ requestData = [
686
- 'isGlobalScopeContent ' => false ,
687
- 'sku ' => 'simple ' ,
688
- 'link ' => [
689
- 'title ' => 'Link Title ' ,
690
- 'sort_order ' => 50 ,
691
- 'price ' => 200 ,
692
- 'is_shareable ' => 0 ,
693
- 'number_of_downloads ' => 10 ,
694
- 'sample_type ' => 'url ' ,
695
- 'sample_url ' => 'http://example.com/ ' ,
696
- 'link_type ' => 'url ' ,
697
- 'link_url ' => 'http://example.com/ ' ,
698
- ],
699
- ];
700
- $ this ->_webApiCall ($ this ->createServiceInfo , $ requestData );
701
- }
702
-
703
- /**
704
- */
705
- public function testCreateThrowsExceptionIfTargetProductDoesNotExist ()
706
- {
707
- $ this ->expectException (\Exception::class);
708
- $ this ->expectExceptionMessage (
709
- 'The product that was requested doesn \'t exist. Verify the product and try again. '
710
- );
711
-
712
- $ this ->createServiceInfo ['rest ' ]['resourcePath ' ] = '/V1/products/wrong-sku/downloadable-links ' ;
713
- $ requestData = [
714
- 'isGlobalScopeContent ' => false ,
715
- 'sku ' => 'wrong-sku ' ,
716
- 'link ' => [
717
- 'title ' => 'Link Title ' ,
718
- 'sort_order ' => 15 ,
719
- 'price ' => 200 ,
720
- 'is_shareable ' => 1 ,
721
- 'number_of_downloads ' => 100 ,
722
- 'sample_type ' => 'url ' ,
723
- 'sample_url ' => 'http://example.com/ ' ,
724
- 'link_type ' => 'url ' ,
725
- 'link_url ' => 'http://example.com/ ' ,
726
- ],
727
- ];
728
- $ this ->_webApiCall ($ this ->createServiceInfo , $ requestData );
729
- }
730
-
731
674
/**
732
675
* @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php
733
676
*/
@@ -964,6 +907,61 @@ public function testDelete()
964
907
$ this ->assertNull ($ link );
965
908
}
966
909
910
+ /**
911
+ * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable_with_files.php
912
+ * @dataProvider getListForAbsentProductProvider
913
+ */
914
+ public function testGetList ($ urlTail , $ method , $ expectations )
915
+ {
916
+ $ sku = 'downloadable-product ' ;
917
+
918
+ $ serviceInfo = [
919
+ 'rest ' => [
920
+ 'resourcePath ' => '/V1/products/ ' . $ sku . $ urlTail ,
921
+ 'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_GET ,
922
+ ],
923
+ 'soap ' => [
924
+ 'service ' => 'downloadableLinkRepositoryV1 ' ,
925
+ 'serviceVersion ' => 'V1 ' ,
926
+ 'operation ' => 'downloadableLinkRepositoryV1 ' . $ method ,
927
+ ],
928
+ ];
929
+
930
+ $ requestData = ['sku ' => $ sku ];
931
+
932
+ $ list = $ this ->_webApiCall ($ serviceInfo , $ requestData );
933
+
934
+ $ this ->assertCount (1 , $ list );
935
+
936
+ $ link = reset ($ list );
937
+ foreach ($ expectations ['fields ' ] as $ index => $ value ) {
938
+ $ this ->assertEquals ($ value , $ link [$ index ]);
939
+ }
940
+ $ this ->assertStringContainsString ('jellyfish_1_3.jpg ' , $ link ['sample_file ' ]);
941
+ }
942
+
943
+ public function getListForAbsentProductProvider ()
944
+ {
945
+ $ linkExpectation = [
946
+ 'fields ' => [
947
+ 'is_shareable ' => 2 ,
948
+ 'price ' => 15 ,
949
+ 'number_of_downloads ' => 15 ,
950
+ 'sample_type ' => 'file ' ,
951
+ 'link_file ' => '/j/e/jellyfish_2_4.jpg ' ,
952
+ 'link_type ' => 'file '
953
+ ]
954
+ ];
955
+
956
+ return [
957
+ 'links ' => [
958
+ '/downloadable-links ' ,
959
+ 'GetList ' ,
960
+ $ linkExpectation ,
961
+ ],
962
+ ];
963
+ }
964
+
967
965
/**
968
966
*/
969
967
public function testDeleteThrowsExceptionIfThereIsNoDownloadableLinkWithGivenId ()
@@ -1040,57 +1038,59 @@ public function testGetListForSimpleProduct($urlTail, $method)
1040
1038
}
1041
1039
1042
1040
/**
1043
- * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable_with_files.php
1044
- * @dataProvider getListForAbsentProductProvider
1041
+ * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
1045
1042
*/
1046
- public function testGetList ( $ urlTail , $ method , $ expectations )
1043
+ public function testCreateThrowsExceptionIfTargetProductTypeIsNotDownloadable ( )
1047
1044
{
1048
- $ sku = 'downloadable-product ' ;
1045
+ $ this ->expectException (\Exception::class);
1046
+ $ this ->expectExceptionMessage (
1047
+ 'The product needs to be the downloadable type. Verify the product and try again. '
1048
+ );
1049
1049
1050
- $ serviceInfo = [
1051
- 'rest ' => [
1052
- 'resourcePath ' => '/V1/products/ ' . $ sku . $ urlTail ,
1053
- 'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_GET ,
1054
- ],
1055
- 'soap ' => [
1056
- 'service ' => 'downloadableLinkRepositoryV1 ' ,
1057
- 'serviceVersion ' => 'V1 ' ,
1058
- 'operation ' => 'downloadableLinkRepositoryV1 ' . $ method ,
1050
+ $ this ->createServiceInfo ['rest ' ]['resourcePath ' ] = '/V1/products/simple/downloadable-links ' ;
1051
+ $ requestData = [
1052
+ 'isGlobalScopeContent ' => false ,
1053
+ 'sku ' => 'simple ' ,
1054
+ 'link ' => [
1055
+ 'title ' => 'Link Title ' ,
1056
+ 'sort_order ' => 50 ,
1057
+ 'price ' => 200 ,
1058
+ 'is_shareable ' => 0 ,
1059
+ 'number_of_downloads ' => 10 ,
1060
+ 'sample_type ' => 'url ' ,
1061
+ 'sample_url ' => 'http://example.com/ ' ,
1062
+ 'link_type ' => 'url ' ,
1063
+ 'link_url ' => 'http://example.com/ ' ,
1059
1064
],
1060
1065
];
1061
-
1062
- $ requestData = ['sku ' => $ sku ];
1063
-
1064
- $ list = $ this ->_webApiCall ($ serviceInfo , $ requestData );
1065
-
1066
- $ this ->assertCount (1 , $ list );
1067
-
1068
- $ link = reset ($ list );
1069
- foreach ($ expectations ['fields ' ] as $ index => $ value ) {
1070
- $ this ->assertEquals ($ value , $ link [$ index ]);
1071
- }
1072
- $ this ->assertStringContainsString ('jellyfish_1_3.jpg ' , $ link ['sample_file ' ]);
1066
+ $ this ->_webApiCall ($ this ->createServiceInfo , $ requestData );
1073
1067
}
1074
1068
1075
- public function getListForAbsentProductProvider ()
1069
+ /**
1070
+ */
1071
+ public function testCreateThrowsExceptionIfTargetProductDoesNotExist ()
1076
1072
{
1077
- $ linkExpectation = [
1078
- 'fields ' => [
1079
- 'is_shareable ' => 2 ,
1080
- 'price ' => 15 ,
1081
- 'number_of_downloads ' => 15 ,
1082
- 'sample_type ' => 'file ' ,
1083
- 'link_file ' => '/j/e/jellyfish_2_4.jpg ' ,
1084
- 'link_type ' => 'file '
1085
- ]
1086
- ];
1073
+ $ this ->expectException (\Exception::class);
1074
+ $ this ->expectExceptionMessage (
1075
+ 'The product that was requested doesn \'t exist. Verify the product and try again. '
1076
+ );
1087
1077
1088
- return [
1089
- 'links ' => [
1090
- '/downloadable-links ' ,
1091
- 'GetList ' ,
1092
- $ linkExpectation ,
1078
+ $ this ->createServiceInfo ['rest ' ]['resourcePath ' ] = '/V1/products/wrong-sku/downloadable-links ' ;
1079
+ $ requestData = [
1080
+ 'isGlobalScopeContent ' => false ,
1081
+ 'sku ' => 'wrong-sku ' ,
1082
+ 'link ' => [
1083
+ 'title ' => 'Link Title ' ,
1084
+ 'sort_order ' => 15 ,
1085
+ 'price ' => 200 ,
1086
+ 'is_shareable ' => 1 ,
1087
+ 'number_of_downloads ' => 100 ,
1088
+ 'sample_type ' => 'url ' ,
1089
+ 'sample_url ' => 'http://example.com/ ' ,
1090
+ 'link_type ' => 'url ' ,
1091
+ 'link_url ' => 'http://example.com/ ' ,
1093
1092
],
1094
1093
];
1094
+ $ this ->_webApiCall ($ this ->createServiceInfo , $ requestData );
1095
1095
}
1096
1096
}
0 commit comments