Skip to content

Commit 9401bac

Browse files
committed
Add unit-test for element registry
1 parent 446cbf3 commit 9401bac

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tests/XML/ElementRegistryTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Test\XMLSecurity\XML;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use PHPUnit\Framework\TestCase;
9+
10+
use function dirname;
11+
use function sprintf;
12+
13+
/**
14+
* Tests for element registry.
15+
*
16+
* @package simplesamlphp/xml-security
17+
*/
18+
#[Group('utils')]
19+
final class ElementRegistryTest extends TestCase
20+
{
21+
/**
22+
* Test that the class-name can be resolved and it's localname matches.
23+
*/
24+
public function testElementRegistry(): void
25+
{
26+
$elementRegistry = dirname(__FILE__, 3) . '/src/XML/element.registry.php';
27+
$namespaces = include($elementRegistry);
28+
29+
foreach ($namespaces as $namespaceURI => $elements) {
30+
foreach ($elements as $localName => $fqdn) {
31+
$this->assertTrue(class_exists($fqdn), sprintf('Class \'%s\' could not be found.', $fqdn));
32+
$this->assertEquals($fqdn::getLocalName(), $localName);
33+
$this->assertEquals($fqdn::getNamespaceURI(), $namespaceURI);
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)