-
-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathHttpExtension.cookie.phpt
More file actions
51 lines (37 loc) · 1.47 KB
/
HttpExtension.cookie.phpt
File metadata and controls
51 lines (37 loc) · 1.47 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
<?php
declare(strict_types=1);
use Nette\Bridges\HttpDI\HttpExtension;
use Nette\Bridges\HttpDI\SessionExtension;
use Nette\DI;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
test('cookie path and domain configuration', function () {
$compiler = new DI\Compiler;
$compiler->addExtension('http', new HttpExtension);
$compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli'));
$loader = new DI\Config\Loader;
$config = $loader->load(Tester\FileMock::create('
http:
cookiePath: /x
cookieDomain: www.nette.org
', 'neon'));
eval($compiler->addConfig($config)->setClassName('ContainerA')->compile());
$container = new ContainerA;
Assert::same('/x', $container->getService('http.response')->cookiePath);
Assert::same('www.nette.org', $container->getService('http.response')->cookieDomain);
});
test('cookie domain normalization based on request host', function () {
$compiler = new DI\Compiler;
$compiler->addExtension('http', new HttpExtension);
$compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli'));
$loader = new DI\Config\Loader;
$config = $loader->load(Tester\FileMock::create('
http:
cookieDomain: domain
services:
http.request: Nette\Http\Request(Nette\Http\UrlScript("http://www.nette.org"))
', 'neon'));
eval($compiler->addConfig($config)->setClassName('ContainerB')->compile());
$container = new ContainerB;
Assert::same('nette.org', $container->getService('http.response')->cookieDomain);
});