Passed
Push — master ( feb95e...9f38d8 )
by Tim
01:59
created

KeyReferenceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\xenc;
6
7
use PHPUnit\Framework\Attributes\CoversClass;
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
11
use SimpleSAML\XMLSecurity\Constants as C;
12
use SimpleSAML\XMLSecurity\XML\ds\Transform;
13
use SimpleSAML\XMLSecurity\XML\ds\Transforms;
14
use SimpleSAML\XMLSecurity\XML\ds\XPath;
15
use SimpleSAML\XMLSecurity\XML\xenc\AbstractReference;
16
use SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement;
17
use SimpleSAML\XMLSecurity\XML\xenc\KeyReference;
18
19
use function dirname;
20
use function strval;
21
22
/**
23
 * Class \SimpleSAML\XMLSecurity\Test\XML\xenc\KeyReferenceTest
24
 *
25
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement
26
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractReference
27
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\KeyReference
28
 *
29
 * @package simplesamlphp/xml-security
30
 */
31
#[CoversClass(AbstractXencElement::class)]
32
#[CoversClass(AbstractReference::class)]
33
#[CoversClass(KeyReference::class)]
34
final class KeyReferenceTest extends TestCase
35
{
36
    use SerializableElementTestTrait;
37
38
    /**
39
     */
40
    public static function setUpBeforeClass(): void
41
    {
42
        self::$testedClass = KeyReference::class;
43
44
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
45
            dirname(__FILE__, 3) . '/resources/xml/xenc_KeyReference.xml',
46
        );
47
    }
48
49
50
    // marshalling
51
52
53
    /**
54
     */
55
    public function testMarshalling(): void
56
    {
57
        $keyReference = new KeyReference(
58
            '#Encrypted_KEY_ID',
59
            [
60
                new Transforms(
61
                    [
62
                        new Transform(
63
                            C::XPATH10_URI,
64
                            new XPath('self::xenc:EncryptedKey[@Id="example1"]'),
65
                        ),
66
                    ],
67
                ),
68
            ],
69
        );
70
71
        $this->assertEquals(
72
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
73
            strval($keyReference),
74
        );
75
    }
76
}
77