Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
created

EventListener/ConsoleExceptionListenerTest.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 Exception;
6
use Kunstmaan\AdminBundle\Command\ApplyAclCommand;
7
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionListener;
8
use PHPUnit_Framework_TestCase;
9
use Psr\Log\LoggerInterface;
10
use Symfony\Component\Console\Event\ConsoleErrorEvent;
11
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
12
13
class ConsoleExceptionListenerTest extends PHPUnit_Framework_TestCase
14
{
15
    public function testListener()
16
    {
17
        $logger = $this->createMock(LoggerInterface::class);
18
        $listener = new ConsoleExceptionListener($logger);
0 ignored issues
show
Deprecated Code introduced by
The class Kunstmaan\AdminBundle\Ev...onsoleExceptionListener has been deprecated with message: in KunstmaanAdminBundle 5.1 and will be removed in KunstmaanNodeBundle 6.0.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
19
20
        $event = $this->createMock(ConsoleExceptionEvent::class);
21
        if (class_exists(ConsoleErrorEvent::class)){
22
            $this->assertNull($listener->onConsoleException($event));
23
        } else {
24
            $command = new ApplyAclCommand();
25
            $exception = new Exception();
26
27
            $logger->expects($this->once())->method('error')->willReturn(true);
28
29
            $event->expects($this->once())->method('getCommand')->willReturn($command);
30
            $event->expects($this->once())->method('getException')->willReturn($exception);
31
32
            $listener->onConsoleException($event);
33
        }
34
    }
35
}