Passed
Branch master (c86cc6)
by Tim
03:54
created

CipherDataTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 47
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 8 1
A testUnmarshalling() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\xenc;
6
7
use DOMDocument;
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\Chunk;
10
use SimpleSAML\XML\DOMDocumentFactory;
11
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
12
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
13
use SimpleSAML\XMLSecurity\XML\xenc\CipherData;
14
use SimpleSAML\XMLSecurity\XML\xenc\CipherValue;
15
use SimpleSAML\XMLSecurity\XMLSecurityDsig;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XMLSecurityDsig was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
use function dirname;
18
use function strval;
19
20
/**
21
 * Class \SimpleSAML\XMLSecurity\Test\XML\xenc\CipherDataTest
22
 *
23
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement
24
 * @covers \SimpleSAML\XMLSecurity\XML\xenc\CipherData
25
 *
26
 * @package simplesamlphp/xml-security
27
 */
28
final class CipherDataTest 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...XML\xenc\CipherDataTest: $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...XML\xenc\CipherDataTest.
Loading history...
32
33
    /**
34
     */
35
    public static function setUpBeforeClass(): void
36
    {
37
        self::$testedClass = CipherData::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_CipherData.xml',
43
        );
44
    }
45
46
47
    // marshalling
48
49
50
    /**
51
     */
52
    public function testMarshalling(): void
53
    {
54
        $cipherData = new CipherData(new CipherValue('c29tZSB0ZXh0'));
55
56
        $this->assertEquals(
57
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
58
            strval($cipherData),
59
        );
60
    }
61
62
63
    // unmarshalling
64
65
66
    /**
67
     */
68
    public function testUnmarshalling(): void
69
    {
70
        $cipherData = CipherData::fromXML(self::$xmlRepresentation->documentElement);
71
72
        $this->assertEquals(
73
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
74
            strval($cipherData),
75
        );
76
    }
77
}
78