|
7 | 7 |
|
8 | 8 | $response = $this->actingAs($admin)->post('/admin/subjects', [ |
9 | 9 | 'name' => 'Platform Testing', |
| 10 | + 'course' => 'hsc', |
10 | 11 | 'tailwind_format' => 'bg-slate-500', |
11 | 12 | 'icon' => 'book-open', |
12 | 13 | 'sort_order' => 1, |
13 | 14 | ]); |
14 | 15 |
|
15 | 16 | $response->assertRedirect(route('admin.subjects.index')); |
| 17 | + |
16 | 18 | $this->assertDatabaseHas('subjects', [ |
17 | 19 | 'name' => 'Platform Testing', |
| 20 | + 'course' => 'hsc', |
18 | 21 | 'tailwind_format' => 'bg-slate-500', |
19 | 22 | 'icon' => 'book-open', |
20 | 23 | 'sort_order' => 1, |
|
27 | 30 | $subject = Subject::create([ |
28 | 31 | 'name' => 'Platform Testing', |
29 | 32 | 'slug' => 'platform-testing', |
| 33 | + 'course' => 'hsc', |
30 | 34 | 'tailwind_format' => 'bg-slate-500', |
31 | 35 | 'icon' => 'book-open', |
32 | 36 | 'sort_order' => 1, |
33 | 37 | ]); |
34 | 38 |
|
35 | 39 | $response = $this->actingAs($admin)->patch("/admin/subjects/edit/{$subject->id}", [ |
36 | 40 | 'name' => 'Platform Testing Updated', |
| 41 | + 'course' => 'ssc', |
37 | 42 | 'tailwind_format' => 'bg-slate-600', |
38 | 43 | 'icon' => 'book-open', |
39 | 44 | 'sort_order' => 2, |
40 | 45 | ]); |
41 | 46 |
|
42 | 47 | $response->assertRedirect(route('admin.subjects.index')); |
| 48 | + |
43 | 49 | $this->assertDatabaseHas('subjects', [ |
44 | 50 | 'id' => $subject->id, |
45 | 51 | 'name' => 'Platform Testing Updated', |
| 52 | + 'course' => 'ssc', |
46 | 53 | 'sort_order' => 2, |
47 | 54 | ]); |
48 | 55 | }); |
|
53 | 60 | $subject = Subject::create([ |
54 | 61 | 'name' => 'Platform Testing', |
55 | 62 | 'slug' => 'platform-testing', |
| 63 | + 'course' => 'hsc', |
56 | 64 | 'tailwind_format' => 'bg-slate-500', |
57 | 65 | 'icon' => 'book-open', |
58 | 66 | 'sort_order' => 1, |
|
61 | 69 | $response = $this->actingAs($admin)->delete("/admin/subjects/{$subject->id}"); |
62 | 70 |
|
63 | 71 | $response->assertRedirect(); |
64 | | - $this->assertDatabaseMissing('subjects', ['id' => $subject->id]); |
| 72 | + |
| 73 | + $this->assertDatabaseMissing('subjects', [ |
| 74 | + 'id' => $subject->id, |
| 75 | + ]); |
65 | 76 | }); |
66 | 77 |
|
67 | 78 | test('invalid subject creation is rejected by validation', function () { |
68 | 79 | $admin = adminUserWithPermissions(['view admin', 'create subjects']); |
69 | 80 |
|
70 | 81 | $response = $this->actingAs($admin)->post('/admin/subjects', [ |
71 | 82 | 'name' => '', |
| 83 | + 'course' => '', |
72 | 84 | 'tailwind_format' => '', |
73 | 85 | 'icon' => '', |
74 | 86 | 'sort_order' => '', |
75 | 87 | ]); |
76 | 88 |
|
77 | 89 | $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 | + ]); |
79 | 99 | }); |
0 commit comments