Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
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 Kunstmaan\AdminBundle\Command\ApplyAclCommand;
6
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionSubscriber;
7
use PHPUnit\Framework\TestCase;
8
use Psr\Log\LoggerInterface;
9
use Symfony\Component\Console\Event\ConsoleErrorEvent;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class ConsoleExceptionSubscriberTest extends TestCase
14
{
15
    public function testListener()
16
    {
17
        if (!class_exists(ConsoleErrorEvent::class)) {
18
            // Nothing to test
19
            return;
20
        }
21
22
        $logger = $this->createMock(LoggerInterface::class);
23
        $logger->expects($this->once())->method('critical')->willReturn(true);
24
        $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...
25
26
        $command = new ApplyAclCommand();
27
        $exception = new \Exception();
28
29
        $input = $this->createMock(InputInterface::class);
30
        $output = $this->createMock(OutputInterface::class);
31
        $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...
32
33
        $subscriber->onConsoleError($event);
34
    }
35
}
36