|
6 | 6 | use App\Models\User;
|
7 | 7 | use Carbon\Carbon;
|
8 | 8 | use Illuminate\Foundation\Testing\DatabaseMigrations;
|
9 |
| -use Tests\Feature\BrowserKitTestCase; |
| 9 | +use Tests\TestCase; |
10 | 10 |
|
11 |
| -uses(BrowserKitTestCase::class); |
| 11 | +uses(TestCase::class); |
12 | 12 | uses(DatabaseMigrations::class);
|
13 | 13 |
|
14 | 14 | test('requires login', function () {
|
15 |
| - $this->visit('/admin') |
16 |
| - ->seePageIs('/login'); |
| 15 | + $this->get('/admin') |
| 16 | + ->assertRedirect('/login'); |
17 | 17 | });
|
18 | 18 |
|
19 | 19 | test('normal users cannot visit the admin section', function () {
|
|
83 | 83 | $this->loginAsAdmin();
|
84 | 84 |
|
85 | 85 | $this->put('/admin/users/'.$user->username().'/ban')
|
86 |
| - ->assertRedirectedTo('/'); |
| 86 | + ->assertRedirect('/'); |
87 | 87 |
|
88 |
| - test()->seeInDatabase('users', ['id' => $user->id(), 'banned_at' => null, 'banned_reason' => null]); |
| 88 | + test()->assertDatabaseHas('users', ['id' => $user->id(), 'banned_at' => null, 'banned_reason' => null]); |
89 | 89 | });
|
90 | 90 |
|
91 | 91 | test('moderators cannot ban a user without a reason', function () {
|
|
94 | 94 | $this->loginAsModerator();
|
95 | 95 |
|
96 | 96 | $this->put('/admin/users/'.$user->username().'/ban')
|
97 |
| - ->assertRedirectedTo('/'); |
| 97 | + ->assertRedirect('/'); |
98 | 98 |
|
99 |
| - test()->seeInDatabase('users', ['id' => $user->id(), 'banned_at' => null, 'banned_reason' => null]); |
| 99 | + test()->assertDatabaseHas('users', ['id' => $user->id(), 'banned_at' => null, 'banned_reason' => null]); |
100 | 100 | });
|
101 | 101 |
|
102 | 102 | test('admins can delete a user', function () {
|
|
108 | 108 | $this->loginAsAdmin();
|
109 | 109 |
|
110 | 110 | $this->delete('/admin/users/'.$user->username())
|
111 |
| - ->assertRedirectedTo('/admin/users'); |
| 111 | + ->assertRedirect('/admin/users'); |
112 | 112 |
|
113 |
| - $this->notSeeInDatabase('users', ['name' => 'Freek Murze']); |
| 113 | + $this->assertDatabaseMissing('users', ['name' => 'Freek Murze']); |
114 | 114 |
|
115 | 115 | // Make sure associated content is deleted.
|
116 |
| - $this->notSeeInDatabase('threads', ['author_id' => $user->id()]); |
117 |
| - $this->notSeeInDatabase('replies', ['replyable_id' => $thread->id()]); |
118 |
| - $this->notSeeInDatabase('replies', ['author_id' => $user->id()]); |
| 116 | + $this->assertDatabaseMissing('threads', ['author_id' => $user->id()]); |
| 117 | + $this->assertDatabaseMissing('replies', ['replyable_id' => $thread->id()]); |
| 118 | + $this->assertDatabaseMissing('replies', ['author_id' => $user->id()]); |
119 | 119 | });
|
120 | 120 |
|
121 | 121 | test('admins cannot delete other admins', function () {
|
|
144 | 144 | $this->loginAsAdmin();
|
145 | 145 |
|
146 | 146 | $this->get('admin')
|
147 |
| - ->see($submittedArticle->title()) |
148 |
| - ->dontSee($draftArticle->title()) |
149 |
| - ->dontSee($liveArticle->title()); |
| 147 | + ->assertSee($submittedArticle->title()) |
| 148 | + ->assertDontSee($draftArticle->title()) |
| 149 | + ->assertDontSee($liveArticle->title()); |
150 | 150 | });
|
151 | 151 |
|
152 | 152 | test('moderators can list submitted articles', function () {
|
|
157 | 157 | $this->loginAsModerator();
|
158 | 158 |
|
159 | 159 | $this->get('admin')
|
160 |
| - ->see($submittedArticle->title()) |
161 |
| - ->dontSee($draftArticle->title()) |
162 |
| - ->dontSee($liveArticle->title()); |
| 160 | + ->assertSee($submittedArticle->title()) |
| 161 | + ->assertDontSee($draftArticle->title()) |
| 162 | + ->assertDontSee($liveArticle->title()); |
163 | 163 | });
|
164 | 164 |
|
165 | 165 | test('users cannot list submitted articles', function () {
|
|
171 | 171 |
|
172 | 172 | test('guests cannot list submitted articles', function () {
|
173 | 173 | $this->get('admin')
|
174 |
| - ->assertRedirectedTo('login'); |
| 174 | + ->assertRedirect('/login'); |
175 | 175 | });
|
176 | 176 |
|
177 | 177 | test('admins can view submitted articles', function () {
|
|
180 | 180 | $this->loginAsAdmin();
|
181 | 181 |
|
182 | 182 | $this->get("articles/{$article->slug()}")
|
183 |
| - ->see('Awaiting Approval'); |
| 183 | + ->assertSee('Awaiting Approval'); |
184 | 184 | });
|
185 | 185 |
|
186 | 186 | test('admins can approve articles', function () {
|
|
216 | 216 | $article = Article::factory()->create(['submitted_at' => now()]);
|
217 | 217 |
|
218 | 218 | $this->put("/admin/articles/{$article->slug()}/approve")
|
219 |
| - ->assertRedirectedTo('/login'); |
| 219 | + ->assertRedirect('/login'); |
220 | 220 |
|
221 | 221 | expect($article->fresh()->approvedAt())->toBeNull();
|
222 | 222 | });
|
|
254 | 254 | $article = Article::factory()->create(['submitted_at' => now(), 'approved_at' => now()]);
|
255 | 255 |
|
256 | 256 | $this->put("/admin/articles/{$article->slug()}/disapprove")
|
257 |
| - ->assertRedirectedTo('/login'); |
| 257 | + ->assertRedirect('/login'); |
258 | 258 |
|
259 | 259 | $this->assertNotNull($article->fresh()->approvedAt());
|
260 | 260 | });
|
@@ -357,30 +357,30 @@ function assertCanSeeTheUserOverview()
|
357 | 357 | User::factory()->create(['name' => 'Freek Murze']);
|
358 | 358 | User::factory()->create(['name' => 'Frederick Vanbrabant']);
|
359 | 359 |
|
360 |
| - test()->visit('/admin/users') |
361 |
| - ->see('Freek Murze') |
362 |
| - ->see('Frederick Vanbrabant'); |
| 360 | + test()->get('/admin/users') |
| 361 | + ->assertSee('Freek Murze') |
| 362 | + ->assertSee('Frederick Vanbrabant'); |
363 | 363 | }
|
364 | 364 |
|
365 | 365 | function assertCanBanUsers()
|
366 | 366 | {
|
367 | 367 | $user = User::factory()->create(['name' => 'Freek Murze']);
|
368 | 368 |
|
369 | 369 | test()->put('/admin/users/'.$user->username().'/ban', ['reason' => 'A good reason'])
|
370 |
| - ->assertRedirectedTo('/user/'.$user->username()); |
| 370 | + ->assertRedirect('/user/'.$user->username()); |
371 | 371 |
|
372 |
| - test()->notSeeInDatabase('users', ['id' => $user->id(), 'banned_at' => null]); |
373 |
| - test()->seeInDatabase('users', ['id' => $user->id(), 'banned_reason' => 'A good reason']); |
| 372 | + test()->assertDatabaseMissing('users', ['id' => $user->id(), 'banned_at' => null]); |
| 373 | + test()->assertDatabaseHas('users', ['id' => $user->id(), 'banned_reason' => 'A good reason']); |
374 | 374 | }
|
375 | 375 |
|
376 | 376 | function assertCanUnbanUsers()
|
377 | 377 | {
|
378 | 378 | $user = User::factory()->create(['name' => 'Freek Murze', 'banned_at' => Carbon::now()]);
|
379 | 379 |
|
380 | 380 | test()->put('/admin/users/'.$user->username().'/unban')
|
381 |
| - ->assertRedirectedTo('/user/'.$user->username()); |
| 381 | + ->assertRedirect('/user/'.$user->username()); |
382 | 382 |
|
383 |
| - test()->seeInDatabase('users', ['id' => $user->id(), 'banned_at' => null, 'banned_reason' => null]); |
| 383 | + test()->assertDatabaseHas('users', ['id' => $user->id(), 'banned_at' => null, 'banned_reason' => null]); |
384 | 384 | }
|
385 | 385 |
|
386 | 386 | function assertCannotBanAdmins()
|
|
0 commit comments