function NestedArrayTest::providerTestFilter

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::providerTestFilter()
  2. 10 core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::providerTestFilter()
  3. 11.x 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 <a href="/api/drupal/core%21lib%21Drupal%21Component%21Utility%21NestedArray.php/class/NestedArray/9" title="Provides helpers to perform operations on nested arrays and array keys of variable depth." class="local">\Drupal\Component\Utility\NestedArray</a> @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;
}

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