Skip to content

Commit 10704ca

Browse files
committed
Skip namespace test for Phug 1
1 parent f8bd535 commit 10704ca

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/Phug/Component/ComponentExtensionTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)