|
3 | 3 | namespace Tests\Feature; |
4 | 4 |
|
5 | 5 | use App\Models\Article; |
| 6 | +use App\Models\Series; |
6 | 7 | use App\Models\Tag; |
7 | 8 | use Illuminate\Foundation\Testing\DatabaseMigrations; |
8 | 9 |
|
@@ -44,4 +45,41 @@ public function users_cannot_create_a_series_with_a_title_that_is_too_long() |
44 | 45 | $response->assertSessionHas('error', 'Something went wrong. Please review the fields below.'); |
45 | 46 | $response->assertSessionHasErrors(['title' => 'The title may not be greater than 100 characters.']); |
46 | 47 | } |
| 48 | + |
| 49 | + /** @test */ |
| 50 | + public function users_can_edit_a_series() |
| 51 | + { |
| 52 | + $user = $this->createUser(); |
| 53 | + $tag = factory(Tag::class)->create(['name' => 'Test Tag']); |
| 54 | + factory(Series::class)->create([ |
| 55 | + 'author_id' => $user->id(), |
| 56 | + ]); |
| 57 | + |
| 58 | + $this->loginAs($user); |
| 59 | + |
| 60 | + $this->put('/articles/series/1', [ |
| 61 | + 'title' => 'A developers guide to SVG', |
| 62 | + 'tags' => [$tag->id()], |
| 63 | + ]) |
| 64 | + ->assertRedirectedTo('/articles/series/1') |
| 65 | + ->assertSessionHas('success', 'Series successfully updated!'); |
| 66 | + } |
| 67 | + |
| 68 | + /** @test */ |
| 69 | + public function users_cannot_edit_a_series_with_a_title_that_is_too_long() |
| 70 | + { |
| 71 | + $user = $this->createUser(); |
| 72 | + factory(Series::class)->create([ |
| 73 | + 'author_id' => $user->id() |
| 74 | + ]); |
| 75 | + |
| 76 | + $this->loginAs($user); |
| 77 | + |
| 78 | + $response = $this->put('/articles/series/1', [ |
| 79 | + 'title' => 'A developers guide to SVG which is an image format written in XML which is highly customisable and flexible', |
| 80 | + ]); |
| 81 | + |
| 82 | + $response->assertSessionHas('error', 'Something went wrong. Please review the fields below.'); |
| 83 | + $response->assertSessionHasErrors(['title' => 'The title may not be greater than 100 characters.']); |
| 84 | + } |
47 | 85 | } |
0 commit comments