You are here

public function NestedArrayTest::providerTestFilter in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::providerTestFilter()

File

core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php, line 265

Class

NestedArrayTest
@coversDefaultClass \Drupal\Component\Utility\NestedArray @group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public function providerTestFilter() {
  $data = [];
  $data['1d-array'] = [
    [
      0,
      1,
      '',
      TRUE,
    ],
    NULL,
    [
      1 => 1,
      3 => TRUE,
    ],
  ];
  $data['1d-array-callable'] = [
    [
      0,
      1,
      '',
      TRUE,
    ],
    function ($element) {
      return $element === '';
    },
    [
      2 => '',
    ],
  ];
  $data['2d-array'] = [
    [
      [
        0,
        1,
        '',
        TRUE,
      ],
      [
        0,
        1,
        2,
        3,
      ],
    ],
    NULL,
    [
      0 => [
        1 => 1,
        3 => TRUE,
      ],
      1 => [
        1 => 1,
        2 => 2,
        3 => 3,
      ],
    ],
  ];
  $data['2d-array-callable'] = [
    [
      [
        0,
        1,
        '',
        TRUE,
      ],
      [
        0,
        1,
        2,
        3,
      ],
    ],
    function ($element) {
      return is_array($element) || $element === 3;
    },
    [
      0 => [],
      1 => [
        3 => 3,
      ],
    ],
  ];
  return $data;
}