Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser.php
<?php | <?php | ||||
namespace Tests; | namespace Tests; | ||||
use Facebook\WebDriver\WebDriverKeys; | use Facebook\WebDriver\WebDriverKeys; | ||||
use PHPUnit\Framework\Assert; | use PHPUnit\Framework\Assert; | ||||
use Tests\Browser\Components\Error; | use Tests\Browser\Components\Error; | ||||
use Tests\Browser\Components\Toast; | |||||
/** | /** | ||||
* Laravel Dusk Browser extensions | * Laravel Dusk Browser extensions | ||||
*/ | */ | ||||
class Browser extends \Laravel\Dusk\Browser | class Browser extends \Laravel\Dusk\Browser | ||||
{ | { | ||||
/** | /** | ||||
* Assert number of (visible) elements | * Assert number of (visible) elements | ||||
Show All 24 Lines | public function assertTip($selector, $content) | ||||
return $this->click($selector) | return $this->click($selector) | ||||
->withinBody(function ($browser) use ($content) { | ->withinBody(function ($browser) use ($content) { | ||||
$browser->assertSeeIn('div.tooltip .tooltip-inner', $content); | $browser->assertSeeIn('div.tooltip .tooltip-inner', $content); | ||||
}) | }) | ||||
->click($selector); | ->click($selector); | ||||
} | } | ||||
/** | /** | ||||
* Assert Toast element content (and close it) | |||||
*/ | |||||
public function assertToast($type, $title, $message) | |||||
{ | |||||
return $this->withinBody(function ($browser) use ($type, $title, $message) { | |||||
$browser->with(new Toast($type), function (Browser $browser) use ($title, $message) { | |||||
$browser->assertToastTitle($title) | |||||
->assertToastMessage($message) | |||||
->closeToast(); | |||||
}); | |||||
}); | |||||
} | |||||
/** | |||||
* Assert specified error page is displayed. | * Assert specified error page is displayed. | ||||
*/ | */ | ||||
public function assertErrorPage(int $error_code) | public function assertErrorPage(int $error_code) | ||||
{ | { | ||||
$this->with(new Error($error_code), function ($browser) { | $this->with(new Error($error_code), function ($browser) { | ||||
// empty, assertions will be made by the Error component itself | // empty, assertions will be made by the Error component itself | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |