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

RetrievalMethodTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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