Yaffs site version 1.1
[yaffs-website] / vendor / symfony / config / Tests / Exception / FileLoaderLoadExceptionTest.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\Config\Tests\Exception;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Exception\FileLoaderLoadException;
16
17 class FileLoaderLoadExceptionTest extends TestCase
18 {
19     public function testMessageCannotLoadResource()
20     {
21         $exception = new FileLoaderLoadException('resource', null);
22         $this->assertEquals('Cannot load resource "resource".', $exception->getMessage());
23     }
24
25     public function testMessageCannotImportResourceFromSource()
26     {
27         $exception = new FileLoaderLoadException('resource', 'sourceResource');
28         $this->assertEquals('Cannot import resource "resource" from "sourceResource".', $exception->getMessage());
29     }
30
31     public function testMessageCannotImportBundleResource()
32     {
33         $exception = new FileLoaderLoadException('@resource', 'sourceResource');
34         $this->assertEquals(
35             'Cannot import resource "@resource" from "sourceResource". '.
36             'Make sure the "resource" bundle is correctly registered and loaded in the application kernel class. '.
37             'If the bundle is registered, make sure the bundle path "@resource" is not empty.',
38             $exception->getMessage()
39         );
40     }
41
42     public function testMessageHasPreviousErrorWithDotAndUnableToLoad()
43     {
44         $exception = new FileLoaderLoadException(
45             'resource',
46             null,
47             null,
48             new \Exception('There was a previous error with an ending dot.')
49         );
50         $this->assertEquals(
51             'There was a previous error with an ending dot in resource (which is loaded in resource "resource").',
52             $exception->getMessage()
53         );
54     }
55
56     public function testMessageHasPreviousErrorWithoutDotAndUnableToLoad()
57     {
58         $exception = new FileLoaderLoadException(
59             'resource',
60             null,
61             null,
62             new \Exception('There was a previous error with no ending dot')
63         );
64         $this->assertEquals(
65             'There was a previous error with no ending dot in resource (which is loaded in resource "resource").',
66             $exception->getMessage()
67         );
68     }
69
70     public function testMessageHasPreviousErrorAndUnableToLoadBundle()
71     {
72         $exception = new FileLoaderLoadException(
73             '@resource',
74             null,
75             null,
76             new \Exception('There was a previous error with an ending dot.')
77         );
78         $this->assertEquals(
79             'There was a previous error with an ending dot in @resource '.
80             '(which is loaded in resource "@resource"). '.
81             'Make sure the "resource" bundle is correctly registered and loaded in the application kernel class. '.
82             'If the bundle is registered, make sure the bundle path "@resource" is not empty.',
83             $exception->getMessage()
84         );
85     }
86 }