Passed
Push — master ( 2f478b...56a532 )
by Tim
02:08
created

SPKIDataTest::testMarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6
7
use PHPUnit\Framework\Attributes\CoversClass;
1 ignored issue
show
Bug introduced by
The type PHPUnit\Framework\Attributes\CoversClass 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...
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
11
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
13
use SimpleSAML\XMLSecurity\XML\ds\AbstractSPKIDataType;
14
use SimpleSAML\XMLSecurity\XML\ds\SPKIData;
15
use SimpleSAML\XMLSecurity\XML\ds\SPKISexp;
16
use SimpleSAML\XMLSecurity\XML\xenc\CarriedKeyName;
17
use SimpleSAML\XMLSecurity\XML\xenc\Seed;
18
19
use function dirname;
20
use function strval;
21
22
/**
23
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\SPKIDataTest
24
 *
25
 * @package simplesamlphp/xml-security
26
 */
27
#[CoversClass(AbstractDsElement::class)]
28
#[CoversClass(AbstractSPKIDataType::class)]
29
#[CoversClass(SPKIData::class)]
30
final class SPKIDataTest extends TestCase
31
{
32
    use SchemaValidationTestTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TestUtils\SchemaValidationTestTrait requires some properties which are not provided by SimpleSAML\XMLSecurity\Test\XML\ds\SPKIDataTest: $documentElement, $ownerDocument, $message, $line
Loading history...
33
    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\Test\XML\ds\SPKIDataTest.
Loading history...
34
35
    /**
36
     */
37
    public static function setUpBeforeClass(): void
38
    {
39
        self::$testedClass = SPKIData::class;
40
41
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd';
42
43
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
44
            dirname(__FILE__, 3) . '/resources/xml/ds_SPKIData.xml',
45
        );
46
    }
47
48
49
    /**
50
     */
51
    public function testMarshalling(): void
52
    {
53
        $SPKISexp1 = new SPKISexp('GpM6');
54
        $seed = new Seed('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
55
        $SPKISexp2 = new SPKISexp('GpM7');
56
        $SPKISexp3 = new SPKISexp('GpM8');
57
        $carriedKeyName = new CarriedKeyName('Some label');
58
59
        $SPKIData = new SPKIData([
60
            [$SPKISexp1, $seed],
61
            [$SPKISexp2, null],
62
            [$SPKISexp3, $carriedKeyName],
63
        ]);
64
65
        $this->assertEquals(
66
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
67
            strval($SPKIData),
68
        );
69
    }
70
}
71