Skip to content

Commit beddcbe

Browse files
kadserobocoder
authored andcommitted
Fixes #105 - fix curl option array and w3c property
- option arrays must be merge with `array_replace` to keep correct keys (index) - property `transientOptions` can be `null` - property `$w3c` must be protected
1 parent f43edf7 commit beddcbe

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class AbstractWebDriver
4343
/**
4444
* @var boolean
4545
*/
46-
private $w3c;
46+
protected $w3c;
4747

4848
/**
4949
* Curl service
@@ -86,6 +86,7 @@ public function __construct($url = 'http://localhost:4444/wd/hub', $w3c = false)
8686
{
8787
$this->url = $url;
8888
$this->w3c = $w3c;
89+
$this->transientOptions = array();
8990
}
9091

9192
/**
@@ -138,6 +139,14 @@ public function setTransientOptions($transientOptions)
138139
$this->transientOptions = is_array($transientOptions) ? $transientOptions : array();
139140
}
140141

142+
/**
143+
* @return array
144+
*/
145+
public function getTransientOptions()
146+
{
147+
return $this->transientOptions;
148+
}
149+
141150
/**
142151
* Is w3c driver?
143152
*
@@ -181,7 +190,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
181190
$url .= '/' . $parameters;
182191
}
183192

184-
list($rawResult, $info) = $this->curlService->execute($requestMethod, $url, $parameters, array_merge($extraOptions, $this->transientOptions));
193+
list($rawResult, $info) = $this->curlService->execute($requestMethod, $url, $parameters, array_replace($extraOptions, $this->transientOptions));
185194

186195
$this->transientOptions = array();
187196

lib/WebDriver/SauceLabs/SauceRest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function execute($requestMethod, $url, $parameters = null, $extraOptio
127127

128128
$url = 'https://saucelabs.com/rest/v1/' . $url;
129129

130-
list($rawResult, $info) = $this->curlService->execute($requestMethod, $url, $parameters, array_merge($extraOptions, $this->transientOptions));
130+
list($rawResult, $info) = $this->curlService->execute($requestMethod, $url, $parameters, array_replace($extraOptions, $this->transientOptions));
131131

132132
$this->transientOptions = array();
133133

lib/WebDriver/Service/CurlService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
105105
break;
106106
}
107107

108-
foreach (array_merge($this->defaultOptions, $extraOptions) as $option => $value) {
108+
foreach (array_replace($this->defaultOptions, $extraOptions) as $option => $value) {
109109
curl_setopt($curl, $option, $value);
110110
}
111111

0 commit comments

Comments
 (0)