File tree 6 files changed +64
-40
lines changed
6 files changed +64
-40
lines changed Original file line number Diff line number Diff line change 1
1
imports :
2
2
- { resource: parameters.yml }
3
3
services :
4
+ _defaults : { public: true }
4
5
centrifugo.client :
5
6
class : Kismia\CentrifugoBundle\Client\CentrifugoClient
6
7
arguments : ["%centrifugo.apiendpoint%", "%centrifugo.secret%", "%centrifugo.transport%"]
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Kismia \CentrifugoBundle \Tests \Client ;
4
+
5
+ use Kismia \CentrifugoBundle \DependencyInjection \CentrifugoExtension ;
6
+ use PHPUnit \Framework \TestCase ;
7
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
8
+ use Symfony \Component \Yaml \Yaml ;
9
+
10
+ class CentrifugoClientTest extends TestCase
11
+ {
12
+ public function testClient ()
13
+ {
14
+ $ config = Yaml::parseFile (__DIR__ .'/../Fixtures/config.yaml ' );
15
+
16
+ $ container = $ this ->getContainer ($ config );
17
+
18
+ $ client = $ container ->get ('centrifugo.client ' );
19
+
20
+ $ this ->assertEquals ('Kismia\CentrifugoBundle\Client\CentrifugoClient ' , get_class ($ client ));
21
+
22
+ }
23
+
24
+ protected function getContainer (array $ config = array (), array $ thirdPartyDefinitions = array ())
25
+ {
26
+ $ container = new ContainerBuilder ();
27
+ foreach ($ thirdPartyDefinitions as $ id => $ definition ) {
28
+ $ container ->setDefinition ($ id , $ definition );
29
+ }
30
+ $ container ->getCompilerPassConfig ()->setOptimizationPasses ([]);
31
+ $ container ->getCompilerPassConfig ()->setRemovingPasses ([]);
32
+
33
+ $ loader = new CentrifugoExtension ();
34
+ $ loader ->load ($ config , $ container );
35
+ $ container ->compile ();
36
+
37
+ return $ container ;
38
+ }
39
+ }
40
+
Original file line number Diff line number Diff line change 4
4
5
5
use Kismia \CentrifugoBundle \DependencyInjection \CentrifugoExtension ;
6
6
use PHPUnit \Framework \TestCase ;
7
+ use Symfony \Component \Config \FileLocator ;
7
8
use Symfony \Component \DependencyInjection \ContainerBuilder ;
9
+ use Symfony \Component \Yaml \Yaml ;
8
10
9
11
10
12
class CentrifugoExtensionTest extends TestCase
11
13
{
12
14
13
15
public function testLoad ()
14
16
{
15
- $ config = [
16
- 'centrifugo ' => [
17
- 'apiendpoint ' => 'localhost ' ,
18
- 'secret ' => 'api-secret ' ,
19
- 'transport ' => [
20
- 'redis ' => [
21
- 'host ' => 'localhost ' ,
22
- 'port ' => 6379 ,
23
- 'shards ' => 6 ,
24
- 'db ' => 1
25
- ]
26
- ]
27
- ]
28
- ];
17
+
18
+ $ config = Yaml::parseFile (__DIR__ .'/../Fixtures/config.yaml ' );
19
+
29
20
30
21
$ container = $ this ->getContainer ($ config );
31
22
$ this ->assertTrue ($ container ->hasDefinition ('centrifugo.client ' ));
32
23
33
- $ centrifugo = $ container ->getDefinition ('centrifugo.client ' );
34
- var_dump ($ centrifugo ->getArguments ());
24
+ $ defination = $ container ->getDefinition ('centrifugo.client ' );
25
+ $ arguments = $ defination ->getArguments ();
26
+
35
27
28
+ $ this ->assertEquals ('%centrifugo.apiendpoint% ' , $ arguments [0 ]);
29
+ $ this ->assertEquals ('%centrifugo.secret% ' , $ arguments [1 ]);
30
+ $ this ->assertEquals ('%centrifugo.transport% ' , $ arguments [2 ]);
36
31
37
32
}
38
33
Original file line number Diff line number Diff line change 5
5
use Kismia \CentrifugoBundle \DependencyInjection \Configuration \Configuration ;
6
6
use PHPUnit \Framework \TestCase ;
7
7
use Symfony \Component \Config \Definition \Processor ;
8
+ use Symfony \Component \Yaml \Yaml ;
8
9
9
10
class ConfigurationTest extends TestCase
10
11
{
11
12
public function testSimpleConfig ()
12
13
{
13
- $ config = [
14
- 'centrifugo ' => [
15
- 'apiendpoint ' => 'localhost ' ,
16
- 'secret ' => 'api-secret ' ,
17
- 'transport ' => [
18
- 'redis ' => [
19
- 'host ' => 'localhost ' ,
20
- 'port ' => 6379 ,
21
- 'shards ' => 6 ,
22
- 'db ' => 1
23
- ]
24
- ]
25
- ]
26
- ];
14
+ $ config = Yaml::parseFile (__DIR__ .'/../../Fixtures/config.yaml ' );
27
15
28
16
$ configs = $ this ->process ($ config );
29
17
Original file line number Diff line number Diff line change
1
+ centrifugo :
2
+ apiendpoint : ' http//localhost:8080'
3
+ secret : ' '
4
+ transport :
5
+ redis :
6
+ host : ' localhost'
7
+ shards : 6
8
+ db : 2
9
+ timeout : 0.3
10
+ port : 6379
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments