Skip to content

Commit d27787c

Browse files
committed
Add xs:public type
1 parent ac87aa1 commit d27787c

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/Type/PublicValue.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XSD\Type;
6+
7+
use SimpleSAML\XML\Type\TokenValue;
8+
9+
/**
10+
* @package simplesaml/xml-xsd
11+
*/
12+
class PublicValue extends TokenValue
13+
{
14+
/** @var string */
15+
public const SCHEMA_TYPE = 'public';
16+
}

tests/Type/PublicValueTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\Test\XSD\Type;
6+
7+
use PHPUnit\Framework\Attributes\{CoversClass, DataProvider};
8+
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\XSD\Type\PublicValue;
10+
11+
/**
12+
* Class \SimpleSAML\Test\XSD\Type\PublicValueTest
13+
*
14+
* @package simplesamlphp/xml-common
15+
*/
16+
#[CoversClass(PublicValue::class)]
17+
final class PublicValueTest extends TestCase
18+
{
19+
/**
20+
* @param string $public
21+
* @param string $normalizedToken
22+
*/
23+
#[DataProvider('providePublic')]
24+
public function testPublic(string $public, string $normalizedPublic): void
25+
{
26+
$value = PublicValue::fromString($public);
27+
$this->assertEquals($normalizedPublic, $value->getValue());
28+
$this->assertEquals($public, $value->getRawValue());
29+
}
30+
31+
32+
/**
33+
* @return array<string, array{0: string, 1: string}>
34+
*/
35+
public static function providePublic(): array
36+
{
37+
return [
38+
'empty string' => ['', ''],
39+
'trim' => [' Snoopy ', 'Snoopy'],
40+
'replace whitespace' => ["Snoopy\trulez", 'Snoopy rulez'],
41+
'collapse' => ["Snoopy\t\n\rrulez", 'Snoopy rulez'],
42+
];
43+
}
44+
}

0 commit comments

Comments
 (0)