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

KeyNameTest   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 testMarshalling() 0 7 1
A setUpBeforeClass() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XML\DOMDocumentFactory;
9
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
10
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
11
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
12
13
use function dirname;
14
use function strval;
15
16
/**
17
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\KeyNameTest
18
 *
19
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
20
 * @covers \SimpleSAML\XMLSecurity\XML\ds\KeyName
21
 *
22
 * @package simplesamlphp/xml-security
23
 */
24
final class KeyNameTest extends TestCase
25
{
26
    use SchemaValidationTestTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TestUtils\SchemaValidationTestTrait requires some properties which are not provided by SimpleSAML\XMLSecurity\Test\XML\ds\KeyNameTest: $documentElement, $ownerDocument, $message, $line
Loading history...
27
    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\Test\XML\ds\KeyNameTest.
Loading history...
28
29
    /**
30
     */
31
    public static function setUpBeforeClass(): void
32
    {
33
        self::$testedClass = KeyName::class;
34
35
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd';
36
37
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
38
            dirname(__FILE__, 3) . '/resources/xml/ds_KeyName.xml',
39
        );
40
    }
41
42
43
    /**
44
     */
45
    public function testMarshalling(): void
46
    {
47
        $keyName = new KeyName('testkey');
48
49
        $this->assertEquals(
50
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
51
            strval($keyName),
52
        );
53
    }
54
55
56
    /**
57
     */
58
    public function testUnmarshalling(): void
59
    {
60
        $keyName = KeyName::fromXML(self::$xmlRepresentation->documentElement);
61
62
        $this->assertEquals(
63
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
64
            strval($keyName),
65
        );
66
    }
67
}
68