Created
April 8, 2018 16:19
-
-
Save deleugpn/0fc627bf0f63fd151496b017b1955835 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Tests\Feature\Administrators; | |
| use Illuminate\Foundation\Testing\WithFaker; | |
| use Illuminate\Support\Facades\Hash; | |
| use App\Eloquent\Auth\Administrator; | |
| use App\Eloquent\Department; | |
| use Tests\Concerns\AuthenticatesAdmin; | |
| use Tests\TestCase; | |
| class CreateAdminTest extends TestCase | |
| { | |
| use AuthenticatesAdmin, WithFaker; | |
| /** | |
| * @test | |
| */ | |
| public function an_admin_can_create_another_admin() | |
| { | |
| [$name, $email, $department] = [ | |
| $this->faker->name, | |
| $this->faker->safeEmail, | |
| create(Department::class) | |
| ]; | |
| $this->post('/administrators', [ | |
| 'name' => $name, | |
| 'email' => $email, | |
| 'department' => $department->id, | |
| 'password' => '123456', | |
| ]) | |
| ->assertStatus(302) | |
| ->assertRedirect('/administrators') | |
| ->assertSessionHas('success'); | |
| $this->assertDatabaseHas('administrators', [ | |
| 'name' => $name, | |
| 'email' => $email, | |
| 'department_id' => $department->id, | |
| ]); | |
| $this->assertTrue( | |
| Hash::check('123456', | |
| Administrator::where('email', $email)->first()->password | |
| ) | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment