Skip to content

Commit 7a9ad38

Browse files
Pierstovaldunglas
authored andcommitted
Add a blocker to avoid using HttpFoundation request and response objects (symfony#42)
* Add a blocker to avoid using HttpFoundation request and response objects * Stop setting request & response httpfoundation object
1 parent 8ac8392 commit 7a9ad38

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Client.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ public function start()
7878
}
7979
}
8080

81+
public function getRequest()
82+
{
83+
throw new \LogicException('HttpFoundation Request object is not available when using WebDriver.');
84+
}
85+
86+
public function getResponse()
87+
{
88+
throw new \LogicException('HttpFoundation Response object is not available when using WebDriver.');
89+
}
90+
8191
public function followRedirects($followRedirect = true): void
8292
{
8393
if (!$followRedirect) {
@@ -180,7 +190,7 @@ protected function createCrawler(): Crawler
180190

181191
protected function doRequest($request)
182192
{
183-
throw new \Exception('Not useful in WebDriver mode.');
193+
throw new \LogicException('Not useful in WebDriver mode.');
184194
}
185195

186196
public function back()
@@ -258,9 +268,9 @@ public function get($uri)
258268
$uri = $this->baseUri.$uri;
259269
}
260270

261-
$this->request = $this->internalRequest = new Request($uri, 'GET');
271+
$this->internalRequest = new Request($uri, 'GET');
262272
$this->webDriver->get($uri);
263-
$this->response = $this->internalResponse = new Response($this->webDriver->getPageSource());
273+
$this->internalResponse = new Response($this->webDriver->getPageSource());
264274
$this->crawler = $this->createCrawler();
265275

266276
return $this;

0 commit comments

Comments
 (0)