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 05ded9c commit 3c4fb66
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/XML/element.registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

return [
'http://www.yale.edu/tp/cas' => [
'Attributes' => '\SimpleSAML\CAS\XML\cas\Attributes',
'AuthenticationDate' => '\SimpleSAML\CAS\XML\cas\AuthenticationDate',
'AuthenticationFailure' => '\SimpleSAML\CAS\XML\cas\AuthenticationFailure',
'AuthenticationSuccess' => '\SimpleSAML\CAS\XML\cas\AuthenticationSuccess',
'IsFromNewLogin' => '\SimpleSAML\CAS\XML\cas\IsFromNewLogin',
'LongTermAuthenticationRequestTokenUsed' => '\SimpleSAML\CAS\XML\cas\LongTermAuthenticationRequestTokenUsed',
'Proxies' => '\SimpleSAML\CAS\XML\cas\Proxies',
'Proxy' => '\SimpleSAML\CAS\XML\cas\Proxy',
'ProxyFailure' => '\SimpleSAML\CAS\XML\cas\ProxyFailure',
'ProxyGrantingTicket' => '\SimpleSAML\CAS\XML\cas\ProxyGrantingTicket',
'ProxySuccess' => '\SimpleSAML\CAS\XML\cas\ProxySuccess',
'ProxyTicket' => '\SimpleSAML\CAS\XML\cas\ProxyTicket',
'ServiceResponse' => '\SimpleSAML\CAS\XML\cas\ServiceResponse',
'User' => '\SimpleSAML\CAS\XML\cas\User',
'attributes' => '\SimpleSAML\CAS\XML\cas\Attributes',
'authenticationDate' => '\SimpleSAML\CAS\XML\cas\AuthenticationDate',
'authenticationFailure' => '\SimpleSAML\CAS\XML\cas\AuthenticationFailure',
'authenticationSuccess' => '\SimpleSAML\CAS\XML\cas\AuthenticationSuccess',
'isFromNewLogin' => '\SimpleSAML\CAS\XML\cas\IsFromNewLogin',
'longTermAuthenticationRequestTokenUsed' => '\SimpleSAML\CAS\XML\cas\LongTermAuthenticationRequestTokenUsed',
'proxies' => '\SimpleSAML\CAS\XML\cas\Proxies',
'proxy' => '\SimpleSAML\CAS\XML\cas\Proxy',
'proxyFailure' => '\SimpleSAML\CAS\XML\cas\ProxyFailure',
'proxyGrantingTicket' => '\SimpleSAML\CAS\XML\cas\ProxyGrantingTicket',
'proxySuccess' => '\SimpleSAML\CAS\XML\cas\ProxySuccess',
'proxyTicket' => '\SimpleSAML\CAS\XML\cas\ProxyTicket',
'serviceResponse' => '\SimpleSAML\CAS\XML\cas\ServiceResponse',
'user' => '\SimpleSAML\CAS\XML\cas\User',
],
];
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\CAS\XML;

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

use function dirname;
use function sprintf;

/**
* Tests for element registry.
*
* @package simplesamlphp/xml-cas
*/
#[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 3c4fb66

Please sign in to comment.