Unit tests overwrite config.php #4106

Open
opened 2026-02-20 16:13:43 -05:00 by deekerman · 0 comments
Owner

Originally created by @connorshea on GitHub (Nov 11, 2019).

Issue

The state checker's removal caused one minor new issue that's causing some problems.

the saveInboundEmailSystemSettings test in tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php messes with the config.php but doesn't put it back to its original state, which means any custom configuration can be lost by running the unit tests.

It was removed in #7807. You can see my original findings on this problem here.

Expected Behavior

I can run the unit tests without them overwriting my config.php.

Actual Behavior

My config.php gets overwritten.

Possible Fix

Add some code to the test that removes

Steps to Reproduce

  1. Be on hotfix-7.10.x.
  2. Create a config.test.php file in tests/ so you can, e.g. use a different database than normal. (see config.test.dist.php for an example).
  3. Make a copy of your config.php to compare to when the tests change the original file.
  4. Run ./vendor/bin/robo tests:unit tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php
  5. See that config.php has changed, compare it to the copy of the original file.

Context

It makes running the tests annoying.

Originally created by @connorshea on GitHub (Nov 11, 2019). #### Issue The state checker's removal caused one minor new issue that's causing some problems. the `saveInboundEmailSystemSettings` test in `tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php` messes with the `config.php` but doesn't put it back to its original state, which means any custom configuration can be lost by running the unit tests. It was removed in #7807. You can see my original findings on this problem [here](https://github.com/salesagility/SuiteCRM/pull/7807#discussion_r342321666). #### Expected Behavior I can run the unit tests without them overwriting my config.php. #### Actual Behavior My config.php gets overwritten. #### Possible Fix Add some code to the test that removes #### Steps to Reproduce 1. Be on `hotfix-7.10.x`. 2. Create a `config.test.php` file in `tests/` so you can, e.g. use a different database than normal. (see `config.test.dist.php` for an example). 3. Make a copy of your `config.php` to compare to when the tests change the original file. 4. Run `./vendor/bin/robo tests:unit tests/unit/phpunit/modules/InboundEmail/InboundEmailTest.php` 5. See that `config.php` has changed, compare it to the copy of the original file. #### Context It makes running the tests annoying.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4106
No description provided.