Skip to content

Commit 6f2b9b2

Browse files
committed
Add missing samlp:Terminate
1 parent c19f8bf commit 6f2b9b2

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

src/XML/samlp/Terminate.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML2\XML\samlp;
6+
7+
use DOMElement;
8+
use SimpleSAML\SAML2\Assert\Assert;
9+
use SimpleSAML\XML\SchemaValidatableElementInterface;
10+
use SimpleSAML\XML\SchemaValidatableElementTrait;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
13+
/**
14+
* Class representing a samlp:Terminate element.
15+
*
16+
* @package simplesaml/saml2
17+
*/
18+
final class Terminate extends AbstractSamlpElement implements SchemaValidatableElementInterface
19+
{
20+
use SchemaValidatableElementTrait;
21+
22+
23+
/**
24+
* Convert XML into a Terminate
25+
*
26+
* @param \DOMElement $xml The XML element we should load
27+
* @return static
28+
*
29+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
30+
* if the qualified name of the supplied element is wrong
31+
*/
32+
public static function fromXML(DOMElement $xml): static
33+
{
34+
Assert::same($xml->localName, 'Terminate', InvalidDOMElementException::class);
35+
Assert::same($xml->namespaceURI, Terminate::NS, InvalidDOMElementException::class);
36+
37+
return new static();
38+
}
39+
40+
41+
/**
42+
* Convert this Terminate to XML.
43+
*
44+
* @param \DOMElement|null $parent The element we are converting to XML.
45+
* @return \DOMElement The XML element after adding the data corresponding to this Terminate.
46+
*/
47+
public function toXML(?DOMElement $parent = null): DOMElement
48+
{
49+
return $this->instantiateParentElement($parent);
50+
}
51+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML2\Test\SAML2\XML\samlp;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\TestCase;
10+
use SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement;
11+
use SimpleSAML\SAML2\XML\samlp\Terminate;
12+
use SimpleSAML\XML\DOMDocumentFactory;
13+
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
14+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
15+
16+
use function dirname;
17+
use function strval;
18+
19+
/**
20+
* Class \SimpleSAML\SAML2\XML\samlp\TerminateTest
21+
*
22+
* @package simplesamlphp/saml2
23+
*/
24+
#[Group('samlp')]
25+
#[CoversClass(Terminate::class)]
26+
#[CoversClass(AbstractSamlpElement::class)]
27+
final class TerminateTest extends TestCase
28+
{
29+
use SchemaValidationTestTrait;
30+
use SerializableElementTestTrait;
31+
32+
33+
/**
34+
*/
35+
public static function setUpBeforeClass(): void
36+
{
37+
self::$testedClass = Terminate::class;
38+
39+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
40+
dirname(__FILE__, 4) . '/resources/xml/samlp_Terminate.xml',
41+
);
42+
}
43+
44+
45+
/**
46+
*/
47+
public function testMarshalling(): void
48+
{
49+
$terminate = new Terminate();
50+
51+
$this->assertEquals(
52+
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
53+
strval($terminate),
54+
);
55+
}
56+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<samlp:Terminate xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" />

0 commit comments

Comments
 (0)