Completed
Push — master ( 90c851...aff568 )
by Petre
02:13
created

ConfigurationTest::testGivenThatTheConfigurationTreeForTheBundleIsBuiltThenAllOfItsOptionsAreInPlace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 64
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 64
c 0
b 0
f 0
rs 9.3956
cc 1
eloc 38
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
declare(strict_types = 1);
3
4
5
namespace SM\AirbrakeBundle\Tests\DependencyInjection;
6
7
use SM\AirbrakeBundle\DependencyInjection\Configuration;
8
use SM\AirbrakeBundle\Enum\AirbrakeDefaultEnum;
9
use Symfony\Component\Config\Definition\ArrayNode;
10
use Symfony\Component\Config\Definition\BooleanNode;
11
use Symfony\Component\Config\Definition\ScalarNode;
12
13
/**
14
 * Tests the functionality of the bundle configuration class.
15
 *
16
 * @package SM\AirbrakeBundle\Tests\DependencyInjection
17
 * @author  Petre Pătrașc <[email protected]>
18
 */
19
class ConfigurationTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var Configuration
23
     */
24
    protected $configuration;
25
26
    /**
27
     * @inheritDoc
28
     */
29
    protected function setUp()
30
    {
31
        $this->configuration = new Configuration;
32
    }
33
34
    public function testGivenThatTheConfigurationTreeForTheBundleIsBuiltThenAllOfItsOptionsAreInPlace()
35
    {
36
        /** @var ArrayNode $compiledTree */
37
        $compiledTree = (new Configuration())->getConfigTreeBuilder()->buildTree();
38
39
        $this->assertTrue($compiledTree instanceof ArrayNode);
40
        $children = $compiledTree->getChildren();
41
42
        $this->assertArrayHasKey('project_id', $children);
43
        /** @var ScalarNode $projectIdNode */
44
        $projectIdNode = $children['project_id'];
45
        $this->assertEquals(AirbrakeDefaultEnum::PROJECT_KEY, $projectIdNode->getDefaultValue());
46
47
        $this->assertArrayHasKey('project_key', $children);
48
        /** @var ScalarNode $projectKeyNode */
49
        $projectKeyNode = $children['project_key'];
50
        $this->assertEquals(AirbrakeDefaultEnum::PROJECT_KEY, $projectKeyNode->getDefaultValue());
51
52
        $this->assertArrayHasKey('host', $children);
53
        /** @var ScalarNode $hostNode */
54
        $hostNode = $children['host'];
55
        $this->assertEquals(AirbrakeDefaultEnum::HOST, $hostNode->getDefaultValue());
56
57
        $this->assertArrayHasKey('ignored_exceptions', $children);
58
        /** @var ArrayNode $ignoredExceptionsNode */
59
        $ignoredExceptionsNode = $children['ignored_exceptions'];
60
        $this->assertInternalType('array', $ignoredExceptionsNode->getDefaultValue());
61
        $this->assertEquals(AirbrakeDefaultEnum::IGNORED_EXCEPTIONS, $ignoredExceptionsNode->getDefaultValue());
62
63
        $this->assertArrayHasKey('global_exception_instance', $children);
64
        /** @var BooleanNode $globalExceptionInstanceNode */
65
        $globalExceptionInstanceNode = $children['global_exception_instance'];
66
        $this->assertEquals(AirbrakeDefaultEnum::GLOBAL_EXCEPTION_INSTANCE, $globalExceptionInstanceNode->getDefaultValue());
67
68
        $this->assertArrayHasKey('global_error_and_exception_handler', $children);
69
        /** @var BooleanNode $globalErrorAndExceptionHandlerNode */
70
        $globalErrorAndExceptionHandlerNode = $children['global_error_and_exception_handler'];
71
        $this->assertEquals(AirbrakeDefaultEnum::GLOBAL_ERROR_AND_EXCEPTION_HANDLER, $globalErrorAndExceptionHandlerNode->getDefaultValue());
72
73
        $this->assertArrayHasKey('http_client', $children);
74
        /** @var ScalarNode $httpClientNode */
75
        $httpClientNode = $children['http_client'];
76
        $this->assertEquals(AirbrakeDefaultEnum::HTTP_CLIENT, $httpClientNode->getDefaultValue());
77
78
        $this->assertArrayHasKey('root_directory', $children);
79
        /** @var ScalarNode $rootDirectoryNode */
80
        $rootDirectoryNode = $children['root_directory'];
81
        $this->assertEquals(AirbrakeDefaultEnum::ROOT_DIRECTORY, $rootDirectoryNode->getDefaultValue());
82
83
        $this->assertArrayHasKey('environment', $children);
84
        /** @var ScalarNode $environmentNode */
85
        $environmentNode = $children['environment'];
86
        $this->assertEquals(AirbrakeDefaultEnum::ENVIRONMENT, $environmentNode->getDefaultValue());
87
88
        $this->assertArrayHasKey('app_version', $children);
89
        /** @var ScalarNode $appVersionNode */
90
        $appVersionNode = $children['app_version'];
91
        $this->assertEquals(AirbrakeDefaultEnum::APP_VERSION, $appVersionNode->getDefaultValue());
92
93
        $this->assertArrayHasKey('listener_enabled', $children);
94
        /** @var ScalarNode $listenerEnabledNode */
95
        $listenerEnabledNode = $children['listener_enabled'];
96
        $this->assertEquals(AirbrakeDefaultEnum::LISTNER_ENABLED, $listenerEnabledNode->getDefaultValue());
97
    }
98
}
99