Skip to content

Commit 7443c27

Browse files
committed
fix: update tests to handle prioritets on events
1 parent 10de895 commit 7443c27

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ matrix:
2626
before_install:
2727
- curl -s https://getcomposer.org/installer | php
2828
- php composer.phar require symfony/symfony:${SYMFONY_VERSION} --no-update
29-
- php composer.phar update
29+
- php -dmemory_limit=-1 composer.phar update
3030

3131
script:
3232
- php -v

Tests/SymfonyRollbarBundle/BundleTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
55
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6+
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
67
use Symfony\Component\HttpFoundation\Request;
78
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
89
use \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
@@ -29,16 +30,23 @@ public function testListeners()
2930
* @var TraceableEventDispatcher $eventDispatcher
3031
*/
3132
$eventDispatcher = $container->get('event_dispatcher');
32-
$listeners = $eventDispatcher->getListeners('kernel.exception');
33+
$listeners = $eventDispatcher->getListeners('kernel.exception');
3334

3435
$expected = [
35-
\SymfonyRollbarBundle\EventListener\AbstractListener::class,
36-
\Symfony\Component\HttpKernel\EventListener\ExceptionListener::class,
36+
\SymfonyRollbarBundle\EventListener\ErrorListener::class,
37+
\SymfonyRollbarBundle\EventListener\ExceptionListener::class,
3738
];
3839

39-
foreach ($listeners as $listener) {
40-
$ok = $listener[0] instanceof $expected[0] || $listener[0] instanceof $expected[1];
41-
$this->assertTrue($ok, 'Listeners were not registered');
40+
foreach ($expected as $class) {
41+
$found = false;
42+
foreach ($listeners as $listener) {
43+
if ($listener[0] instanceof $class) {
44+
$found = true;
45+
break;
46+
}
47+
}
48+
49+
$this->assertTrue($found, "Listeners {$class} was not registered");
4250
}
4351

4452
restore_error_handler();

Tests/SymfonyRollbarBundle/EventListener/AbstractListenerTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@ public function setUp()
2121
static::bootKernel();
2222
}
2323

24-
public function testListeners()
25-
{
26-
$container = static::$kernel->getContainer();
27-
28-
/**
29-
* @var TraceableEventDispatcher $eventDispatcher
30-
*/
31-
$eventDispatcher = $container->get('event_dispatcher');
32-
$listeners = $eventDispatcher->getListeners('kernel.exception');
33-
34-
$expected = [
35-
\SymfonyRollbarBundle\EventListener\AbstractListener::class,
36-
\Symfony\Component\HttpKernel\EventListener\ExceptionListener::class,
37-
];
38-
39-
foreach ($listeners as $listener) {
40-
$ok = $listener[0] instanceof $expected[0] || $listener[0] instanceof $expected[1];
41-
$this->assertTrue($ok, 'Listeners were not registered');
42-
}
43-
44-
restore_error_handler();
45-
}
46-
4724
/**
4825
* @return array
4926
*/

0 commit comments

Comments
 (0)