Passed
Branch master (c86cc6)
by Tim
03:54
created

KeyInfoReferenceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testUnmarshalling() 0 7 1
A setUpBeforeClass() 0 8 1
A testMarshalling() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\dsig11;
6
7
use DOMDocument;
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\dsig11\KeyInfoReference;
14
15
use function dirname;
16
use function strval;
17
18
/**
19
 * Class \SimpleSAML\XMLSecurity\Test\XML\dsig11\KeyInfoReferenceTest
20
 *
21
 * @covers \SimpleSAML\XMLSecurity\XML\dsig11\AbstractDsig11Element
22
 * @covers \SimpleSAML\XMLSecurity\XML\dsig11\KeyInfoReference
23
 *
24
 * @package simplesamlphp/xml-security
25
 */
26
final class KeyInfoReferenceTest extends TestCase
27
{
28
    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...11\KeyInfoReferenceTest: $documentElement, $ownerDocument, $message, $line
Loading history...
29
    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...11\KeyInfoReferenceTest.
Loading history...
30
31
    /**
32
     */
33
    public static function setUpBeforeClass(): void
34
    {
35
        self::$testedClass = KeyInfoReference::class;
36
37
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig11-schema.xsd';
38
39
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
40
            dirname(__FILE__, 3) . '/resources/xml/dsig11_KeyInfoReference.xml',
41
        );
42
    }
43
44
45
    /**
46
     */
47
    public function testMarshalling(): void
48
    {
49
        $KeyInfoReference = new KeyInfoReference('#_e395489e5f8444f1aabb4b2ca98a23b793d211ddf0', 'abc123');
50
51
        $this->assertEquals(
52
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
53
            strval($KeyInfoReference),
54
        );
55
    }
56
57
58
    /**
59
     */
60
    public function testUnmarshalling(): void
61
    {
62
        $KeyInfoReference = KeyInfoReference::fromXML(self::$xmlRepresentation->documentElement);
63
64
        $this->assertEquals(
65
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
66
            strval($KeyInfoReference),
67
        );
68
    }
69
}
70