You are here

public function WebformOptionsHelperTest::testRange in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Unit/Utility/WebformOptionsHelperTest.php \Drupal\Tests\webform\Unit\Utility\WebformOptionsHelperTest::testRange()

Tests WebformOptionsHelper::range().

@dataProvider providerRange

Parameters

array $element: The array to run through WebformOptionsHelper::range().

string $expected: The expected result from calling the function.

See also

WebformOptionsHelper::range()

File

tests/src/Unit/Utility/WebformOptionsHelperTest.php, line 122

Class

WebformOptionsHelperTest
Tests webform options utility.

Namespace

Drupal\Tests\webform\Unit\Utility

Code

public function testRange(array $element, $expected) {
  $element += [
    '#min' => 1,
    '#max' => 100,
    '#step' => 1,
    '#pad_length' => NULL,
    '#pad_str' => 0,
  ];
  $result = WebformOptionsHelper::range($element['#min'], $element['#max'], $element['#step'], $element['#pad_length'], $element['#pad_str']);
  $this
    ->assertEquals($expected, $result);
}