Skip to content

Commit 6259b01

Browse files
committed
Fix backwards incompatible TestResponse reference
1 parent 8d81015 commit 6259b01

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tests/TestCase.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Illuminate\Support\Facades\Config;
1111
use Illuminate\Support\Facades\Lang;
1212
use Illuminate\Support\Facades\Route;
13-
use Illuminate\Testing\Assert as PHPUnit;
14-
use Illuminate\Testing\TestResponse;
1513
use Orchestra\Testbench\TestCase as BaseTestCase;
1614

1715
abstract class TestCase extends BaseTestCase
@@ -25,13 +23,24 @@ protected function setUp(): void
2523
{
2624
parent::setUp();
2725

28-
TestResponse::macro('assertResponseHasNoView', function () {
29-
if (isset($this->original) && $this->original instanceof View) {
30-
PHPUnit::fail('The response has a view.');
31-
}
26+
if ($this->app->version() < 7) {
27+
\Illuminate\Foundation\Testing\TestResponse::macro('assertResponseHasNoView', function () {
28+
if (isset($this->original) && $this->original instanceof View) {
29+
Illuminate\Foundation\Testing\Assert::fail('The response has a view.');
30+
}
31+
32+
return $this;
33+
});
34+
} else {
35+
\Illuminate\Testing\TestResponse::macro('assertResponseHasNoView', function () {
36+
if (isset($this->original) && $this->original instanceof View) {
37+
Illuminate\Testing\Assert::fail('The response has a view.');
38+
}
39+
40+
return $this;
41+
});
42+
}
3243

33-
return $this;
34-
});
3544
}
3645

3746
/**

0 commit comments

Comments
 (0)