Completed
Push — 1.0-symfony2-rename ( d9b26c )
by Kamil
98:47 queued 78:51
created

it_extends_fos_oauth_server_client_manager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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