Closed iainsaxon closed 3 months ago
Thanks for reporting that! Fixed now for the next Craft 4 and 5 releases.
To get the fix early, change your craftcms/cms
requirement in composer.json to:
"craftcms/cms": "5.x-dev as 5.2.9",
and then run composer update
.
Craft 4.10.8 and 5.2.10 are out with that fix. Thanks again!
What happened?
Codeception tests fail if using
GeneralConfig::create()-> defaultCpLanguage('en-GB')
.Description
I'm setting up Codeception for a Craft 5 site using this repository's tests as a starting point and then altering it as needed.
If our
config/general.php
file is using the newerGeneralConfig::create()
pattern and we use thedefaultCpLanguage
method with a string value the tests will fail with the following error (more detailed tracestack below):This is because the Localization helper uses
Craft::$app->getI18n()
which is not initialised in Codeception so early on in the testing process.Does the
GeneralConfig
class orLocalization
helper need to check first if thei18n
service is available before trying to use it?Steps to reproduce
config/general.php
:tests/unit.suite.yml
file:config/general.php
line where thedefaultCpLanguage
method is called.Expected behavior
Tests should work using the project's general config file.
Actual behavior
Tests fail with:
Craft CMS version
5.2.2
PHP version
8.2.20
Operating system and version
Debian Bookworm via
ddev
Database type and version
Postgres 15
Image driver and version
NA
Installed plugins and versions
NA