Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Issue tags: +Random test failure

Let's make sure to always tag such issues with "Random test failure". In the long run, we want to learn from previous mistakes.

alexpott’s picture

This fail occurs when the user_id is 0. Haven't work out exactly why yet...

alexpott’s picture

Status: Active » Needs review

As so the $name1 and $name2 could will cause failures if they're the same so I've made them different lengths.

Berdir’s picture

Ok, so the actual problem here is that when the uid is 0, then it fails the form validation and we never attempt to delete.

Debug output shows "UID field is required.".

Can we add an assertion message for "entity_test 1 has been deleted."? That might tell us a bit better what exactly the problem is if we encounter something like this again.

Not sure if we should just change anything in the form handling/validation (like adding limit validation errors on the delete button) or just stick to mt_rand(1, 128) and live with it.

alexpott’s picture

Actually this issue is due to if (!empty($values)) { in the setValue method of Drupal\Core\Entity\Field\Type\Field. If $values = 0 then this does not set the value to 0 as 0 the same as an empty array to the empty function.

I think the correct fix is the patch attached. I've attached a provethisworks.patch that sets the user_id to 0 to, well, prove this works!

alexpott’s picture

alexpott’s picture

Issue tags: +Entity Field API

tagging

Berdir’s picture

Issue tags: -Entity Field API

Makes sense I think and is related to the previous random test failure issue at #1798382: Random Test failures in Entity translation tests.

Maybe we can extend the tests that were added there instead of using the entity form tests for that?

Berdir’s picture

Issue tags: +Entity Field API

Crosspost.

alexpott’s picture

alexpott’s picture

Noticed that the change to setValue will break stuff in $values is an empt array. Patch attached fixes that.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Random test failure, -Entity Field API

Looks great. Has test coverage and fixes another ugly random test failure.

Berdir’s picture

Weird double post.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Thanks folks! Committed/pushed to 8.x.

fago’s picture

Status: Fixed » Needs review
FileSize
3.06 KB
4.22 KB

I also ran into this issue while working on #1778178: Convert comments to the new Entity Field API, however didn't notice it's causing test failures. :/

The committed fix does not account for setting NULL properly. I've attached a patch with a test that shows that.

An easy and correct fix is to check for isset($value) and !== array() instead of using !empty(). Attached patch reverts the fix to do so and adds the mentioned test for NULL. Also, I've moved over the test for setting to 0 to the entity-field test case as it's not specific to translation at all.

Patches attached, tests only should fail.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

Tested locally... and this looks good and makes sense. If #15 is green this is rtbc.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, d8_entity_tests_only.patch, failed testing.

Berdir’s picture

Status: Needs work » Reviewed & tested by the community

Tests passed/failed as expected, they were just in the wrong order. Back to RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great work all, thanks.

Committed and pushed to 8.x.

Automatically closed -- issue fixed for 2 weeks with no activity.