1
1
<?php
2
2
3
+ namespace CurlTest ;
4
+
3
5
use \Curl \Curl ;
4
6
use \Curl \CaseInsensitiveArray ;
5
7
use \Helper \Test ;
@@ -283,7 +285,7 @@ public function testPostContinueResponseHeader()
283
285
'Connection: keep-alive ' . "\r\n" .
284
286
"\r\n" ;
285
287
286
- $ reflector = new ReflectionClass ('\Curl\Curl ' );
288
+ $ reflector = new \ ReflectionClass ('\Curl\Curl ' );
287
289
$ reflection_method = $ reflector ->getMethod ('parseResponseHeaders ' );
288
290
$ reflection_method ->setAccessible (true );
289
291
@@ -366,17 +368,17 @@ public function testPostMultidimensionalDataWithFile()
366
368
{
367
369
$ tests = array ();
368
370
369
- $ file_path_1 = Helper \get_png ();
371
+ $ file_path_1 = \ Helper \get_png ();
370
372
$ tests [] = array (
371
373
'file_path ' => $ file_path_1 ,
372
374
'post_data_image ' => '@ ' . $ file_path_1 ,
373
375
);
374
376
375
377
if (class_exists ('CURLFile ' )) {
376
- $ file_path_2 = Helper \get_png ();
378
+ $ file_path_2 = \ Helper \get_png ();
377
379
$ tests [] = array (
378
380
'file_path ' => $ file_path_2 ,
379
- 'post_data_image ' => new CURLFile ($ file_path_2 ),
381
+ 'post_data_image ' => new \ CURLFile ($ file_path_2 ),
380
382
);
381
383
}
382
384
@@ -426,7 +428,7 @@ public function testPostMultidimensionalDataWithFile()
426
428
427
429
public function testPostFilePathUpload ()
428
430
{
429
- $ file_path = Helper \get_png ();
431
+ $ file_path = \ Helper \get_png ();
430
432
431
433
$ test = new Test ();
432
434
$ this ->assertEquals ('image/png ' , $ test ->server ('post_file_path_upload ' , 'POST ' , array (
@@ -441,12 +443,12 @@ public function testPostFilePathUpload()
441
443
public function testPostCurlFileUpload ()
442
444
{
443
445
if (class_exists ('CURLFile ' )) {
444
- $ file_path = Helper \get_png ();
446
+ $ file_path = \ Helper \get_png ();
445
447
446
448
$ test = new Test ();
447
449
$ this ->assertEquals ('image/png ' , $ test ->server ('post_file_path_upload ' , 'POST ' , array (
448
450
'key ' => 'image ' ,
449
- 'image ' => new CURLFile ($ file_path ),
451
+ 'image ' => new \ CURLFile ($ file_path ),
450
452
)));
451
453
452
454
unlink ($ file_path );
@@ -486,7 +488,7 @@ public function testPostRedirectGet()
486
488
public function testPostRedirectGetReuseObjectIncompatibleEngine ()
487
489
{
488
490
if ((version_compare (PHP_VERSION , '5.5.11 ' ) > 0 ) && !defined ('HHVM_VERSION ' )) {
489
- $ this ->markTestSkipped (' This test is not applicable to this platform. ' );
491
+ $ this ->markTestSkipped ();
490
492
}
491
493
492
494
try {
@@ -503,7 +505,7 @@ public function testPostRedirectGetReuseObjectIncompatibleEngine()
503
505
false ,
504
506
'Reusing an existing Curl object on incompatible PHP engines shall trigger an error. '
505
507
);
506
- } catch (PHPUnit_Framework_Error $ e ) {
508
+ } catch (\ PHPUnit_Framework_Error $ e ) {
507
509
$ this ->assertTrue (true );
508
510
}
509
511
}
@@ -529,8 +531,8 @@ public function testPutData()
529
531
530
532
public function testPutFileHandle ()
531
533
{
532
- $ png = Helper \create_png ();
533
- $ tmp_file = Helper \create_tmp_file ($ png );
534
+ $ png = \ Helper \create_png ();
535
+ $ tmp_file = \ Helper \create_tmp_file ($ png );
534
536
535
537
$ test = new Test ();
536
538
$ test ->curl ->setHeader ('X-DEBUG-TEST ' , 'put_file_handle ' );
@@ -610,8 +612,8 @@ public function testOptionsRequestMethod()
610
612
public function testDownload ()
611
613
{
612
614
// Create and upload a file.
613
- $ upload_file_path = Helper \get_png ();
614
- $ uploaded_file_path = Helper \upload_file_to_server ($ upload_file_path );
615
+ $ upload_file_path = \ Helper \get_png ();
616
+ $ uploaded_file_path = \ Helper \upload_file_to_server ($ upload_file_path );
615
617
616
618
// Download the file.
617
619
$ downloaded_file_path = tempnam ('/tmp ' , 'php-curl-class. ' );
@@ -632,7 +634,7 @@ public function testDownload()
632
634
$ this ->assertFalse (is_bool ($ download_test ->curl ->rawResponse ));
633
635
634
636
// Remove server file.
635
- Helper \remove_file_from_server ($ uploaded_file_path );
637
+ \ Helper \remove_file_from_server ($ uploaded_file_path );
636
638
637
639
unlink ($ upload_file_path );
638
640
unlink ($ downloaded_file_path );
@@ -643,8 +645,8 @@ public function testDownload()
643
645
public function testDownloadCallback ()
644
646
{
645
647
// Create and upload a file.
646
- $ upload_file_path = Helper \get_png ();
647
- $ uploaded_file_path = Helper \upload_file_to_server ($ upload_file_path );
648
+ $ upload_file_path = \ Helper \get_png ();
649
+ $ uploaded_file_path = \ Helper \upload_file_to_server ($ upload_file_path );
648
650
649
651
// Download the file.
650
652
$ callback_called = false ;
@@ -665,7 +667,7 @@ public function testDownloadCallback()
665
667
$ this ->assertTrue ($ callback_called );
666
668
667
669
// Remove server file.
668
- Helper \remove_file_from_server ($ uploaded_file_path );
670
+ \ Helper \remove_file_from_server ($ uploaded_file_path );
669
671
670
672
unlink ($ upload_file_path );
671
673
$ this ->assertFalse (file_exists ($ upload_file_path ));
@@ -674,8 +676,8 @@ public function testDownloadCallback()
674
676
public function testDownloadRange ()
675
677
{
676
678
// Create and upload a file.
677
- $ filename = Helper \get_png ();
678
- $ uploaded_file_path = Helper \upload_file_to_server ($ filename );
679
+ $ filename = \ Helper \get_png ();
680
+ $ uploaded_file_path = \ Helper \upload_file_to_server ($ filename );
679
681
680
682
$ filesize = filesize ($ filename );
681
683
@@ -712,7 +714,7 @@ public function testDownloadRange()
712
714
713
715
) as $ length ) {
714
716
$ source = Test::TEST_URL ;
715
- $ destination = Helper \get_tmp_file_path ();
717
+ $ destination = \ Helper \get_tmp_file_path ();
716
718
717
719
// Start with no file.
718
720
if ($ length === false ) {
@@ -774,7 +776,7 @@ public function testDownloadRange()
774
776
}
775
777
776
778
// Remove server file.
777
- Helper \remove_file_from_server ($ uploaded_file_path );
779
+ \ Helper \remove_file_from_server ($ uploaded_file_path );
778
780
779
781
unlink ($ filename );
780
782
$ this ->assertFalse (file_exists ($ filename ));
@@ -1123,7 +1125,7 @@ public function testRequestHeaderCaseSensitivity()
1123
1125
$ curl = new Curl ();
1124
1126
$ curl ->setHeader ('Content-Type ' , $ content_type );
1125
1127
1126
- $ reflector = new ReflectionClass ('\Curl\Curl ' );
1128
+ $ reflector = new \ ReflectionClass ('\Curl\Curl ' );
1127
1129
$ property = $ reflector ->getProperty ('headers ' );
1128
1130
$ property ->setAccessible (true );
1129
1131
$ headers = $ property ->getValue ($ curl );
@@ -1248,7 +1250,7 @@ public function testPostArrayUrlEncodedContentType()
1248
1250
1249
1251
public function testPostFileFormDataContentType ()
1250
1252
{
1251
- $ file_path = Helper \get_png ();
1253
+ $ file_path = \ Helper \get_png ();
1252
1254
1253
1255
$ test = new Test ();
1254
1256
$ test ->server ('server ' , 'POST ' , array (
@@ -1268,11 +1270,11 @@ public function testPostCurlFileFormDataContentType()
1268
1270
$ this ->markTestSkipped ();
1269
1271
}
1270
1272
1271
- $ file_path = Helper \get_png ();
1273
+ $ file_path = \ Helper \get_png ();
1272
1274
1273
1275
$ test = new Test ();
1274
1276
$ test ->server ('server ' , 'POST ' , array (
1275
- 'image ' => new CURLFile ($ file_path ),
1277
+ 'image ' => new \ CURLFile ($ file_path ),
1276
1278
));
1277
1279
$ this ->assertEquals ('100-continue ' , $ test ->curl ->requestHeaders ['Expect ' ]);
1278
1280
preg_match ('/^multipart\/form-data; boundary=/ ' , $ test ->curl ->requestHeaders ['Content-Type ' ], $ content_type );
@@ -1481,7 +1483,7 @@ public function testJsonContentTypeDetection()
1481
1483
'text/x-json ' ,
1482
1484
);
1483
1485
1484
- $ class = new ReflectionClass ('\Curl\Curl ' );
1486
+ $ class = new \ ReflectionClass ('\Curl\Curl ' );
1485
1487
$ property = $ class ->getProperty ('jsonPattern ' );
1486
1488
$ property ->setAccessible (true );
1487
1489
$ json_pattern = $ property ->getValue (new Curl );
@@ -2595,7 +2597,7 @@ public function testXMLResponse()
2595
2597
2596
2598
$ this ->assertInstanceOf ('SimpleXMLElement ' , $ test ->curl ->response );
2597
2599
2598
- $ doc = new DOMDocument ();
2600
+ $ doc = new \ DOMDocument ();
2599
2601
$ doc ->formatOutput = true ;
2600
2602
$ rss = $ doc ->appendChild ($ doc ->createElement ('rss ' ));
2601
2603
$ rss ->setAttribute ('version ' , '2.0 ' );
@@ -2620,7 +2622,7 @@ public function testEmptyResponse()
2620
2622
{
2621
2623
$ response = "\r\n\r\n" ;
2622
2624
2623
- $ reflector = new ReflectionClass ('\Curl\Curl ' );
2625
+ $ reflector = new \ ReflectionClass ('\Curl\Curl ' );
2624
2626
$ reflection_method = $ reflector ->getMethod ('parseResponseHeaders ' );
2625
2627
$ reflection_method ->setAccessible (true );
2626
2628
@@ -2817,78 +2819,78 @@ public function testRequiredOptionCurlOptReturnTransferEmitsWarning()
2817
2819
public function testRequestMethodSuccessiveGetRequests ()
2818
2820
{
2819
2821
$ test = new Test ();
2820
- $ test ->chain_requests ('GET ' , 'POST ' );
2821
- $ test ->chain_requests ('GET ' , 'PUT ' );
2822
- $ test ->chain_requests ('GET ' , 'PATCH ' );
2823
- $ test ->chain_requests ('GET ' , 'DELETE ' );
2824
- $ test ->chain_requests ('GET ' , 'HEAD ' );
2825
- $ test ->chain_requests ('GET ' , 'OPTIONS ' );
2822
+ $ test ->chainRequests ('GET ' , 'POST ' );
2823
+ $ test ->chainRequests ('GET ' , 'PUT ' );
2824
+ $ test ->chainRequests ('GET ' , 'PATCH ' );
2825
+ $ test ->chainRequests ('GET ' , 'DELETE ' );
2826
+ $ test ->chainRequests ('GET ' , 'HEAD ' );
2827
+ $ test ->chainRequests ('GET ' , 'OPTIONS ' );
2826
2828
}
2827
2829
2828
2830
public function testRequestMethodSuccessivePostRequests ()
2829
2831
{
2830
2832
$ test = new Test ();
2831
- $ test ->chain_requests ('POST ' , 'GET ' );
2832
- $ test ->chain_requests ('POST ' , 'PUT ' );
2833
- $ test ->chain_requests ('POST ' , 'PATCH ' );
2834
- $ test ->chain_requests ('POST ' , 'DELETE ' );
2835
- $ test ->chain_requests ('POST ' , 'HEAD ' );
2836
- $ test ->chain_requests ('POST ' , 'OPTIONS ' );
2833
+ $ test ->chainRequests ('POST ' , 'GET ' );
2834
+ $ test ->chainRequests ('POST ' , 'PUT ' );
2835
+ $ test ->chainRequests ('POST ' , 'PATCH ' );
2836
+ $ test ->chainRequests ('POST ' , 'DELETE ' );
2837
+ $ test ->chainRequests ('POST ' , 'HEAD ' );
2838
+ $ test ->chainRequests ('POST ' , 'OPTIONS ' );
2837
2839
}
2838
2840
2839
2841
public function testRequestMethodSuccessivePutRequests ()
2840
2842
{
2841
2843
$ test = new Test ();
2842
- $ test ->chain_requests ('PUT ' , 'GET ' );
2843
- $ test ->chain_requests ('PUT ' , 'POST ' );
2844
- $ test ->chain_requests ('PUT ' , 'PATCH ' );
2845
- $ test ->chain_requests ('PUT ' , 'DELETE ' );
2846
- $ test ->chain_requests ('PUT ' , 'HEAD ' );
2847
- $ test ->chain_requests ('PUT ' , 'OPTIONS ' );
2844
+ $ test ->chainRequests ('PUT ' , 'GET ' );
2845
+ $ test ->chainRequests ('PUT ' , 'POST ' );
2846
+ $ test ->chainRequests ('PUT ' , 'PATCH ' );
2847
+ $ test ->chainRequests ('PUT ' , 'DELETE ' );
2848
+ $ test ->chainRequests ('PUT ' , 'HEAD ' );
2849
+ $ test ->chainRequests ('PUT ' , 'OPTIONS ' );
2848
2850
}
2849
2851
2850
2852
public function testRequestMethodSuccessivePatchRequests ()
2851
2853
{
2852
2854
$ test = new Test ();
2853
- $ test ->chain_requests ('PATCH ' , 'GET ' );
2854
- $ test ->chain_requests ('PATCH ' , 'POST ' );
2855
- $ test ->chain_requests ('PATCH ' , 'PUT ' );
2856
- $ test ->chain_requests ('PATCH ' , 'DELETE ' );
2857
- $ test ->chain_requests ('PATCH ' , 'HEAD ' );
2858
- $ test ->chain_requests ('PATCH ' , 'OPTIONS ' );
2855
+ $ test ->chainRequests ('PATCH ' , 'GET ' );
2856
+ $ test ->chainRequests ('PATCH ' , 'POST ' );
2857
+ $ test ->chainRequests ('PATCH ' , 'PUT ' );
2858
+ $ test ->chainRequests ('PATCH ' , 'DELETE ' );
2859
+ $ test ->chainRequests ('PATCH ' , 'HEAD ' );
2860
+ $ test ->chainRequests ('PATCH ' , 'OPTIONS ' );
2859
2861
}
2860
2862
2861
2863
public function testRequestMethodSuccessiveDeleteRequests ()
2862
2864
{
2863
2865
$ test = new Test ();
2864
- $ test ->chain_requests ('DELETE ' , 'GET ' );
2865
- $ test ->chain_requests ('DELETE ' , 'POST ' );
2866
- $ test ->chain_requests ('DELETE ' , 'PUT ' );
2867
- $ test ->chain_requests ('DELETE ' , 'PATCH ' );
2868
- $ test ->chain_requests ('DELETE ' , 'HEAD ' );
2869
- $ test ->chain_requests ('DELETE ' , 'OPTIONS ' );
2866
+ $ test ->chainRequests ('DELETE ' , 'GET ' );
2867
+ $ test ->chainRequests ('DELETE ' , 'POST ' );
2868
+ $ test ->chainRequests ('DELETE ' , 'PUT ' );
2869
+ $ test ->chainRequests ('DELETE ' , 'PATCH ' );
2870
+ $ test ->chainRequests ('DELETE ' , 'HEAD ' );
2871
+ $ test ->chainRequests ('DELETE ' , 'OPTIONS ' );
2870
2872
}
2871
2873
2872
2874
public function testRequestMethodSuccessiveHeadRequests ()
2873
2875
{
2874
2876
$ test = new Test ();
2875
- $ test ->chain_requests ('HEAD ' , 'GET ' );
2876
- $ test ->chain_requests ('HEAD ' , 'POST ' );
2877
- $ test ->chain_requests ('HEAD ' , 'PUT ' );
2878
- $ test ->chain_requests ('HEAD ' , 'PATCH ' );
2879
- $ test ->chain_requests ('HEAD ' , 'DELETE ' );
2880
- $ test ->chain_requests ('HEAD ' , 'OPTIONS ' );
2877
+ $ test ->chainRequests ('HEAD ' , 'GET ' );
2878
+ $ test ->chainRequests ('HEAD ' , 'POST ' );
2879
+ $ test ->chainRequests ('HEAD ' , 'PUT ' );
2880
+ $ test ->chainRequests ('HEAD ' , 'PATCH ' );
2881
+ $ test ->chainRequests ('HEAD ' , 'DELETE ' );
2882
+ $ test ->chainRequests ('HEAD ' , 'OPTIONS ' );
2881
2883
}
2882
2884
2883
2885
public function testRequestMethodSuccessiveOptionsRequests ()
2884
2886
{
2885
2887
$ test = new Test ();
2886
- $ test ->chain_requests ('OPTIONS ' , 'GET ' );
2887
- $ test ->chain_requests ('OPTIONS ' , 'POST ' );
2888
- $ test ->chain_requests ('OPTIONS ' , 'PUT ' );
2889
- $ test ->chain_requests ('OPTIONS ' , 'PATCH ' );
2890
- $ test ->chain_requests ('OPTIONS ' , 'DELETE ' );
2891
- $ test ->chain_requests ('OPTIONS ' , 'HEAD ' );
2888
+ $ test ->chainRequests ('OPTIONS ' , 'GET ' );
2889
+ $ test ->chainRequests ('OPTIONS ' , 'POST ' );
2890
+ $ test ->chainRequests ('OPTIONS ' , 'PUT ' );
2891
+ $ test ->chainRequests ('OPTIONS ' , 'PATCH ' );
2892
+ $ test ->chainRequests ('OPTIONS ' , 'DELETE ' );
2893
+ $ test ->chainRequests ('OPTIONS ' , 'HEAD ' );
2892
2894
}
2893
2895
2894
2896
public function testMemoryLeak ()
@@ -3121,7 +3123,7 @@ public function testBuildUrlArgs()
3121
3123
);
3122
3124
foreach ($ tests as $ test ) {
3123
3125
$ curl_1 = new Curl ();
3124
- $ reflector = new ReflectionObject ($ curl_1 );
3126
+ $ reflector = new \ ReflectionObject ($ curl_1 );
3125
3127
$ method = $ reflector ->getMethod ('buildURL ' );
3126
3128
$ method ->setAccessible (true );
3127
3129
$ actual_url = $ method ->invoke ($ curl_1 , $ test ['args ' ]['url ' ], $ test ['args ' ]['mixed_data ' ]);
@@ -3149,7 +3151,7 @@ public function testBuildUrlArgSeparator()
3149
3151
3150
3152
$ curl = new Curl ();
3151
3153
3152
- $ reflector = new ReflectionObject ($ curl );
3154
+ $ reflector = new \ ReflectionObject ($ curl );
3153
3155
$ method = $ reflector ->getMethod ('buildURL ' );
3154
3156
$ method ->setAccessible (true );
3155
3157
0 commit comments