You are here

public function BetterExposedFiltersHelperUnitTest::providerTestSortOptions in Better Exposed Filters 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Unit/BetterExposedFiltersHelperUnitTest.php \Drupal\Tests\better_exposed_filters\Unit\BetterExposedFiltersHelperUnitTest::providerTestSortOptions()

Data provider for ::testSortOptions.

File

tests/src/Unit/BetterExposedFiltersHelperUnitTest.php, line 219

Class

BetterExposedFiltersHelperUnitTest
Tests the helper functions for better exposed filters.

Namespace

Drupal\Tests\better_exposed_filters\Unit

Code

public function providerTestSortOptions() {

  // Data providers run before ::setUp. We rely on the stringTranslationTrait
  // for some of our option values so call it here instead.
  $this->stringTranslation = $this
    ->getStringTranslationStub();
  $data = [];

  // List of strings.
  $data[] = [
    [
      'e',
      'a',
      'b',
      'd',
      'c',
    ],
    [
      'a',
      'b',
      'c',
      'd',
      'e',
    ],
  ];

  // List of mixed values.
  $data[] = [
    [
      '1',
      'a',
      '2',
      'b',
      '3',
    ],
    [
      '1',
      '2',
      '3',
      'a',
      'b',
    ],
  ];

  // List of taxonomy terms.
  $data[] = [
    [
      (object) [
        'option' => [
          555 => 'term5',
        ],
      ],
      (object) [
        'option' => [
          222 => 'term2',
        ],
      ],
      (object) [
        'option' => [
          444 => 'term4',
        ],
      ],
      (object) [
        'option' => [
          333 => 'term3',
        ],
      ],
      (object) [
        'option' => [
          111 => 'term1',
        ],
      ],
    ],
    [
      (object) [
        'option' => [
          111 => 'term1',
        ],
      ],
      (object) [
        'option' => [
          222 => 'term2',
        ],
      ],
      (object) [
        'option' => [
          333 => 'term3',
        ],
      ],
      (object) [
        'option' => [
          444 => 'term4',
        ],
      ],
      (object) [
        'option' => [
          555 => 'term5',
        ],
      ],
    ],
  ];
  return $data;
}