-
Notifications
You must be signed in to change notification settings - Fork 25
/
TestCase.php
42 lines (32 loc) · 1.18 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Overblog\GraphiQLBundle\Tests;
use Overblog\GraphiQLBundle\Tests\Fixtures\TestKernel;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpKernel\KernelInterface;
abstract class TestCase extends WebTestCase
{
/** @var TestKernel[] */
private static $kernels = [];
/**
* {@inheritdoc}
*/
protected static function getKernelClass(): string
{
return TestKernel::class;
}
/**
* {@inheritdoc}
*/
protected static function createKernel(array $options = []): KernelInterface
{
static::$class = static::getKernelClass();
$options['test_case'] = isset($options['test_case']) ? $options['test_case'] : 'default';
$env = isset($options['environment']) ? $options['environment'] : 'overbloggraphibundletest'.strtolower($options['test_case']);
$debug = isset($options['debug']) ? $options['debug'] : true;
$kernelKey = '//'.$env.'//'.var_export($debug, true);
if (!isset(self::$kernels[$kernelKey])) {
self::$kernels[$kernelKey] = new static::$class($env, $debug, $options['test_case']);
}
return self::$kernels[$kernelKey];
}
}