Completed
Push — feature/fix-some-deps-no-debug ( 88213d )
by Narcotic
10:30
created

WebTestCase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 53
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKernelClass() 0 8 1
A createClient() 0 22 3
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
    protected static function createClient(array $options = array(), array $server = array())
31
    {
32
        WebTestCase::ensureKernelShutdown();
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
33
34
        if (null === KernelTestCase::$class) {
35
            KernelTestCase::$class = '\\Graviton\\'.static::getKernelClass();
36
        }
37
38
        WebTestCase::$kernel = new WebTestCase::$class(
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
39
            isset($options['environment']) ? $options['environment'] : 'test',
40
            false
41
        );
42
43
        WebTestCase::$kernel->setBundleLoader(new BundleLoader(new GravitonBundleBundle()));
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
44
45
        WebTestCase::$kernel->boot();
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
46
47
        $client = WebTestCase::$kernel->getContainer()->get('test.client');
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
48
        $client->setServerParameters($server);
49
50
        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
    protected static function getKernelClass()
63
    {
64
        // @codingStandardsIgnoreStart
65
        require_once __DIR__ . '/../../../../app/AppKernel.php';
66
        // @codingStandardsIgnoreEnd
67
68
        return 'AppKernel';
69
    }
70
}
71