@@ -22,16 +22,19 @@ abstract class AbstractTestCase extends TestCase
2222 /**
2323 * @throws \Phug\RendererException
2424 */
25- protected function setUp ()
25+ protected function getRenderer (): Renderer
2626 {
27- parent ::setUp ();
28- $ this ->renderer = new Renderer ([
29- 'debug ' => true ,
30- 'execution_max_time ' => 180000 ,
31- 'modules ' => array_merge ([
32- PhugBemto::class,
33- ], $ this ->modules ),
34- ]);
27+ if (!isset ($ this ->renderer )) {
28+ $ this ->renderer = new Renderer ([
29+ 'debug ' => true ,
30+ 'execution_max_time ' => 180000 ,
31+ 'modules ' => array_merge ([
32+ PhugBemto::class,
33+ ], $ this ->modules ),
34+ ]);
35+ }
36+
37+ return $ this ->renderer ;
3538 }
3639
3740 protected function renderFile ($ sourceFile )
@@ -40,13 +43,13 @@ protected function renderFile($sourceFile)
4043 $ actualOutput = null ;
4144
4245 try {
43- $ actualOutput = $ this ->renderer ->renderFile ($ sourceFile );
46+ $ actualOutput = $ this ->getRenderer () ->renderFile ($ sourceFile );
4447 } catch (\Throwable $ exception ) {
4548 $ error = $ exception ;
4649
4750 try {
4851 $ debugFile = __DIR__ . '/../debug.php ' ;
49- file_put_contents ($ debugFile , $ this ->renderer ->compileFile ($ sourceFile ));
52+ file_put_contents ($ debugFile , $ this ->getRenderer () ->compileFile ($ sourceFile ));
5053 include $ debugFile ;
5154 } catch (\Throwable $ exception ) {
5255 throw new \Exception ('Error in ' . $ sourceFile . "\n" . $ exception ->getMessage (), 0 , $ exception );
@@ -72,6 +75,10 @@ protected static function htmlStandardize($html)
7275 $ html = preg_replace ('/([a-z" \'])\/>/ ' , '$1 /> ' , $ html );
7376 $ html = preg_replace ('/(<[a-z][^>]*)\s\/>/ ' , '$1> ' , $ html );
7477
78+ if (version_compare (PHP_VERSION , '8.1.0-dev ' , '>= ' )) {
79+ $ html = str_replace ('' ' , "' " , $ html );
80+ }
81+
7582 return $ html ;
7683 }
7784
0 commit comments