Completed
Push — 5.6 ( c5fe0b...561087 )
by Jeroen
19:25 queued 04:42
created

unit/Helper/Security/OAuth/OAuthUserFinderTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\AdminBundle\Tests\Helper\Security\Acl;
4
5
use DateTime;
6
use Doctrine\ORM\EntityManager;
7
use Doctrine\ORM\EntityRepository;
8
use Kunstmaan\AdminBundle\Entity\User;
9
use Kunstmaan\AdminBundle\Helper\Security\OAuth\OAuthUserFinder;
10
use PHPUnit\Framework\TestCase;
11
12
class OAuthUserFinderTest extends TestCase
13
{
14
    /**
15
     * @var OAuthUserFinder
16
     */
17
    private $object;
18
19
    /**
20
     * @var EntityManager
21
     */
22
    private $em;
23
24
    /**
25
     * @return \PHPUnit_Framework_MockObject_MockObject
0 ignored issues
show
Should the return type not be \PHPUnit\Framework\MockO...ockObject|EntityManager?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
26
     */
27
    private function getEm()
28
    {
29
        if (!isset($this->em)) {
30
            $this->em = $this->createMock(EntityManager::class);
31
        }
32
33
        return $this->em;
34
    }
35
36
    public function setup()
37
    {
38
        $em = $this->getEm();
39
        $object = new OAuthUserFinder($em, User::class);
40
        $this->object = $object;
41
    }
42
43
    public function testFindUserByGoogleSignInData()
44
    {
45
        $object = $this->object;
46
        $repo = $this->createMock(EntityRepository::class);
47
        $repo->expects($this->exactly(3))->method('findOneBy')->will($this->onConsecutiveCalls(new DateTime(), new DateTime(), new User()));
48
        $this->getEm()->expects($this->exactly(3))->method('getRepository')->willReturn($repo);
49
        $user = $object->findUserByGoogleSignInData('[email protected]', 12345679);
50
        $this->assertInstanceOf(User::class, $user);
51
    }
52
}
53