Passed
Push — master ( be09b3...67068d )
by Tim
13:28
created

DigestMethodTest::testUnmarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
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 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XML\Chunk;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
11
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12
use SimpleSAML\XMLSecurity\Constants as C;
13
use SimpleSAML\XMLSecurity\XML\ds\DigestMethod;
14
15
use function dirname;
16
use function strval;
17
18
/**
19
 * Class \SimpleSAML\XMLSecurity\XML\Test\ds\DigestMethodTest
20
 *
21
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
22
 * @covers \SimpleSAML\XMLSecurity\XML\ds\DigestMethod
23
 *
24
 * @package simplesamlphp/xml-security
25
 */
26
final class DigestMethodTest extends TestCase
27
{
28
    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\ds\DigestMethodTest: $documentElement, $ownerDocument, $message, $line
Loading history...
29
    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\ds\DigestMethodTest.
Loading history...
30
31
    /**
32
     */
33
    public static function setUpBeforeClass(): void
34
    {
35
        self::$testedClass = DigestMethod::class;
36
37
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd';
38
39
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
40
            dirname(__FILE__, 3) . '/resources/xml/ds_DigestMethod.xml',
41
        );
42
    }
43
44
45
    /**
46
     */
47
    public function testMarshalling(): void
48
    {
49
        $digestMethod = new DigestMethod(
50
            C::DIGEST_SHA256,
51
            [
52
                new Chunk(DOMDocumentFactory::fromString(
53
                    '<some:Chunk xmlns:some="urn:test:some">Random</some:Chunk>'
54
                )->documentElement)
55
            ],
56
        );
57
58
        $this->assertEquals(
59
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
60
            strval($digestMethod),
61
        );
62
    }
63
}
64