@@ -34,19 +34,32 @@ public function setUp()
3434 * @dataProvider commandProvider
3535 * @param int $command
3636 * @param array $params
37+ * @param bool $shouldResetExpectHeader
3738 * @param string $expectedUrl
3839 * @param string $expectedPostData
3940 */
40- public function testShouldSendRequestToAssembledUrl ($ command , array $ params , $ expectedUrl , $ expectedPostData )
41- {
41+ public function testShouldSendRequestToAssembledUrl (
42+ $ command ,
43+ array $ params ,
44+ $ shouldResetExpectHeader ,
45+ $ expectedUrl ,
46+ $ expectedPostData
47+ ) {
4248 $ command = new WebDriverCommand ('foo-123 ' , $ command , $ params );
4349
4450 $ curlSetoptMock = $ this ->getFunctionMock (__NAMESPACE__ , 'curl_setopt ' );
4551 $ curlSetoptMock ->expects ($ this ->at (0 ))
4652 ->with ($ this ->anything (), CURLOPT_URL , $ expectedUrl );
4753
48- $ curlSetoptMock ->expects ($ this ->at (2 ))
49- ->with ($ this ->anything (), CURLOPT_POSTFIELDS , $ expectedPostData );
54+ if ($ shouldResetExpectHeader ) {
55+ $ curlSetoptMock ->expects ($ this ->at (2 ))
56+ ->with ($ this ->anything (), CURLOPT_HTTPHEADER , ['Expect: ' ]);
57+ $ curlSetoptMock ->expects ($ this ->at (3 ))
58+ ->with ($ this ->anything (), CURLOPT_POSTFIELDS , $ expectedPostData );
59+ } else {
60+ $ curlSetoptMock ->expects ($ this ->at (2 ))
61+ ->with ($ this ->anything (), CURLOPT_POSTFIELDS , $ expectedPostData );
62+ }
5063
5164 $ curlExecMock = $ this ->getFunctionMock (__NAMESPACE__ , 'curl_exec ' );
5265 $ curlExecMock ->expects ($ this ->once ())
@@ -64,30 +77,35 @@ public function commandProvider()
6477 'POST command having :id placeholder in url ' => [
6578 DriverCommand::SEND_KEYS_TO_ELEMENT ,
6679 ['value ' => 'submitted-value ' , ':id ' => '1337 ' ],
80+ true ,
6781 'http://localhost:4444/session/foo-123/element/1337/value ' ,
6882 '{"value":"submitted-value"} ' ,
6983 ],
7084 'POST command without :id placeholder in url ' => [
7185 DriverCommand::TOUCH_UP ,
7286 ['x ' => 3 , 'y ' => 6 ],
87+ true ,
7388 'http://localhost:4444/session/foo-123/touch/up ' ,
7489 '{"x":3,"y":6} ' ,
7590 ],
7691 'Extra useless placeholder parameter should be removed ' => [
7792 DriverCommand::TOUCH_UP ,
7893 ['x ' => 3 , 'y ' => 6 , ':useless ' => 'foo ' ],
94+ true ,
7995 'http://localhost:4444/session/foo-123/touch/up ' ,
8096 '{"x":3,"y":6} ' ,
8197 ],
8298 'DELETE command ' => [
8399 DriverCommand::DELETE_COOKIE ,
84100 [':name ' => 'cookie-name ' ],
101+ false ,
85102 'http://localhost:4444/session/foo-123/cookie/cookie-name ' ,
86103 null ,
87104 ],
88105 'GET command without session in URL ' => [
89106 DriverCommand::GET_ALL_SESSIONS ,
90107 [],
108+ false ,
91109 'http://localhost:4444/sessions ' ,
92110 null ,
93111 ],
0 commit comments