AzineSocialBarExtensionTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 59
dl 0
loc 117
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testFullConfigEmpty() 0 5 1
A getMinimalConfig() 0 7 1
A testFullConfigWithValues() 0 12 1
A testMinimalConfig() 0 5 1
A assertParameter() 0 3 1
A getFullConfigWithValues() 0 21 1
A tearDown() 0 3 1
A getFullConfigEmpty() 0 21 1
1
<?php
2
3
namespace Azine\SocialBarBundle\Tests\DependencyInjection;
4
5
use Azine\SocialBarBundle\DependencyInjection\AzineSocialBarExtension;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
use Symfony\Component\Yaml\Parser;
9
10
/**
11
 * This is the class that loads and manages your bundle configuration.
12
 *
13
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14
 */
15
class AzineSocialBarExtensionTest extends \PHPUnit\Framework\TestCase
16
{
17
    /** @var ContainerBuilder */
18
    protected $configuration;
19
20
    /**
21
     * This should not throw an exception.
22
     */
23
    public function testMinimalConfig()
24
    {
25
        $loader = new AzineSocialBarExtension();
26
        $config = $this->getMinimalConfig();
27
        $loader->load(array($config), new ContainerBuilder());
28
    }
29
30
    /**
31
     * This should not throw an exception.
32
     */
33
    public function testFullConfigEmpty()
34
    {
35
        $loader = new AzineSocialBarExtension();
36
        $config = $this->getFullConfigEmpty();
37
        $loader->load(array($config), new ContainerBuilder());
38
    }
39
40
    public function testFullConfigWithValues()
41
    {
42
        $this->configuration = new ContainerBuilder();
43
        $loader = new AzineSocialBarExtension();
44
        $config = $this->getFullConfigWithValues();
45
        $loader->load(array($config), $this->configuration);
46
47
        $this->assertParameter('http://fb.profile.url.com', 'azine_social_bar_fb_profile_url');
48
        $this->assertParameter('http://xing.profile.url.com', 'azine_social_bar_xing_profile_url');
49
        $this->assertParameter(1234567890, 'azine_social_bar_linked_in_company_id');
50
        $this->assertParameter('http://google.plus.profile.url.com', 'azine_social_bar_google_plus_profile_url');
51
        $this->assertParameter('acme', 'azine_social_bar_twitter_username');
52
    }
53
54
    /**
55
     * Get the minimal config.
56
     *
57
     * @return array
58
     */
59
    protected function getMinimalConfig()
60
    {
61
        $yaml = <<<EOF
62
EOF;
63
        $parser = new Parser();
64
65
        return $parser->parse($yaml);
66
    }
67
68
    /**
69
     * Get a full config for this bundle.
70
     */
71
    protected function getFullConfigEmpty()
72
    {
73
        $yaml = <<<EOF
74
# the url to you Facebook profile
75
fb_profile_url:       ~
76
77
# the url to your Google+ profile
78
google_plus_profile_url:  ~
79
80
# the url to your xing profile
81
xing_profile_url:     ~
82
83
# your profile-id => get it here http://developer.linkedin.com/plugins
84
linked_in_company_id:  ~
85
86
# your twitter username
87
twitter_username:     ~
88
EOF;
89
        $parser = new Parser();
90
91
        return $parser->parse($yaml);
92
    }
93
94
    /**
95
     * Get a full config for this bundle.
96
     */
97
    protected function getFullConfigWithValues()
98
    {
99
        $yaml = <<<EOF
100
# the url to you Facebook profile
101
fb_profile_url:       http://fb.profile.url.com
102
103
# the url to your Google+ profile
104
google_plus_profile_url:  http://google.plus.profile.url.com
105
106
# the url to your xing profile
107
xing_profile_url:     http://xing.profile.url.com
108
109
# your profile-id => get it here http://developer.linkedin.com/plugins
110
linked_in_company_id:  1234567890
111
112
# your twitter username
113
twitter_username:     acme
114
EOF;
115
        $parser = new Parser();
116
117
        return $parser->parse($yaml);
118
    }
119
120
    /**
121
     * @param mixed  $value
122
     * @param string $key
123
     */
124
    private function assertParameter($value, $key)
125
    {
126
        $this->assertSame($value, $this->configuration->getParameter($key), sprintf('%s parameter is correct', $key));
127
    }
128
129
    protected function tearDown()
130
    {
131
        unset($this->configuration);
132
    }
133
}
134