@@ -1999,7 +1999,7 @@ public function testDigestHttpAuthSuccess()
1999
1999
$ multi_curl ->start ();
2000
2000
}
2001
2001
2002
- public function testCookies ()
2002
+ public function testSetCookie ()
2003
2003
{
2004
2004
$ multi_curl = new MultiCurl ();
2005
2005
$ multi_curl ->setHeader ('X-DEBUG-TEST ' , 'setcookie ' );
@@ -2034,6 +2034,51 @@ public function testCookies()
2034
2034
$ this ->assertEquals ('yummy ' , $ get_2 ->responseCookies ['mycookie ' ]);
2035
2035
}
2036
2036
2037
+ public function testSetCookies ()
2038
+ {
2039
+ $ multi_curl = new MultiCurl ();
2040
+ $ multi_curl ->setHeader ('X-DEBUG-TEST ' , 'setcookie ' );
2041
+ $ multi_curl ->setCookies (array (
2042
+ 'mycookie ' => 'yum ' ,
2043
+ 'cookie-for-all-before ' => 'a ' ,
2044
+ ));
2045
+
2046
+ $ get_1 = $ multi_curl ->addGet (Test::TEST_URL );
2047
+ $ get_1 ->setCookies (array (
2048
+ 'cookie-for-1st-request ' => '1 ' ,
2049
+ ));
2050
+ $ get_1 ->complete (function ($ instance ) {
2051
+ PHPUnit_Framework_Assert::assertEquals ('yum ' , $ instance ->responseCookies ['mycookie ' ]);
2052
+ PHPUnit_Framework_Assert::assertEquals ('a ' , $ instance ->responseCookies ['cookie-for-all-before ' ]);
2053
+ PHPUnit_Framework_Assert::assertEquals ('b ' , $ instance ->responseCookies ['cookie-for-all-after ' ]);
2054
+ PHPUnit_Framework_Assert::assertEquals ('1 ' , $ instance ->responseCookies ['cookie-for-1st-request ' ]);
2055
+ });
2056
+
2057
+ $ get_2 = $ multi_curl ->addGet (Test::TEST_URL );
2058
+ $ get_2 ->setCookies (array (
2059
+ 'cookie-for-2nd-request ' => '2 ' ,
2060
+ ));
2061
+ $ get_2 ->beforeSend (function ($ instance ) {
2062
+ $ instance ->setCookies (array (
2063
+ 'mycookie ' => 'yummy ' ,
2064
+ ));
2065
+ });
2066
+ $ get_2 ->complete (function ($ instance ) {
2067
+ PHPUnit_Framework_Assert::assertEquals ('yummy ' , $ instance ->responseCookies ['mycookie ' ]);
2068
+ PHPUnit_Framework_Assert::assertEquals ('a ' , $ instance ->responseCookies ['cookie-for-all-before ' ]);
2069
+ PHPUnit_Framework_Assert::assertEquals ('b ' , $ instance ->responseCookies ['cookie-for-all-after ' ]);
2070
+ PHPUnit_Framework_Assert::assertEquals ('2 ' , $ instance ->responseCookies ['cookie-for-2nd-request ' ]);
2071
+ });
2072
+
2073
+ $ multi_curl ->setCookies (array (
2074
+ 'cookie-for-all-after ' => 'b ' ,
2075
+ ));
2076
+ $ multi_curl ->start ();
2077
+
2078
+ $ this ->assertEquals ('yum ' , $ get_1 ->responseCookies ['mycookie ' ]);
2079
+ $ this ->assertEquals ('yummy ' , $ get_2 ->responseCookies ['mycookie ' ]);
2080
+ }
2081
+
2037
2082
public function testJSONDecoder ()
2038
2083
{
2039
2084
$ multi_curl = new MultiCurl ();
0 commit comments