Expanded class hierarchy of RegisterListenersPassTest
class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase {
/**
* Tests that event subscribers not implementing EventSubscriberInterface
* trigger an exception.
*
* @expectedException \InvalidArgumentException
*/
public function testEventSubscriberWithoutInterface() {
// one service, not implementing any interface
$services = array(
'my_event_subscriber' => array(
0 => array(),
),
);
$definition = $this
->getMock('Symfony\\Component\\DependencyInjection\\Definition');
$definition
->expects($this
->atLeastOnce())
->method('getClass')
->will($this
->returnValue('stdClass'));
$builder = $this
->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
$builder
->expects($this
->any())
->method('hasDefinition')
->will($this
->returnValue(true));
// We don't test kernel.event_listener here
$builder
->expects($this
->atLeastOnce())
->method('findTaggedServiceIds')
->will($this
->onConsecutiveCalls(array(), $services));
$builder
->expects($this
->atLeastOnce())
->method('getDefinition')
->will($this
->returnValue($definition));
$registerListenersPass = new RegisterListenersPass();
$registerListenersPass
->process($builder);
}
public function testValidEventSubscriber() {
$services = array(
'my_event_subscriber' => array(
0 => array(),
),
);
$definition = $this
->getMock('Symfony\\Component\\DependencyInjection\\Definition');
$definition
->expects($this
->atLeastOnce())
->method('getClass')
->will($this
->returnValue('Symfony\\Component\\HttpKernel\\Tests\\DependencyInjection\\SubscriberService'));
$builder = $this
->getMock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
$builder
->expects($this
->any())
->method('hasDefinition')
->will($this
->returnValue(true));
// We don't test kernel.event_listener here
$builder
->expects($this
->atLeastOnce())
->method('findTaggedServiceIds')
->will($this
->onConsecutiveCalls(array(), $services));
$builder
->expects($this
->atLeastOnce())
->method('getDefinition')
->will($this
->returnValue($definition));
$registerListenersPass = new RegisterListenersPass();
$registerListenersPass
->process($builder);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RegisterListenersPassTest:: |
public | function | Tests that event subscribers not implementing EventSubscriberInterface trigger an exception. | |
RegisterListenersPassTest:: |
public | function |