function NumericFilterTest::provideAcceptExposedInput

Same name and namespace in other branches
  1. 10 core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php \Drupal\Tests\views\Unit\Plugin\views\filter\NumericFilterTest::provideAcceptExposedInput()

Data provider for testAcceptExposedInput test.

Return value

array[] The test cases.

File

core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php, line 47

Class

NumericFilterTest
@coversDefaultClass \Drupal\views\Plugin\views\filter\NumericFilter[[api-linebreak]] @group Views

Namespace

Drupal\Tests\views\Unit\Plugin\views\filter

Code

public static function provideAcceptExposedInput() : array {
  // [$options, $value, $expected]
  return [
    // Not exposed by default. Bypass parsing and return true.
'defaults' => [
      [],
      [],
      TRUE,
    ],
    'exposed but not configured' => [
      [
        'exposed' => TRUE,
        'expose' => [],
        'group_info' => [],
      ],
      [],
      FALSE,
    ],
    // Exposed but not grouped.
'exposed not grouped - missing value' => [
      [
        'exposed' => TRUE,
        'expose' => [
          'identifier' => 'test_id',
        ],
      ],
      [],
      TRUE,
    ],
    'exposed not grouped - wrong group config' => [
      [
        'exposed' => TRUE,
        'group_info' => [
          'identifier' => 'test_id',
        ],
      ],
      [
        'test_id' => [
          'value' => 1,
        ],
      ],
      // Wrong identifier configured.
FALSE,
    ],
    'exposed not grouped' => [
      [
        'exposed' => TRUE,
        'expose' => [
          'identifier' => 'test_id',
        ],
      ],
      [
        'test_id' => [
          'value' => 1,
        ],
      ],
      TRUE,
    ],
    // Exposed and grouped.
'exposed grouped - missing value' => [
      [
        'exposed' => TRUE,
        'is_grouped' => TRUE,
        'group_info' => [
          'identifier' => 'test_id',
        ],
      ],
      [],
      TRUE,
    ],
    'exposed grouped - wrong group config' => [
      [
        'exposed' => TRUE,
        'is_grouped' => TRUE,
        'expose' => [
          'identifier' => 'test_id',
        ],
      ],
      [
        'test_id' => [
          'value' => 1,
        ],
      ],
      FALSE,
    ],
    'exposed grouped' => [
      [
        'exposed' => TRUE,
        'is_grouped' => TRUE,
        'group_info' => [
          'identifier' => 'test_id',
        ],
      ],
      [
        'test_id' => [
          'value' => 1,
        ],
      ],
      TRUE,
    ],
  ];
}

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