Skip to content

Commit 3843a0c

Browse files
committed
Raise coverage
1 parent 0a526a6 commit 3843a0c

8 files changed

Lines changed: 100 additions & 38 deletions

File tree

src/XML/sp_200507/Type/IncludeTokenValue.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ public function toAttribute(): XMLAttribute
4444
}
4545

4646

47+
/**
48+
* @return \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\IncludeToken $value
49+
*/
50+
public function toEnum(): IncludeToken
51+
{
52+
return IncludeToken::from($this->getValue());
53+
}
54+
55+
4756
/**
4857
* @param \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\IncludeToken $value
4958
* @return static
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\WebServices\SecurityPolicy\XML\sp_200507\Type;
6+
7+
use DOMNodeList;
8+
use DOMXPath;
9+
use SimpleSAML\Assert\Assert;
10+
use SimpleSAML\XML\DOMDocumentFactory;
11+
use SimpleSAML\XMLSchema\Type\StringValue;
12+
13+
/**
14+
* @package simplesaml/xml-ws-security-policy
15+
*/
16+
class XPathValue extends StringValue
17+
{
18+
/**
19+
* Validate the content of the element.
20+
*
21+
* @throws \SimpleSAML\Assert\AssertionFailedException on failure
22+
*/
23+
protected function validateValue(string $content): void
24+
{
25+
$dom = new DOMXPath(DOMDocumentFactory::create());
26+
$result = $dom->evaluate($content);
27+
Assert::isInstanceOf($result, DOMNodeList::class);
28+
}
29+
}

src/XML/sp_200507/XPath.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
66

7-
use DOMNodeList;
8-
use DOMXPath;
9-
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
10-
use SimpleSAML\XML\DOMDocumentFactory;
7+
use SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\Type\XPathValue;
118
use SimpleSAML\XML\TypedTextContentTrait;
12-
use SimpleSAML\XMLSchema\Type\StringValue;
139

1410
/**
1511
* An XPath element
@@ -21,18 +17,5 @@ final class XPath extends AbstractSpElement
2117
use TypedTextContentTrait;
2218

2319

24-
public const string TEXTCONTENT_TYPE = StringValue::class;
25-
26-
27-
/**
28-
* Validate the content of the element.
29-
*
30-
* @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
31-
*/
32-
protected function validateContent(string $content): void
33-
{
34-
$dom = new DOMXPath(DOMDocumentFactory::create());
35-
$result = $dom->evaluate($content);
36-
Assert::isInstanceOf($result, DOMNodeList::class);
37-
}
20+
public const string TEXTCONTENT_TYPE = XPathValue::class;
3821
}

src/XML/sp_200702/Type/IncludeTokenValue.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function toAttribute(): XMLAttribute
4242
}
4343

4444

45+
/**
46+
* @return \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\IncludeToken $value
47+
*/
48+
public function toEnum(): IncludeToken
49+
{
50+
return IncludeToken::from($this->getValue());
51+
}
52+
53+
4554
/**
4655
* @param \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\IncludeToken $value
4756
* @return static
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\WebServices\SecurityPolicy\XML\sp_200702\Type;
6+
7+
use DOMNodeList;
8+
use DOMXPath;
9+
use SimpleSAML\Assert\Assert;
10+
use SimpleSAML\XML\DOMDocumentFactory;
11+
use SimpleSAML\XMLSchema\Type\StringValue;
12+
13+
/**
14+
* @package simplesaml/xml-ws-security-policy
15+
*/
16+
class XPathValue extends StringValue
17+
{
18+
/**
19+
* Validate the content of the element.
20+
*
21+
* @throws \SimpleSAML\Assert\AssertionFailedException on failure
22+
*/
23+
protected function validateValue(string $content): void
24+
{
25+
$dom = new DOMXPath(DOMDocumentFactory::create());
26+
$result = $dom->evaluate($content);
27+
Assert::isInstanceOf($result, DOMNodeList::class);
28+
}
29+
}

src/XML/sp_200702/XPath.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
66

7-
use DOMNodeList;
8-
use DOMXPath;
9-
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
10-
use SimpleSAML\XML\DOMDocumentFactory;
7+
use SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\Type\XPathValue;
118
use SimpleSAML\XML\TypedTextContentTrait;
12-
use SimpleSAML\XMLSchema\Type\StringValue;
139

1410
/**
1511
* An XPath element
@@ -21,18 +17,5 @@ final class XPath extends AbstractSpElement
2117
use TypedTextContentTrait;
2218

2319

24-
public const string TEXTCONTENT_TYPE = StringValue::class;
25-
26-
27-
/**
28-
* Validate the content of the element.
29-
*
30-
* @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
31-
*/
32-
protected function validateContent(string $content): void
33-
{
34-
$dom = new DOMXPath(DOMDocumentFactory::create());
35-
$result = $dom->evaluate($content);
36-
Assert::isInstanceOf($result, DOMNodeList::class);
37-
}
20+
public const string TEXTCONTENT_TYPE = XPathValue::class;
3821
}

tests/SecurityPolicy/XML/sp_200507/Type/IncludeTokenValueTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public function testToAttribute(): void
5757
}
5858

5959

60+
public function testFromEnum(): void
61+
{
62+
$x = IncludeTokenValue::fromEnum(IncludeToken::Always);
63+
$this->assertEquals(IncludeToken::Always, $x->toEnum());
64+
65+
$y = IncludeTokenValue::fromString(IncludeToken::Always->value);
66+
$this->assertEquals(IncludeToken::Always, $y->toEnum());
67+
}
68+
69+
6070
/**
6171
=======
6272
>>>>>>> cca25c1 (Fix namespaced IncludeToken-attribute (both sp-versions and coverage))

tests/SecurityPolicy/XML/sp_200702/Type/IncludeTokenValueTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public function testToAttribute(): void
5757
}
5858

5959

60+
public function testFromEnum(): void
61+
{
62+
$x = IncludeTokenValue::fromEnum(IncludeToken::Always);
63+
$this->assertEquals(IncludeToken::Always, $x->toEnum());
64+
65+
$y = IncludeTokenValue::fromString(IncludeToken::Always->value);
66+
$this->assertEquals(IncludeToken::Always, $y->toEnum());
67+
}
68+
69+
6070
/**
6171
=======
6272
>>>>>>> cca25c1 (Fix namespaced IncludeToken-attribute (both sp-versions and coverage))

0 commit comments

Comments
 (0)