Skip to content

Commit f0eabe7

Browse files
committed
Use SignedElementTestTrait
1 parent 43d17aa commit f0eabe7

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/XML/CustomSignableTest.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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\Test\XML\SerializableElementTestTrait;
12+
use SimpleSAML\XML\DOMDocumentFactory;
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+
/** @var \DOMElement */
30+
private DOMElement $logoutRequestElement;
31+
32+
33+
/**
34+
* Load a fixture.
35+
*/
36+
public function setUp(): void
37+
{
38+
$this->testedClass = CustomSignable::class;
39+
40+
$this->xmlRepresentation = DOMDocumentFactory::fromFile(
41+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignable.xml',
42+
);
43+
}
44+
45+
46+
/**
47+
* No marshalling test, because the constructor is private
48+
*/
49+
50+
51+
/**
52+
*/
53+
public function testUnmarshalling(): void
54+
{
55+
$customSignable = CustomSignable::fromXML($this->xmlRepresentation->documentElement);
56+
57+
$this->assertEquals(
58+
$this->xmlRepresentation->saveXML($this->xmlRepresentation->documentElement),
59+
strval($customSignable),
60+
);
61+
}
62+
}

0 commit comments

Comments
 (0)