41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Pterodactyl\Tests\Browser;
|
|
|
|
use Laravel\Dusk\Browser;
|
|
use Illuminate\Support\Str;
|
|
use PHPUnit\Framework\Assert as PHPUnit;
|
|
|
|
class PterodactylBrowser extends Browser
|
|
{
|
|
/**
|
|
* Perform a case insensitive search for a string in the body.
|
|
*
|
|
* @param string $text
|
|
* @return \Pterodactyl\Tests\Browser\PterodactylBrowser
|
|
*/
|
|
public function assertSee($text)
|
|
{
|
|
return $this->assertSeeIn('', $text);
|
|
}
|
|
|
|
/**
|
|
* Perform a case insensitive search for a string in a given selector.
|
|
*
|
|
* @param string $selector
|
|
* @param string $text
|
|
* @return \Pterodactyl\Tests\Browser\PterodactylBrowser
|
|
*/
|
|
public function assertSeeIn($selector, $text)
|
|
{
|
|
$fullSelector = $this->resolver->format($selector);
|
|
$element = $this->resolver->findOrFail($selector);
|
|
|
|
PHPUnit::assertTrue(
|
|
Str::contains(mb_strtolower($element->getText()), mb_strtolower($text)),
|
|
"Did not see expected text [{$text}] within element [{$fullSelector}] using case-insensitive search."
|
|
);
|
|
|
|
return $this;
|
|
}
|
|
}
|