Completed
Push — feature/EVO-4597-rabbitmq-hand... ( 6e503b...616297 )
by
unknown
52:22 queued 46:35
created

WebTestCase::getKernelClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.064
Metric Value
dl 0
loc 8
ccs 3
cts 5
cp 0.6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1.064
1
<?php
2
/**
3
 * Base class for tests that need a http client..
4
 */
5
6
namespace Graviton\TestBundle\Test;
7
8
use Graviton\BundleBundle\GravitonBundleBundle;
9
use Graviton\BundleBundle\Loader\BundleLoader;
10
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
11
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymWebTestCase;
12
13
/**
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
abstract class WebTestCase extends SymWebTestCase
0 ignored issues
show
Coding Style introduced by
WebTestCase does not seem to conform to the naming convention (^Abstract|Factory$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
19
{
20
    /**
21
     * Provides a HttpClient based on the Graviton\AppKernel
22
     *
23
     * @todo why are we not using createClient from SymWebTestCase? This need fixing or an explanation.
24
     *
25
     * @param array $options environment and debug option for kernel
26
     * @param array $server  server params
27
     *
28
     * @return \Symfony\Bundle\FrameworkBundle\Client
29
     */
30 1
    protected static function createClient(array $options = array(), array $server = array())
31
    {
32 1
        WebTestCase::ensureKernelShutdown();
33
34 1
        if (null === KernelTestCase::$class) {
35 1
            KernelTestCase::$class = '\\Graviton\\'.static::getKernelClass();
36 1
        }
37
38 1
        WebTestCase::$kernel = new WebTestCase::$class(
39 1
            isset($options['environment']) ? $options['environment'] : 'test',
40 1
            isset($options['debug']) ? $options['debug'] : true
41 1
        );
42
43 1
        WebTestCase::$kernel->setBundleLoader(new BundleLoader(new GravitonBundleBundle()));
44
45 1
        WebTestCase::$kernel->boot();
46
47 1
        $client = WebTestCase::$kernel->getContainer()->get('test.client');
48 1
        $client->setServerParameters($server);
49
50 1
        return $client;
51
    }
52
53
    /**
54
     * Attempts to guess the kernel location.
55
     *
56
     * When the Kernel is located, the file is required.
57
     *
58
     * @return string The Kernel class name
59
     *
60
     * @throws \RuntimeException
61
     */
62 1
    protected static function getKernelClass()
63
    {
64
        // @codingStandardsIgnoreStart
65 1
        require_once __DIR__ . '/../../../../app/AppKernel.php';
66
        // @codingStandardsIgnoreEnd
67
68 1
        return 'AppKernel';
69
    }
70
}
71