You are here

public function RedirectAPITest::testSortRecursive in Redirect 8

Test redirect_sort_recursive().

File

tests/src/Kernel/RedirectAPITest.php, line 185

Class

RedirectAPITest
Redirect entity and redirect API test coverage.

Namespace

Drupal\Tests\redirect\Kernel

Code

public function testSortRecursive() {
  $test_cases = [
    [
      'input' => [
        'b' => 'aa',
        'c' => [
          'c2' => 'aa',
          'c1' => 'aa',
        ],
        'a' => 'aa',
      ],
      'expected' => [
        'a' => 'aa',
        'b' => 'aa',
        'c' => [
          'c1' => 'aa',
          'c2' => 'aa',
        ],
      ],
      'callback' => 'ksort',
    ],
  ];
  foreach ($test_cases as $index => $test_case) {
    $output = $test_case['input'];
    redirect_sort_recursive($output, $test_case['callback']);
    $this
      ->assertIdentical($output, $test_case['expected']);
  }
}