You are here

public function DecimalFractionTest::decimalFractionDataProvider in Fraction 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/process/DecimalFractionTest.php \Drupal\Tests\fraction\Unit\process\DecimalFractionTest::decimalFractionDataProvider()

Data provider for testDecimalFraction().

Return value

array Array of input values and expected output values.

File

tests/src/Unit/process/DecimalFractionTest.php, line 41

Class

DecimalFractionTest
Tests the decimal fraction process plugin.

Namespace

Drupal\Tests\fraction\Unit\process

Code

public function decimalFractionDataProvider() {
  return [
    'basic decimal' => [
      'input' => 0.5,
      'expected_output' => [
        'numerator' => '5',
        'denominator' => '10',
      ],
    ],
    'negative decimal' => [
      'input' => -1,
      'expected_output' => [
        'numerator' => '-1',
        'denominator' => '1',
      ],
    ],
    'zero value' => [
      'input' => 0,
      'expected_output' => [
        'numerator' => '0',
        'denominator' => '1',
      ],
    ],
    'empty string' => [
      'input' => '',
      'expected_output' => [
        'numerator' => '',
        'denominator' => '',
      ],
    ],
    'string' => [
      'input' => 'test',
      'expected_output' => [
        'numerator' => '',
        'denominator' => '',
      ],
    ],
  ];
}