Passed
Branch master (c86cc6)
by Tim
11:28
created

X509SubjectNameTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testMarshalling() 0 7 1
A setUpBeforeClass() 0 6 1
A testUnmarshalling() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6
7
use DOMDocument;
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
11
use SimpleSAML\XMLSecurity\XML\ds\X509SubjectName;
12
13
use function dirname;
14
use function strval;
15
16
/**
17
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\X509SubjectNameTest
18
 *
19
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
20
 * @covers \SimpleSAML\XMLSecurity\XML\ds\X509SubjectName
21
 *
22
 * @package simplesamlphp/xml-security
23
 */
24
final class X509SubjectNameTest extends TestCase
25
{
26
    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\X509SubjectNameTest.
Loading history...
27
28
    /**
29
     */
30
    public static function setUpBeforeClass(): void
31
    {
32
        self::$testedClass = X509SubjectName::class;
33
34
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
35
            dirname(__FILE__, 3) . '/resources/xml/ds_X509SubjectName.xml',
36
        );
37
    }
38
39
40
    /**
41
     */
42
    public function testMarshalling(): void
43
    {
44
        $subjectName = new X509SubjectName('some name');
45
46
        $this->assertEquals(
47
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
48
            strval($subjectName),
49
        );
50
    }
51
52
53
    /**
54
     */
55
    public function testUnmarshalling(): void
56
    {
57
        $subjectName = X509SubjectName::fromXML(self::$xmlRepresentation->documentElement);
58
59
        $this->assertEquals(
60
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
61
            strval($subjectName),
62
        );
63
    }
64
}
65