Completed
Push — master ( 6d6774...64f3ed )
by Jeroen
11:23 queued 05:13
created

Tests/unit/EventListener/LoginListenerTest.php (3 issues)

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\EventListener;
4
5
use Kunstmaan\AdminBundle\Entity\User;
6
use Kunstmaan\AdminBundle\EventListener\LoginListener;
7
use Kunstmaan\AdminBundle\Helper\VersionCheck\VersionChecker;
8
use PHPUnit\Framework\TestCase;
9
use Psr\Log\AbstractLogger;
10
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
11
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
12
13
class LoginListenerTest extends TestCase
14
{
15
    public function testListener()
16
    {
17
        $logger = $this->createMock(AbstractLogger::class);
18
        $version = $this->createMock(VersionChecker::class);
19
        $token = $this->createMock(TokenInterface::class);
20
        $user = $this->createMock(User::class);
21
        $event = $this->createMock(InteractiveLoginEvent::class);
22
23
        $logger->expects($this->once())->method('info')->willReturn(true);
24
        $version->expects($this->once())->method('periodicallyCheck')->willReturn(true);
25
        $event->expects($this->once())->method('getAuthenticationToken')->willReturn($token);
26
        $token->expects($this->once())->method('getUser')->willReturn($user);
27
28
        $listener = new LoginListener($logger, $version);
0 ignored issues
show
$logger is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Psr\Log\LoggerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$version is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminBu...onCheck\VersionChecker>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
        $listener->onSecurityInteractiveLogin($event);
0 ignored issues
show
$event is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component...\InteractiveLoginEvent>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
30
    }
31
}
32