-
-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathHttpExtension.featurePolicy.phpt
More file actions
52 lines (36 loc) · 1.06 KB
/
HttpExtension.featurePolicy.phpt
File metadata and controls
52 lines (36 loc) · 1.06 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
<?php
/**
* Test: HttpExtension.
*/
declare(strict_types=1);
use Nette\Bridges\HttpDI\HttpExtension;
use Nette\DI;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
if (PHP_SAPI === 'cli') {
Tester\Environment::skip('Headers are not testable in CLI mode');
}
$compiler = new DI\Compiler;
$compiler->addExtension('http', new HttpExtension);
$loader = new DI\Config\Loader;
$config = $loader->load(Tester\FileMock::create(<<<'EOD'
http:
featurePolicy:
unsized-media: none
geolocation:
- self
- https://example.com
camera: *
EOD
, 'neon'));
eval($compiler->addConfig($config)->compile());
$container = new Container;
$container->getService('http.response');
$headers = headers_list();
var_dump($headers);
Assert::contains("Feature-Policy: unsized-media 'none'; geolocation 'self' https://example.com; camera *;", $headers);
echo ' '; @ob_flush(); flush();
Assert::true(headers_sent());
Assert::exception(function () use ($container) {
$container->createService('http.response');
}, Nette\InvalidStateException::class, 'Cannot send header after %a%');