@@ -27,7 +27,8 @@ public function test_can_create_department_with_all_fields()
2727 $ company = Company::factory ()->create ();
2828 $ location = Location::factory ()->create ();
2929 $ manager = User::factory ()->create ();
30- $ response = $ this ->actingAsForApi (User::factory ()->superuser ()->create ())
30+ $ user = User::factory ()->superuser ()->create ();
31+ $ response = $ this ->actingAsForApi ($ user )
3132 ->postJson (route ('api.departments.store ' ), [
3233 'name ' => 'Test Department ' ,
3334 'company_id ' => $ company ->id ,
@@ -46,6 +47,17 @@ public function test_can_create_department_with_all_fields()
4647 $ department = Department::find ($ response ['payload ' ]['id ' ]);
4748 $ this ->assertEquals ('Test Department ' , $ department ->name );
4849 $ this ->assertEquals ('Test Note ' , $ department ->notes );
50+
51+ $ this ->assertDatabaseHas ('departments ' , [
52+ 'name ' => 'Test Department ' ,
53+ 'company_id ' => $ company ->id ,
54+ 'location_id ' => $ location ->id ,
55+ 'manager_id ' => $ manager ->id ,
56+ 'notes ' => 'Test Note ' ,
57+ 'phone ' => '1234567890 ' ,
58+ 'fax ' => '1234567890 ' ,
59+ 'created_by ' => $ user ->id ,
60+ ]);
4961 }
5062
5163 public function test_name_required_for_department ()
0 commit comments