public function SortArrayTest::providerSortByWeightElement in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php \Drupal\Tests\Component\Utility\SortArrayTest::providerSortByWeightElement()
- 9 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 45
Class
- SortArrayTest
- Tests the SortArray component.
Namespace
Drupal\Tests\Component\UtilityCode
public 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;
}