Skip to content

Commit 3c3129c

Browse files
committed
Add dsig11:CoFactor-element
1 parent 486e5ec commit 3c3129c

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

src/XML/dsig11/CoFactor.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\XML\dsig11;
6+
7+
use SimpleSAML\XML\IntegerElementTrait;
8+
9+
/**
10+
* Class representing a dsig11:CoFactor element.
11+
*
12+
* @package simplesaml/xml-security
13+
*/
14+
final class CoFactor extends AbstractDsig11Element
15+
{
16+
use IntegerElementTrait;
17+
18+
19+
/**
20+
* Initialize a CoFactor element.
21+
*
22+
* @param string $value
23+
*/
24+
public function __construct(
25+
string $value,
26+
) {
27+
$this->setContent($value);
28+
}
29+
}

tests/XML/dsig11/CoFactorTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\Test\XML\dsig11;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\XML\DOMDocumentFactory;
10+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
11+
use SimpleSAML\XMLSecurity\XML\dsig11\AbstractDsig11Element;
12+
use SimpleSAML\XMLSecurity\XML\dsig11\CoFactor;
13+
14+
use function dirname;
15+
use function strval;
16+
17+
/**
18+
* Class \SimpleSAML\XMLSecurity\Test\XML\dsig11\CoFactorTest
19+
*
20+
* @package simplesamlphp/xml-security
21+
*/
22+
#[CoversClass(AbstractDsig11Element::class)]
23+
#[CoversClass(CoFactor::class)]
24+
final class CoFactorTest extends TestCase
25+
{
26+
use SerializableElementTestTrait;
27+
28+
29+
/**
30+
*/
31+
public static function setUpBeforeClass(): void
32+
{
33+
self::$testedClass = CoFactor::class;
34+
35+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
36+
dirname(__FILE__, 3) . '/resources/xml/dsig11_CoFactor.xml',
37+
);
38+
}
39+
40+
41+
/**
42+
*/
43+
public function testMarshalling(): void
44+
{
45+
$coFactor = new CoFactor('128');
46+
47+
$this->assertEquals(
48+
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
49+
strval($coFactor),
50+
);
51+
}
52+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<dsig11:CoFactor xmlns:dsig11="http://www.w3.org/2009/xmldsig11#">128</dsig11:CoFactor>

0 commit comments

Comments
 (0)