Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Apr 13, 2020
1 parent a3fd27b commit 45ae210
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Concerns/MakesUrlAssertions.php
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Arr;
use PHPUnit\Framework\Assert as PHPUnit;
use PHPUnit\Framework\Constraint\RegularExpression;

trait MakesUrlAssertions
{
Expand All @@ -27,8 +28,8 @@ public function assertUrlIs($url)
Arr::get($segments, 'path', '')
);

PHPUnit::assertRegExp(
'/^'.$pattern.'$/u', $currentUrl,
PHPUnit::assertThat(
$currentUrl, new RegularExpression('/^'.$pattern.'$/u'),
"Actual URL [{$this->driver->getCurrentURL()}] does not equal expected URL [{$url}]."
);

Expand All @@ -47,8 +48,8 @@ public function assertSchemeIs($scheme)

$actual = parse_url($this->driver->getCurrentURL(), PHP_URL_SCHEME) ?? '';

PHPUnit::assertRegExp(
'/^'.$pattern.'$/u', $actual,
PHPUnit::assertThat(
$actual, new RegularExpression('/^'.$pattern.'$/u'),
"Actual scheme [{$actual}] does not equal expected scheme [{$pattern}]."
);

Expand Down Expand Up @@ -85,8 +86,8 @@ public function assertHostIs($host)

$actual = parse_url($this->driver->getCurrentURL(), PHP_URL_HOST) ?? '';

PHPUnit::assertRegExp(
'/^'.$pattern.'$/u', $actual,
PHPUnit::assertThat(
$actual, new RegularExpression('/^'.$pattern.'$/u'),
"Actual host [{$actual}] does not equal expected host [{$pattern}]."
);

Expand Down Expand Up @@ -121,10 +122,10 @@ public function assertPortIs($port)
{
$pattern = str_replace('\*', '.*', preg_quote($port, '/'));

$actual = parse_url($this->driver->getCurrentURL(), PHP_URL_PORT) ?? '';
$actual = (string) parse_url($this->driver->getCurrentURL(), PHP_URL_PORT) ?? '';

PHPUnit::assertRegExp(
'/^'.$pattern.'$/u', $actual,
PHPUnit::assertThat(
$actual, new RegularExpression('/^'.$pattern.'$/u'),
"Actual port [{$actual}] does not equal expected port [{$pattern}]."
);

Expand Down Expand Up @@ -161,8 +162,8 @@ public function assertPathIs($path)

$actualPath = parse_url($this->driver->getCurrentURL(), PHP_URL_PATH) ?? '';

PHPUnit::assertRegExp(
'/^'.$pattern.'$/u', $actualPath,
PHPUnit::assertThat(
$actualPath, new RegularExpression('/^'.$pattern.'$/u'),
"Actual path [{$actualPath}] does not equal expected path [{$path}]."
);

Expand Down Expand Up @@ -217,8 +218,8 @@ public function assertFragmentIs($fragment)

$actualFragment = (string) parse_url($this->driver->executeScript('return window.location.href;'), PHP_URL_FRAGMENT);

PHPUnit::assertRegExp(
'/^'.str_replace('\*', '.*', $pattern).'$/u', $actualFragment,
PHPUnit::assertThat(
$actualFragment, new RegularExpression('/^'.str_replace('\*', '.*', $pattern).'$/u'),
"Actual fragment [{$actualFragment}] does not equal expected fragment [{$fragment}]."
);

Expand Down

0 comments on commit 45ae210

Please sign in to comment.