function FieldUiTableTest::providerTestReduceOrder

Same name in other branches
  1. 9 core/modules/field_ui/tests/src/Unit/FieldUiTableTest.php \Drupal\Tests\field_ui\Unit\FieldUiTableTest::providerTestReduceOrder()
  2. 11.x core/modules/field_ui/tests/src/Unit/FieldUiTableTest.php \Drupal\Tests\field_ui\Unit\FieldUiTableTest::providerTestReduceOrder()

Provides test data for testReduceOrder().

File

core/modules/field_ui/tests/src/Unit/FieldUiTableTest.php, line 28

Class

FieldUiTableTest
@coversDefaultClass \Drupal\field_ui\Element\FieldUiTable

Namespace

Drupal\Tests\field_ui\Unit

Code

public static function providerTestReduceOrder() {
    return [
        'Flat' => [
            'array' => [
                [
                    'name' => 'foo',
                ],
                [
                    'name' => 'bar',
                ],
                [
                    'name' => 'baz',
                ],
            ],
            'expected' => [
                'foo',
                'bar',
                'baz',
            ],
        ],
        'Nested' => [
            'array' => [
                [
                    'name' => 'foo',
                    'children' => [
                        [
                            'name' => 'bar',
                            'weight' => 0,
                        ],
                        [
                            'name' => 'baz',
                            'weight' => -1,
                        ],
                    ],
                ],
                [
                    'name' => 'biz',
                ],
            ],
            'expected' => [
                'foo',
                'baz',
                'bar',
                'biz',
            ],
        ],
        'Nested no name key' => [
            'array' => [
                [
                    'children' => [
                        [
                            'name' => 'foo',
                            'weight' => -1,
                        ],
                        [
                            'name' => 'bar',
                            'weight' => 1,
                        ],
                        [
                            'name' => 'baz',
                            'weight' => 0,
                        ],
                    ],
                ],
                [
                    'name' => 'biz',
                ],
            ],
            'expected' => [
                'foo',
                'baz',
                'bar',
                'biz',
            ],
        ],
    ];
}

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