Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
hal.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Mar 2014 at 10:32 UTC
Updated:
29 Jul 2014 at 23:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jessebeach commentedWe need to do two things for this issue.
One is super simple: Roll a patch changing
LogicExceptionto\LogicException-- not the preceding slash.Two is a little more tricky. We need to create a test that will trigger the two exceptions noted in the issue summary. These two exceptions are currently untested.
Comment #2
boobaaAttached is a patch with tests only and another patch with tests and fix.
Comment #4
dawehnerNote: There is a logicexception as part of the serializer namespace, see Symfony\Component\Serializer\Exception\LogicException. The original code intended to use that, as it was probably copied from another place. On top of that I really wonder why we don't use an InvalidArgumentException given that seems to have a better semantic
These bits probably have to be adapted based on the previous point.
Comment #5
boobaaFirstly, @alexpott asked at #drupaldevdays to convert this mocking mess to proper getMock() stuff, so I implemented that one instead.
Secondly, I have changed from LogicException to InvalidArgumentException as @dawehner asked.
Attached is a patch with tests only and another patch with tests and the fix.
Comment #7
boobaaThe bot threw this issue back to NW because of the patch which contains only the tests, so it must have failed. The other patch contains tests AND the fix and passed, so setting the issue to NR, as @ianthomas_uk suggested on IRC.
Comment #8
jessebeach commentedRead through the code; it looks succinct and well written. The fix changes the incorrect
LogicExceptionto an\InvalidArgumentException.Comment #9
alexpottNo need for this - can use the phpunit annotation
@expectedExceptionand this should be two tests or use a data providerNo new line at end of file
Plus lets fix and test
Drupal\hal\Normalizer\FieldNormalizertoo as this has the same bug.Comment #10
boobaaHere we go. Changes:
@expectedException.Drupal\hal\Normalizer\FieldNormalizertoo.Comment #11
dawehnerDo we also want to unit test the other class?
You could also use Symfony\Component\Serializer\Exception\InvalidArgumentException.
Comment #14
boobaa10: 2225333-fielditemnormalizer-logicexception-10-tests-and-fix.patch queued for re-testing.
Comment #16
boobaa10: 2225333-fielditemnormalizer-logicexception-10-tests-and-fix.patch queued for re-testing.
Comment #17
boobaaRerolled the pair of patches as @dawehner asked at #drupaldevdays: testing
FieldItemNormalizer::denormalize()andFieldNormalizer::denormalize()in two different classes, but they have a common abstract ancestor as the dataProvider for the two is the same.Additionally, changed from
\InvalidArgumentExceptionto\Symfony\Component\Serializer\Exception\InvalidArgumentExceptionwhich is eventually the same at code level, but makes more sense semantically.Comment #18
dawehnerAwesome!
Comment #20
jessebeach commentedThe "fail" patch failed in #17. The green patch passed.
Comment #21
dawehnerAwesome!
Comment #22
alexpottNice test!
Committed 5a0edc3 and pushed to 8.x. Thanks!