|
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
|
|
|
|