cakephp / app

CakePHP application template
366 stars 390 forks source link

test/bootstrap.php and 'App.fullBaseUrl' #899

Closed OneHatRepo closed 2 years ago

OneHatRepo commented 2 years ago

Description

Hello. The tests/bootstrap.php file sets 'App.fullBaseUrl' even if this is already set in config/app_local.php. This was causing issues for me in tests which call shell commands, like sending an email or formatting a PDF. It seems like it would be preferable to only set this value when it is not already set.

So instead of line 35 being as so:

if (empty($_SERVER['HTTP_HOST'])) {
    Configure::write('App.fullBaseUrl', 'http://localhost');
}

... it would first check for an existing value, as so:

if (empty($_SERVER['HTTP_HOST']) && !Configure::read('App.fullBaseUrl')) {
    Configure::write('App.fullBaseUrl', 'http://localhost');
}

CakePHP Version

4.3.0

PHP Version

7.4

markstory commented 2 years ago

I'm not sure we need to change the default framework behavior for this as you are supposed to modify tests/bootstrap.php to fit the needs of your application.

OneHatRepo commented 2 years ago

We’ll this requested change is supposed to bring things in line with what config/bootstrap already does—It checks if the value is already defined and if so leaves it alone. Is there a reason the default behavior for tests doesn’t do this?l

markstory commented 2 years ago

Is there a reason the default behavior for tests doesn’t do this?l

Fair point. I agree that aligning the defaults is a good idea.