Completed
Push — master ( 157467...db6785 )
by Artem
28:48
created

FreshFirebaseCloudMessagingBundleExtensionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the FirebaseCloudMessagingBundle
4
 *
5
 * (c) Artem Henvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fresh\FirebaseCloudMessagingBundle\Tests\DependencyInjection;
12
13
use Fresh\FirebaseCloudMessagingBundle\DependencyInjection\FreshFirebaseCloudMessagingExtension;
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\Yaml\Parser;
17
18
/**
19
 * FreshFirebaseCloudMessagingBundleExtensionTest.
20
 *
21
 * @author Artem Henvald <[email protected]>
22
 */
23
class FreshFirebaseCloudMessagingBundleExtensionTest extends TestCase
24
{
25
    /** @var FreshFirebaseCloudMessagingExtension */
26
    private $extension;
27
28
    /** @var ContainerBuilder */
29
    private $container;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function setUp()
35
    {
36
        $this->extension = new FreshFirebaseCloudMessagingExtension();
37
        $this->container = new ContainerBuilder();
38
        $this->container->registerExtension($this->extension);
39
    }
40
41
    public function testGetAlias()
42
    {
43
        $this->assertSame('fresh_firebase_cloud_messaging', $this->extension->getAlias());
44
    }
45
46
    public function testLoadExtension()
47
    {
48
        $yaml = <<<'YAML'
49
fresh_firebase_cloud_messaging:
50
    sender_id: some_dummy_key
51
    server_key: some_dummy_secret
52
YAML;
53
        $parser = new Parser();
54
        $config = $parser->parse($yaml);
55
        $this->extension->load($config, $this->container);
56
        $this->container->loadFromExtension($this->extension->getAlias(), $config['fresh_firebase_cloud_messaging']);
57
        $this->container->set('event_dispatcher', new \stdClass());
58
        $this->container->compile();
59
60
        $this->assertTrue($this->container->hasParameter('firebase_cloud_messaging.sender_id'));
61
        $this->assertTrue($this->container->hasParameter('firebase_cloud_messaging.server_key'));
62
        $this->assertTrue($this->container->hasParameter('firebase_cloud_messaging.endpoint'));
63
        $this->assertTrue($this->container->hasParameter('firebase_cloud_messaging.guzzle_timeout'));
64
65
        $this->assertTrue($this->container->has('firebase_cloud_messaging.client'));
66
    }
67
}
68