mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #6005] Improve functional test query logger #9811
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/6005
State: closed
Merged: Yes
The
onNotSuccessfulTestmethod inOrmFunctionalTestCaseprints out the actual queries that were executed during a failed test, but currently it does not show the last query at all.This is because the
DebugStackthat is used to record the queries starts it's index from 1, but the code that iterates them assumes it starts from 0.So I changed the iteration to use
foreachinstead of aforloop and transform the array beforehand to only contain the last 25 queries in reverse order.Also, the way query params is currently handeled fails on array types with the following message:
I have used
var_exportto overcome this issue and print out the array values.Example output:
The downside is that it breaks it into multiple lines, but I think it's OK. It could be further improved to output something like
[0 => 'Sales', 1 => 'Marketing']if that is a problem. But at least it's better than an error.By using
var_exportinstead of plain string concatenation we also get better insight into the types of the parameters, as it shows numeric values without quotes, boolean values astrueandfalse(instead of'1'and'') and null values asNULL(instead of'').Below is a more detailed example of the output before and after the changes.
After: