1313use Illuminate \Support \Facades \Route ;
1414use Illuminate \Support \Facades \Session ;
1515use Illuminate \Support \Str ;
16+ use Illuminate \Testing \TestResponse ;
1617use Orchestra \Testbench \TestCase as BaseTestCase ;
18+ use PHPUnit \Framework \Assert ;
1719
1820abstract class TestCase extends BaseTestCase
1921{
@@ -37,24 +39,27 @@ protected function setUp(): void
3739 $ this ->sessionKey = Config::get ('localized-routes.session_key ' );
3840 $ this ->cookieName = Config::get ('localized-routes.cookie_name ' );
3941
40- if (version_compare ($ this ->app ->version (), '7.0.0 ' ) === -1 ) {
41- \Illuminate \Foundation \Testing \TestResponse::macro ('assertResponseHasNoView ' , function () {
42- if (isset ($ this ->original ) && $ this ->original instanceof View) {
43- Illuminate \Foundation \Testing \Assert::fail ('The response has a view. ' );
44- }
45-
46- return $ this ;
47- });
48- } else {
49- \Illuminate \Testing \TestResponse::macro ('assertResponseHasNoView ' , function () {
50- if (isset ($ this ->original ) && $ this ->original instanceof View) {
51- Illuminate \Testing \Assert::fail ('The response has a view. ' );
52- }
53-
54- return $ this ;
55- });
56- }
42+ TestResponse::macro ('assertResponseHasNoView ' , function () {
43+ if (isset ($ this ->original ) && $ this ->original instanceof View) {
44+ Assert::fail ('The response has a view. ' );
45+ }
46+
47+ return $ this ;
48+ });
49+ }
5750
51+ /**
52+ * Skip test if laravel version is lower than the given version.
53+ *
54+ * @param string $version
55+ *
56+ * @return void
57+ */
58+ protected function skipTestIfLaravelVersionIsLowerThan ($ version )
59+ {
60+ if (version_compare (App::version (), $ version ) === -1 ) {
61+ $ this ->markTestSkipped ("This test only applies to Laravel {$ version } and higher. " );
62+ }
5863 }
5964
6065 /**
0 commit comments