Skip to content

Commit d0a1bf1

Browse files
committed
Test YAML-files
1 parent b6de826 commit d0a1bf1

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/www/RouterTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace SimpleSAML\Test\Web;
4+
5+
use Symfony\Component\Yaml\Parser;
6+
use PHPUnit\Framework\TestCase;
7+
use \SimpleSAML\Configuration;
8+
use \SimpleSAML\Module;
9+
10+
class RouterTest extends TestCase
11+
{
12+
public function testSyntax()
13+
{
14+
$config = Configuration::loadFromArray([
15+
'module.enable' => array_fill_keys(Module::getModules(), true),
16+
]);
17+
Configuration::setPreLoadedConfig($config);
18+
19+
$yaml = new Parser();
20+
21+
// Module templates
22+
foreach (Module::getModules() as $module) {
23+
$basedir = Module::getModuleDir($module);
24+
if (file_exists($basedir)) {
25+
$files = array_diff(scandir($basedir), ['.', '..']);
26+
foreach ($files as $file) {
27+
if (preg_match('/.(yml|yaml)$/', $file)) {
28+
try {
29+
$value = $yaml->parse(file_get_contents('../../modules/'.$module.'/'.$file));
30+
$this->addToAssertionCount(1);
31+
} catch (\ParseException $e) {
32+
$this->fail($e->getMessage().' in '.$e->getFile().':'.$e->getLine());
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)