title: Expected status code 200 but received 500
body: <p>That's the code for my unit test.
  It's working fine on local machine but when I push it to gitLab, I get</p>
  
  <pre><code>Expected status code 200 but received 500.
  Failed asserting that false is true.
  </code></pre>
  
  <p>I've other similar tests too, but those tests are working fine.
  The error I'm getting is against <code>edit</code> url. </p>
  
  <pre><code>&lt;?php
  
  namespace Tests\Unit;
  
  use App\Models\ACL\Permission;
  use App\Models\ACL\Role;
  use App\Models\Benefit\EmployeeDependent;
  use App\Models\Employee\Employee;
  use Illuminate\Foundation\Testing\RefreshDatabase;
  use Illuminate\Support\Facades\DB;
  use Tests\TestCase;
  
  class EmployeeDependentPolicyTest extends TestCase
  {
      use RefreshDatabase;
  
      public function setUp(): void
      {
          parent::setUp();
          $this-&gt;seed();
      }
  
      /**
       * Full Admin
       * @return mixed
       */
      public function createUserWithAdminRole()
      {
          $admin = factory(Employee::class)-&gt;create();
          $admin-&gt;assignRole('admin');
          return $admin;
      }
  
      /**
       *
       * A user with edit first and last name of dependents can create new dependents
       * @return mixed
       */
      public function createEmployeeRoleWithCreateDependentPermissions()
      {
          $employeeRole = factory(Role::class)-&gt;create(['type' =&gt; 'employee']);
          DB::table('role_permission_has_access_levels')-&gt;insert([
              ['role_id' =&gt; $employeeRole-&gt;id, 'permission_id' =&gt; (Permission::where('name', 'edit employeedependent first_name')-&gt;pluck('id')-&gt;first()), 'access_level_id' =&gt; 0],
              ['role_id' =&gt; $employeeRole-&gt;id, 'permission_id' =&gt; (Permission::where('name', 'edit employeedependent last_name')-&gt;pluck('id')-&gt;first()), 'access_level_id' =&gt; 0],
              ['role_id' =&gt; $employeeRole-&gt;id, 'permission_id' =&gt; (Permission::where('name', 'view employeedependent middlename')-&gt;pluck('id')-&gt;first()), 'access_level_id' =&gt; 0],
                  ]);
  
          return $employeeRole;
      }
  
      /**
       * A user with any of the edit dependent permissions can edit dependent
       * @return mixed
       */
      public function createEmployeeRoleWithEditDependentPermissions()
      {
          $employeeRole = factory(Role::class)-&gt;create(['type' =&gt; 'employee']);
          DB::table('role_permission_has_access_levels')-&gt;insert([
              ['role_id' =&gt; $employeeRole-&gt;id, 'permission_id' =&gt; (Permission::where('name', 'view employeedependent first_name')-&gt;pluck('id')-&gt;first()), 'access_level_id' =&gt; 0],
              ['role_id' =&gt; $employeeRole-&gt;id, 'permission_id' =&gt; (Permission::where('name', 'edit employeedependent last_name')-&gt;pluck('id')-&gt;first()), 'access_level_id' =&gt; 0],
              ['role_id' =&gt; $employeeRole-&gt;id, 'permission_id' =&gt; (Permission::where('name', 'view employeedependent middlename')-&gt;pluck('id')-&gt;first()), 'access_level_id' =&gt; 0],
          ]);
  
          return $employeeRole;
      }
  
      /**
       * @return mixed
       */
      public function createEmployeeWithCreatePermissions()
      {
          $employee['employee'] = factory(Employee::class)-&gt;create();
          $employee['role'] = $this-&gt;createEmployeeRoleWithCreateDependentPermissions();
          $employee['employee']-&gt;assignRole($employee['role']-&gt;name);
          $employee['dependent']=$this-&gt;createEmployeeDependents($employee['employee']-&gt;id);
          return $employee;
      }
      /**
       * @return mixed
       */
      public function createEmployeeWithEditPermissions()
      {
          $employee['employee'] = factory(Employee::class)-&gt;create();
          $employee['role'] = $this-&gt;createEmployeeRoleWithEditDependentPermissions();
          $employee['employee']-&gt;assignRole($employee['role']-&gt;name);
          $employee['dependent']=$this-&gt;createEmployeeDependents($employee['employee']-&gt;id);
          return $employee;
      }
  
      /**
       *  Admin can view all employees' dependents
       */
      public function test_admin_can_view_dependents_of_all_employees()
      {
          $admin = $this-&gt;createUserWithAdminRole();
          $employee1 = $this-&gt;createEmployeeWithCreatePermissions();
          $response = $this-&gt;actingAs($admin)
              -&gt;get('/en/employees/' . $employee1['employee']-&gt;id.'/dependents');
          $response-&gt;assertStatus(200);
      }
  
      /**
       * Admin can access create/edit dependents page for all Employees
       */
      public function test_admin_can_create_and_edit_dependents_for_all_employees()
      {
          $admin = $this-&gt;createUserWithAdminRole();
          $employee1 = $this-&gt;createEmployeeWithCreatePermissions();
          $response = $this-&gt;actingAs($admin)
              -&gt;get('/en/employees/' . $employee1['employee']-&gt;id.'/dependents/create');
          $response-&gt;assertStatus(200);
          $response = $this-&gt;actingAs($admin)
              -&gt;get('/en/employees/' . $employee1['employee']-&gt;id.'/dependents/'.$employee1['dependent']-&gt;id.'/edit');
          $response-&gt;assertStatus(200);
      }
  
      /**
       * @param $id
       * @return mixed
       */
      public function createEmployeeDependents($id)
      {
          return factory(EmployeeDependent::class)-&gt;create(['emp_id'=&gt; $id]);
      }
  
      /**
       *  Employee can view his dependents
       */
      public function test_employee_can_view_his_dependents()
      {
          $employee = $this-&gt;createEmployeeWithCreatePermissions();
          $response = $this-&gt;actingAs($employee['employee'])
              -&gt;get('/en/employees/' . $employee['employee']-&gt;id.'/dependents');
          $response-&gt;assertStatus(200);
      }
      /**
       *  Employee who can create his dependents can also edit
       */
      public function test_employee_can_create_and_edit_his_dependents()
      {
          $employee = $this-&gt;createEmployeeWithCreatePermissions();
          $response = $this-&gt;actingAs($employee['employee'])
              -&gt;get('/en/employees/' . $employee['employee']-&gt;id.'/dependents/create');
          $response-&gt;assertStatus(200);
          $response = $this-&gt;actingAs($employee['employee'])
              -&gt;get('/en/employees/' . $employee['employee']-&gt;id.'/dependents/'.$employee['dependent']-&gt;id.'/edit');
          $response-&gt;assertStatus(200);
      }
  
      /**
       *  Employee who can no permission to edit first or last name cannot create his dependents but only edit them
       */
      public function test_employee_can_edit_his_dependents_but_not_create()
      {
          $employee = $this-&gt;createEmployeeWithEditPermissions();
          $response = $this-&gt;actingAs($employee['employee'])
              -&gt;get('/en/employees/' . $employee['employee']-&gt;id.'/dependents/create');
          $response-&gt;assertStatus(403);
          $response = $this-&gt;actingAs($employee['employee'])
              -&gt;get('/en/employees/' . $employee['employee']-&gt;id.'/dependents/'.$employee['dependent']-&gt;id.'/edit');
          $response-&gt;assertStatus(200);
      }
  }
  </code></pre>
  
  <p>That's my error log:</p>
  
  <pre><code>continuous-integration — test
  00:23
  
  
  latest: Pulling from jakzal/phpqa
  Digest: sha256:9638cd6c39a865c5f80ae29d02348cce3918a6709d8f8cee4d9cb054860b81b1
  Status: Image is up to date for jakzal/phpqa:latest
  + vendor/bin/phpunit --no-coverage --colors=never
  PHPUnit 7.5.17 by Sebastian Bergmann and contributors.
  
  R.R...RR....R............F.FF.............                        42 / 42 (100%)
  
  Time: 21.39 seconds, Memory: 44.00 MB
  
  There were 3 failures:
  
  1) Tests\Unit\EmployeeDependentPolicyTest::test_admin_can_create_and_edit_dependents_for_all_employees
  Expected status code 200 but received 500.
  Failed asserting that false is true.
  
  /drone/src/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:151
  /drone/src/tests/Unit/EmployeeDependentPolicyTest.php:114
  
  2) Tests\Unit\EmployeeDependentPolicyTest::test_employee_can_create_and_edit_his_dependents
  Expected status code 200 but received 500.
  Failed asserting that false is true.
  
  /drone/src/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:151
  /drone/src/tests/Unit/EmployeeDependentPolicyTest.php:147
  
  3) Tests\Unit\EmployeeDependentPolicyTest::test_employee_can_edit_his_dependents_but_not_create
  Expected status code 200 but received 500.
  Failed asserting that false is true.
  
  /drone/src/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:151
  /drone/src/tests/Unit/EmployeeDependentPolicyTest.php:161
  
  --
  
  There were 5 risky tests:
  
  1) Tests\Feature\EditMangerTest::test_admin_can_edit_manager
  This test did not perform any assertions
  
  /drone/src/tests/Feature/EditMangerTest.php:14
  
  2) Tests\Feature\createRoleTest::test_user_can_create_role
  This test did not perform any assertions
  
  /drone/src/tests/Feature/createRoleTest.php:11
  
  3) Tests\Unit\Approval\restoreStandardApprovalTest::testStandardApprovalHaveDefaultFields
  This test did not perform any assertions
  
  /drone/src/tests/Unit/Approval/restoreStandardApprovalTest.php:14
  
  4) Tests\Unit\Approval\restoreStandardApprovalTest::testRestoreStandardApproval
  This test did not perform any assertions
  
  /drone/src/tests/Unit/Approval/restoreStandardApprovalTest.php:20
  
  5) Tests\Unit\DefaultApprovalsTest::testDefaultApprovalsCount
  This test did not perform any assertions
  
  /drone/src/tests/Unit/DefaultApprovalsTest.php:22
  
  FAILURES!
  Tests: 42, Assertions: 100, Failures: 3, Risky: 5.
  DocumentationPluginsSupport
  GitHubTwitterDiscourseGitter
  </code></pre>