Skip to content

Commit

Permalink
Add xenc11:Specified element
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 5, 2024
1 parent 7f4947b commit c1aeb1a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/XML/xenc11/Specified.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\XML\xenc11;

use SimpleSAML\XML\Base64ElementTrait;

/**
* Class representing a xenc11:Specified element.
*
* @package simplesamlphp/xml-security
*/
final class Specified extends AbstractXenc11Element
{
use Base64ElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
51 changes: 51 additions & 0 deletions tests/XML/xenc11/SpecifiedTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\Test\XML\xenc11;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractXenc11Element;
use SimpleSAML\XMLSecurity\XML\xenc11\Specified;

use function dirname;
use function strval;

/**
* Class \SimpleSAML\XMLSecurity\XML\Test\xenc11\SpecifiedTest
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(AbstractXenc11Element::class)]
#[CoversClass(Specified::class)]
final class SpecifiedTest extends TestCase
{
use SerializableElementTestTrait;

/**
*/
public static function setUpBeforeClass(): void
{
self::$testedClass = Specified::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 3) . '/resources/xml/xenc11_Specified.xml',
);
}


/**
*/
public function testMarshalling(): void
{
$specified = new Specified('GpM6');

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($specified),
);
}
}
1 change: 1 addition & 0 deletions tests/resources/xml/xenc11_Specified.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<xenc11:Specified xmlns:xenc11="http://www.w3.org/2009/xmlenc11#">GpM6</xenc11:Specified>

0 comments on commit c1aeb1a

Please sign in to comment.