@@ -122,4 +122,45 @@ public function users_cannot_delete_a_thread_they_do_not_own()
122122 $ this ->delete ('/forum/my-first-thread ' )
123123 ->assertForbidden ();
124124 }
125+
126+ /** @test */
127+ public function users_cannot_create_a_thread_with_a_subject_that_is_too_long ()
128+ {
129+ $ tag = factory (Tag::class)->create (['name ' => 'Test Tag ' ]);
130+
131+ $ this ->login ();
132+
133+ $ this ->visit ('/forum/create-thread ' )
134+ ->submitForm ('Create Thread ' , [
135+ 'subject ' => 'How to make Eloquent, Doctrine, Entities and Annotations work together in Laravel? ' ,
136+ 'body ' => 'This is a thread with 82 characters in the subject ' ,
137+ 'tags ' => [$ tag ->id ()],
138+ ])
139+ ->seePageIs ('/forum/create-thread ' )
140+ ->see ('Something went wrong. Please review the fields below. ' )
141+ ->see ('The subject may not be greater than 60 characters. ' );
142+ }
143+
144+ /** @test */
145+ public function users_cannot_edit_a_thread_with_a_subject_that_is_too_long ()
146+ {
147+ $ user = $ this ->createUser ();
148+ $ tag = factory (Tag::class)->create (['name ' => 'Test Tag ' ]);
149+ factory (Thread::class)->create ([
150+ 'author_id ' => $ user ->id (),
151+ 'slug ' => 'my-first-thread ' ,
152+ ]);
153+
154+ $ this ->loginAs ($ user );
155+
156+ $ this ->visit ('/forum/my-first-thread/edit ' )
157+ ->submitForm ('Update Thread ' , [
158+ 'subject ' => 'How to make Eloquent, Doctrine, Entities and Annotations work together in Laravel? ' ,
159+ 'body ' => 'This is a thread with 82 characters in the subject ' ,
160+ 'tags ' => [$ tag ->id ()],
161+ ])
162+ ->seePageIs ('/forum/my-first-thread/edit ' )
163+ ->see ('Something went wrong. Please review the fields below. ' )
164+ ->see ('The subject may not be greater than 60 characters. ' );
165+ }
125166}
0 commit comments