Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
EntityTypedDataDefinitionTest fails on MySQL with an AJAX error. The relevant part of the error message is:
Data too long for column 'message' at row 1: INSERT INTO {simpletest} (...
There are two problems here. One is that the test case is using assertEquals() with no message and passing in two serialized entities as arguments. The other is that simpletest is not validating its input and failing cleanly.
Proposed resolution
Since the base test class being used is deprecated, my proposed resolution is:
- Use the new kernel test which compares objects and just stores the difference in the message, in case it fails, but don't store anything, if it works fine
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#12 | 2609770-12.patch | 1.12 KB | pflame |
#2 | 2609770-2.patch | 1.23 KB | dawehner |
Comments
Comment #2
dawehnerInteresting, this is the easiest bugfix I can think of. ... PHPUnit just doens't store the entire objects when they are equal.
Comment #3
BerdirIs this the only broken test? I think I've seen others explode like this on things like assertNull($term) when they are failing. Those are web tests, so we can't just convert them to phpunit :)
Should we try to make our logging/verbose comparison output better?
Comment #4
blackra CreditAttribution: blackra at SK Plus commentedBerdir, yes we should, but not for this issue. If you know of any other broken simpletest tests (especially web test cases), please open issues for them.
For this particular issue, the original base class is \Drupal\simpletest\KernelTestBase which has been deprecated in favour of one that works. The replacement doesn't give you the most friendly of output, but at least you know which test is failing and it doesn't kill the whole testsuite.
I have tested this, running it from the command line. I also tried adding a '.' to one of the serialized objects to cause this test to fail. It fails cleanly (although it gives a lengthy binary diff in the output).
An additional piece of information from Mixologi- is that the d.o bots use sqlite for running tests, and it has different constraints from running things through the UI with a MySQL database.
Anyway, I think this has had enough testing and reviewing for such a simple change. Marking this as RTBC.
Comment #5
blackra CreditAttribution: blackra at SK Plus commentedActually marking it as RTBC this time :-)
Comment #6
catchThere's no change to the assertEqual here - so either the patch or the issue summary needs updating?
Comment #7
dawehnerLet me explain what is going on
Comment #9
catchFuture archeologists thank you.
But I just committed and reverted this again, because now we report fatal errors, the patch is failing.
Comment #11
Mile23::future archaeologist raises hand::
Thanks.
I'm seeing this as a consequence of #2624926: Refactor run-tests.sh for Console component.
Running the patched test as
php ./core/scripts/run-tests.sh --class "Drupal\\KernelTests\\Core\\Entity\\EntityTypedDataDefinitionTest"
yields a happy passing test. This is without sqlite.Running it in the UI leads to unhappiness in the form of "No test results to display."
Also, I can repro the original issue in the UI unpatched. I get this:
Comment #12
pflame CreditAttribution: pflame commentedAdded message parameter to assertEqual which removed this error and test case passed.
Comment #23
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedEntityTypedDataDefinitionTest
runs just fine on MySQL these days :)