function LanguageUnitTest::providerTestSortArrayOfLanguages

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::providerTestSortArrayOfLanguages()
  2. 8.9.x core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::providerTestSortArrayOfLanguages()
  3. 10 core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php \Drupal\Tests\Core\Language\LanguageUnitTest::providerTestSortArrayOfLanguages()

Provides data for testSortArrayOfLanguages.

Return value

array An array of test data.

File

core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php, line 108

Class

LanguageUnitTest
@coversDefaultClass \Drupal\Core\Language\Language @group Language

Namespace

Drupal\Tests\Core\Language

Code

public static function providerTestSortArrayOfLanguages() {
    $language9A = new Language([
        'id' => 'dd',
        'name' => 'A',
        'weight' => 9,
    ]);
    $language10A = new Language([
        'id' => 'ee',
        'name' => 'A',
        'weight' => 10,
    ]);
    $language10B = new Language([
        'id' => 'ff',
        'name' => 'B',
        'weight' => 10,
    ]);
    return [
        // Set up data set #0, already ordered by weight.
[
            // Set the data.
[
                $language9A->getId() => $language9A,
                $language10B->getId() => $language10B,
            ],
            // Set the expected key order.
[
                $language9A->getId(),
                $language10B->getId(),
            ],
        ],
        // Set up data set #1, out of order by weight.
[
            [
                $language10B->getId() => $language10B,
                $language9A->getId() => $language9A,
            ],
            [
                $language9A->getId(),
                $language10B->getId(),
            ],
        ],
        // Set up data set #2, tied by weight, already ordered by name.
[
            [
                $language10A->getId() => $language10A,
                $language10B->getId() => $language10B,
            ],
            [
                $language10A->getId(),
                $language10B->getId(),
            ],
        ],
        // Set up data set #3, tied by weight, out of order by name.
[
            [
                $language10B->getId() => $language10B,
                $language10A->getId() => $language10A,
            ],
            [
                $language10A->getId(),
                $language10B->getId(),
            ],
        ],
    ];
}

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