Passed
Push — master ( d0dfd7...5d1985 )
by Tim
12:54
created

EncryptionPropertyTest::setUpBeforeClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\xenc;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XML\Attribute as XMLAttribute;
9
use SimpleSAML\XML\Chunk;
10
use SimpleSAML\XML\Constants as C;
11
use SimpleSAML\XML\DOMDocumentFactory;
12
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
13
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
14
use SimpleSAML\XMLSecurity\XML\xenc\EncryptionProperty;
15
16
use function dirname;
17
use function strval;
18
19
/**
20
 * Class \SimpleSAML\XMLSecurity\Test\XML\xenc\EncryptionPropertyTest
21
 *
22
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement
23
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractEncryptionPropertyType
24
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\EncryptionProperty
25
 *
26
 * @package simplesamlphp/xml-security
27
 */
28
final class EncryptionPropertyTest extends TestCase
29
{
30
    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...\EncryptionPropertyTest: $documentElement, $ownerDocument, $message, $line
Loading history...
31
    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...\EncryptionPropertyTest.
Loading history...
32
33
    /**
34
     */
35
    public static function setUpBeforeClass(): void
36
    {
37
        self::$testedClass = EncryptionProperty::class;
38
39
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xenc-schema.xsd';
40
41
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
42
            dirname(__FILE__, 3) . '/resources/xml/xenc_EncryptionProperty.xml',
43
        );
44
    }
45
46
47
    // marshalling
48
49
50
    /**
51
     */
52
    public function testMarshalling(): void
53
    {
54
        $doc = DOMDocumentFactory::fromString(
55
            '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>',
56
        );
57
        /** @var \DOMElement $elt */
58
        $elt = $doc->documentElement;
59
60
        $attr = new XMLAttribute(C::NS_XML, 'xml', 'lang', 'en');
61
        $encryptionProperty = new EncryptionProperty(
62
            [new Chunk($elt)],
63
            'urn:x-simplesamlphp:phpunit',
64
            'phpunit',
65
            [$attr],
66
        );
67
68
        $this->assertEquals(
69
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
70
            strval($encryptionProperty),
71
        );
72
    }
73
}
74