1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Gesdinet\JWTRefreshTokenBundle\Command; |
4
|
|
|
|
5
|
|
|
use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; |
6
|
|
|
use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; |
7
|
|
|
use PhpSpec\ObjectBehavior; |
8
|
|
|
use Prophecy\Argument; |
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
12
|
|
|
|
13
|
|
|
class RevokeRefreshTokenCommandSpec extends ObjectBehavior |
14
|
|
|
{ |
15
|
|
|
public function let(RefreshTokenManagerInterface $refreshTokenManager) |
16
|
|
|
{ |
17
|
|
|
$this->beConstructedWith($refreshTokenManager); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function it_is_initializable() |
21
|
|
|
{ |
22
|
|
|
$this->shouldHaveType('Gesdinet\JWTRefreshTokenBundle\Command\RevokeRefreshTokenCommand'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function it_is_a_command() |
26
|
|
|
{ |
27
|
|
|
$this->shouldHaveType('Symfony\Component\Console\Command\Command'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function it_has_a_name() |
31
|
|
|
{ |
32
|
|
|
$this->getName()->shouldReturn('gesdinet:jwt:revoke'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function it_revokes_a_refresh_token(InputInterface $input, OutputInterface $output, RefreshTokenManagerInterface $refreshTokenManager, RefreshTokenInterface $refreshToken) |
36
|
|
|
{ |
37
|
|
|
$refreshTokenManager->get(Argument::any())->shouldBeCalled()->willReturn($refreshToken); |
38
|
|
|
|
39
|
|
|
$refreshTokenManager->delete($refreshToken)->shouldBeCalled(); |
40
|
|
|
$output->writeln(Argument::any())->shouldBeCalled(); |
41
|
|
|
|
42
|
|
|
$this->run($input, $output); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function it_not_revokes_a_refresh_token(InputInterface $input, OutputInterface $output, RefreshTokenManagerInterface $refreshTokenManager, RefreshTokenInterface $refreshToken) |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$refreshTokenManager->get(Argument::any())->shouldBeCalled()->willReturn(null); |
48
|
|
|
|
49
|
|
|
$this->run($input, $output)->shouldBe(-1); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.