Skip to content

Commit

Permalink
Make sure all XML-classes have a marshalling/unmarshalling test
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed May 26, 2023
1 parent 4fa17d2 commit 0d43197
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 458 deletions.
2 changes: 1 addition & 1 deletion tests/SAML2/XML/md/RoleDescriptorTest.php
Expand Up @@ -154,7 +154,7 @@ public function testMarshalling(): void
/**
* Test unmarshalling a known object as a RoleDescriptor.
*/
public function testUnmarshallingRegistered(): void
public function testUnmarshalling(): void
{
$descriptor = AbstractRoleDescriptor::fromXML(self::$xmlRepresentation->documentElement);

Expand Down
2 changes: 1 addition & 1 deletion tests/SAML2/XML/saml/AttributeStatementTest.php
Expand Up @@ -49,7 +49,7 @@ public static function setUpBeforeClass(): void

/**
*/
public function testMarshallingAttributes(): void
public function testMarshalling(): void
{
$attrStatement = new AttributeStatement(
[
Expand Down
32 changes: 17 additions & 15 deletions tests/SAML2/XML/saml/AttributeValueTest.php
Expand Up @@ -45,36 +45,37 @@ public static function setUpBeforeClass(): void
// marshalling


/**
* Test creating an AttributeValue from scratch using a string.
*
*/
public function testMarshallingString(): void
{
$av = new AttributeValue('value');

$this->assertEquals('value', $av->getValue());
$this->assertEquals('xs:string', $av->getXsiType());
}


/**
* Test creating an AttributeValue from scratch using an integer.
*
*/
public function testMarshallingInteger(): void
public function testMarshalling(): void
{
$av = new AttributeValue(2);
$this->assertIsInt($av->getValue());
$this->assertEquals(2, $av->getValue());
$this->assertEquals('xs:integer', $av->getXsiType());

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


/**
* Test creating an AttributeValue from scratch using a string.
*/
public function testMarshallingString(): void
{
$av = new AttributeValue('value');

$this->assertEquals('value', $av->getValue());
$this->assertEquals('xs:string', $av->getXsiType());
}


/**
*/
public function testMarshallingNull(): void
{
$av = new AttributeValue(null);
Expand Down Expand Up @@ -124,6 +125,7 @@ public function testUnmarshalling(): void

$this->assertIsInt($av->getValue());
$this->assertEquals(2, $av->getValue());

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($av),
Expand Down
3 changes: 2 additions & 1 deletion tests/SAML2/XML/saml/BaseIDTest.php
Expand Up @@ -77,8 +77,9 @@ public function testMarshalling(): void


/**
* Test unmarshalling a registered class
*/
public function testUnmarshallingRegistered(): void
public function testUnmarshalling(): void
{
$baseId = AbstractBaseID::fromXML(self::$xmlRepresentation->documentElement);

Expand Down
3 changes: 2 additions & 1 deletion tests/SAML2/XML/saml/ConditionTest.php
Expand Up @@ -74,8 +74,9 @@ public function testMarshalling(): void


/**
* Test unmarshalling a registered class
*/
public function testUnmarshallingRegistered(): void
public function testUnmarshalling(): void
{
$condition = CustomCondition::fromXML(self::$xmlRepresentation->documentElement);

Expand Down
13 changes: 13 additions & 0 deletions tests/SAML2/XML/saml/EncryptedAssertionTest.php
Expand Up @@ -104,6 +104,19 @@ public function testMarshalling(): void
}


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

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


/**
* Test encryption / decryption
*/
Expand Down
13 changes: 13 additions & 0 deletions tests/SAML2/XML/saml/EncryptedIDTest.php
Expand Up @@ -161,6 +161,19 @@ public function testMarshallingElementOrdering(): void
}


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

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


/**
* Test encryption / decryption
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/SAML2/XML/saml/StatementTest.php
Expand Up @@ -75,8 +75,9 @@ public function testMarshalling(): void


/**
* Test unmarshalling a registered class
*/
public function testUnmarshallingRegistered(): void
public function testUnmarshalling(): void
{
$statement = CustomStatement::fromXML(self::$xmlRepresentation->documentElement);
$this->assertInstanceOf(CustomStatement::class, $statement);
Expand Down
2 changes: 1 addition & 1 deletion tests/SAML2/XML/saml/SubjectTest.php
Expand Up @@ -87,7 +87,7 @@ public function setup(): void

/**
*/
public function testMarshallingNameID(): void
public function testMarshalling(): void
{
$arbitrary = DOMDocumentFactory::fromString('<some>Arbitrary Element</some>');

Expand Down

0 comments on commit 0d43197

Please sign in to comment.