From f49b1b0e8a475bcf0f0d0240960f7d0b3b77a4e3 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Sun, 11 Dec 2022 13:04:36 -0500 Subject: [PATCH] Set HTTP_HOST in BaseDriverTest --- tests/Drivers/BaseDriverTestCase.php | 5 +++++ tests/Drivers/BasicValetDriverTest.php | 10 ---------- tests/Drivers/BasicWithPublicValetDriverTest.php | 12 ------------ tests/Drivers/BedrockValetDriverTest.php | 2 -- tests/Drivers/CraftValetDriverTest.php | 2 -- tests/Drivers/DrupalValetDriverTest.php | 2 -- tests/Drivers/JoomlaValetDriverTest.php | 2 -- tests/Drivers/KirbyValetDriverTest.php | 2 -- tests/Drivers/WordPressValetDriverTest.php | 2 -- 9 files changed, 5 insertions(+), 34 deletions(-) diff --git a/tests/Drivers/BaseDriverTestCase.php b/tests/Drivers/BaseDriverTestCase.php index d48359f..8bbc2c6 100644 --- a/tests/Drivers/BaseDriverTestCase.php +++ b/tests/Drivers/BaseDriverTestCase.php @@ -2,6 +2,11 @@ class BaseDriverTestCase extends Yoast\PHPUnitPolyfills\TestCases\TestCase { + public function set_up(): void + { + $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; + } + public function projects(): array { return Filesystem::scanDir(__DIR__.'/projects'); diff --git a/tests/Drivers/BasicValetDriverTest.php b/tests/Drivers/BasicValetDriverTest.php index 8955ddb..49a4a96 100644 --- a/tests/Drivers/BasicValetDriverTest.php +++ b/tests/Drivers/BasicValetDriverTest.php @@ -18,8 +18,6 @@ public function test_it_serves_php_files_from_root() $projectPath = $this->projectDir('basic-no-public'); $driver = new BasicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/file-in-root.php', $driver->frontControllerPath($projectPath, 'my-site', '/file-in-root.php') @@ -31,8 +29,6 @@ public function test_it_serves_directory_with_index_php() $projectPath = $this->projectDir('basic-no-public'); $driver = new BasicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/about/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/about') @@ -44,8 +40,6 @@ public function test_it_routes_to_index_if_404() $projectPath = $this->projectDir('basic-no-public'); $driver = new BasicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/not-a-real-url') @@ -57,8 +51,6 @@ public function test_it_serves_directory_with_index_html() $projectPath = $this->projectDir('basic-no-public'); $driver = new BasicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/team/index.html', $driver->isStaticFile($projectPath, 'my-site', '/team') @@ -70,8 +62,6 @@ public function test_it_serves_static_files() $projectPath = $this->projectDir('basic-no-public'); $driver = new BasicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/assets/document.txt', $driver->isStaticFile($projectPath, 'my-site', '/assets/document.txt') diff --git a/tests/Drivers/BasicWithPublicValetDriverTest.php b/tests/Drivers/BasicWithPublicValetDriverTest.php index b91a09e..51a7ed2 100644 --- a/tests/Drivers/BasicWithPublicValetDriverTest.php +++ b/tests/Drivers/BasicWithPublicValetDriverTest.php @@ -23,8 +23,6 @@ public function test_it_serves_php_files_from_public() $projectPath = $this->projectDir('public-with-index-non-laravel'); $driver = new BasicWithPublicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/public/file-in-public.php', $driver->frontControllerPath($projectPath, 'my-site', '/file-in-public.php') @@ -36,8 +34,6 @@ public function test_it_doesnt_serve_php_files_from_root() $projectPath = $this->projectDir('public-with-index-non-laravel'); $driver = new BasicWithPublicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/public/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/file-in-root.php') @@ -49,8 +45,6 @@ public function test_it_serves_directory_with_index_php() $projectPath = $this->projectDir('public-with-index-non-laravel'); $driver = new BasicWithPublicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/public/about/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/about') @@ -62,8 +56,6 @@ public function test_it_route_to_public_index_if_404() $projectPath = $this->projectDir('public-with-index-non-laravel'); $driver = new BasicWithPublicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/public/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/not-a-real-url') @@ -75,8 +67,6 @@ public function test_it_serves_directory_with_index_html() $projectPath = $this->projectDir('public-with-index-non-laravel'); $driver = new BasicWithPublicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/public/team/index.html', $driver->isStaticFile($projectPath, 'my-site', '/team') @@ -88,8 +78,6 @@ public function test_it_serves_static_files() $projectPath = $this->projectDir('public-with-index-non-laravel'); $driver = new BasicWithPublicValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $this->assertEquals( $projectPath.'/public/assets/document.txt', $driver->isStaticFile($projectPath, 'my-site', '/assets/document.txt') diff --git a/tests/Drivers/BedrockValetDriverTest.php b/tests/Drivers/BedrockValetDriverTest.php index 39613ac..75ef6d5 100644 --- a/tests/Drivers/BedrockValetDriverTest.php +++ b/tests/Drivers/BedrockValetDriverTest.php @@ -22,8 +22,6 @@ public function test_it_gets_front_controller() { $driver = new BedrockValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $projectPath = $this->projectDir('bedrock'); $this->assertEquals($projectPath.'/web/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } diff --git a/tests/Drivers/CraftValetDriverTest.php b/tests/Drivers/CraftValetDriverTest.php index 19c0dc9..1a75479 100644 --- a/tests/Drivers/CraftValetDriverTest.php +++ b/tests/Drivers/CraftValetDriverTest.php @@ -22,8 +22,6 @@ public function test_it_gets_front_controller() { $driver = new CraftValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $projectPath = $this->projectDir('craft'); $this->assertEquals($projectPath.'/public/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } diff --git a/tests/Drivers/DrupalValetDriverTest.php b/tests/Drivers/DrupalValetDriverTest.php index 6253b27..b992793 100644 --- a/tests/Drivers/DrupalValetDriverTest.php +++ b/tests/Drivers/DrupalValetDriverTest.php @@ -22,8 +22,6 @@ public function test_it_gets_front_controller() { $driver = new DrupalValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $projectPath = $this->projectDir('drupal'); $this->assertEquals($projectPath.'/public/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } diff --git a/tests/Drivers/JoomlaValetDriverTest.php b/tests/Drivers/JoomlaValetDriverTest.php index 7a86f2a..0807aa9 100644 --- a/tests/Drivers/JoomlaValetDriverTest.php +++ b/tests/Drivers/JoomlaValetDriverTest.php @@ -22,8 +22,6 @@ public function test_it_gets_front_controller() { $driver = new JoomlaValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $projectPath = $this->projectDir('joomla'); $this->assertEquals($projectPath.'/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } diff --git a/tests/Drivers/KirbyValetDriverTest.php b/tests/Drivers/KirbyValetDriverTest.php index f37a72c..b6759d5 100644 --- a/tests/Drivers/KirbyValetDriverTest.php +++ b/tests/Drivers/KirbyValetDriverTest.php @@ -22,8 +22,6 @@ public function test_it_gets_front_controller() { $driver = new KirbyValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $projectPath = $this->projectDir('kirby'); $this->assertEquals($projectPath.'/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } diff --git a/tests/Drivers/WordPressValetDriverTest.php b/tests/Drivers/WordPressValetDriverTest.php index 5f0d493..e458752 100644 --- a/tests/Drivers/WordPressValetDriverTest.php +++ b/tests/Drivers/WordPressValetDriverTest.php @@ -22,8 +22,6 @@ public function test_it_gets_front_controller() { $driver = new WordPressValetDriver(); - $_SERVER['HTTP_HOST'] = 'this is set in Valet requests but not phpunit'; - $projectPath = $this->projectDir('wordpress'); $this->assertEquals($projectPath.'/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); }