File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed
src/Symfony/Component/HttpKernel
Fixtures/ExtensionNotValidBundle Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,13 @@ public function getContainerExtension()
78
78
if (class_exists ($ class )) {
79
79
$ extension = new $ class ();
80
80
81
+ if (!$ extension instanceof ExtensionInterface) {
82
+ throw new \LogicException (sprintf (
83
+ 'Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface. ' ,
84
+ $ class
85
+ ));
86
+ }
87
+
81
88
// check naming convention
82
89
$ expectedAlias = Container::underscore ($ basename );
83
90
if ($ expectedAlias != $ extension ->getAlias ()) {
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \HttpKernel \Tests \Bundle ;
13
13
14
+ use Symfony \Component \HttpKernel \Tests \Fixtures \ExtensionNotValidBundle \ExtensionNotValidBundle ;
14
15
use Symfony \Component \HttpKernel \Tests \Fixtures \ExtensionPresentBundle \ExtensionPresentBundle ;
15
16
use Symfony \Component \HttpKernel \Tests \Fixtures \ExtensionAbsentBundle \ExtensionAbsentBundle ;
16
17
use Symfony \Component \HttpKernel \Tests \Fixtures \ExtensionPresentBundle \Command \FooCommand ;
@@ -30,4 +31,14 @@ public function testRegisterCommands()
30
31
31
32
$ this ->assertNull ($ bundle2 ->registerCommands ($ app ));
32
33
}
34
+
35
+ /**
36
+ * @expectedException \LogicException
37
+ * @expectedExceptionMessage must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface
38
+ */
39
+ public function testGetContainerExtensionWithInvalidClass ()
40
+ {
41
+ $ bundle = new ExtensionNotValidBundle ();
42
+ $ bundle ->getContainerExtension ();
43
+ }
33
44
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
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 \HttpKernel \Tests \Fixtures \ExtensionNotValidBundle \DependencyInjection ;
13
+
14
+ class ExtensionNotValidExtension
15
+ {
16
+ public function getAlias ()
17
+ {
18
+ return 'extension_not_valid ' ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
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 \HttpKernel \Tests \Fixtures \ExtensionNotValidBundle ;
13
+
14
+ use Symfony \Component \HttpKernel \Bundle \Bundle ;
15
+
16
+ class ExtensionNotValidBundle extends Bundle
17
+ {
18
+ }
You can’t perform that action at this time.
0 commit comments