Passed
Branch master (c86cc6)
by Tim
01:57
created

X509IssuerNameTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 39
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 6 1
A testMarshalling() 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\Assert\AssertionFailedException;
10
use SimpleSAML\XML\DOMDocumentFactory;
11
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12
use SimpleSAML\XMLSecurity\XML\ds\X509IssuerName;
13
14
use function dirname;
15
use function strval;
16
17
/**
18
 * Class \SimpleSAML\XMLSecurity\XML\ds\X509IssuerNameTest
19
 *
20
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
21
 * @covers \SimpleSAML\XMLSecurity\XML\ds\X509IssuerName
22
 *
23
 * @package simplesamlphp/xml-security
24
 */
25
final class X509IssuerNameTest extends TestCase
26
{
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\T...L\ds\X509IssuerNameTest.
Loading history...
28
29
30
    /**
31
     */
32
    public static function setUpBeforeClass(): void
33
    {
34
        self::$testedClass = X509IssuerName::class;
35
36
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
37
            dirname(__FILE__, 3) . '/resources/xml/ds_X509IssuerName.xml',
38
        );
39
    }
40
41
42
    /**
43
     */
44
    public function testMarshalling(): void
45
    {
46
        $issuerName = new X509IssuerName('some name');
47
48
        $this->assertEquals(
49
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
50
            strval($issuerName),
51
        );
52
    }
53
54
55
    /**
56
     */
57
    public function testUnmarshalling(): void
58
    {
59
        $issuerName = X509IssuerName::fromXML(self::$xmlRepresentation->documentElement);
60
61
        $this->assertEquals(
62
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
63
            strval($issuerName),
64
        );
65
    }
66
}
67