function FieldNumericTest::providerTestFieldNumeric

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FieldNumericTest.php \Drupal\Tests\views\Kernel\Handler\FieldNumericTest::providerTestFieldNumeric()
  2. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldNumericTest.php \Drupal\Tests\views\Kernel\Handler\FieldNumericTest::providerTestFieldNumeric()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FieldNumericTest.php \Drupal\Tests\views\Kernel\Handler\FieldNumericTest::providerTestFieldNumeric()

Data provider for testFieldNumeric.

Return value

array The data set containing field settings, values to set and expected values.

File

core/modules/views/tests/src/Kernel/Handler/FieldNumericTest.php, line 52

Class

FieldNumericTest
Tests the core Drupal\views\Plugin\views\field\Numeric handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public static function providerTestFieldNumeric() {
    return [
        'no-formatting' => [
            [],
            [
                0,
                0.1234,
                -0.1234,
                1000.1234,
                -1000.1234,
            ],
            [
                '0',
                '0.1234',
                '-0.1234',
                '1,000.1234',
                '-1,000.1234',
            ],
        ],
        'precision_2-hide_empty-hide_zero' => [
            [
                'hide_empty' => TRUE,
                'precision' => 2,
                'set_precision' => TRUE,
                'empty_zero' => TRUE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
            ],
            [
                0,
                0.1234,
                -0.1234,
                1000.1234,
                -1000.1234,
                0.0001,
                -0.0001,
                NULL,
                '',
            ],
            [
                '',
                '0.12',
                '-0.12',
                '1,000.12',
                '-1,000.12',
                '',
                '',
                '',
                '',
            ],
        ],
        'decimal-separator' => [
            [
                'hide_empty' => TRUE,
                'decimal' => ',',
                'separator' => '.',
                'empty_zero' => TRUE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
            ],
            [
                0.1234,
                -0.1234,
                1000.1234,
                -1000.1234,
            ],
            [
                '0,1234',
                '-0,1234',
                '1.000,1234',
                '-1.000,1234',
            ],
        ],
        'precision_2-no_separator' => [
            [
                'hide_empty' => TRUE,
                'precision' => 2,
                'set_precision' => TRUE,
                'decimal' => ',',
                'separator' => '',
                'empty_zero' => TRUE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
            ],
            [
                1234,
                1234.01,
                -1234,
                -1234.01,
            ],
            [
                '1234,00',
                '1234,01',
                '-1234,00',
                '-1234,01',
            ],
        ],
        'precision_0-no_separator' => [
            [
                'hide_empty' => TRUE,
                'precision' => 0,
                'set_precision' => TRUE,
                'separator' => '',
                'empty_zero' => TRUE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
            ],
            [
                1234,
                1234.01,
                -1234,
                -1234.01,
            ],
            [
                '1234',
                '1234',
                '-1234',
                '-1234',
            ],
        ],
        'precision_0-hide_empty-zero_empty' => [
            [
                'hide_empty' => TRUE,
                'precision' => 0,
                'set_precision' => TRUE,
                'empty_zero' => TRUE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
                'prefix' => 'test: ',
            ],
            [
                0,
                0.1234,
                -0.1234,
                1000.1234,
                -1000.1234,
            ],
            [
                '',
                '',
                '',
                'test: 1,000',
                'test: -1,000',
            ],
        ],
        'precision_0-hide_empty-not_zero_empty' => [
            [
                'hide_empty' => TRUE,
                'precision' => 0,
                'set_precision' => TRUE,
                'empty_zero' => FALSE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
                'prefix' => '',
            ],
            [
                0,
                0.1234,
                -0.1234,
            ],
            [
                '0',
                '0',
                '0',
            ],
        ],
        'precision_2-hide_empty-not_zero_empty' => [
            [
                'hide_empty' => TRUE,
                'precision' => 2,
                'set_precision' => TRUE,
                'empty_zero' => FALSE,
                'id' => 'age',
                'table' => 'views_test_data',
                'field' => 'age',
                'relationship' => 'none',
                'prefix' => '',
            ],
            [
                0,
                0.001234,
                -0.001234,
                NULL,
            ],
            [
                '0.00',
                '0.00',
                '0.00',
                '',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.