Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Components/Toast.php
<?php | <?php | ||||
namespace Tests\Browser\Components; | namespace Tests\Browser\Components; | ||||
use Laravel\Dusk\Browser; | use Laravel\Dusk\Browser; | ||||
use Laravel\Dusk\Component as BaseComponent; | use Laravel\Dusk\Component as BaseComponent; | ||||
use PHPUnit\Framework\Assert as PHPUnit; | use PHPUnit\Framework\Assert as PHPUnit; | ||||
class Toast extends BaseComponent | class Toast extends BaseComponent | ||||
{ | { | ||||
public const TYPE_ERROR = 'error'; | public const TYPE_ERROR = 'error'; | ||||
public const TYPE_SUCCESS = 'success'; | public const TYPE_SUCCESS = 'success'; | ||||
public const TYPE_WARNING = 'warning'; | public const TYPE_WARNING = 'warning'; | ||||
public const TYPE_INFO = 'info'; | public const TYPE_INFO = 'info'; | ||||
protected $type; | protected $type; | ||||
protected $element; | |||||
public function __construct($type) | public function __construct($type) | ||||
{ | { | ||||
$this->type = $type; | $this->type = $type; | ||||
} | } | ||||
/** | /** | ||||
Show All 11 Lines | class Toast extends BaseComponent | ||||
* | * | ||||
* @param Browser $browser | * @param Browser $browser | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function assert(Browser $browser) | public function assert(Browser $browser) | ||||
{ | { | ||||
$browser->waitFor($this->selector()); | $browser->waitFor($this->selector()); | ||||
$this->element = $browser->element($this->selector()); | |||||
} | } | ||||
/** | /** | ||||
* Get the element shortcuts for the component. | * Get the element shortcuts for the component. | ||||
* | * | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
public function elements() | public function elements() | ||||
Show All 24 Lines | public function assertToastMessage(Browser $browser, string $message) | ||||
$browser->assertSeeIn('@message', $message); | $browser->assertSeeIn('@message', $message); | ||||
} | } | ||||
/** | /** | ||||
* Close the toast with a click | * Close the toast with a click | ||||
*/ | */ | ||||
public function closeToast(Browser $browser) | public function closeToast(Browser $browser) | ||||
{ | { | ||||
$browser->click(); | $this->element->click(); | ||||
} | } | ||||
} | } |