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

ExponentTest::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\DOMDocumentFactory;
9
use SimpleSAML\XML\Exception\SchemaViolationException;
10
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
11
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper;
12
use SimpleSAML\XMLSecurity\XML\ds\Exponent;
13
14
use function dirname;
15
use function strval;
16
17
/**
18
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\ExponentTest
19
 *
20
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
21
 * @covers \SimpleSAML\XMLSecurity\XML\ds\Exponent
22
 *
23
 * @package simplesamlphp/xml-security
24
 */
25
final class ExponentTest extends TestCase
26
{
27
    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\ExponentTest.
Loading history...
28
29
    /**
30
     */
31
    public static function setUpBeforeClass(): void
32
    {
33
        self::$testedClass = Exponent::class;
34
35
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
36
            dirname(__FILE__, 3) . '/resources/xml/ds_Exponent.xml',
37
        );
38
    }
39
40
41
    /**
42
     */
43
    public function testMarshalling(): void
44
    {
45
        $exponent = new Exponent('dGhpcyBpcyBzb21lIHJhbmRvbSBleHBvbmVudAo=');
46
47
        $this->assertEquals(
48
            XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation),
49
            strval($exponent),
50
        );
51
    }
52
53
54
    /**
55
     */
56
    public function testMarshallingNotBase64(): void
57
    {
58
        $this->expectException(SchemaViolationException::class);
59
        new Exponent('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
60
    }
61
}
62