function SortArrayTest::providerSortByWeightElement

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php \Drupal\Tests\Component\Utility\SortArrayTest::providerSortByWeightElement()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php \Drupal\Tests\Component\Utility\SortArrayTest::providerSortByWeightElement()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php \Drupal\Tests\Component\Utility\SortArrayTest::providerSortByWeightElement()

Data provider for SortArray::sortByWeightElement().

Return value

array An array of tests, matching the parameter inputs for testSortByWeightElement.

See also

\Drupal\Tests\Component\Utility\SortArrayTest::testSortByWeightElement()

File

core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php, line 47

Class

SortArrayTest
Tests the SortArray component.

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerSortByWeightElement() {
    $tests = [];
    // Weights set and equal.
    $tests[] = [
        [
            'weight' => 1,
        ],
        [
            'weight' => 1,
        ],
        0,
    ];
    // Weights set and $a is less (lighter) than $b.
    $tests[] = [
        [
            'weight' => 1,
        ],
        [
            'weight' => 2,
        ],
        -1,
    ];
    // Weights set and $a is greater (heavier) than $b.
    $tests[] = [
        [
            'weight' => 2,
        ],
        [
            'weight' => 1,
        ],
        1,
    ];
    // Weights not set.
    $tests[] = [
        [],
        [],
        0,
    ];
    // Weights for $b not set.
    $tests[] = [
        [
            'weight' => 1,
        ],
        [],
        1,
    ];
    // Weights for $a not set.
    $tests[] = [
        [],
        [
            'weight' => 1,
        ],
        -1,
    ];
    return $tests;
}

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