Skip to content

Commit bed3740

Browse files
committed
Raise coverage
1 parent 0aaddc1 commit bed3740

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

tests/Utils/URIElement.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66

77
use SimpleSAML\XML\AbstractElement;
88
use SimpleSAML\XML\URIElementTrait;
9+
use SimpleSAML\XML\SchemaValidatableElementInterface;
10+
use SimpleSAML\XML\SchemaValidatableElementTrait;
911

1012
/**
1113
* Empty shell class for testing URIElement.
1214
*
1315
* @package simplesaml/xml-common
1416
*/
15-
final class URIElement extends AbstractElement
17+
final class URIElement extends AbstractElement implements SchemaValidatableElementInterface
1618
{
19+
use SchemaValidatableElementTrait;
1720
use URIElementTrait;
1821

1922
/** @var string */
@@ -22,6 +25,9 @@ final class URIElement extends AbstractElement
2225
/** @var string */
2326
public const NS_PREFIX = 'ssp';
2427

28+
/** @var string */
29+
public const SCHEMA = 'tests/resources/schemas/simplesamlphp.xsd';
30+
2531

2632
/**
2733
* @param string $content

tests/XML/SchemaValidatableElementTraitTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public function testSchemaValidationPasses(): void
3232
}
3333

3434

35+
public function testSchemaValidationFails(): void
36+
{
37+
$file = 'tests/resources/xml/invalid_ExtendableElement.xml';
38+
$chunk = DOMDocumentFactory::fromFile($file);
39+
40+
$this->expectException(SchemaViolationException::class);
41+
$document = StringElement::schemaValidate($chunk);
42+
}
43+
44+
3545
public function testSchemaValidationWrongElementFails(): void
3646
{
3747
$file = 'tests/resources/xml/ssp_Base64Element.xml';

tests/resources/schemas/simplesamlphp.xsd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747

4848
<!-- End StringElement -->
4949

50+
<!-- Start URIElement -->
51+
52+
<element name="URIElement" type="anyURI"/>
53+
54+
<!-- End URIElement -->
55+
5056
<!-- Start ExtendableAttributesElement -->
5157

5258
<element name="ExtendableAttributesElement" type="ssp:ExtendableAttributesElementType"/>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<ssp:ExtendableElement xmlns:ssp="urn:x-simplesamlphp:namespace">
2+
<dummy:Chunk xmlns:dummy="urn:custom:dummy">some</dummy:Chunk>
3+
</ssp:ExtendableElement>

0 commit comments

Comments
 (0)