@@ -65,14 +65,12 @@ public function the_thread_subject_cannot_be_an_url()
6565
6666 $ this ->login ();
6767
68- $ this ->visit ('/forum/create-thread ' )
69- ->submitForm ('Create Thread ' , [
68+ $ this ->post ('/forum/create-thread ' , [
7069 'subject ' => 'http://example.com Foo title ' ,
7170 'body ' => 'This text explains how to work with Eloquent. ' ,
7271 'tags ' => [$ tag ->id ()],
7372 ])
74- ->seePageIs ('/forum/create-thread ' )
75- ->see ('The subject field cannot contain an url. ' );
73+ ->assertSessionHasErrors (['subject ' => 'The subject field cannot contain an url. ' ]);
7674 }
7775
7876 /** @test */
@@ -82,16 +80,13 @@ public function users_can_create_a_thread()
8280
8381 $ this ->login ();
8482
85- $ this ->visit ('/forum/create-thread ' )
86- ->submitForm ('Create Thread ' , [
83+ $ this ->post ('/forum/create-thread ' , [
8784 'subject ' => 'How to work with Eloquent? ' ,
8885 'body ' => 'This text explains how to work with Eloquent. ' ,
8986 'tags ' => [$ tag ->id ()],
9087 ])
91- ->seePageIs ('/forum/how-to-work-with-eloquent ' )
92- ->see ('How to work with Eloquent? ' )
93- ->see ('Test Tag ' )
94- ->see ('Thread successfully created! ' );
88+ ->assertRedirectedTo ('/forum/how-to-work-with-eloquent ' )
89+ ->assertSessionHas ('success ' , 'Thread successfully created! ' );
9590 }
9691
9792 /** @test */
@@ -106,16 +101,13 @@ public function users_can_edit_a_thread()
106101
107102 $ this ->loginAs ($ user );
108103
109- $ this ->visit ('/forum/my-first-thread/edit ' )
110- ->submitForm ('Update Thread ' , [
104+ $ this ->put ('/forum/my-first-thread ' , [
111105 'subject ' => 'How to work with Eloquent? ' ,
112106 'body ' => 'This text explains how to work with Eloquent. ' ,
113107 'tags ' => [$ tag ->id ()],
114108 ])
115- ->seePageIs ('/forum/how-to-work-with-eloquent ' )
116- ->see ('How to work with Eloquent? ' )
117- ->see ('Test Tag ' )
118- ->see ('Thread successfully updated! ' );
109+ ->assertRedirectedTo ('/forum/how-to-work-with-eloquent ' )
110+ ->assertSessionHas ('success ' , 'Thread successfully updated! ' );
119111 }
120112
121113 /** @test */
@@ -147,15 +139,14 @@ public function users_cannot_create_a_thread_with_a_subject_that_is_too_long()
147139
148140 $ this ->login ();
149141
150- $ this ->visit ('/forum/create-thread ' )
151- ->submitForm ('Create Thread ' , [
152- 'subject ' => 'How to make Eloquent, Doctrine, Entities and Annotations work together in Laravel? ' ,
153- 'body ' => 'This is a thread with 82 characters in the subject ' ,
154- 'tags ' => [$ tag ->id ()],
155- ])
156- ->seePageIs ('/forum/create-thread ' )
157- ->see ('Something went wrong. Please review the fields below. ' )
158- ->see ('The subject may not be greater than 60 characters. ' );
142+ $ response = $ this ->post ('/forum/create-thread ' , [
143+ 'subject ' => 'How to make Eloquent, Doctrine, Entities and Annotations work together in Laravel? ' ,
144+ 'body ' => 'This is a thread with 82 characters in the subject ' ,
145+ 'tags ' => [$ tag ->id ()],
146+ ]);
147+
148+ $ response ->assertSessionHas ('error ' , 'Something went wrong. Please review the fields below. ' );
149+ $ response ->assertSessionHasErrors (['subject ' => 'The subject may not be greater than 60 characters. ' ]);
159150 }
160151
161152 /** @test */
@@ -170,14 +161,13 @@ public function users_cannot_edit_a_thread_with_a_subject_that_is_too_long()
170161
171162 $ this ->loginAs ($ user );
172163
173- $ this ->visit ('/forum/my-first-thread/edit ' )
174- ->submitForm ('Update Thread ' , [
175- 'subject ' => 'How to make Eloquent, Doctrine, Entities and Annotations work together in Laravel? ' ,
176- 'body ' => 'This is a thread with 82 characters in the subject ' ,
177- 'tags ' => [$ tag ->id ()],
178- ])
179- ->seePageIs ('/forum/my-first-thread/edit ' )
180- ->see ('Something went wrong. Please review the fields below. ' )
181- ->see ('The subject may not be greater than 60 characters. ' );
164+ $ response = $ this ->put ('/forum/my-first-thread ' , [
165+ 'subject ' => 'How to make Eloquent, Doctrine, Entities and Annotations work together in Laravel? ' ,
166+ 'body ' => 'This is a thread with 82 characters in the subject ' ,
167+ 'tags ' => [$ tag ->id ()],
168+ ]);
169+
170+ $ response ->assertSessionHas ('error ' , 'Something went wrong. Please review the fields below. ' );
171+ $ response ->assertSessionHasErrors (['subject ' => 'The subject may not be greater than 60 characters. ' ]);
182172 }
183173}
0 commit comments