|
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\Model; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\ORM\EntityManager; |
|
17
|
|
|
use Doctrine\ORM\EntityRepository; |
|
18
|
|
|
use FOS\OAuthServerBundle\Entity\ClientManager as FOSClientManager; |
|
19
|
|
|
use FOS\OAuthServerBundle\Model\ClientInterface; |
|
20
|
|
|
use FOS\OAuthServerBundle\Model\ClientManagerInterface; |
|
21
|
|
|
use PhpSpec\ObjectBehavior; |
|
22
|
|
|
|
|
23
|
|
|
final class ClientManagerSpec extends ObjectBehavior |
|
24
|
|
|
{ |
|
25
|
|
|
function let(EntityManager $em, EntityRepository $repository, $clientClass = 'Client/Class/String'): void |
|
26
|
|
|
{ |
|
27
|
|
|
$em->getRepository($clientClass)->shouldBeCalled()->willReturn($repository); |
|
28
|
|
|
$this->beConstructedWith($em, $clientClass); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function it_extends_fos_oauth_server_client_manager(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$this->shouldHaveType(FOSClientManager::class); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_implements_fos_oauth_server_client_manager_interface(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->shouldImplement(ClientManagerInterface::class); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_finds_client_by_public_id(ClientInterface $client, $repository): void |
|
42
|
|
|
{ |
|
43
|
|
|
$repository->findOneBy(['randomId' => 'random_string'])->willReturn($client); |
|
44
|
|
|
|
|
45
|
|
|
$this->findClientByPublicId('random_string')->shouldReturn($client); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
function it_returns_null_if_client_does_not_exist($repository): void |
|
49
|
|
|
{ |
|
50
|
|
|
$repository->findOneBy(['randomId' => 'random_string'])->willReturn(null); |
|
51
|
|
|
|
|
52
|
|
|
$this->findClientByPublicId('random_string')->shouldReturn(null); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|