-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
In short: When editing an existing entity with a Symfony form and making it invalid, calling $I->grabEntityFromRepository()
in a functional tests causes the (invalid!) entity to get persisted to the database.
Sample repository to reproduce: https://github.com/ThomasLandauer/codeception_issue_5439
Instructions:
- The sqlite database is located at
/data.sqlite
. Doublecheck that user ID 1's name is NULL. - Start PHP's internal webserver in
/public
withphp -S localhost:8000
- Open http://localhost:8000/user in the browser. The form is editing user ID 1.
- Enter "foobar" and submit. You'll see an error message, due to the constraint at https://github.com/ThomasLandauer/codeception_issue_5439/blob/master/src/Entity/User.php#L22
- Doublecheck that user ID 1's name is still NULL in the database.
- Now run
vendor/bin/codecept run functional UserCest
. The test does the same as you just did in the browser. Even the error message is present, see https://github.com/ThomasLandauer/codeception_issue_5439/blob/master/tests/functional/UserCest.php#L24 - Now look into the database: User ID 1's name is "foobar"!
The bug only appears if the form is editing an existing user (not creating a new one).
This might be related to https://github.com/Codeception/Codeception/issues/4804 , but it's worse, since it doesn't just flush what is "ready" to get flushed, but performs a full persist
on its own.
Metadata
Metadata
Assignees
Labels
No labels