Completed
Push — master ( 06c1ce...67d37c )
by Jeroen
06:20
created

EventListener/ConsoleExceptionSubscriberTest.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\EventListener;
4
5
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionSubscriber;
6
use PHPUnit\Framework\TestCase;
7
use Psr\Log\LoggerInterface;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Event\ConsoleErrorEvent;
10
use Symfony\Component\Console\Input\ArgvInput;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class ConsoleExceptionSubscriberTest extends TestCase
14
{
15
    public function testListener()
16
    {
17
        // Remove when sf3.4 support is removed
18
        if (!class_exists(ConsoleErrorEvent::class)) {
19
            // Nothing to test
20
            return;
21
        }
22
23
        $error = new \TypeError('An error occurred');
0 ignored issues
show
The call to TypeError::__construct() has too many arguments starting with 'An error occurred'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
24
        $output = $this->createMock(OutputInterface::class);
25
        $logger = $this->createMock(LoggerInterface::class);
26
        $logger->expects($this->once())->method('critical');
27
28
        $subscriber = new ConsoleExceptionSubscriber($logger);
29
        $subscriber->onConsoleError(new ConsoleErrorEvent(new ArgvInput(['console.php', 'test:run', '--foo=baz', 'buzz']), $output, $error, new Command('test:run')));
30
    }
31
}
32