Passed
Push — master ( be09b3...67068d )
by Tim
13:28
created

InclusiveNamespacesTest::testUnmarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
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