function NestedArrayTest::providerTestFilter

Same name in other branches
  1. 9 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 \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;
}

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