function FieldNumericTest::testFieldNumeric

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

Tests the Numeric handler with different settings.

@dataProvider providerTestFieldNumeric

File

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

Class

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

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFieldNumeric($field_settings, $values, $expected_values) {
    $view = Views::getView('test_view');
    $view->setDisplay();
    if (!empty($field_settings)) {
        $view->displayHandlers
            ->get('default')
            ->overrideOption('fields', [
            'age' => $field_settings,
        ]);
    }
    $this->executeView($view);
    foreach ($values as $key => $value) {
        $view->result[0]->views_test_data_age = $value;
        $this->assertSame($expected_values[$key], $view->field['age']
            ->advancedRender($view->result[0]));
    }
}

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