|
11 | 11 |
|
12 | 12 | namespace DependencyInjection;
|
13 | 13 |
|
| 14 | +use FOS\OAuthServerBundle\DependencyInjection\FOSOAuthServerExtension; |
14 | 15 | use Symfony\Component\Config\FileLocator;
|
| 16 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 17 | +use Symfony\Component\DependencyInjection\Extension\Extension; |
15 | 18 | use Symfony\Component\Routing\Loader\XmlFileLoader;
|
16 | 19 |
|
17 | 20 | class FOSOAuthServerExtensionTest extends \PHPUnit_Framework_TestCase
|
18 | 21 | {
|
| 22 | + public function testShouldImplementConfigurationInterface() |
| 23 | + { |
| 24 | + $rc = new \ReflectionClass(FOSOAuthServerExtension::class); |
| 25 | + |
| 26 | + $this->assertTrue($rc->isSubclassOf(Extension::class)); |
| 27 | + } |
| 28 | + |
| 29 | + public function testCouldBeConstructedWithoutAnyArguments() |
| 30 | + { |
| 31 | + new FOSOAuthServerExtension(); |
| 32 | + } |
| 33 | + |
| 34 | + public function testShouldLoadAuthorizeRelatedServicesIfAuthorizationIsEnabled() |
| 35 | + { |
| 36 | + $container = new ContainerBuilder(); |
| 37 | + |
| 38 | + $extension = new FOSOAuthServerExtension(); |
| 39 | + $extension->load([[ |
| 40 | + 'db_driver' => 'orm', |
| 41 | + 'client_class' => 'aClientClass', |
| 42 | + 'access_token_class' => 'anAccessTokenClass', |
| 43 | + 'refresh_token_class' => 'aRefreshTokenClass', |
| 44 | + 'auth_code_class' => 'anAuthCodeClass', |
| 45 | + 'authorize' => true, |
| 46 | + ]], $container); |
| 47 | + |
| 48 | + $this->assertTrue($container->hasDefinition('fos_oauth_server.authorize.form')); |
| 49 | + $this->assertTrue($container->hasDefinition('fos_oauth_server.authorize.form.type')); |
| 50 | + $this->assertTrue($container->hasDefinition('fos_oauth_server.authorize.form.handler.default')); |
| 51 | + $this->assertTrue($container->hasDefinition('fos_oauth_server.controller.authorize')); |
| 52 | + } |
| 53 | + |
| 54 | + public function testShouldNotLoadAuthorizeRelatedServicesIfAuthorizationIsDisabled() |
| 55 | + { |
| 56 | + $container = new ContainerBuilder(); |
| 57 | + |
| 58 | + $extension = new FOSOAuthServerExtension(); |
| 59 | + $extension->load([[ |
| 60 | + 'db_driver' => 'orm', |
| 61 | + 'client_class' => 'aClientClass', |
| 62 | + 'access_token_class' => 'anAccessTokenClass', |
| 63 | + 'refresh_token_class' => 'aRefreshTokenClass', |
| 64 | + 'auth_code_class' => 'anAuthCodeClass', |
| 65 | + 'authorize' => false, |
| 66 | + ]], $container); |
| 67 | + |
| 68 | + $this->assertFalse($container->hasDefinition('fos_oauth_server.authorize.form')); |
| 69 | + $this->assertFalse($container->hasDefinition('fos_oauth_server.authorize.form.type')); |
| 70 | + $this->assertFalse($container->hasDefinition('fos_oauth_server.authorize.form.handler.default')); |
| 71 | + $this->assertFalse($container->hasDefinition('fos_oauth_server.controller.authorize')); |
| 72 | + } |
| 73 | + |
19 | 74 | public function testLoadAuthorizeRouting()
|
20 | 75 | {
|
21 | 76 | $locator = new FileLocator();
|
|
0 commit comments