Using the return GeneralConfig::create(); syntax in tests/_craft/config/general.php throws an error when running Codeception tests on a fresh Craft-CSM 4.2 installation.
Steps to reproduce
Get a fresh Craft-CMS 4.3 installation
I downloaded the zip file from the Installation Instructions to get up and running inside a DDEV project.
Install Codeception ^4.1 with composer require codeception/codeception:^4.1 --devCodeception ^3.1 is not compatible with PHP 8, and I did not manage to setup Craft-CMS tests with Codeception ^5.0.
Follow steps to Setup Tests for Craft-CMS from the documentation
To run the example unit test (steps 4-5), I had to un composer require codeception/module-yii2:^1.1 --dev first
Expected behavior
The example test should run and pass.
Actual behavior
The Uncaught Error: Call to a member function getConfig() on null error is thrown.
After replacing the GeneralConfig::create(); syntax with the array syntax the tests/_craft/config/general.php, the test runs and passes:
<?php
use craft\helpers\App;
return [
// Set the default week start day for date pickers (0 = Sunday, 1 = Monday, etc.)
'defaultWeekStartDay' => 1,
// Prevent generated URLs from including "index.php"
'omitScriptNameInUrls' => true,
// Enable Dev Mode (see https://craftcms.com/guides/what-dev-mode-does)
'devMode' => App::env('DEV_MODE') ?? false,
// Allow administrative changes
'allowAdminChanges' => App::env('ALLOW_ADMIN_CHANGES') ?? false,
// Disallow robots
'disallowRobots' => App::env('DISALLOW_ROBOTS') ?? false,
];
What happened?
Description
Using the
return GeneralConfig::create();
syntax intests/_craft/config/general.php
throws an error when running Codeception tests on a fresh Craft-CSM 4.2 installation.Steps to reproduce
composer require codeception/codeception:^4.1 --dev
Codeception ^3.1 is not compatible with PHP 8, and I did not manage to setup Craft-CMS tests with Codeception ^5.0.composer require codeception/module-yii2:^1.1 --dev
firstExpected behavior
The example test should run and pass.
Actual behavior
The
Uncaught Error: Call to a member function getConfig() on null
error is thrown.After replacing the
GeneralConfig::create();
syntax with the array syntax thetests/_craft/config/general.php
, the test runs and passes:Craft CMS version
4.2.7
PHP version
8.0.21
Operating system and version
Linux 5.10.124-linuxkit (DDEV v1.20.0)
Database type and version
MySQL 10.4.25 (MariaDB 10.4)
Image driver and version
Imagick 3.6.0 (ImageMagick 6.9.11-60)
Installed plugins and versions