Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Components/Error.php
<?php | <?php | ||||
namespace Tests\Browser\Components; | namespace Tests\Browser\Components; | ||||
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 Error extends BaseComponent | class Error extends BaseComponent | ||||
{ | { | ||||
protected $code; | protected $code; | ||||
protected $message; | protected $message; | ||||
protected $messages_map = [ | protected $messages_map = [ | ||||
400 => "Bad request", | 400 => "Bad request", | ||||
401 => "Unauthorized", | 401 => "Unauthorized", | ||||
403 => "Access denied", | 403 => "Access denied", | ||||
404 => "Not Found", | 404 => "Not found", | ||||
405 => "Method not allowed", | 405 => "Method not allowed", | ||||
500 => "Internal server error", | 500 => "Internal server error", | ||||
]; | ]; | ||||
public function __construct($code) | public function __construct($code) | ||||
{ | { | ||||
$this->code = $code; | $this->code = $code; | ||||
$this->message = $this->messages_map[$code]; | $this->message = $this->messages_map[$code]; | ||||
Show All 14 Lines | class Error extends BaseComponent | ||||
* | * | ||||
* @param \Laravel\Dusk\Browser $browser | * @param \Laravel\Dusk\Browser $browser | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function assert($browser) | public function assert($browser) | ||||
{ | { | ||||
$browser->waitFor($this->selector()) | $browser->waitFor($this->selector()) | ||||
->assertSeeIn('@code', $this->code) | ->assertSeeIn('@code', $this->code); | ||||
->assertSeeIn('@message', $this->message); | |||||
$message = $browser->text('@message'); | |||||
PHPUnit::assertSame(strtolower($message), strtolower($this->message)); | |||||
} | } | ||||
/** | /** | ||||
* 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 9 Lines |