Completed
Push — master ( 415ff3...9dbf7b )
by Loïc
46:34 queued 37:56
created

ClientManagerSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Monofony package.
5
 *
6
 * (c) Monofony
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
namespace spec\Monofony\Bundle\CoreBundle\Entity\OAuth;
13
14
use Doctrine\ORM\EntityManager;
15
use Doctrine\ORM\EntityRepository;
16
use FOS\OAuthServerBundle\Entity\ClientManager as FOSClientManager;
17
use FOS\OAuthServerBundle\Model\ClientInterface;
18
use FOS\OAuthServerBundle\Model\ClientManagerInterface;
19
use Monofony\Bundle\CoreBundle\Entity\OAuth\ClientManager;
20
use PhpSpec\ObjectBehavior;
21
22
class ClientManagerSpec extends ObjectBehavior
23
{
24
    function let(EntityManager $em, EntityRepository $repository, $clientClass = 'Client/Class/String'): void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
    {
26
        $em->getRepository($clientClass)->shouldBeCalled()->willReturn($repository);
0 ignored issues
show
Bug introduced by
The method shouldBeCalled() does not exist on Doctrine\Common\Persistence\ObjectRepository. It seems like you code against a sub-type of Doctrine\Common\Persistence\ObjectRepository such as Doctrine\ORM\EntityRepository or Sylius\Bundle\ResourceBu...ne\ORM\EntityRepository or App\Repository\UserRepository or Sylius\Bundle\UserBundle...rine\ORM\UserRepository. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $em->getRepository($clientClass)->/** @scrutinizer ignore-call */ shouldBeCalled()->willReturn($repository);
Loading history...
27
        $this->beConstructedWith($em, $clientClass);
28
    }
29
30
    function it_is_initializable()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
31
    {
32
        $this->shouldHaveType(ClientManager::class);
33
    }
34
35
    function it_extends_fos_oauth_server_client_manager(): void
36
    {
37
        $this->shouldHaveType(FOSClientManager::class);
38
    }
39
40
    function it_implements_fos_oauth_server_client_manager_interface(): void
41
    {
42
        $this->shouldImplement(ClientManagerInterface::class);
43
    }
44
45
    function it_finds_client_by_public_id(ClientInterface $client, $repository): void
46
    {
47
        $repository->findOneBy(['randomId' => 'random_string'])->willReturn($client);
48
49
        $this->findClientByPublicId('random_string')->shouldReturn($client);
0 ignored issues
show
Bug introduced by
The method findClientByPublicId() does not exist on spec\Monofony\Bundle\Cor...OAuth\ClientManagerSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        $this->/** @scrutinizer ignore-call */ 
50
               findClientByPublicId('random_string')->shouldReturn($client);
Loading history...
50
    }
51
52
    function it_returns_null_if_client_does_not_exist($repository): void
53
    {
54
        $repository->findOneBy(['randomId' => 'random_string'])->willReturn(null);
55
56
        $this->findClientByPublicId('random_string')->shouldReturn(null);
57
    }
58
}
59