Skip to content

Commit 7933a7e

Browse files
committed
Fix url issue - closes #46
1 parent 5f7c166 commit 7933a7e

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/Extensions/Goutte.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function submitForm($buttonText, $formData = null)
6060

6161
$this->currentPage = $this->client()->getHistory()->current()->getUri();
6262

63-
$this->clearInputs()->assertPageLoaded($this->currentPage);
63+
$this->clearInputs()->assertPageLoaded($this->currentPage());
6464

6565
return $this;
6666
}

src/Extensions/IntegrationTrait.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ protected function prepareUrl($url)
8989
}
9090

9191
if (! Str::startsWith($url, 'http')) {
92-
$url = rtrim(sprintf("%s/%s", $this->baseUrl(), $url), '/');
92+
$url = sprintf("%s/%s", $this->baseUrl(), $url);
9393
}
9494

95-
return $url;
95+
return trim($url, '/');
9696
}
9797

9898
/**
@@ -130,7 +130,7 @@ public function seePageIs($uri)
130130

131131
$message = "Expected to be on the page, {$uri}, but wasn't.";
132132

133-
$this->assertEquals($uri, $this->currentPage, $message);
133+
$this->assertEquals($uri, $this->currentPage(), $message);
134134

135135
return $this;
136136
}
@@ -342,6 +342,16 @@ protected function getForm($button = null)
342342
}
343343
}
344344

345+
/**
346+
* Get the current URL for the request.
347+
*
348+
* @return string
349+
*/
350+
protected function currentPage()
351+
{
352+
return rtrim($this->currentPage, '/');
353+
}
354+
345355
/**
346356
* Assert that a 200 status code was returned from the last call.
347357
*

src/Extensions/Laravel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function makeRequest($requestType, $uri, $parameters = [], $cookies =
6969

7070
$this->currentPage = $this->app['request']->fullUrl();
7171

72-
$this->crawler = new Crawler($this->response(), $this->currentPage);
72+
$this->crawler = new Crawler($this->response(), $this->currentPage());
7373

7474
return $this;
7575
}
@@ -142,7 +142,7 @@ protected function statusCode()
142142
*/
143143
protected function handleInternalError($message = null)
144144
{
145-
$crawler = new Crawler($this->response(), $this->currentPage);
145+
$crawler = new Crawler($this->response(), $this->currentPage());
146146

147147
// A little weird, but we need to parse the output HTML to
148148
// figure out the specifics of where the error occurred.

src/Extensions/Selenium.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ protected function makeRequest($requestType, $uri, $parameters = [])
9292
*/
9393
public function click($name)
9494
{
95+
$page = $this->currentPage();
96+
9597
try {
9698
$link = $this->findByBody($name)->click();
9799
} catch (InvalidArgumentException $e) {
@@ -101,9 +103,9 @@ public function click($name)
101103
$this->updateCurrentUrl();
102104

103105
$this->assertPageLoaded(
104-
$this->currentPage,
106+
$page,
105107
"Successfully clicked on a link with a body, name, or class of '{$name}', " .
106-
"but its destination, {$this->currentPage}, did not produce a 200 status code."
108+
"but its destination, {$page}, did not produce a 200 status code."
107109
);
108110

109111
return $this;

0 commit comments

Comments
 (0)