Skip to content

Commit 66b0678

Browse files
committed
Fix deprecated and modulate TestCase
1 parent d15b8e4 commit 66b0678

File tree

7 files changed

+36
-25
lines changed

7 files changed

+36
-25
lines changed

src/CacheWarmer/CompileCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function isOptional(): bool
3131
*
3232
* @return string[]
3333
*/
34-
public function warmUp($cacheDir, string $buildDir = null)
34+
public function warmUp(string $cacheDir, ?string $buildDir = null): array
3535
{
3636
if ($this->compiled) {
3737
// use warm up cache dir if type generator cache dir not already explicitly declared

tests/Functional/App/Resolver/NodeResolver.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
namespace Overblog\GraphQLBundle\Tests\Functional\App\Resolver;
66

77
use GraphQL\Type\Definition\ResolveInfo;
8-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
108

11-
final class NodeResolver implements ContainerAwareInterface
9+
final class NodeResolver
1210
{
13-
use ContainerAwareTrait;
14-
1511
private array $userData = [
1612
'1' => [
1713
'id' => 1,

tests/Functional/App/config/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ framework:
99
http_method_override: false
1010

1111
security:
12-
enable_authenticator_manager: true
12+
#enable_authenticator_manager: true
1313
providers:
1414
in_memory:
1515
memory:

tests/Functional/App/config/conflictingValidatorNamespaces/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ imports:
22
- { resource: ../config.yml }
33

44
framework:
5-
annotations: true
5+
# annotations: true
66
validation:
77
enabled: true
8-
enable_annotations: true
8+
# enable_annotations: true
99

1010
overblog_graphql:
1111
definitions:
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
imports:
22
- { resource: ../config.yml }
33
framework:
4-
annotations: true
4+
# annotations: true
55
validation:
66
enabled: true
7-
enable_annotations: true
7+
# enable_annotations: true
88

99
overblog_graphql:
1010
errors_handler:
@@ -15,6 +15,5 @@ overblog_graphql:
1515
query: RootQuery
1616
mappings:
1717
types:
18-
-
19-
type: yaml
20-
dir: "%kernel.project_dir%/config/typeShorthand/mapping"
18+
- type: yaml
19+
dir: "%kernel.project_dir%/config/typeShorthand/mapping"

tests/Functional/TestCase.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
use Overblog\GraphQLBundle\Tests\Functional\App\TestKernel;
99
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1010
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
11+
use Symfony\Component\DependencyInjection\Container;
1112
use Symfony\Component\DependencyInjection\ContainerInterface;
1213
use Symfony\Component\Filesystem\Filesystem;
1314
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpKernel\Kernel;
1416
use Symfony\Component\HttpKernel\KernelInterface;
1517

1618
use function call_user_func;
@@ -23,10 +25,31 @@
2325
use function strtolower;
2426
use function sys_get_temp_dir;
2527

28+
if (Kernel::VERSION_ID < 70000) {
29+
abstract class TestCase extends BaseTestCase
30+
{
31+
protected static function getContainer(): ContainerInterface
32+
{
33+
/** @phpstan-ignore-next-line */
34+
return static::$kernel->getContainer();
35+
}
36+
}
37+
} else {
38+
abstract class TestCase extends BaseTestCase
39+
{
40+
protected static function getContainer(): Container
41+
{
42+
/** @phpstan-ignore-next-line */
43+
return static::$kernel->getContainer();
44+
}
45+
}
46+
}
47+
48+
2649
/**
2750
* TestCase.
2851
*/
29-
abstract class TestCase extends WebTestCase
52+
abstract class BaseTestCase extends WebTestCase
3053
{
3154
public const USER_RYAN = 'ryan';
3255
public const USER_ADMIN = 'admin';
@@ -52,7 +75,7 @@ protected static function createKernel(array $options = []): KernelInterface
5275

5376
$options['test_case'] ??= '';
5477

55-
$env = $options['environment'] ?? 'test'.strtolower($options['test_case']);
78+
$env = $options['environment'] ?? 'test' . strtolower($options['test_case']);
5679
$debug = $options['debug'] ?? true;
5780

5881
return new static::$class($env, $debug, $options['test_case']);
@@ -64,7 +87,7 @@ protected static function createKernel(array $options = []): KernelInterface
6487
public static function setUpBeforeClass(): void
6588
{
6689
$fs = new Filesystem();
67-
$fs->remove(sys_get_temp_dir().'/OverblogGraphQLBundle/');
90+
$fs->remove(sys_get_temp_dir() . '/OverblogGraphQLBundle/');
6891
}
6992

7093
protected function tearDown(): void
@@ -105,12 +128,6 @@ protected static function assertGraphQL(string $query, array $expectedData = nul
105128
static::assertSame($expected, $result, json_encode($result));
106129
}
107130

108-
protected static function getContainer(): ContainerInterface
109-
{
110-
/** @phpstan-ignore-next-line */
111-
return static::$kernel->getContainer();
112-
}
113-
114131
protected static function query(string $query, string $username, string $testCase, string $password = self::DEFAULT_PASSWORD): KernelBrowser
115132
{
116133
$client = static::createClientAuthenticated($username, $testCase, $password);
@@ -164,7 +181,7 @@ public static function expressionFunctionFromPhp(string $phpFunctionName)
164181
return call_user_func([ExpressionFunction::class, 'fromPhp'], $phpFunctionName);
165182
}
166183

167-
return new ExpressionFunction($phpFunctionName, fn () => sprintf('\%s(%s)', $phpFunctionName, implode(', ', func_get_args())), function (): void {});
184+
return new ExpressionFunction($phpFunctionName, fn() => sprintf('\%s(%s)', $phpFunctionName, implode(', ', func_get_args())), function (): void {});
168185
}
169186

170187
/**

tests/Functional/Validator/DummyEntity.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/**
1010
* Class DummyEntity.
11-
*
1211
*/
1312
#[Assert\Callback([StaticValidator::class, 'validateClass'])]
1413
final class DummyEntity

0 commit comments

Comments
 (0)