Passed
Push — master ( 2d3781...f48916 )
by Tim
11:07 queued 06:44
created

ParametersTest::setUpBeforeClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Test\SAML2\XML\xenc11;
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\Attribute as XMLAttribute;
10
use SimpleSAML\XML\Chunk;
11
use SimpleSAML\XML\DOMDocumentFactory;
12
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
13
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractXenc11Element;
14
use SimpleSAML\XMLSecurity\XML\xenc11\Parameters;
15
16
use function dirname;
17
use function strval;
18
19
/**
20
 * Class \SimpleSAML\XMLSecurity\XML\xenc11\ParametersTest
21
 *
22
 * @package simplesamlphp/xml-security
23
 */
24
#[CoversClass(Parameters::class)]
25
#[CoversClass(AbstractXenc11Element::class)]
26
final class ParametersTest extends TestCase
27
{
28
    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\Test\SAML2\XML\xenc11\ParametersTest.
Loading history...
29
30
    /**
31
     */
32
    public static function setUpBeforeClass(): void
33
    {
34
        self::$testedClass = Parameters::class;
35
36
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
37
            dirname(__FILE__, 3) . '/resources/xml/xenc11_Parameters.xml',
38
        );
39
    }
40
41
42
    // marshalling
43
44
45
    /**
46
     */
47
    public function testMarshalling(): void
48
    {
49
        $chunk = new Chunk(DOMDocumentFactory::fromString(
50
            <<<XML
51
  <ssp:AuthenticationContextDeclaration xmlns:ssp="urn:x-simplesamlphp:namespace">
52
    <ssp:Identification nym="verinymity">
53
      <ssp:Extension>
54
        <ssp:NoVerification/>
55
      </ssp:Extension>
56
    </ssp:Identification>
57
  </ssp:AuthenticationContextDeclaration>
58
XML
59
            ,
60
        )->documentElement);
61
62
        $parameters = new Parameters(
63
            [$chunk],
64
            [new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1')],
65
        );
66
67
        $this->assertEquals(
68
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
69
            strval($parameters),
70
        );
71
    }
72
73
74
    /**
75
     * Adding an empty Parameters element should yield an empty element.
76
     */
77
    public function testMarshallingEmptyElement(): void
78
    {
79
        $xenc11_ns = Parameters::NS;
80
        $parameters = new Parameters();
81
        $this->assertEquals(
82
            "<xenc11:Parameters xmlns:xenc11=\"$xenc11_ns\"/>",
83
            strval($parameters),
84
        );
85
        $this->assertTrue($parameters->isEmptyElement());
86
    }
87
}
88