Passed
Pull Request — master (#60)
by Tim
02:12
created

SaltTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Test\SAML2\XML\xenc11;
6
7
use PHPUnit\Framework\Attributes\{CoversClass, Group};
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\Attribute as XMLAttribute;
10
use SimpleSAML\XML\{Chunk, DOMDocumentFactory};
11
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12
use SimpleSAML\XML\Type\{AnyURIValue, StringValue};
13
use SimpleSAML\XMLSecurity\XML\xenc11\{AbstractXenc11Element, OtherSource, Parameters, Salt};
14
15
use function dirname;
16
use function strval;
17
18
/**
19
 * Class \SimpleSAML\XMLSecurity\XML\xenc11\SaltTest
20
 *
21
 * @package simplesamlphp/xml-security
22
 */
23
#[Group('xenc11')]
24
#[CoversClass(Salt::class)]
25
#[CoversClass(AbstractXenc11Element::class)]
26
final class SaltTest extends TestCase
27
{
28
    use SerializableElementTestTrait;
29
30
    /**
31
     */
32
    public static function setUpBeforeClass(): void
33
    {
34
        self::$testedClass = Salt::class;
35
36
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
37
            dirname(__FILE__, 3) . '/resources/xml/xenc11_Salt.xml',
38
        );
39
    }
40
41
42
    // marshalling
43
44
45
    /**
46
     */
47
    public function testMarshalling(): void
48
    {
49
        $someDoc = DOMDocumentFactory::fromString(
50
            '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>',
51
        );
52
53
        $parameters = new Parameters(
54
            [new Chunk($someDoc->documentElement)],
55
            [new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'))],
56
        );
57
58
        $otherSource = new OtherSource(
59
            AnyURIValue::fromString('urn:x-simplesamlphp:algorithm'),
60
            $parameters,
61
        );
62
        $salt = new Salt($otherSource);
63
64
        $this->assertEquals(
65
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
66
            strval($salt),
67
        );
68
    }
69
}
70