Skip to content

Commit

Permalink
Add unit-test for element registry
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Sep 15, 2024
1 parent 446cbf3 commit 9401bac
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/XML/ElementRegistryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\XMLSecurity\XML;

use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function dirname;
use function sprintf;

/**
* Tests for element registry.
*
* @package simplesamlphp/xml-security
*/
#[Group('utils')]
final class ElementRegistryTest extends TestCase
{
/**
* Test that the class-name can be resolved and it's localname matches.
*/
public function testElementRegistry(): void
{
$elementRegistry = dirname(__FILE__, 3) . '/src/XML/element.registry.php';
$namespaces = include($elementRegistry);

foreach ($namespaces as $namespaceURI => $elements) {
foreach ($elements as $localName => $fqdn) {
$this->assertTrue(class_exists($fqdn), sprintf('Class \'%s\' could not be found.', $fqdn));
$this->assertEquals($fqdn::getLocalName(), $localName);
$this->assertEquals($fqdn::getNamespaceURI(), $namespaceURI);
}
}
}
}

0 comments on commit 9401bac

Please sign in to comment.