@@ -466,22 +466,54 @@ public function testNestedData()
466
466
);
467
467
}
468
468
469
- public function testPostUrlEncodedContentType ()
469
+ public function testPostStringUrlEncodedContentType ()
470
470
{
471
471
$ test = new Test ();
472
472
$ test ->server ('server ' , 'POST ' , 'foo=bar ' );
473
473
$ this ->assertEquals ($ test ->curl ->request_headers ['Content-Type ' ], 'application/x-www-form-urlencoded ' );
474
474
}
475
475
476
- public function testPostFormDataContentType ()
476
+ public function testPostArrayUrlEncodedContentType ()
477
477
{
478
478
$ test = new Test ();
479
479
$ test ->server ('server ' , 'POST ' , array (
480
480
'foo ' => 'bar ' ,
481
481
));
482
+ $ this ->assertEquals ($ test ->curl ->request_headers ['Content-Type ' ], 'application/x-www-form-urlencoded ' );
483
+ }
484
+
485
+ public function testPostFileFormDataContentType ()
486
+ {
487
+ $ file_path = get_png ();
488
+
489
+ $ test = new Test ();
490
+ $ test ->server ('server ' , 'POST ' , array (
491
+ 'image ' => '@ ' . $ file_path ,
492
+ ));
482
493
$ this ->assertEquals ($ test ->curl ->request_headers ['Expect ' ], '100-continue ' );
483
494
preg_match ('/^multipart\/form-data; boundary=/ ' , $ test ->curl ->request_headers ['Content-Type ' ], $ content_type );
484
495
$ this ->assertTrue (!empty ($ content_type ));
496
+
497
+ unlink ($ file_path );
498
+ $ this ->assertFalse (file_exists ($ file_path ));
499
+ }
500
+
501
+ public function testPostCurlFileFormDataContentType ()
502
+ {
503
+ if (class_exists ('CURLFile ' )) {
504
+ $ file_path = get_png ();
505
+
506
+ $ test = new Test ();
507
+ $ test ->server ('server ' , 'POST ' , array (
508
+ 'image ' => new CURLFile ($ file_path ),
509
+ ));
510
+ $ this ->assertEquals ($ test ->curl ->request_headers ['Expect ' ], '100-continue ' );
511
+ preg_match ('/^multipart\/form-data; boundary=/ ' , $ test ->curl ->request_headers ['Content-Type ' ], $ content_type );
512
+ $ this ->assertTrue (!empty ($ content_type ));
513
+
514
+ unlink ($ file_path );
515
+ $ this ->assertFalse (file_exists ($ file_path ));
516
+ }
485
517
}
486
518
487
519
public function testJSONResponse ()
0 commit comments