From 925256c81f3be3678ced527fe32f5ae59418ad00 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 27 Oct 2023 22:10:28 +0300 Subject: unify test class naming --- tests/ConfigTest.php | 113 ++++++++++++++++++++++++++++++++++++++++++++++ tests/SelfDirTest.php | 12 ----- tests/SelfUrlPathTest.php | 106 ------------------------------------------- 3 files changed, 113 insertions(+), 118 deletions(-) create mode 100644 tests/ConfigTest.php delete mode 100644 tests/SelfDirTest.php delete mode 100644 tests/SelfUrlPathTest.php 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 @@ +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() + ); + } +} diff --git a/tests/SelfDirTest.php b/tests/SelfDirTest.php deleted file mode 100644 index 5b7396a66..000000000 --- a/tests/SelfDirTest.php +++ /dev/null @@ -1,12 +0,0 @@ -assertEquals( - dirname(__DIR__), # we're in (app)/tests/ - Config::get_self_dir() - ); - } -} diff --git a/tests/SelfUrlPathTest.php b/tests/SelfUrlPathTest.php deleted file mode 100644 index b8892f84b..000000000 --- a/tests/SelfUrlPathTest.php +++ /dev/null @@ -1,106 +0,0 @@ -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) - ); - } -} -- cgit v1.2.3