File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -376,6 +376,12 @@ public function testWithPug()
376376 */
377377 public function testNamespace ()
378378 {
379+ $ phugVersion = $ this ->getPhugInstalledVersion ();
380+
381+ if ($ phugVersion !== null && version_compare ($ phugVersion , '2.0.0 ' , '< ' )) {
382+ self ::markTestSkipped ('Namespace support is only available since Phug 2.0.0 ' );
383+ }
384+
379385 $ pug = new Pug ([
380386 'on_output ' => function (OutputEvent $ event ) {
381387 $ event ->prependCode ('namespace pug; ' );
@@ -452,4 +458,20 @@ private function rawHtml($html)
452458
453459 return $ html ;
454460 }
461+
462+ private function getPhugInstalledVersion (): ?string
463+ {
464+ $ composerLockFile = __DIR__ . '/../../../composer.lock ' ;
465+ $ packages = file_exists ($ composerLockFile )
466+ ? (json_decode (file_get_contents ($ composerLockFile ), true )['packages ' ] ?? [])
467+ : [];
468+
469+ foreach ($ packages as $ package ) {
470+ if (($ package ['name ' ] ?? null ) === 'phug/phug ' ) {
471+ return $ package ['version ' ] ?? null ;
472+ }
473+ }
474+
475+ return null ;
476+ }
455477}
You can’t perform that action at this time.
0 commit comments