testConfigLoadThrowsExceptionWhenNoAuthenticationRoute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Ghoubre\FirebaseServiceBundle\Tests\DependencyInjection;
4
5
use Ghoubre\FirebaseServiceBundle\DependencyInjection\GhoubreFirebaseServiceExtension;
6
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Extension\Extension;
9
use Symfony\Component\Yaml\Parser;
10
11
class GhoubreFirebaseServiceExtensionTest extends TestCase
12
{
13
    protected $configuration;
14
15
16
    /**
17
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
18
     */
19
    public function testConfigLoadThrowsExceptionWhenNoAuthenticationRoute()
20
    {
21
        $loader = new GhoubreFirebaseServiceExtension();
22
        $config = $this->getEmptyConfig();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $config is correct as $this->getEmptyConfig() targeting Ghoubre\FirebaseServiceB...nTest::getEmptyConfig() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
23
        $loader->load(array($config), new ContainerBuilder());
24
    }
25
26
    public function testFullConfig()
27
    {
28
        $this->configuration = new ContainerBuilder();
29
        $loader = new GhoubreFirebaseServiceExtension();
30
        $config = $this->getFullConfig();
31
32
        $loader->load(array($config), $this->configuration);
33
34
        $this->assertHasDefinition('ghoubre.firebase_notification_service');
35
        $this->assertEquals($this->getDefinitionArgument('ghoubre.firebase_notification_service', 0), 'serverKey');
36
        $this->assertEquals($this->getDefinitionArgument('ghoubre.firebase_notification_service', 1), true);
37
        $this->assertEquals($this->getDefinitionArgument('ghoubre.firebase_notification_service', 2), 30);
38
    }
39
40
    protected function getFullConfig()
41
    {
42
        $yaml = <<<EOF
43
serverKey: serverKey
44
content_available: true
45
time_to_live: 30
46
EOF;
47
        $parser = new Parser();
48
        return $parser->parse($yaml);
49
    }
50
51
    protected function getEmptyConfig()
52
    {
53
54
    }
55
56
    private function assertHasDefinition($id)
57
    {
58
        $this->assertTrue($this->configuration->hasDefinition($id));
59
    }
60
61
    private function getDefinitionArgument($id, $index)
62
    {
63
        return $this->configuration->getDefinition($id)->getArgument($index);
64
    }
65
66
67
}
68