Passed
Branch master (c86cc6)
by Tim
01:57
created

RetrievalMethodTest::setUpBeforeClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6
7
use DOMElement;
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\RetrievalMethod;
14
use SimpleSAML\XMLSecurity\XML\ds\Reference;
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
 * @covers \SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod
26
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
27
 *
28
 * @package simplesamlphp/saml2
29
 */
30
final class RetrievalMethodTest extends TestCase
31
{
32
    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...\ds\RetrievalMethodTest: $documentElement, $ownerDocument, $message, $line
Loading history...
33
    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...\ds\RetrievalMethodTest.
Loading history...
34
35
36
    /**
37
     */
38
    public static function setUpBeforeClass(): void
39
    {
40
        self::$testedClass = RetrievalMethod::class;
41
42
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd';
43
44
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
45
            dirname(__FILE__, 3) . '/resources/xml/ds_RetrievalMethod.xml',
46
        );
47
    }
48
49
50
    /**
51
     */
52
    public function testMarshalling(): void
53
    {
54
        $transforms = new Transforms(
55
            [new Transform(C::XPATH_URI, new XPath('self::xenc:CipherValue[@Id="example1"]', ['xenc' => C::NS_XENC]))],
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
67
    /**
68
     */
69
    public function testUnmarshalling(): void
70
    {
71
        $retrievalMethod = retrievalMethod::fromXML(self::$xmlRepresentation->documentElement);
72
73
        $this->assertEquals(
74
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
75
            strval($retrievalMethod),
76
        );
77
    }
78
}
79