blob: 30f3a212a7e3da23ddaca3b166986a4b22ebef30 (
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
107
108
109
110
111
112
113
|
<?php
use PHPUnit\Framework\TestCase;
final class SelfUrlPathTest extends TestCase {
public function test_self_url_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_self_url_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_self_url_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_self_url_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_self_url_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_self_url_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_self_url_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_self_url_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)
);
}
public function test_get_self_dir(): void {
$this->assertEquals(
dirname(__DIR__), # we're in (app)/tests/
Config::get_self_dir()
);
}
}
|