Passed
Push — master ( 5a07d0...30f015 )
by Tim
23:49 queued 11:01
created

KeyReferenceTest::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\xenc;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XML\DOMDocumentFactory;
9
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
10
use SimpleSAML\XMLSecurity\Constants as C;
11
use SimpleSAML\XMLSecurity\XML\ds\Transform;
12
use SimpleSAML\XMLSecurity\XML\ds\Transforms;
13
use SimpleSAML\XMLSecurity\XML\ds\XPath;
14
use SimpleSAML\XMLSecurity\XML\xenc\KeyReference;
15
16
use function dirname;
17
use function strval;
18
19
/**
20
 * Class \SimpleSAML\XMLSecurity\Test\XML\xenc\KeyReferenceTest
21
 *
22
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement
23
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractReference
24
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\KeyReference
25
 *
26
 * @package simplesamlphp/xml-security
27
 */
28
final class KeyReferenceTest extends TestCase
29
{
30
    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...L\xenc\KeyReferenceTest.
Loading history...
31
32
    /**
33
     */
34
    public static function setUpBeforeClass(): void
35
    {
36
        self::$testedClass = KeyReference::class;
37
38
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
39
            dirname(__FILE__, 3) . '/resources/xml/xenc_KeyReference.xml',
40
        );
41
    }
42
43
44
    // marshalling
45
46
47
    /**
48
     */
49
    public function testMarshalling(): void
50
    {
51
        $keyReference = new KeyReference(
52
            '#Encrypted_KEY_ID',
53
            [
54
                new Transforms(
55
                    [
56
                        new Transform(
57
                            C::XPATH_URI,
58
                            new XPath('self::xenc:EncryptedKey[@Id="example1"]'),
59
                        ),
60
                    ],
61
                ),
62
            ],
63
        );
64
65
        $this->assertEquals(
66
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
67
            strval($keyReference),
68
        );
69
    }
70
}
71