You are here

public function SortArrayTest::providerSortByWeightProperty in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 126
Contains \Drupal\Tests\Component\Utility\SortArrayTest.

Class

SortArrayTest
Tests the SortArray component.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerSortByWeightProperty() {
  $tests = array();

  // Weights set and equal.
  $tests[] = array(
    array(
      '#weight' => 1,
    ),
    array(
      '#weight' => 1,
    ),
    0,
  );

  // Weights set and $a is less (lighter) than $b.
  $tests[] = array(
    array(
      '#weight' => 1,
    ),
    array(
      '#weight' => 2,
    ),
    -1,
  );

  // Weights set and $a is greater (heavier) than $b.
  $tests[] = array(
    array(
      '#weight' => 2,
    ),
    array(
      '#weight' => 1,
    ),
    1,
  );

  // Weights not set.
  $tests[] = array(
    array(),
    array(),
    0,
  );

  // Weights for $b not set.
  $tests[] = array(
    array(
      '#weight' => 1,
    ),
    array(),
    1,
  );

  // Weights for $a not set.
  $tests[] = array(
    array(),
    array(
      '#weight' => 1,
    ),
    -1,
  );
  return $tests;
}