50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Browser\Users;
|
||
|
|
|
||
|
|
use Laravel\Dusk\Browser;
|
||
|
|
use Tests\DuskTestCase;
|
||
|
|
use Tests\Browser\Pages\UsersPage;
|
||
|
|
use Tests\Browser\Components\UserModal;
|
||
|
|
use Tests\Browser\LoginHelpers;
|
||
|
|
|
||
|
|
class CreateUserFormValidationTest extends DuskTestCase
|
||
|
|
{
|
||
|
|
use LoginHelpers;
|
||
|
|
|
||
|
|
protected static $createUserFormValidationTestPlanner = null;
|
||
|
|
protected static $createUserFormValidationTestEmail = null;
|
||
|
|
|
||
|
|
protected function setUp(): void
|
||
|
|
{
|
||
|
|
parent::setUp();
|
||
|
|
// Reset static planner for this specific test class
|
||
|
|
self::$testPlanner = self::$createUserFormValidationTestPlanner;
|
||
|
|
self::$testEmail = self::$createUserFormValidationTestEmail;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function tearDown(): void
|
||
|
|
{
|
||
|
|
// Save the planner for next test method in this class
|
||
|
|
self::$createUserFormValidationTestPlanner = self::$testPlanner;
|
||
|
|
self::$createUserFormValidationTestEmail = self::$testEmail;
|
||
|
|
parent::tearDown();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testCreateUserFormValidation(): void
|
||
|
|
{
|
||
|
|
$this->browse(function (Browser $browser) {
|
||
|
|
$this->loginAndGoToUsers($browser);
|
||
|
|
|
||
|
|
$browser->on(new UsersPage)
|
||
|
|
->openCreateModal()
|
||
|
|
->within(new UserModal('create'), function ($browser) {
|
||
|
|
$browser->submit();
|
||
|
|
})
|
||
|
|
->pause(self::PAUSE_MEDIUM)
|
||
|
|
->within(new UserModal('create'), function ($browser) {
|
||
|
|
$browser->assertValidationError();
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|