Passed
Pull Request — master (#61)
by
unknown
12:50
created

SPKIDataTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 41
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\XML\ds\AbstractDsElement;
13
use SimpleSAML\XMLSecurity\XML\ds\AbstractSPKIDataType;
14
use SimpleSAML\XMLSecurity\XML\ds\SPKIData;
15
use SimpleSAML\XMLSecurity\XML\ds\SPKISexp;
16
use SimpleSAML\XMLSecurity\XML\xenc\CarriedKeyName;
17
use SimpleSAML\XMLSecurity\XML\xenc\Seed;
18
19
use function dirname;
20
use function strval;
21
22
/**
23
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\SPKIDataTest
24
 *
25
 * @package simplesamlphp/xml-security
26
 */
27
#[CoversClass(AbstractDsElement::class)]
28
#[CoversClass(AbstractSPKIDataType::class)]
29
#[CoversClass(SPKIData::class)]
30
final class SPKIDataTest extends TestCase
31
{
32
    use SchemaValidationTestTrait;
33
    use SerializableElementTestTrait;
34
35
    /**
36
     */
37
    public static function setUpBeforeClass(): void
38
    {
39
        self::$testedClass = SPKIData::class;
40
41
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
42
            dirname(__FILE__, 3) . '/resources/xml/ds_SPKIData.xml',
43
        );
44
    }
45
46
47
    /**
48
     */
49
    public function testMarshalling(): void
50
    {
51
        $SPKISexp1 = new SPKISexp('GpM6');
52
        $seed = new Seed('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
53
        $SPKISexp2 = new SPKISexp('GpM7');
54
        $SPKISexp3 = new SPKISexp('GpM8');
55
        $carriedKeyName = new CarriedKeyName('Some label');
56
        $SPKISexp4 = new SPKISexp('GpM9');
57
58
        $SPKIData = new SPKIData([
59
            [$SPKISexp1, $seed],
60
            [$SPKISexp2, null],
61
            [$SPKISexp3, $carriedKeyName],
62
            [$SPKISexp4, null],
63
        ]);
64
65
        $this->assertEquals(
66
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
67
            strval($SPKIData),
68
        );
69
    }
70
}
71