-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x]: Error running codeception Acceptance tests with module setting in config/app.php #12088
Comments
I just followed the steps above on a Craft 4.2 installation, and confirm this is also happening for Craft-CMS 4.x. |
@yoannisj do you have the The full file should look similar to the following <?php
use craft\helpers\App;
return [
'id' => App::env('APP_ID') ?: 'CraftCMS',
'modules' => [
'my-module' => \modules\Module::class,
],
'bootstrap' => ['my-module'],
]; That being said, not including |
@brianjhanson , no I removed the Yes, it does not throw an error in a normal install, and I also figured that one might want to define/configure a module that gets loaded inside a test without bootstrapping it. |
This is fixed for the next Craft 3 and 4 releases, via #12093. |
Craft 3.7.57 and 4.2.8 are out now with the fix. Thanks again! |
What happened?
Description
Running Codeception acceptance tests with modules defined in
config/app.php
throws error[TypeError] get_class(): Argument #1 ($object) must be of type object, string given
.To make sure this is not an issue with my project's module configuration, I tried with a fresh Craft-CMS 3.7 install, and could reproduce the error.
Steps to reproduce
I downloaded the zip file from the Installation Instructions to get up and running inside a DDEV project.
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.
To run the example unit test (steps 4-5), I had to run
composer require codeception/module-yii2:^1.1 --dev
firsttests/acceptance/ExampleCest.php
like so:php vendor/bin/codecept run acceptance
Expected behavior
The acceptance test should run and pass.
Actual behavior
The
[TypeError] get_class(): Argument #1 ($object) must be of type object, string given
error is thrown.The
[TypeError] get_class(): Argument #1 ($object) must be of type object, array given
error is thrown if I define the module as an array intests/_craft/config/app.php
:The test runs and passes if I comment out the
'modules'
setting altogether intests/_craft/config/app.php
.Craft CMS version
3.7.55.3
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
The text was updated successfully, but these errors were encountered: