Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

EventListener/ConsoleExceptionSubscriberTest.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 Exception;
6
use Codeception\Test\Unit;
7
use Kunstmaan\AdminBundle\Command\ApplyAclCommand;
8
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionSubscriber;
9
use Psr\Log\LoggerInterface;
10
use Symfony\Component\Console\Event\ConsoleErrorEvent;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class ConsoleExceptionSubscriberTest extends Unit
15
{
16
    public function testListener()
17
    {
18
        if (!class_exists(ConsoleErrorEvent::class)) {
19
            // Nothing to test
20
            return;
21
        }
22
23
        $logger = $this->createMock(LoggerInterface::class);
24
        $logger->expects($this->once())->method('error')->willReturn(true);
25
        $subscriber = new ConsoleExceptionSubscriber($logger);
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...
26
27
        $command = new ApplyAclCommand();
28
        $exception = new Exception();
29
30
        $input = $this->createMock(InputInterface::class);
31
        $output = $this->createMock(OutputInterface::class);
32
        $event = new ConsoleErrorEvent($input, $output, $exception, $command);
0 ignored issues
show
$input is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component...e\Input\InputInterface>.

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...
$output is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component...Output\OutputInterface>.

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...
33
34
        $subscriber->onConsoleError($event);
35
    }
36
}
37