Skip to content

Commit 1b397cd

Browse files
committed
assertDbHas
1 parent 120316b commit 1b397cd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/Feature/Departments/Api/CreateDepartmentsTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)