-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSpaceValueTest.php
More file actions
73 lines (62 loc) · 1.92 KB
/
Copy pathSpaceValueTest.php
File metadata and controls
73 lines (62 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
namespace SimpleSAML\Test\XML\Type;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Type\SpaceValue;
use SimpleSAML\XML\XML\Enumeration\SpaceEnum;
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
/**
* Class \SimpleSAML\Test\XML\Type\SpaceValueTest
*
* @package simplesamlphp/xml-common
*/
#[CoversClass(SpaceValue::class)]
final class SpaceValueTest extends TestCase
{
/**
* @param string $space
* @param bool $shouldPass
*/
#[DataProvider('provideSpace')]
public function testSpaceValue(string $space, bool $shouldPass): void
{
try {
SpaceValue::fromString($space);
$this->assertTrue($shouldPass);
} catch (SchemaViolationException $e) {
$this->assertFalse($shouldPass);
}
}
/**
* Test helpers
*/
public function testHelpers(): void
{
$lang = SpaceValue::fromString('default');
$attr = $lang->toAttribute();
$this->assertEquals($attr->getNamespaceURI(), C::NS_XML);
$this->assertEquals($attr->getNamespacePrefix(), 'xml');
$this->assertEquals($attr->getAttrName(), 'space');
$this->assertEquals($attr->getAttrValue(), 'default');
//
$x = SpaceValue::fromEnum(SpaceEnum::Default);
$this->assertEquals(SpaceEnum::Default, $x->toEnum());
$y = SpaceValue::fromString('default');
$this->assertEquals(SpaceEnum::Default, $y->toEnum());
}
/**
* @return array<string, array{0: string, 1: bool}>
*/
public static function provideSpace(): array
{
return [
'default' => ['default', true],
'preserve' => ['preserve', true],
'undefined' => ['undefined', false],
'empty' => ['', false],
];
}
}