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.
I recently wrote a test which passes an instance of TranslatableMarkup to \Drupal\commerce_order\AvailabilityResult::unavailable. It failed the assertion:
public static function unavailable($reason = NULL) : AvailabilityResult {
assert(is_string($reason) || is_null($reason));
TranslatableMarkup can be converted into a string, but it is not a string.
Comment | File | Size | Author |
---|---|---|---|
#11 | 3151272-final.patch | 1.09 KB | shubhangi1995 |
| |||
#8 | 3151272-8.patch | 1.23 KB | shubhangi1995 |
#4 | 3151272-4.patch | 1.21 KB | shubhangi1995 |
Comments
Comment #2
mglamanThe fix is to also support \Drupal\Component\Render\MarkupInterface in the assertion.
Comment #3
shubhangi1995Comment #4
shubhangi1995Please review
Comment #5
shubhangi1995Comment #7
mglamanThanks, @shubhangi1995. I provided the changes we required in #2. We don't want to convert to a string but change our assertions to allow for a MarkupInterface object.
Comment #8
shubhangi1995please review.
Just used the changes mentioned in #2
Comment #10
mglamanWe don't want to implement the interface.
👍 perfect
Comment #11
shubhangi1995sorry and thanks :)
Comment #12
shubhangi1995Comment #13
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #14
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedPatch #11 looks good for me and applied cleanly. I am moving to RTBC.
Comment #15
jsacksick CreditAttribution: jsacksick at Centarro commentedBtw, we can probably remove the assert() from unavailable() since it calls the constructor which already has it. So doing the same check twice seems a little bit unnecessary.
Comment #17
mglamanThanks @shubhangi1995! Commited, 🥳.