9
9
use Tonysm \TurboLaravel \Http \Middleware \TurboMiddleware ;
10
10
use Tonysm \TurboLaravel \Tests \TestCase ;
11
11
use Tonysm \TurboLaravel \Tests \TestModel ;
12
+ use Tonysm \TurboLaravel \Turbo ;
12
13
use Tonysm \TurboLaravel \TurboFacade ;
13
14
14
15
class TurboMiddlewareTest extends TestCase
@@ -36,7 +37,7 @@ public function handles_redirect_responses()
36
37
{
37
38
$ request = Request::create ('/source ' );
38
39
$ request ->headers ->add ([
39
- 'Accept ' => ' text/html; turbo-stream , text/html, application/xhtml+xml ' ,
40
+ 'Accept ' => sprintf ( ' %s , text/html, application/xhtml+xml ', Turbo:: TURBO_STREAM_FORMAT ) ,
40
41
]);
41
42
$ response = new RedirectResponse ('/destination ' );
42
43
$ next = function () use ($ response ) {
@@ -82,7 +83,7 @@ public function respects_the_redirects_to_property_of_the_validation_failed_exce
82
83
$ request = Request::create ('/test-models ' , 'POST ' );
83
84
84
85
$ request ->headers ->add ([
85
- 'Accept ' => ' text/html; turbo-stream , text/html, application/xhtml+xml ' ,
86
+ 'Accept ' => sprintf ( ' %s , text/html, application/xhtml+xml ', Turbo:: TURBO_STREAM_FORMAT ) ,
86
87
]);
87
88
88
89
$ next = function () {
@@ -115,7 +116,7 @@ public function redirects_back_to_resource_create_routes_on_failed_validation_fo
115
116
})->name ('test-models.store ' )->middleware (TurboMiddleware::class);
116
117
117
118
$ response = $ this ->from ('/source ' )->post (route ('test-models.store ' ), [], [
118
- 'Accept ' => ' text/html; turbo-stream , text/html, application/xhtml+xml ' ,
119
+ 'Accept ' => sprintf ( ' %s , text/html, application/xhtml+xml ', Turbo:: TURBO_STREAM_FORMAT ) ,
119
120
]);
120
121
121
122
$ response ->assertRedirect (route ('test-models.create ' ));
@@ -136,7 +137,7 @@ public function redirects_back_to_resource_edit_routes_on_failed_validation_foll
136
137
$ testModel = TestModel::create (['name ' => 'Dummy model ' ]);
137
138
138
139
$ response = $ this ->from ('/source ' )->put (route ('test-models.update ' , $ testModel ), [], [
139
- 'Accept ' => ' text/html; turbo-stream , text/html, application/xhtml+xml ' ,
140
+ 'Accept ' => sprintf ( ' %s , text/html, application/xhtml+xml ', Turbo:: TURBO_STREAM_FORMAT ) ,
140
141
]);
141
142
142
143
$ response ->assertRedirect (route ('test-models.edit ' , $ testModel ));
@@ -153,7 +154,7 @@ public function lets_it_crash_when_redirect_route_does_not_exist()
153
154
$ testModel = TestModel::create (['name ' => 'Dummy model ' ]);
154
155
155
156
$ response = $ this ->from ('/source ' )->put (route ('test-models.update ' , $ testModel ), [], [
156
- 'Accept ' => ' text/html; turbo-stream , text/html, application/xhtml+xml ' ,
157
+ 'Accept ' => sprintf ( ' %s , text/html, application/xhtml+xml ', Turbo:: TURBO_STREAM_FORMAT ) ,
157
158
]);
158
159
159
160
$ response ->assertRedirect ('/source ' );
0 commit comments