@@ -981,37 +981,22 @@ public function testSetCookieEncodingSpace()
981
981
{
982
982
$ curl = new Curl ();
983
983
$ curl ->setCookie ('cookie ' , 'Om nom nom nom ' );
984
-
985
- $ reflectionClass = new ReflectionClass ('\Curl\Curl ' );
986
- $ reflectionProperty = $ reflectionClass ->getProperty ('options ' );
987
- $ reflectionProperty ->setAccessible (true );
988
- $ options = $ reflectionProperty ->getValue ($ curl );
989
- $ this ->assertEquals ('cookie=Om%20nom%20nom%20nom ' , $ options [CURLOPT_COOKIE ]);
984
+ $ this ->assertEquals ('cookie=Om%20nom%20nom%20nom ' , $ curl ->getOpt (CURLOPT_COOKIE ));
990
985
}
991
986
992
987
public function testSetMultipleCookies ()
993
988
{
994
989
$ curl = new Curl ();
995
990
$ curl ->setCookie ('cookie ' , 'Om nom nom nom ' );
996
991
$ curl ->setCookie ('foo ' , 'bar ' );
997
-
998
- $ reflectionClass = new ReflectionClass ('\Curl\Curl ' );
999
- $ reflectionProperty = $ reflectionClass ->getProperty ('options ' );
1000
- $ reflectionProperty ->setAccessible (true );
1001
- $ options = $ reflectionProperty ->getValue ($ curl );
1002
- $ this ->assertEquals ('cookie=Om%20nom%20nom%20nom; foo=bar ' , $ options [CURLOPT_COOKIE ]);
992
+ $ this ->assertEquals ('cookie=Om%20nom%20nom%20nom; foo=bar ' , $ curl ->getOpt (CURLOPT_COOKIE ));
1003
993
}
1004
994
1005
995
public function testSetCookieEncodingColon ()
1006
996
{
1007
997
$ curl = new Curl ();
1008
998
$ curl ->setCookie ('JSESSIONID ' , '0000wd-PcsB3bZ-KzYGAqm_rKlm:17925chrl ' );
1009
-
1010
- $ reflectionClass = new ReflectionClass ('\Curl\Curl ' );
1011
- $ reflectionProperty = $ reflectionClass ->getProperty ('options ' );
1012
- $ reflectionProperty ->setAccessible (true );
1013
- $ options = $ reflectionProperty ->getValue ($ curl );
1014
- $ this ->assertEquals ('JSESSIONID=0000wd-PcsB3bZ-KzYGAqm_rKlm:17925chrl ' , $ options [CURLOPT_COOKIE ]);
999
+ $ this ->assertEquals ('JSESSIONID=0000wd-PcsB3bZ-KzYGAqm_rKlm:17925chrl ' , $ curl ->getOpt (CURLOPT_COOKIE ));
1015
1000
}
1016
1001
1017
1002
public function testSetCookieString ()
@@ -1020,12 +1005,7 @@ public function testSetCookieString()
1020
1005
1021
1006
$ test = new Test ();
1022
1007
$ test ->curl ->setCookieString ($ cookie_string );
1023
-
1024
- $ reflectionClass = new ReflectionClass ('\Curl\Curl ' );
1025
- $ reflectionProperty = $ reflectionClass ->getProperty ('options ' );
1026
- $ reflectionProperty ->setAccessible (true );
1027
- $ options = $ reflectionProperty ->getValue ($ test ->curl );
1028
- $ this ->assertEquals ($ cookie_string , $ options [CURLOPT_COOKIE ]);
1008
+ $ this ->assertEquals ($ cookie_string , $ test ->curl ->getOpt (CURLOPT_COOKIE ));
1029
1009
$ this ->assertEquals ('fruit=apple&color=red ' , $ test ->server ('cookie ' , 'GET ' ));
1030
1010
}
1031
1011
@@ -3005,27 +2985,16 @@ public function testOptionSet()
3005
2985
$ curl = new Curl ();
3006
2986
$ success = $ curl ->setOpt ($ option , $ value );
3007
2987
3008
- $ reflector = new ReflectionObject ($ curl );
3009
- $ property = $ reflector ->getProperty ('options ' );
3010
- $ property ->setAccessible (true );
3011
- $ options = $ property ->getValue ($ curl );
3012
-
3013
2988
$ this ->assertTrue ($ success );
3014
- $ this ->assertTrue (isset ($ options [$ option ]));
3015
- $ this ->assertEquals ($ value , $ options [$ option ]);
2989
+ $ this ->assertEquals ($ value , $ curl ->getOpt ($ option ));
3016
2990
3017
2991
// Ensure the option is not stored when curl_setopt() fails. Make curl_setopt() return false and suppress
3018
2992
// errors. Triggers warning: "curl_setopt(): Curl option contains invalid characters (\0)".
3019
2993
$ curl = new Curl ();
3020
2994
$ success = @$ curl ->setOpt ($ option , $ null );
3021
2995
3022
- $ reflector = new ReflectionObject ($ curl );
3023
- $ property = $ reflector ->getProperty ('options ' );
3024
- $ property ->setAccessible (true );
3025
- $ options = $ property ->getValue ($ curl );
3026
-
3027
2996
$ this ->assertFalse ($ success );
3028
- $ this ->assertFalse ( isset ( $ options [ $ option] ));
2997
+ $ this ->assertNull ( $ curl -> getOpt ( $ option ));
3029
2998
3030
2999
// Ensure options following a Curl::setOpt() failure are not set when using Curl::setOpts().
3031
3000
$ options = array (
@@ -3035,13 +3004,8 @@ public function testOptionSet()
3035
3004
$ curl = new Curl ();
3036
3005
$ success = @$ curl ->setOpts ($ options );
3037
3006
3038
- $ reflector = new ReflectionObject ($ curl );
3039
- $ property = $ reflector ->getProperty ('options ' );
3040
- $ property ->setAccessible (true );
3041
- $ options = $ property ->getValue ($ curl );
3042
-
3043
3007
$ this ->assertFalse ($ success );
3044
- $ this ->assertFalse ( isset ( $ options [ CURLOPT_COOKIE ] ));
3008
+ $ this ->assertNull ( $ curl -> getOpt ( CURLOPT_COOKIE ));
3045
3009
3046
3010
// Ensure Curl::setOpts() returns true when all options are successfully set.
3047
3011
$ options = array (
@@ -3052,15 +3016,10 @@ public function testOptionSet()
3052
3016
$ curl = new Curl ();
3053
3017
$ success = $ curl ->setOpts ($ options );
3054
3018
3055
- $ reflector = new ReflectionObject ($ curl );
3056
- $ property = $ reflector ->getProperty ('options ' );
3057
- $ property ->setAccessible (true );
3058
- $ options = $ property ->getValue ($ curl );
3059
-
3060
3019
$ this ->assertTrue ($ success );
3061
- $ this ->assertEquals ('a=b ' , $ options [ CURLOPT_COOKIE ] );
3062
- $ this ->assertTrue ($ options [ CURLOPT_FOLLOWLOCATION ] );
3063
- $ this ->assertTrue ($ options [ CURLOPT_VERBOSE ] );
3020
+ $ this ->assertEquals ('a=b ' , $ curl -> getOpt ( CURLOPT_COOKIE ) );
3021
+ $ this ->assertTrue ($ curl -> getOpt ( CURLOPT_FOLLOWLOCATION ) );
3022
+ $ this ->assertTrue ($ curl -> getOpt ( CURLOPT_VERBOSE ) );
3064
3023
}
3065
3024
3066
3025
public function testBuildUrlArgSeparator ()
0 commit comments