1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML; |
6
|
|
|
|
7
|
|
|
use DOMDocument; |
8
|
|
|
use DOMElement; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use SimpleSAML\XMLSecurity\TestUtils\SignedElementTestTrait; |
11
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
12
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
13
|
|
|
|
14
|
|
|
use function dirname; |
15
|
|
|
use function strval; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\CustomSignableTest |
19
|
|
|
* |
20
|
|
|
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable |
21
|
|
|
* @package simplesamlphp/xml-security |
22
|
|
|
*/ |
23
|
|
|
final class CustomSignableTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
26
|
|
|
use SignedElementTestTrait; |
|
|
|
|
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Load a fixture. |
31
|
|
|
*/ |
32
|
|
|
public static function setUpBeforeClass(): void |
33
|
|
|
{ |
34
|
|
|
self::$testedClass = CustomSignable::class; |
35
|
|
|
|
36
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
37
|
|
|
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignable.xml', |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* No marshalling test, because the constructor is private |
44
|
|
|
*/ |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
*/ |
49
|
|
|
public function testMarshalling(): void |
50
|
|
|
{ |
51
|
|
|
$document = DOMDocumentFactory::fromString(<<<XML |
52
|
|
|
<ssp:CustomSignable xmlns:ssp="urn:x-simplesamlphp:namespace"><ssp:Chunk>Some</ssp:Chunk></ssp:CustomSignable> |
53
|
|
|
XML |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$customSignable = new CustomSignable($document->documentElement, null); |
57
|
|
|
|
58
|
|
|
$this->assertEquals( |
59
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
60
|
|
|
strval($customSignable), |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
*/ |
67
|
|
|
public function testUnmarshalling(): void |
68
|
|
|
{ |
69
|
|
|
$customSignable = CustomSignable::fromXML(self::$xmlRepresentation->documentElement); |
70
|
|
|
|
71
|
|
|
$this->assertEquals( |
72
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
73
|
|
|
strval($customSignable), |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|