Add missing test for StringDescription:: toString#90
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a missing test to verify that StringDescription::toString properly appends self-describing objects.
- Added test method testToStringAppendsSelfDescribing in the StringDescriptionTest file
- Validates that casting the description object to string yields the expected output
Comments suppressed due to low confidence (1)
tests/Hamcrest/StringDescriptionTest.php:168
- Consider adding additional test cases to cover scenarios with multiple self describing objects or edge cases to further validate comprehensive behavior.
$description = $this->_description->toString(new \Hamcrest\SampleSelfDescriber('foo'));
|
It doesnt show what I thought was a bug, no. But it tests a method that didnt had a test before? edit: but now that I read your comment, let me extract the fix with the static into this |
The public method was tested indirectly (which I don't like personally). So 👍 for the test. Probably we need to double check (as a separate PR) if all the tests actually test connected class at 100% by themselves.
Without PhpStan I have no way to see if this worked, so I'll merge this anyway. |
|
Merging, thank you @pscheit . |
interestingly, the code is totally fine:
https://github.com/hamcrest/JavaHamcrest/blob/master/hamcrest/src/main/java/org/hamcrest/StringDescription.java#L35
This calls toString, but we actually implemented __toString on the class. So casting as
(string)must be fine.Anyway, the test might be helpful