1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\AdminApiBundle\Command; |
15
|
|
|
|
16
|
|
|
use FOS\OAuthServerBundle\Model\ClientManager; |
17
|
|
|
use PhpSpec\ObjectBehavior; |
18
|
|
|
use Prophecy\Argument; |
19
|
|
|
use Sylius\Bundle\AdminApiBundle\Model\Client; |
20
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
21
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
22
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
23
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
24
|
|
|
|
25
|
|
|
final class CreateClientCommandSpec extends ObjectBehavior |
26
|
|
|
{ |
27
|
|
|
public function it_is_a_container_aware_command() |
28
|
|
|
{ |
29
|
|
|
$this->shouldHaveType(ContainerAwareCommand::class); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function it_has_a_name() |
33
|
|
|
{ |
34
|
|
|
$this->getName()->shouldReturn('sylius:oauth-server:create-client'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function it_creates_a_client_without_client_manager( |
38
|
|
|
ContainerInterface $container, |
39
|
|
|
InputInterface $input, |
40
|
|
|
OutputInterface $output, |
41
|
|
|
ClientManager $clientManager, |
42
|
|
|
Client $client |
43
|
|
|
) { |
44
|
|
|
$input->bind(Argument::any())->shouldBeCalled(); |
45
|
|
|
$input->isInteractive()->shouldBeCalled(); |
46
|
|
|
$input->validate()->shouldBeCalled(); |
47
|
|
|
$input->hasArgument('command')->willReturn(false); |
48
|
|
|
|
49
|
|
|
$container->get('fos_oauth_server.client_manager.default')->willReturn($clientManager); |
50
|
|
|
$clientManager->createClient()->willReturn($client); |
51
|
|
|
|
52
|
|
|
$input->getOption('redirect-uri')->willReturn(['redirect-uri']); |
53
|
|
|
$input->getOption('grant-type')->willReturn(['grant-type']); |
54
|
|
|
|
55
|
|
|
$client->setRedirectUris(['redirect-uri'])->shouldBeCalled(); |
56
|
|
|
$client->setAllowedGrantTypes(['grant-type'])->shouldBeCalled(); |
57
|
|
|
|
58
|
|
|
$clientManager->updateClient($client)->shouldBeCalled(); |
59
|
|
|
|
60
|
|
|
$client->getPublicId()->shouldBeCalled(); |
61
|
|
|
$client->getSecret()->shouldBeCalled(); |
62
|
|
|
|
63
|
|
|
$output->writeln(Argument::type('string'))->shouldBeCalled(); |
64
|
|
|
|
65
|
|
|
$this->setContainer($container); |
66
|
|
|
$this->run($input, $output); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function it_creates_a_client( |
70
|
|
|
ContainerInterface $container, |
71
|
|
|
InputInterface $input, |
72
|
|
|
OutputInterface $output, |
73
|
|
|
ClientManager $clientManager, |
74
|
|
|
Client $client |
75
|
|
|
) { |
76
|
|
|
$this->beConstructedWith(null, $clientManager); |
77
|
|
|
|
78
|
|
|
$input->bind(Argument::any())->shouldBeCalled(); |
79
|
|
|
$input->isInteractive()->shouldBeCalled(); |
80
|
|
|
$input->validate()->shouldBeCalled(); |
81
|
|
|
$input->hasArgument('command')->willReturn(false); |
82
|
|
|
|
83
|
|
|
$container->get('fos_oauth_server.client_manager.default')->willReturn($clientManager); |
84
|
|
|
$clientManager->createClient()->willReturn($client); |
85
|
|
|
|
86
|
|
|
$input->getOption('redirect-uri')->willReturn(['redirect-uri']); |
87
|
|
|
$input->getOption('grant-type')->willReturn(['grant-type']); |
88
|
|
|
|
89
|
|
|
$client->setRedirectUris(['redirect-uri'])->shouldBeCalled(); |
90
|
|
|
$client->setAllowedGrantTypes(['grant-type'])->shouldBeCalled(); |
91
|
|
|
|
92
|
|
|
$clientManager->updateClient($client)->shouldBeCalled(); |
93
|
|
|
|
94
|
|
|
$client->getPublicId()->shouldBeCalled(); |
95
|
|
|
$client->getSecret()->shouldBeCalled(); |
96
|
|
|
|
97
|
|
|
$output->writeln(Argument::type('string'))->shouldBeCalled(); |
98
|
|
|
|
99
|
|
|
$this->setContainer($container); |
100
|
|
|
$this->run($input, $output); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|