4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Tests\Compiler;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Definition;
19 class DefinitionErrorExceptionPassTest extends TestCase
22 * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
23 * @expectedExceptionMessage Things went wrong!
25 public function testThrowsException()
27 $container = new ContainerBuilder();
28 $def = new Definition();
29 $def->addError('Things went wrong!');
30 $def->addError('Now something else!');
31 $container->register('foo_service_id')
36 $pass = new DefinitionErrorExceptionPass();
37 $pass->process($container);
40 public function testNoExceptionThrown()
42 $container = new ContainerBuilder();
43 $def = new Definition();
44 $container->register('foo_service_id')
49 $pass = new DefinitionErrorExceptionPass();
50 $pass->process($container);
51 $this->assertSame($def, $container->getDefinition('foo_service_id')->getArgument(0));