Skip to content

Commit

Permalink
Fix url issue - closes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Apr 20, 2015
1 parent 5f7c166 commit 7933a7e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Extensions/Goutte.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function submitForm($buttonText, $formData = null)

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

$this->clearInputs()->assertPageLoaded($this->currentPage);
$this->clearInputs()->assertPageLoaded($this->currentPage());

return $this;
}
Expand Down
16 changes: 13 additions & 3 deletions src/Extensions/IntegrationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ protected function prepareUrl($url)
}

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

return $url;
return trim($url, '/');
}

/**
Expand Down Expand Up @@ -130,7 +130,7 @@ public function seePageIs($uri)

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

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

return $this;
}
Expand Down Expand Up @@ -342,6 +342,16 @@ protected function getForm($button = null)
}
}

/**
* Get the current URL for the request.
*
* @return string
*/
protected function currentPage()
{
return rtrim($this->currentPage, '/');
}

/**
* Assert that a 200 status code was returned from the last call.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/Laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function makeRequest($requestType, $uri, $parameters = [], $cookies =

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

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

return $this;
}
Expand Down Expand Up @@ -142,7 +142,7 @@ protected function statusCode()
*/
protected function handleInternalError($message = null)
{
$crawler = new Crawler($this->response(), $this->currentPage);
$crawler = new Crawler($this->response(), $this->currentPage());

// A little weird, but we need to parse the output HTML to
// figure out the specifics of where the error occurred.
Expand Down
6 changes: 4 additions & 2 deletions src/Extensions/Selenium.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ protected function makeRequest($requestType, $uri, $parameters = [])
*/
public function click($name)
{
$page = $this->currentPage();

try {
$link = $this->findByBody($name)->click();
} catch (InvalidArgumentException $e) {
Expand All @@ -101,9 +103,9 @@ public function click($name)
$this->updateCurrentUrl();

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

return $this;
Expand Down

0 comments on commit 7933a7e

Please sign in to comment.