diff options
author | Andrew Dolgov <[email protected]> | 2023-10-27 22:10:28 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2023-10-27 22:10:28 +0300 |
commit | 925256c81f3be3678ced527fe32f5ae59418ad00 (patch) | |
tree | 51f25e831ab0fb758c29f1b638592a553653edd0 /tests/ConfigTest.php | |
parent | 5a7c5b8249e880952e011dd4e91726c0409c92de (diff) |
unify test class naming
Diffstat (limited to 'tests/ConfigTest.php')
-rw-r--r-- | tests/ConfigTest.php | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 000000000..30f3a212a --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,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() + ); + } +} |