Merge pull request #16764 from grokability/fixed_flaky_user_create_tests
Fixed flaky user creation tests
This commit is contained in:
commit
db1af98992
2 changed files with 30 additions and 6 deletions
|
@ -7,14 +7,38 @@ use Tests\TestCase;
|
||||||
|
|
||||||
class CreateUserTest extends TestCase
|
class CreateUserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function testPermissionRequiredToCreateUser()
|
||||||
|
{
|
||||||
|
$this->actingAs(User::factory()->create())
|
||||||
|
->get(route('users.create'))
|
||||||
|
->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
public function testPageRenders()
|
public function testPageRenders()
|
||||||
{
|
{
|
||||||
$admin = User::factory()->createUsers()->create();
|
$this->actingAs(User::factory()->createUsers()->create())
|
||||||
$response = $this->actingAs(User::factory()->superuser()->create())
|
|
||||||
->get(route('users.create'))
|
->get(route('users.create'))
|
||||||
->assertOk();
|
->assertOk();
|
||||||
$response->assertDontSee($admin->first_name);
|
|
||||||
$response->assertDontSee($admin->last_name);
|
}
|
||||||
$response->assertDontSee($admin->email);
|
|
||||||
|
public function testCanCreateUser()
|
||||||
|
{
|
||||||
|
|
||||||
|
$response = $this->actingAs(User::factory()->createUsers()->viewUsers()->create())
|
||||||
|
->from(route('users.index'))
|
||||||
|
->post(route('users.store'), [
|
||||||
|
'first_name' => 'Test First Name',
|
||||||
|
'last_name' => 'Test Last Name',
|
||||||
|
'username' => 'testuser',
|
||||||
|
'password' => 'testpassword1235!!',
|
||||||
|
//'notes' => 'Test Note',
|
||||||
|
])
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.index'));
|
||||||
|
|
||||||
|
$this->followRedirects($response)->assertSee('Success');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class IndexUsersTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testPageRenders()
|
public function testPageRenders()
|
||||||
{
|
{
|
||||||
$this->actingAs(User::factory()->superuser()->create())
|
$this->actingAs(User::factory()->viewUsers()->create())
|
||||||
->get(route('users.index'))
|
->get(route('users.index'))
|
||||||
->assertOk();
|
->assertOk();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue