Passed
Pull Request — master (#81)
by
unknown
06:53
created

GesdinetJWTRefreshTokenExtensionSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace spec\Gesdinet\JWTRefreshTokenBundle\DependencyInjection;
4
5
use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
use Symfony\Component\DependencyInjection\Alias;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
11
12
class GesdinetJWTRefreshTokenExtensionSpec extends ObjectBehavior
13
{
14
    public function let(ContainerBuilder $container)
15
    {
16
        $container->fileExists(dirname(dirname(__DIR__)).'/DependencyInjection/../Resources/config/services.yml')
17
                  ->willReturn(true);
18
        $container->has('gesdinet.jwtrefreshtoken.name_generator.underscore')
19
                  ->willReturn(true);
20
    }
21
22
    public function it_is_initializable()
23
    {
24
        $this->shouldHaveType('Gesdinet\JWTRefreshTokenBundle\DependencyInjection\GesdinetJWTRefreshTokenExtension');
25
    }
26
27
    public function it_should_set_parameters_correctly(ContainerBuilder $container)
28
    {
29
        // setParameter calls with default values
30
        $container->setParameter('gesdinet_jwt_refresh_token.ttl', 2592000)
31
                  ->shouldBeCalled();
32
        $container->setParameter('gesdinet_jwt_refresh_token.ttl_update', false)
33
                  ->shouldBeCalled();
34
        $container->setParameter('gesdinet_jwt_refresh_token.security.firewall', 'api')
35
                  ->shouldBeCalled();
36
        $container->setParameter('gesdinet_jwt_refresh_token.user_provider', null)
37
                  ->shouldBeCalled();
38
        $container->setParameter('gesdinet.jwtrefreshtoken.refresh_token.class', 'Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken')
39
                  ->shouldBeCalled();
40
        $container->setParameter('gesdinet.jwtrefreshtoken.entity_manager.id', 'doctrine.orm.entity_manager')
41
                  ->shouldBeCalled();
42
43
        // Ignore these calls
44
        $container->has(Argument::cetera())
45
                  ->willReturn();
46
        $container->setDefinition(Argument::cetera())
47
                  ->willReturn();
48
        $container->setAlias(Argument::cetera())
49
                  ->willReturn();
50
51
        $configs = [];
52
        $this->load($configs, $container);
53
    }
54
55
    public function it_should_configure_the_default_naming_generator(ContainerBuilder $container)
56
    {
57
        $container->setAlias(
58
            'gesdinet.jwtrefreshtoken.name_generator.default',
59
            Argument::exact(new Alias('gesdinet.jwtrefreshtoken.name_generator.underscore'))
60
        )
61
                  ->shouldBeCalled();
62
63
        // Ignore these calls
64
        $container->setParameter(Argument::cetera())
65
                  ->willReturn();
66
        $container->setDefinition(Argument::cetera())
67
                  ->willReturn();
68
69
        $configs = array();
70
        $this->load($configs, $container);
71
    }
72
73 View Code Duplication
    public function it_should_throw_an_exception_if_specifying_a_non_existent_name_generator_service(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
        ContainerBuilder $container
75
    ) {
76
        $container->has('some.service.name')
77
                  ->willReturn(false);
78
79
        // Ignore these calls
80
        $container->setParameter(Argument::cetera())
81
                  ->willReturn();
82
        $container->setDefinition(Argument::cetera())
83
                  ->willReturn();
84
        $container->setAlias(Argument::cetera())
85
                  ->willReturn();
86
87
        $configs = array(array('parameter_name_generator' => 'some.service.name'));
88
        $this->shouldThrow('\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException')
89
             ->during('load', array($configs, $container));
90
    }
91
92 View Code Duplication
    public function it_should_configure_a_custom_name_generator(ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
93
    {
94
        // Expectations
95
        $container->setAlias('gesdinet.jwtrefreshtoken.name_generator.default', 'some.service.name')
96
                  ->shouldBeCalled();
97
98
        // Stubs
99
        $container->has('some.service.name')
100
                  ->willReturn(true);
101
102
        // Ignore these calls
103
        $container->setParameter(Argument::cetera())
104
                  ->willReturn();
105
        $container->setDefinition(Argument::cetera())
106
                  ->willReturn();
107
        $container->setAlias(Argument::cetera())
108
                  ->willReturn();
109
110
        $configs = array(array('parameter_name_generator' => 'some.service.name'));
111
        $this->load($configs, $container);
112
    }
113
}
114