Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / DefinitionErrorExceptionPassTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DependencyInjection\Tests\Compiler;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Definition;
18
19 class DefinitionErrorExceptionPassTest extends TestCase
20 {
21     /**
22      * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
23      * @expectedExceptionMessage Things went wrong!
24      */
25     public function testThrowsException()
26     {
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')
32             ->setArguments(array(
33                 $def,
34             ));
35
36         $pass = new DefinitionErrorExceptionPass();
37         $pass->process($container);
38     }
39
40     public function testNoExceptionThrown()
41     {
42         $container = new ContainerBuilder();
43         $def = new Definition();
44         $container->register('foo_service_id')
45             ->setArguments(array(
46                 $def,
47             ));
48
49         $pass = new DefinitionErrorExceptionPass();
50         $pass->process($container);
51         $this->assertSame($def, $container->getDefinition('foo_service_id')->getArgument(0));
52     }
53 }