Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit dc29ced

Browse files
committed
Fix tests with Laravel 6 to 8
1 parent b0500c6 commit dc29ced

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/JsonApiServiceProvider.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace SkoreLabs\JsonApi;
44

5+
use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;
56
use Illuminate\Database\Eloquent\Builder;
6-
use Illuminate\Foundation\Testing\TestResponse;
7+
use Illuminate\Testing\TestResponse;
78
use Illuminate\Support\ServiceProvider;
89
use SkoreLabs\JsonApi\Builder as JsonApiBuilder;
910
use SkoreLabs\JsonApi\Testing\TestResponseMacros;
@@ -35,8 +36,22 @@ public function register()
3536

3637
$this->mergeConfigFrom(__DIR__.'/../config/json-api.php', 'json-api');
3738

39+
$this->registerTestingMacros();
40+
}
41+
42+
protected function registerTestingMacros()
43+
{
3844
if (class_exists(TestResponse::class)) {
3945
TestResponse::mixin(new TestResponseMacros());
46+
47+
return;
48+
}
49+
50+
// Laravel <= 6.0
51+
if (class_exists(LegacyTestResponse::class)) {
52+
LegacyTestResponse::mixin(new TestResponseMacros());
53+
54+
return;
4055
}
4156
}
4257
}

0 commit comments

Comments
 (0)