You are here

public function TwigConvertTest::providerTestBooleanValues in Twig Tools 8

Provides test data for testBooleanValue.

Return value

array An array of test data and their boolean equivalents.

File

tests/src/Unit/TwigConvertTest.php, line 48

Class

TwigConvertTest
Tests to ensure conversions filters work correctly.

Namespace

Drupal\Tests\twig_tools\Unit

Code

public function providerTestBooleanValues() {
  return [
    [
      "{{ 0|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
    [
      "{{ 42|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ 0.0|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
    [
      "{{ -1|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ 4.2|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ ''|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
    [
      "{{ 'string'|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ 'true'|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ 'false'|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ '0'|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
    [
      "{{ '1'|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ [1, 2]|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ [0]|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ [0, 0]|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ []|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
    [
      "{{ false|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
    [
      "{{ true|boolean is same as (false) ? 'false' : 'true' }}",
      "true",
    ],
    [
      "{{ null|boolean is same as (false) ? 'false' : 'true' }}",
      "false",
    ],
  ];
}