@@ -68,11 +68,6 @@ public function parseProvider()
68
68
array ('FooBundle:Post:foo.bar.index.html.php ' , 'FooBundle:Post:foo.bar.index.html.php ' , '@FooBundle/Resources/views/Post/foo.bar.index.html.php ' , new TemplateReference ('FooBundle ' , 'Post ' , 'foo.bar.index ' , 'html ' , 'php ' )),
69
69
array ('@FooBundle/Resources/views/layout.html.twig ' , '@FooBundle/Resources/views/layout.html.twig ' , '@FooBundle/Resources/views/layout.html.twig ' , new BaseTemplateReference ('@FooBundle/Resources/views/layout.html.twig ' , 'twig ' )),
70
70
array ('@FooBundle/Foo/layout.html.twig ' , '@FooBundle/Foo/layout.html.twig ' , '@FooBundle/Foo/layout.html.twig ' , new BaseTemplateReference ('@FooBundle/Foo/layout.html.twig ' , 'twig ' )),
71
- array ('/path/to/section/index.html.php ' , '/path/to/section/index.html.php ' , '/path/to/section/index.html.php ' , new BaseTemplateReference ('/path/to/section/index.html.php ' , 'php ' )),
72
- array ('C: \\path \\to \\section \\name.html.php ' , 'C:path/to/section/name.html.php ' , 'C:path/to/section/name.html.php ' , new BaseTemplateReference ('C:path/to/section/name.html.php ' , 'php ' )),
73
- array ('C: \\path \\to \\section \\name:foo.html.php ' , 'C:path/to/section/name:foo.html.php ' , 'C:path/to/section/name:foo.html.php ' , new BaseTemplateReference ('C:path/to/section/name:foo.html.php ' , 'php ' )),
74
- array ('\\path \\to \\section \\name.html.php ' , '/path/to/section/name.html.php ' , '/path/to/section/name.html.php ' , new BaseTemplateReference ('/path/to/section/name.html.php ' , 'php ' )),
75
- array ('/path/to/section/name.php ' , '/path/to/section/name.php ' , '/path/to/section/name.php ' , new BaseTemplateReference ('/path/to/section/name.php ' , 'php ' )),
76
71
array ('name.twig ' , 'name.twig ' , 'name.twig ' , new BaseTemplateReference ('name.twig ' , 'twig ' )),
77
72
array ('name ' , 'name ' , 'name ' , new BaseTemplateReference ('name ' )),
78
73
array ('default/index.html.php ' , '::default/index.html.php ' , 'views/default/index.html.php ' , new TemplateReference (null , null , 'default/index ' , 'html ' , 'php ' )),
@@ -86,4 +81,39 @@ public function testParseValidNameWithNotFoundBundle()
86
81
{
87
82
$ this ->parser ->parse ('BarBundle:Post:index.html.php ' );
88
83
}
84
+
85
+ /**
86
+ * @group legacy
87
+ * @dataProvider provideAbsolutePaths
88
+ */
89
+ public function testAbsolutePathsAreDeprecated ($ name , $ logicalName , $ path , $ ref )
90
+ {
91
+ $ deprecations = array ();
92
+ set_error_handler (function ($ type , $ msg ) use (&$ deprecations ) {
93
+ if (E_USER_DEPRECATED === $ type ) {
94
+ $ deprecations [] = $ msg ;
95
+ }
96
+ });
97
+
98
+ $ template = $ this ->parser ->parse ($ name );
99
+
100
+ restore_error_handler ();
101
+
102
+ $ this ->assertSame ($ ref ->getLogicalName (), $ template ->getLogicalName ());
103
+ $ this ->assertSame ($ logicalName , $ template ->getLogicalName ());
104
+ $ this ->assertSame ($ path , $ template ->getPath ());
105
+ $ this ->assertCount (1 , $ deprecations );
106
+ $ this ->assertContains ('Absolute template path support is deprecated since Symfony 3.1 and will throw an exception in 4.0. ' , $ deprecations [0 ]);
107
+ }
108
+
109
+ public function provideAbsolutePaths ()
110
+ {
111
+ return array (
112
+ array ('/path/to/section/index.html.php ' , '/path/to/section/index.html.php ' , '/path/to/section/index.html.php ' , new BaseTemplateReference ('/path/to/section/index.html.php ' , 'php ' )),
113
+ array ('C: \\path \\to \\section \\name.html.php ' , 'C:path/to/section/name.html.php ' , 'C:path/to/section/name.html.php ' , new BaseTemplateReference ('C:path/to/section/name.html.php ' , 'php ' )),
114
+ array ('C: \\path \\to \\section \\name:foo.html.php ' , 'C:path/to/section/name:foo.html.php ' , 'C:path/to/section/name:foo.html.php ' , new BaseTemplateReference ('C:path/to/section/name:foo.html.php ' , 'php ' )),
115
+ array ('\\path \\to \\section \\name.html.php ' , '/path/to/section/name.html.php ' , '/path/to/section/name.html.php ' , new BaseTemplateReference ('/path/to/section/name.html.php ' , 'php ' )),
116
+ array ('/path/to/section/name.php ' , '/path/to/section/name.php ' , '/path/to/section/name.php ' , new BaseTemplateReference ('/path/to/section/name.php ' , 'php ' )),
117
+ );
118
+ }
89
119
}
0 commit comments