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