Skip to content

Commit

Permalink
Implement generic version of testUnmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 25, 2023
1 parent d7b3390 commit e26d16b
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 188 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ext-dom": "*",

"simplesamlphp/assert": "^1.0",
"simplesamlphp/xml-common": "^1.12"
"simplesamlphp/xml-common": "^1.14"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "^1.5"
Expand Down
10 changes: 6 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory>./src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
Expand All @@ -14,4 +11,9 @@
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
3 changes: 2 additions & 1 deletion src/XML/cas/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

use function array_pop;

Expand All @@ -27,7 +28,7 @@ final class Attributes extends AbstractCasElement
final public const LOCALNAME = 'attributes';

/** The namespace-attribute for the xs:any element */
final public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
final public const XS_ANY_ELT_NAMESPACE = NS::ANY;


/**
Expand Down
13 changes: 0 additions & 13 deletions tests/XML/cas/AttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,4 @@ public function testMarshallingElementOrdering(): void
$this->assertEquals('cas:longTermAuthenticationRequestTokenUsed', $attributesElements[0]->tagName);
$this->assertEquals('cas:isFromNewLogin', $attributesElements[1]->tagName);
}


/**
*/
public function testUnmarshalling(): void
{
$attributes = Attributes::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($attributes),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/AuthenticationDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,4 @@ public function testMarshalling(): void
strval($authenticationDate),
);
}


/**
*/
public function testUnmarshalling(): void
{
$authenticationDate = AuthenticationDate::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($authenticationDate),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/AuthenticationFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,4 @@ public function testMarshalling(): void
strval($authenticationFailure),
);
}


/**
*/
public function testUnmarshalling(): void
{
$authenticationFailure = AuthenticationFailure::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($authenticationFailure),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/AuthenticationSuccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,4 @@ public function testMarshallingElementOrdering(): void
$this->assertEquals('cas:proxyGrantingTicket', $authenticationSuccessElements[1]->tagName);
$this->assertEquals('cas:proxies', $authenticationSuccessElements[2]->tagName);
}


/**
*/
public function testUnmarshalling(): void
{
$authenticationSuccess = AuthenticationSuccess::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($authenticationSuccess),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/IsFromNewLoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,4 @@ public function testMarshalling(): void
strval($isFromNewLogin),
);
}


/**
*/
public function testUnmarshalling(): void
{
$isFromNewLogin = IsFromNewLogin::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($isFromNewLogin),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/LongTermAuthenticationRequestTokenUsedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,4 @@ public function testMarshalling(): void
strval($longTerm),
);
}


/**
*/
public function testUnmarshalling(): void
{
$longTerm = LongTermAuthenticationRequestTokenUsed::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($longTerm),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,4 @@ public function testMarshalling(): void
strval($list),
);
}


/**
*/
public function testUnmarshalling(): void
{
$list = Proxies::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($list),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ProxyFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,4 @@ public function testMarshalling(): void
strval($proxyFailure),
);
}


/**
*/
public function testUnmarshalling(): void
{
$proxyFailure = ProxyFailure::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($proxyFailure),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ProxyGrantingTicketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,4 @@ public function testMarshalling(): void
strval($proxyGrantingTicket),
);
}


/**
*/
public function testUnmarshalling(): void
{
$proxyGrantingTicket = ProxyGrantingTicket::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($proxyGrantingTicket),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ProxySuccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,4 @@ public function testMarshalling(): void
strval($proxySuccess),
);
}


/**
*/
public function testUnmarshalling(): void
{
$proxySuccess = ProxySuccess::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($proxySuccess),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,4 @@ public function testMarshalling(): void
strval($proxy),
);
}


/**
*/
public function testUnmarshalling(): void
{
$proxy = Proxy::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($proxy),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ProxyTicketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,4 @@ public function testMarshalling(): void
strval($proxyTicket),
);
}


/**
*/
public function testUnmarshalling(): void
{
$proxyTicket = ProxyTicket::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($proxyTicket),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/ServiceResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,4 @@ public function testMarshalling(): void
strval($serviceResponse),
);
}


/**
*/
public function testUnmarshalling(): void
{
$serviceResponse = ServiceResponse::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($serviceResponse),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/cas/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,4 @@ public function testMarshalling(): void
strval($user),
);
}


/**
*/
public function testUnmarshalling(): void
{
$user = User::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($user),
);
}
}

0 comments on commit e26d16b

Please sign in to comment.