Problem/Motivation
In NumberFieldTest::testNumberDecimalField
you can find $this->assertRaw(round($value, 2)
where $value
is "-1234.5678
. Now, round()
creates a floating point value. assertRaw
runsstrpos($this->drupalGetContent(), $raw)
.
If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
Opsie! Actually, strpos($haystack, round(-1234.5678, 2))
searches for the humble dot. (YES! We love PHP.) Check For kicks, try php -r 'var_dump(strpos(".", round(-1234.5678, 2)));'
-- consequently, this test will pass for any page containing a dot.
Proposed resolution
Do not round the string. Easy!
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
NumberFieldTest.patch | 763 bytes | chx | |
Comments
Comment #1
chx CreditAttribution: chx commentedComment #2
webchickchx and I looked through git blame to figure out where this came from, since it seemed odd to go through that amount of shenanigans in order to just check a value. We found our way all the way back to the issue where this was originally committed #950134: Number module maxlength prevents saving negative decimal. The intent of that issue was to make sure that - and . are accounted for in the maxlength. Reading the rest of the test, the fix chx has done here is sufficient.
Marking RTBC.
Comment #3
chx CreditAttribution: chx commentedComment #4
alexpottCommitted 54c2834 and pushed to 8.x. Thanks!