Commit a10d5be2 authored by catch's avatar catch

Issue #2259337 by sun, chx: Do not hide the error messages in TaggedHandlersPass.

parent 68d6316b
......@@ -89,9 +89,6 @@ public function process(ContainerBuilder $container) {
$accepts_priority = isset($params[1]) && $params[1]->getName() === 'priority';
if (!isset($interface)) {
if ($container->getParameter('kernel.environment') === 'prod') {
continue;
}
throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", array(
$consumer_id,
$consumer->getClass(),
......@@ -106,9 +103,6 @@ public function process(ContainerBuilder $container) {
// Validate the interface.
$handler = $container->getDefinition($id);
if (!is_subclass_of($handler->getClass(), $interface)) {
if ($container->getParameter('kernel.environment') === 'prod') {
continue;
}
throw new LogicException("Service '$id' for consumer '$consumer_id' does not implement $interface.");
}
$handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
......
......@@ -73,24 +73,6 @@ public function testProcessMissingInterface() {
$handler_pass->process($container);
}
/**
* Tests consumer with missing interface in production environment.
*
* @covers ::process
*/
public function testProcessMissingInterfaceProd() {
$container = $this->buildContainer('prod');
$container
->register('consumer_id', __NAMESPACE__ . '\InvalidConsumer')
->addTag('service_collector');
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
$this->assertCount(1, $container->getDefinitions());
$this->assertFalse($container->getDefinition('consumer_id')->hasMethodCall('addHandler'));
}
/**
* Tests one consumer and two handlers.
*
......@@ -205,35 +187,6 @@ public function testProcessInterfaceMismatch() {
$handler_pass->process($container);
}
/**
* Tests interface validation in production environment.
*
* @covers ::process
*/
public function testProcessInterfaceMismatchProd() {
$container = $this->buildContainer('prod');
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumer')
->addTag('service_collector');
$container
->register('handler1', __NAMESPACE__ . '\InvalidHandler')
->addTag('consumer_id');
$container
->register('handler2', __NAMESPACE__ . '\ValidHandler')
->addTag('consumer_id', array(
'priority' => 10,
));
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
$method_calls = $container->getDefinition('consumer_id')->getMethodCalls();
$this->assertCount(1, $method_calls);
$this->assertEquals(new Reference('handler2'), $method_calls[0][1][0]);
$this->assertEquals(10, $method_calls[0][1][1]);
}
}
interface HandlerInterface {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment