forked from nette/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestFactory.scriptPath.phpt
More file actions
109 lines (77 loc) · 2.66 KB
/
RequestFactory.scriptPath.phpt
File metadata and controls
109 lines (77 loc) · 2.66 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Test: Nette\Http\RequestFactory scriptPath detection.
*/
use Nette\Http\RequestFactory,
Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$factory = new RequestFactory;
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/projects/modules-usage/www/',
'SCRIPT_FILENAME' => 'W:/projects/modules-usage/www/index.php',
'SCRIPT_NAME' => '/projects/modules-usage/www/index.php',
);
Assert::same( '/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/projects/modules-usage/www/default/add-item',
'SCRIPT_FILENAME' => 'W:/projects/modules-usage/www/index.php',
'SCRIPT_NAME' => '/projects/modules-usage/www/index.php',
);
Assert::same( '/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/www/index.php',
'SCRIPT_FILENAME' => 'w:\projects\modules-usage\www\index.php',
'SCRIPT_NAME' => '/www/index.php',
);
Assert::same( '/www/index.php', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/www/',
'SCRIPT_FILENAME' => 'w:\projects\modules-usage\www\index.php',
'SCRIPT_NAME' => '/www/',
);
Assert::same( '/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/test/in',
'SCRIPT_NAME' => '/test/index.php',
);
Assert::same( '/test/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/test//',
'SCRIPT_NAME' => '/test/index.php',
);
Assert::same( '/test/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
// http://forum.nette.org/cs/5932-lepsi-detekce-requesturi-a-scriptpath
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/sign/in/',
'SCRIPT_NAME' => '/sign/in/',
);
Assert::same( '/sign/in/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
// http://forum.nette.org/cs/9139-spatny-urlscript-scriptpath
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/configuration/',
'SCRIPT_NAME' => '/configuration/www/index.php',
);
Assert::same( '/configuration/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});
test(function() use ($factory) {
$_SERVER = array(
'REQUEST_URI' => '/blog/WWW/',
'SCRIPT_NAME' => '/blog/www/index.php',
);
Assert::same( '/blog/', $factory->createHttpRequest()->getUrl()->getScriptPath() );
});