Skip to content
Snippets Groups Projects

Issue #2230909: Simple decimals fail to pass validation

Open Issue #2230909: Simple decimals fail to pass validation
8 unresolved threads
Open Joshua Sedler requested to merge issue/drupal-2230909:2230909-simple-decimals-fail into 11.x
8 unresolved threads

Closes #2230909

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
73 *
74 * @dataProvider provideCountSignificantDecimals
75 *
76 * @param int $expected
77 * The expected number of significant decimals.
78 * @param int|float|string $number
79 * The number to test the count on.
80 */
81 public function testCountSignificantDecimals($expected, $number) {
82 $this->assertEquals($expected, Number::countSignificantDecimals($number));
83 }
84
85 /**
86 * Provides data to self::testCountSignificantDecimals().
87 */
88 public static function provideCountSignificantDecimals() {
  • 66 [1234.1234567800000000000000001, 1234.12345678],
    67 ['1234.1234567800000000000000001', '1234.1234567800000000000000001'],
    68 ];
    69 }
    70
    71 /**
    72 * @covers ::countSignificantDecimals
    73 *
    74 * @dataProvider provideCountSignificantDecimals
    75 *
    76 * @param int $expected
    77 * The expected number of significant decimals.
    78 * @param int|float|string $number
    79 * The number to test the count on.
    80 */
    81 public function testCountSignificantDecimals($expected, $number) {
  • 41 *
    42 * @param int|float|string $number
    43 * The number to test the count on.
    44 * @param int $expected
    45 * The expected number of significant decimals.
    46 *
    47 * @dataProvider providerNormalize
    48 */
    49 public function testNormalize($number, $expected) {
    50 $this->assertEquals($expected, Number::normalize($number));
    51 }
    52
    53 /**
    54 * Provides data to self::testNormalize().
    55 */
    56 public static function providerNormalize() {
  • 36 36 $this->assertEquals($expected, $return);
    37 37 }
    38 38
    39 /**
    40 * @covers \Drupal\Component\Utility\Number::normalize
    41 *
    42 * @param int|float|string $number
    43 * The number to test the count on.
    44 * @param int $expected
    45 * The expected number of significant decimals.
    46 *
    47 * @dataProvider providerNormalize
    48 */
    49 public function testNormalize($number, $expected) {
  • 11 11 function field_update_last_removed() {
    12 12 return 8500;
    13 13 }
    14
    15 /**
    16 * Update existing DecimalItem fields to match the new maximum value.
    17 */
    18 function field_update_10001() {
  • Lap Pham added 1 commit

    added 1 commit

    Compare with previous version

  • Lap Pham added 1 commit

    added 1 commit

    Compare with previous version

  • Lap Pham added 1 commit

    added 1 commit

    Compare with previous version

  • 14
    15 /**
    16 * Update existing DecimalItem fields to match the new maximum value.
    17 */
    18 function field_update_10001(): void {
    19
    20 // Load all decimal field storage entities:
    21 $decimalFieldStorageEntities = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties([
    22 'type' => 'decimal',
    23 ]);
    24
    25 foreach ($decimalFieldStorageEntities as $decimalFieldStorageEntity) {
    26 /** @var \Drupal\field\Entity\FieldStorageConfig $decimalFieldStorageEntity*/
    27
    28 $precision = (int) ini_get('precision');
    29 $precisionMax = max($precision, 10);
  • 74 74 '#type' => 'number',
    75 75 '#title' => $this->t('Precision'),
    76 76 '#min' => 10,
    77 '#max' => 32,
    77 '#max' => max((int) ini_get('precision'), 10),
  • 84 84 '#type' => 'number',
    85 85 '#title' => $this->t('Scale', [], ['context' => 'decimal places']),
    86 86 '#min' => 0,
    87 '#max' => 10,
    87 '#max' => max((int) ini_get('precision'), 10),
  • Joshua Sedler added 241 commits

    added 241 commits

    • dc6eff4d...be7c988b - 231 commits from branch project:11.x
    • 4f17ac23 - Apply rerolled patch "2230909-309.patch" by @szeidler
    • 777d626a - Add update hook
    • 5a563aa0 - Update field_update hook name
    • 905d0363 - Only update storage entity settings if they changed
    • f8df831c - Set "providerNormalize" and "provideCountSignificantDecimals" static
    • 2fdde162 - Fix typo in update hook, cast string values and adjust "scale" max value
    • cb38cde7 - Update field storage schema through "updateFieldStorageDefinition")
    • 5aea096e - Update file NumberTest.php
    • 060b3644 - Update file NumberTest.php
    • 2114bc26 - Update file field.install

    Compare with previous version

  • Joshua Sedler added 8 commits

    added 8 commits

    • 4a41e572 - 1 commit from branch project:11.x
    • 7d9bbb4c - Apply rerolled patch "2230909-309.patch" by @szeidler
    • f5a65a8a - Add update hook
    • d78eb5ca - Update field_update hook name
    • a0104bf8 - Only update storage entity settings if they changed
    • 51341d63 - Set "providerNormalize" and "provideCountSignificantDecimals" static
    • 884ec874 - Fix typo in update hook, cast string values and adjust "scale" max value
    • b4798042 - Update field storage schema through "updateFieldStorageDefinition")

    Compare with previous version

  • Julian Pustkuchen added 445 commits

    added 445 commits

    Compare with previous version

  • added 1 commit

    • bba3f160 - Added $decimalFieldStorageEntity->setSetting('column_changes_handled', TRUE);...

    Compare with previous version

  • Please register or sign in to reply
    Loading