Skip to content

Commit 369cb54

Browse files
committed
fix: update test for new database scheme
1 parent 4556f45 commit 369cb54

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

‎tests/Feature/SubjectManagementTest.php‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

88
$response = $this->actingAs($admin)->post('/admin/subjects', [
99
'name' => 'Platform Testing',
10+
'course' => 'hsc',
1011
'tailwind_format' => 'bg-slate-500',
1112
'icon' => 'book-open',
1213
'sort_order' => 1,
1314
]);
1415

1516
$response->assertRedirect(route('admin.subjects.index'));
17+
1618
$this->assertDatabaseHas('subjects', [
1719
'name' => 'Platform Testing',
20+
'course' => 'hsc',
1821
'tailwind_format' => 'bg-slate-500',
1922
'icon' => 'book-open',
2023
'sort_order' => 1,
@@ -27,22 +30,26 @@
2730
$subject = Subject::create([
2831
'name' => 'Platform Testing',
2932
'slug' => 'platform-testing',
33+
'course' => 'hsc',
3034
'tailwind_format' => 'bg-slate-500',
3135
'icon' => 'book-open',
3236
'sort_order' => 1,
3337
]);
3438

3539
$response = $this->actingAs($admin)->patch("/admin/subjects/edit/{$subject->id}", [
3640
'name' => 'Platform Testing Updated',
41+
'course' => 'ssc',
3742
'tailwind_format' => 'bg-slate-600',
3843
'icon' => 'book-open',
3944
'sort_order' => 2,
4045
]);
4146

4247
$response->assertRedirect(route('admin.subjects.index'));
48+
4349
$this->assertDatabaseHas('subjects', [
4450
'id' => $subject->id,
4551
'name' => 'Platform Testing Updated',
52+
'course' => 'ssc',
4653
'sort_order' => 2,
4754
]);
4855
});
@@ -53,6 +60,7 @@
5360
$subject = Subject::create([
5461
'name' => 'Platform Testing',
5562
'slug' => 'platform-testing',
63+
'course' => 'hsc',
5664
'tailwind_format' => 'bg-slate-500',
5765
'icon' => 'book-open',
5866
'sort_order' => 1,
@@ -61,19 +69,31 @@
6169
$response = $this->actingAs($admin)->delete("/admin/subjects/{$subject->id}");
6270

6371
$response->assertRedirect();
64-
$this->assertDatabaseMissing('subjects', ['id' => $subject->id]);
72+
73+
$this->assertDatabaseMissing('subjects', [
74+
'id' => $subject->id,
75+
]);
6576
});
6677

6778
test('invalid subject creation is rejected by validation', function () {
6879
$admin = adminUserWithPermissions(['view admin', 'create subjects']);
6980

7081
$response = $this->actingAs($admin)->post('/admin/subjects', [
7182
'name' => '',
83+
'course' => '',
7284
'tailwind_format' => '',
7385
'icon' => '',
7486
'sort_order' => '',
7587
]);
7688

7789
$response->assertStatus(302);
78-
$response->assertSessionHasErrors(['name', 'slug', 'tailwind_format', 'icon', 'sort_order']);
90+
91+
$response->assertSessionHasErrors([
92+
'name',
93+
'slug',
94+
'course',
95+
'tailwind_format',
96+
'icon',
97+
'sort_order',
98+
]);
7999
});

0 commit comments

Comments
 (0)