1
1
<?php
2
2
/*
3
- * Copyright 2021 Cloud Creativity Limited
3
+ * Copyright 2022 Cloud Creativity Limited
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
20
20
namespace LaravelJsonApi \BooleanSoftDeletes \Tests \Acceptance ;
21
21
22
22
use App \Schemas \PostSchema ;
23
+ use Illuminate \Foundation \Testing \Concerns \InteractsWithDeprecationHandling ;
23
24
use LaravelJsonApi \Contracts \Schema \Container as SchemaContainerContract ;
24
25
use LaravelJsonApi \Contracts \Server \Server ;
25
26
use LaravelJsonApi \Core \Schema \Container as SchemaContainer ;
27
+ use LaravelJsonApi \Core \Support \ContainerResolver ;
26
28
use Orchestra \Testbench \TestCase as BaseTestCase ;
27
29
28
30
class TestCase extends BaseTestCase
29
31
{
32
+ use InteractsWithDeprecationHandling;
30
33
31
34
/**
32
35
* @return void
@@ -35,14 +38,22 @@ protected function setUp(): void
35
38
{
36
39
parent ::setUp ();
37
40
41
+ $ this ->withoutDeprecationHandling ();
42
+
38
43
$ this ->loadMigrationsFrom (__DIR__ . '/../../database/migrations ' );
39
44
40
- $ this ->app ->singleton (
41
- SchemaContainerContract::class,
42
- fn ($ container ) => new SchemaContainer ($ container , $ container ->make (Server::class), [
45
+ // @TODO can simplify this when only supporting laravel-json-api/eloquent:^2.0
46
+ $ this ->app ->singleton (SchemaContainerContract::class, static function ($ container ) {
47
+ if (class_exists (ContainerResolver::class)) {
48
+ $ resolver = new ContainerResolver (static fn () => $ container );
49
+ } else {
50
+ $ resolver = $ container ;
51
+ }
52
+
53
+ return new SchemaContainer ($ resolver , $ container ->make (Server::class), [
43
54
PostSchema::class,
44
- ]),
45
- );
55
+ ]);
56
+ } );
46
57
47
58
$ this ->app ->singleton (Server::class, function () {
48
59
$ server = $ this ->createMock (Server::class);
0 commit comments