Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
editor.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Aug 2014 at 11:10 UTC
Updated:
23 Sep 2014 at 11:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
olli commentedI guess these are not the same thing as it wouldn't record each usage but only one per entity.
Comment #3
dawehnerSome comment above would be great to explain what we are testing here.
Comment #4
olli commentedThanks for the review! Something like this?
Comment #6
dawehnerGreat!
I wonder whether we could also test a non-existing UUID
Comment #7
wim leersSo very close! I'm sure the next one will be RTBC :)
There should also be test coverage for
hook_entity_insert()andhook_entity_delete(). Finally, ideally this would test both an invalid UUID (like you're doing now) and a non-existing UUID.This should be .
Comment #8
dawehnerWhat about directly pointing to the code handling that?
Comment #9
olli commentedThanks!
Re #6: added a random uuid.
Re #7/#8: modified the comment pointing to functions we're fixing. These functions are called from hook_insert/update/revision_delete/delete.
Comment #12
dawehnerAwesome!
Comment #13
wim leers$original_valuecontains a valid file entity UUID. So this doesn't test the deletion hook in any way, it tests the insertion hook for a valid UUID, which is a case already covered by existing tests.Your assertion also proves this: the assertion verifies that after this code has run, there are two usages, versus one before. If this was the deletion of an invalid file UUID, then the number of usages would have to remain constant.
Therefore, I'm afraid that #9 is wrong. It claims to test
hook_entity_delete(), but it doesn't, as I've explained above. It also doesn't yet testhook_entity_insert(). And it also doesn't do this yet:So… I'm afraid I have to unRTBC this :(
Comment #14
olli commentedRe #13: Yes, you are right, this doesn't test those hooks at all. This (cl)aims to test _editor_record_file_usage() and _editor_delete_file_usage() by first replacing the valid value with an invalid value (_editor_record_file_usage for invalid value fails, fail1 patch above) which decreases usage from 2 to 1, and then replacing the invalid value with the original valid value (_editor_record_delete_usage for invalid value fails, fail2 patch) which restores usage from 1 to 2.
Hooks (editor_entity_insert, editor_entity_update, editor_entity_revision_delete and editor_entity_delete) are already covered by existing tests. Do you think it is necessary to run those again with invalid values? If so, maybe just append them to original value like in #0 editor_file_usage-fail.patch rather than what I've done in #9?
About the UUIDs, the latter is just a random one and the other value is what you get if you disable file uploads. Which values would you prefer?
Thank you again and sorry for not providing interdiffs!
Comment #15
wim leersYes and yes :)
Both! A valid, but non-existing UUID and something that doesn't even resemble a UUID.
Thank you, and no worries! :)
Comment #16
olli commentedHere's #15.
Comment #17
wim leersPerfect — thank you :)
Comment #18
alexpottCommitted 7e2ab24 and pushed to 8.0.x. Thanks!