13
13
14
14
namespace FOS \OAuthServerBundle \Tests \DependencyInjection ;
15
15
16
+ use FOS \OAuthServerBundle \DependencyInjection \FOSOAuthServerExtension ;
16
17
use Symfony \Component \Config \FileLocator ;
18
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
19
+ use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
17
20
use Symfony \Component \Routing \Loader \XmlFileLoader ;
18
21
19
22
class FOSOAuthServerExtensionTest extends \PHPUnit \Framework \TestCase
20
23
{
24
+ private $ container ;
25
+
26
+ public function setUp ()
27
+ {
28
+ $ parameterBag = new ParameterBag ();
29
+ $ this ->container = new ContainerBuilder ($ parameterBag );
30
+
31
+ parent ::setUp ();
32
+ }
33
+
21
34
public function testLoadAuthorizeRouting ()
22
35
{
23
36
$ locator = new FileLocator ();
@@ -39,4 +52,51 @@ public function testLoadTokenRouting()
39
52
$ this ->assertSame ('/oauth/v2/token ' , $ tokenRoute ->getPath ());
40
53
$ this ->assertSame (['GET ' , 'POST ' ], $ tokenRoute ->getMethods ());
41
54
}
55
+
56
+ public function testWithoutService ()
57
+ {
58
+ $ config = [
59
+ 'db_driver ' => 'orm ' ,
60
+ 'client_class ' => 'dumb_class ' ,
61
+ 'access_token_class ' => 'dumb_access_token_class ' ,
62
+ 'refresh_token_class ' => 'dumb_refresh_token_class ' ,
63
+ 'auth_code_class ' => 'dumb_auth_code_class ' ,
64
+ ];
65
+ $ instance = new FOSOAuthServerExtension ();
66
+ $ instance ->load ([$ config ], $ this ->container );
67
+
68
+ $ this ->assertSame (
69
+ $ this ->container ->getParameter ('fos_oauth_server.server.options ' ),
70
+ []
71
+ );
72
+ }
73
+
74
+ public function testMultilineScopes ()
75
+ {
76
+ $ scopes = <<<'SCOPES'
77
+ scope1
78
+ scope2
79
+ scope3 scope4
80
+ SCOPES;
81
+
82
+ $ config = [
83
+ 'db_driver ' => 'orm ' ,
84
+ 'client_class ' => 'dumb_class ' ,
85
+ 'access_token_class ' => 'dumb_access_token_class ' ,
86
+ 'refresh_token_class ' => 'dumb_refresh_token_class ' ,
87
+ 'auth_code_class ' => 'dumb_auth_code_class ' ,
88
+ 'service ' => [
89
+ 'options ' => [
90
+ 'supported_scopes ' => $ scopes ,
91
+ ],
92
+ ],
93
+ ];
94
+ $ instance = new FOSOAuthServerExtension ();
95
+ $ instance ->load ([$ config ], $ this ->container );
96
+
97
+ $ this ->assertSame (
98
+ $ this ->container ->getParameter ('fos_oauth_server.server.options ' ),
99
+ ['supported_scopes ' => 'scope1 scope2 scope3 scope4 ' ]
100
+ );
101
+ }
42
102
}
0 commit comments