function SortArrayTest::providerSortByWeightProperty

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

Data provider for SortArray::sortByWeightProperty().

Return value

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

See also

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

File

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

Class

SortArrayTest
Tests the SortArray component.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerSortByWeightProperty() {
    $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.