Passed
Branch master (c86cc6)
by Tim
03:54
created

CustomSignableTest::testUnmarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Bug introduced by
The trait SimpleSAML\XML\TestUtils...lizableElementTestTrait requires the property $documentElement which is not provided by SimpleSAML\XMLSecurity\Test\XML\CustomSignableTest.
Loading history...
26
    use SignedElementTestTrait;
0 ignored issues
show
Bug introduced by
The trait SimpleSAML\XMLSecurity\T...\SignedElementTestTrait requires the property $documentElement which is not provided by SimpleSAML\XMLSecurity\Test\XML\CustomSignableTest.
Loading history...
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