public function SortArrayTest::providerSortByWeightProperty in Drupal 9
Same name and namespace in other branches
- 8 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 121
Class
- SortArrayTest
- Tests the SortArray component.
Namespace
Drupal\Tests\Component\UtilityCode
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;
}