function SortArrayTest::testSortByWeightElement

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

Tests SortArray::sortByWeightElement() input against expected output.

@dataProvider providerSortByWeightElement @covers ::sortByWeightElement @covers ::sortByKeyInt

Parameters

array $a: The first input array for the SortArray::sortByWeightElement() method.

array $b: The second input array for the SortArray::sortByWeightElement().

int $expected: The expected output from calling the method.

File

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

Class

SortArrayTest
Tests the SortArray component.

Namespace

Drupal\Tests\Component\Utility

Code

public function testSortByWeightElement($a, $b, $expected) : void {
    $result = SortArray::sortByWeightElement($a, $b);
    $this->assertBothNegativePositiveOrZero($expected, $result);
}

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