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

ClientManagerSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 32
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 5 1
A it_extends_fos_oauth_server_client_manager() 0 4 1
A it_implements_fos_oauth_server_client_manager_interface() 0 4 1
A it_finds_client_by_public_id() 0 6 1
A it_returns_null_if_client_does_not_exist() 0 6 1
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