-
Notifications
You must be signed in to change notification settings - Fork 8
/
DirectiveTest.php
46 lines (39 loc) · 1.47 KB
/
DirectiveTest.php
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
<?php
namespace Mazedlx\FeaturePolicy\Tests;
use PHPUnit\Framework\Attributes\Test;
use Mazedlx\FeaturePolicy\Directive;
use Mazedlx\FeaturePolicy\Exceptions\UnsupportedPermissionException;
use Mazedlx\FeaturePolicy\Value;
final class DirectiveTest extends TestCase
{
#[Test]
public function it_can_make_an_directive_from_name(): void
{
$directive = Directive::make(Directive::GEOLOCATION);
$this->assertSame(Directive::GEOLOCATION, $directive->name());
$this->assertIsArray($directive->rules());
$this->assertEmpty($directive->rules());
}
#[Test]
public function it_will_throw_an_invalid_directive_exception_for_unknown_directive(): void
{
$this->expectException(UnsupportedPermissionException::class);
Directive::make('invalid-directive');
}
#[Test]
public function it_can_add_an_rule(): void
{
$directive = Directive::make(Directive::GEOLOCATION);
$this->assertEmpty($directive->rules());
$directive->addRule(Value::SELF);
$this->assertNotEmpty($directive->rules());
$this->assertCount(1, $directive->rules());
$this->assertSame(Value::SELF, $directive->rules()[0]);
}
#[Test]
public function xr_spatial_tracking_adds_the_correct_header_directive_instead_of_the_deprecated_one(): void
{
$directive = Directive::make(Directive::XR_SPATIAL_TRACKING);
$this->assertSame(Directive::XR_SPATIAL_TRACKING, $directive->name());
}
}