DashboardFeatureTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Tests\Feature\Admin\Dashboard;
  3. use App\Shop\Employees\Employee;
  4. use App\Shop\Employees\Repositories\EmployeeRepository;
  5. use App\Shop\Roles\Role;
  6. use Tests\TestCase;
  7. class DashboardFeatureTest extends TestCase
  8. {
  9. /** @test */
  10. public function it_should_show_the_admin_abilities_when_the_employee_is_admin()
  11. {
  12. $this
  13. ->actingAs($this->employee, 'employee')
  14. ->get(route('admin.dashboard'))
  15. ->assertStatus(200)
  16. ->assertSee('Home')
  17. ->assertSee('List products')
  18. ->assertSee('Create product')
  19. ->assertSee('List categories')
  20. ->assertSee('Create category')
  21. ->assertSee('List brands')
  22. ->assertSee('Create brand');
  23. }
  24. /** @test */
  25. public function it_should_not_show_admin_abilities_when_the_employee_is_not_admin()
  26. {
  27. $employee = factory(Employee::class)->create();
  28. $role = factory(Role::class)->create(['name' => 'clerk']);
  29. $employeeRepo = new EmployeeRepository($employee);
  30. $employeeRepo->syncRoles([$role->id]);
  31. $this
  32. ->actingAs($employee, 'employee')
  33. ->get(route('admin.dashboard'))
  34. ->assertStatus(200)
  35. ->assertSee('Home');
  36. }
  37. }