blob: b8892f84b0065334d001279186731c121fe0028c (
plain)
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
|
<?php
use PHPUnit\Framework\TestCase;
final class SelfUrlPathTest extends TestCase {
public function test_a(): void {
$_SERVER = [];
$_SERVER["HTTP_X_FORWARDED_PROTO"] = "http";
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/tt-rss/api/index.php";
$this->assertEquals(
'http://example.com/tt-rss',
Config::get_self_url(true)
);
}
public function test_b(): void {
$_SERVER = [];
$_SERVER["HTTP_X_FORWARDED_PROTO"] = "https";
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/api/";
$this->assertEquals(
'https://example.com',
Config::get_self_url(true)
);
}
public function test_c(): void {
$_SERVER = [];
$_SERVER["HTTP_X_FORWARDED_PROTO"] = "https";
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/api/index.php";
$this->assertEquals(
'https://example.com',
Config::get_self_url(true)
);
}
public function test_d(): void {
$_SERVER = [];
$_SERVER["HTTP_X_FORWARDED_PROTO"] = "https";
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/api//";
$this->assertEquals(
'https://example.com',
Config::get_self_url(true)
);
}
public function test_e(): void {
$_SERVER = [];
$_SERVER["HTTP_X_FORWARDED_PROTO"] = "https";
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/";
$this->assertEquals(
'https://example.com',
Config::get_self_url(true)
);
}
public function test_f(): void {
$_SERVER = [];
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/tt-rss/index.php";
$this->assertEquals(
'http://example.com/tt-rss',
Config::get_self_url(true)
);
}
public function test_g(): void {
$_SERVER = [];
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/tt-rss/";
$this->assertEquals(
'http://example.com/tt-rss',
Config::get_self_url(true)
);
}
public function test_h(): void {
$_SERVER = [];
$_SERVER["HTTP_HOST"] = "example.com";
$_SERVER["REQUEST_URI"] = "/tt-rss";
$this->assertEquals(
'http://example.com/tt-rss',
Config::get_self_url(true)
);
}
}
|