-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
147 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\XML; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Test\XML\ExtendableAttributesElement; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
use SimpleSAML\XML\Attribute; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\XML\ExtendableAttributesTest | ||
* | ||
* @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait | ||
* @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait | ||
* | ||
* @package simplesamlphp\xml-common | ||
*/ | ||
final class ExtendableAttributesTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 2) . '/resources/schemas/simplesamlphp.xsd'; | ||
|
||
self::$testedClass = ExtendableAttributesElement::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 2) . '/resources/xml/ssp_ExtendableAttributesElement.xml', | ||
); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$extendableElement = new ExtendableAttributesElement( | ||
[ | ||
new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'), | ||
new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr2', 'testval2'), | ||
], | ||
); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($extendableElement), | ||
); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public function testUnmarshalling(): void | ||
{ | ||
$extendableElement = ExtendableAttributesElement::fromXML(self::$xmlRepresentation->documentElement); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($extendableElement), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\XML; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Test\XML\ExtendableElementElement; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
use SimpleSAML\XML\Attribute; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\XML\ExtendableElementTest | ||
* | ||
* @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait | ||
* @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait | ||
* | ||
* @package simplesamlphp\xml-common | ||
*/ | ||
final class ExtendableElementTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 2) . '/resources/schemas/simplesamlphp.xsd'; | ||
|
||
self::$testedClass = ExtendableElement::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 2) . '/resources/xml/ssp_ExtendableElement.xml', | ||
); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$extendableElement = new ExtendableElement( | ||
[ | ||
new Chunk(DOMDocumentFactory::fromString('<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>')->documentElement), | ||
new Chunk(DOMDocumentFactory::fromString('<dummy:Chunk xmlns:dummy="urn:custom:dummy">some</dummy:Chunk>')->documentElement), | ||
], | ||
); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($extendableElement), | ||
); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public function testUnmarshalling(): void | ||
{ | ||
$extendableElement = ExtendableElement::fromXML(self::$xmlRepresentation->documentElement); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($extendableElement), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters