bootstrapApplication(); } protected function bootstrapApplication() { $this->app = new Application(APP_ROOT); $this->app->bootstrapWith([LoadConfig::class, SetRequestForConsole::class]); $this->app->boot(); $this->config = $this->app['config']; } public function test_base_url_is_set_correctly_from_config(): void { // BASE_URL constant is set from LEAN_APP_URL in the environment. // Verify the config matches whatever BASE_URL was resolved to. $this->assertEquals(BASE_URL, $this->config->get('app.url')); // Test with LEAN_APP_URL set to a known value putenv('LEAN_APP_URL=https://example.com'); $_ENV['LEAN_APP_URL'] = 'https://example.com'; // Reinitialize application to test new environment $this->bootstrapApplication(); $this->assertEquals('https://example.com', $this->config->get('app.url')); $this->assertEquals('https://example.com', $this->config->get('appUrl')); } public function test_base_url_handles_trailing_slash(): void { $_ENV['LEAN_APP_URL'] = 'https://example.com/'; $this->bootstrapApplication(); $this->assertEquals('https://example.com', $this->config->get('app.url')); $this->assertEquals('https://example.com', $this->config->get('appUrl')); } public function test_base_url_handles_subdirectory(): void { $_ENV['LEAN_APP_URL'] = 'https://example.com/leantime'; $this->bootstrapApplication(); $this->assertEquals('https://example.com/leantime', $this->config->get('app.url')); $this->assertEquals('https://example.com/leantime', $this->config->get('appUrl')); } public function test_base_url_handles_port(): void { $_ENV['LEAN_APP_URL'] = 'https://example.com:8443'; $this->bootstrapApplication(); $this->assertEquals('https://example.com:8443', $this->config->get('app.url')); $this->assertEquals('https://example.com:8443', $this->config->get('appUrl')); } public function test_base_url_handles_reverse_proxy(): void { // Simulate reverse proxy headers $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; $_SERVER['HTTP_X_FORWARDED_HOST'] = 'example.com'; $_ENV['LEAN_APP_URL'] = 'https://example.com'; $this->bootstrapApplication(); $this->assertEquals('https://example.com', $this->config->get('app.url')); $this->assertEquals('https://example.com', $this->config->get('appUrl')); } protected function tearDown(): void { parent::tearDown(); // Clean up environment putenv('LEAN_APP_URL'); unset($_SERVER['HTTP_X_FORWARDED_PROTO']); unset($_SERVER['HTTP_X_FORWARDED_HOST']); } }