Passed
Pull Request — master (#60)
by Tim
02:12
created

KeyDerivationMethodTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
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\xenc11;
6
7
use PHPUnit\Framework\Attributes\{CoversClass, Group};
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\{SchemaValidationTestTrait, SerializableElementTestTrait};
11
use SimpleSAML\XML\Type\{AnyURIValue, StringValue};
12
use SimpleSAML\XMLSecurity\Constants as C;
13
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
14
use SimpleSAML\XMLSecurity\XML\xenc11\{AbstractKeyDerivationMethodType, AbstractXenc11Element, KeyDerivationMethod};
15
16
use function dirname;
17
use function strval;
18
19
/**
20
 * Tests for the xenc:KeyDerivationMethod element.
21
 *
22
 * @covers \SimpleSAML\XMLSecurity\XML\xenc11\AbstractXenc11Element
23
 * @covers \SimpleSAML\XMLSecurity\XML\xenc11\AbstractKeyDerivationMethodType
24
 * @covers \SimpleSAML\XMLSecurity\XML\xenc11\KeyDerivationMethod
25
 * @package simplesamlphp/xml-security
26
 */
27
#[Group('xenc11')]
28
#[CoversClass(AbstractXenc11Element::class)]
29
#[CoversClass(AbstractKeyDerivationMethodType::class)]
30
#[CoversClass(KeyDerivationMethod::class)]
31
final class KeyDerivationMethodTest extends TestCase
32
{
33
    use SchemaValidationTestTrait;
34
    use SerializableElementTestTrait;
35
36
    /**
37
     */
38
    public static function setUpBeforeClass(): void
39
    {
40
        self::$testedClass = KeyDerivationMethod::class;
41
42
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
43
            dirname(__FILE__, 3) . '/resources/xml/xenc11_KeyDerivationMethod.xml',
44
        );
45
    }
46
47
48
    // test marshalling
49
50
51
    /**
52
     * Test creating an KeyDerivationMethod object from scratch.
53
     */
54
    public function testMarshalling(): void
55
    {
56
        $kdm = new KeyDerivationMethod(
57
            AnyURIValue::fromString(C::KEY_DERIVATION_CONCATKDF),
58
            [
59
                new KeyName(StringValue::fromString('testkey')),
60
            ],
61
        );
62
63
        $this->assertEquals(
64
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
65
            strval($kdm),
66
        );
67
    }
68
}
69