Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
number.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Anonymous (not verified)
Created:
24 Aug 2009 at 21:08 UTC
Updated:
11 Feb 2025 at 22:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bjaspan commentedA patch in #557924: Options widget broken presumably soon to be committed shows how to test Field API widgets. It turns out to be pretty easy. We will probably want to move the functions like getTagById() and getOptionByValue() etc. into FieldTestCase in field.test, which is trivial, and then it should be straightforward to crank out widget tests.
Comment #2
plachThis has been fixed in #557924: Options widget broken.
Comment #3
plachSorry, Number module still needs tests.
Comment #4
catch#653074: Review test coverage / outstanding tests before release
Comment #6
bleen commentedsome tests were added here: #950134: Number module maxlength prevents saving negative decimal
Comment #7
Dave.Ingram commentedNumber field still has no tests for integers and floats. I'll work on that.
Comment #8
Dave.Ingram commentedComment #9
mtiftLooks good. Ran tests locally with no problems.
Comment #10
chx commented+ 'precision' => 8, 'scale' => 4, 'decimal_separator' => '.', multiline this please.
i cringe when i read + $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', t('Widget is displayed')); "{$this->field['field_name']}[$langcode][0][value]" => $value, cant we store that {} thing in $field_name so that the thing is, you know, readable.
Comment #11
mtiftI updated the patch per chx's instructions (I hope).
Comment #12
dabl commented#11: numberfield_test_coverage-558362-11.patch queued for re-testing.
Comment #14
Letharion commentedMe and dabl, updated the patch to account for the tests file being moved and the syntax having changed somewhat since the patch was initially written.
Comment #16
dabl commentedComment #17
Letharion commentedOk, so the invalid syntax is that the patch adds a function that already exists. Without looking in any detail on what the two functions actually do, it seems like this functionality has already gotten into core at some point, and this issue could probably be closed duplicate or works as designed.
Comment #18
yesct commentedneeds confirmation that the issue is no longer present?
Comment #19
star-szrA testNumberIntegerField() test method was added in #1002734: Multiple "Undefined index" notices in modules/field/modules/number/number.module. At a glance they look similar, but we should compare the coverage and see if we there's anything of value to be added to that test from the patch in #14. testNumberFloatField() and the changes to testNumberDecimalField() are still completely valid from what I can tell.
Comment #20
scor commentedI've merged #14 with core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php but it needs more work, as I'm realizing the tests in there are quite inconsistent with each other. I've found another test for number at core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php but this file seems to be dealing with Entity API stuff rather than field and field UI.
Comment #21
star-szrSending to testbot for now, thanks @scor!
Comment #23
Jamesap commentedChanged LANGUAGE_NONE to LANGUAGE_NOT_SPECIFIED
Comment #24
Jamesap commentedChanged LANGUAGE_NONE to LANGUAGE_NOT_SPECIFIED
Comment #26
swentel commentedMoving to right component.
Comment #27
star-szrTagging for reroll and unassigning.
Comment #28
aaronott commentedHere is a re-roll of this test.
Comment #29
aaronott commentedComment #31
aaronott commentedThis is another reroll and passes all tests locally. I changed a few items to make it more consistent through out the tests.
Comment #32
swentel commentedGreat, thanks for working on this. Quick review.
We don't use t() anymore in tests. format_string() must be used now.
This comment is weird compared to the value used in the $valid_entries array
Comment #33
aaronott commentedThanks for letting me know about the t -> format_string change.
Huh... strange comment there. I've updated it to make it make sense now.
Thanks again!
Comment #34
swentel commentedOh crap, I messed up with my t() comment - so sorry about that :/
The page which explains the t() usage is https://drupal.org/simpletest-tutorial-drupal7#t - I had to read it again just to make sure.
So basically, you can still use t(), but not in assertion messages. I must have been completely confused when reading the patch.
So you'll have to revert those, again, so sorry :/
But, after that, it's as good as RTBC from me though!
Comment #35
swentel commentedBack to the good one + the small text change, works for me.
Comment #37
swentel commentedSmall fix after the rename of field and field instance config entities. Still good to go.
Comment #38
alexpottCommitted 3d4c167 and pushed to 8.x. Thanks!
Looks like Drupal 7 could still benefit from this coverage?
Comment #43
twodFor D7 this also needs to test just
-as inputting just that currently leads toPDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '-' for column 'FIELD_NAME' at row 1: INSERT IN ....Comment #44
poker10 commentedDrupal 7 is now EOL. Moving back to Drupal 8, where it was fixed originally, so that credits are assigned correctly. Thanks everyone!