Passed
Push — master ( be09b3...67068d )
by Tim
13:28
created

SignaturePropertyTest::testUnmarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XML\Chunk;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
11
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12
use SimpleSAML\XMLSecurity\XML\ds\SignatureProperty;
13
14
use function dirname;
15
use function strval;
16
17
/**
18
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\SignaturePropertyTest
19
 *
20
 * @covers \SimpleSAML\XMLSecurity\XML\ds\SignatureProperty
21
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
22
 *
23
 * @package simplesamlphp/saml2
24
 */
25
final class SignaturePropertyTest extends TestCase
26
{
27
    use SchemaValidationTestTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TestUtils\SchemaValidationTestTrait requires some properties which are not provided by SimpleSAML\XMLSecurity\T...s\SignaturePropertyTest: $documentElement, $ownerDocument, $message, $line
Loading history...
28
    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\T...s\SignaturePropertyTest.
Loading history...
29
30
31
    /**
32
     */
33
    public static function setUpBeforeClass(): void
34
    {
35
        self::$testedClass = SignatureProperty::class;
36
37
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd';
38
39
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
40
            dirname(__FILE__, 3) . '/resources/xml/ds_SignatureProperty.xml',
41
        );
42
    }
43
44
45
    /**
46
     */
47
    public function testMarshalling(): void
48
    {
49
        $document = DOMDocumentFactory::fromString(
50
            '<ssp:HSMSerialNumber xmlns:ssp="urn:x-simplesamlphp:namespace">1234567890</ssp:HSMSerialNumber>'
51
        );
52
53
        $signatureProperty = new SignatureProperty(
54
            [new Chunk($document->documentElement)],
55
            'https://simplesamlphp.org/some/target',
56
            'abc123'
57
        );
58
59
        $this->assertEquals(
60
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
61
            strval($signatureProperty)
62
        );
63
    }
64
}
65