Passed
Branch master (c86cc6)
by Tim
04:58 queued 52s
created

InclusiveNamespacesTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpBeforeClass() 0 8 1
A testMarshalling() 0 11 1
A testUnmarshalling() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ec;
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\ec\InclusiveNamespaces;
12
13
use function dirname;
14
use function strval;
15
16
/**
17
 * Class \SimpleSAML\XMLSecurity\Test\XML\ec\InclusiveNamespacesTest
18
 *
19
 * @covers \SimpleSAML\XMLSecurity\XML\ec\InclusiveNamespaces
20
 * @covers \SimpleSAML\XMLSecurity\XML\ec\AbstractEcElement
21
 *
22
 * @package simplesamlphp/xml-security
23
 */
24
class InclusiveNamespacesTest 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\T...InclusiveNamespacesTest: $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\T...InclusiveNamespacesTest.
Loading history...
28
29
    /**
30
     */
31
    public static function setUpBeforeClass(): void
32
    {
33
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/exc-c14n.xsd';
34
35
        self::$testedClass = InclusiveNamespaces::class;
36
37
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
38
            dirname(__FILE__, 3) . '/resources/xml/ec_InclusiveNamespaces.xml',
39
        );
40
    }
41
42
43
    public function testMarshalling(): void
44
    {
45
        $inclusiveNamespaces = new InclusiveNamespaces(["dsig", "soap"]);
46
47
        $this->assertCount(2, $inclusiveNamespaces->getPrefixes());
48
        $this->assertEquals("dsig", $inclusiveNamespaces->getPrefixes()[0]);
49
        $this->assertEquals("soap", $inclusiveNamespaces->getPrefixes()[1]);
50
51
        $this->assertEquals(
52
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
53
            strval($inclusiveNamespaces),
54
        );
55
    }
56
57
58
    /**
59
     */
60
    public function testUnmarshalling(): void
61
    {
62
        $inclusiveNamespaces = InclusiveNamespaces::fromXML(
63
            self::$xmlRepresentation->documentElement,
64
        );
65
66
        $this->assertEquals(
67
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
68
            strval($inclusiveNamespaces),
69
        );
70
    }
71
}
72