Skip to content

Commit

Permalink
Use proper PHPUnit assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Mar 1, 2019
1 parent 3f6312a commit d48f990
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/Concerns/MakesAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Laravel\Dusk\Concerns;

use Illuminate\Support\Str;
use PHPUnit\Framework\Assert as PHPUnit;
use Facebook\WebDriver\Remote\RemoteWebElement;
use Facebook\WebDriver\Exception\NoSuchElementException;
Expand Down Expand Up @@ -33,8 +32,9 @@ public function assertTitle($title)
*/
public function assertTitleContains($title)
{
PHPUnit::assertTrue(
Str::contains($this->driver->getTitle(), $title),
PHPUnit::assertStringContainsString(
$this->driver->getTitle(),
$title,
"Did not see expected value [{$title}] within title [{$this->driver->getTitle()}]."
);

Expand Down Expand Up @@ -168,8 +168,9 @@ public function assertSeeIn($selector, $text)

$element = $this->resolver->findOrFail($selector);

PHPUnit::assertTrue(
Str::contains($element->getText(), $text),
PHPUnit::assertStringContainsString(
$element->getText(),
$text,
"Did not see expected text [{$text}] within element [{$fullSelector}]."
);

Expand All @@ -189,8 +190,9 @@ public function assertDontSeeIn($selector, $text)

$element = $this->resolver->findOrFail($selector);

PHPUnit::assertFalse(
Str::contains($element->getText(), $text),
PHPUnit::assertStringNotContainsString(
$element->getText(),
$text,
"Saw unexpected text [{$text}] within element [{$fullSelector}]."
);

Expand All @@ -205,8 +207,9 @@ public function assertDontSeeIn($selector, $text)
*/
public function assertSourceHas($code)
{
PHPUnit::assertContains(
$code, $this->driver->getPageSource(),
PHPUnit::assertStringContainsString(
$code,
$this->driver->getPageSource(),
"Did not find expected source code [{$code}]"
);

Expand All @@ -221,8 +224,9 @@ public function assertSourceHas($code)
*/
public function assertSourceMissing($code)
{
PHPUnit::assertNotContains(
$code, $this->driver->getPageSource(),
PHPUnit::assertStringNotContainsString(
$code,
$this->driver->getPageSource(),
"Found unexpected source code [{$code}]"
);

Expand Down Expand Up @@ -737,7 +741,7 @@ public function assertVueIsNot($key, $value, $componentSelector = null)
*/
public function assertVueContains($key, $value, $componentSelector = null)
{
PHPUnit::assertContains($value, $this->vueAttribute($componentSelector, $key));
PHPUnit::assertStringContainsString($value, $this->vueAttribute($componentSelector, $key));

return $this;
}
Expand All @@ -753,7 +757,7 @@ public function assertVueContains($key, $value, $componentSelector = null)
*/
public function assertVueDoesNotContain($key, $value, $componentSelector = null)
{
PHPUnit::assertNotContains($value, $this->vueAttribute($componentSelector, $key));
PHPUnit::assertStringNotContainsString($value, $this->vueAttribute($componentSelector, $key));

return $this;
}
Expand Down

0 comments on commit d48f990

Please sign in to comment.