You are here

public function SortNormalizerTest::denormalizeProvider in JSON:API 8

Provides a suite of shortcut sort pamaters and their expected expansions.

File

tests/src/Kernel/Normalizer/SortNormalizerTest.php, line 61

Class

SortNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\SortNormalizer @group jsonapi @group jsonapi_normalizers @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

public function denormalizeProvider() {
  return [
    [
      'lorem',
      [
        [
          'path' => 'foo',
          'direction' => 'ASC',
          'langcode' => NULL,
        ],
      ],
    ],
    [
      '-lorem',
      [
        [
          'path' => 'foo',
          'direction' => 'DESC',
          'langcode' => NULL,
        ],
      ],
    ],
    [
      '-lorem,ipsum',
      [
        [
          'path' => 'foo',
          'direction' => 'DESC',
          'langcode' => NULL,
        ],
        [
          'path' => 'bar',
          'direction' => 'ASC',
          'langcode' => NULL,
        ],
      ],
    ],
    [
      '-lorem,-ipsum',
      [
        [
          'path' => 'foo',
          'direction' => 'DESC',
          'langcode' => NULL,
        ],
        [
          'path' => 'bar',
          'direction' => 'DESC',
          'langcode' => NULL,
        ],
      ],
    ],
    [
      [
        [
          'path' => 'lorem',
          'langcode' => NULL,
        ],
        [
          'path' => 'ipsum',
          'langcode' => 'ca',
        ],
        [
          'path' => 'dolor',
          'direction' => 'ASC',
          'langcode' => 'ca',
        ],
        [
          'path' => 'sit',
          'direction' => 'DESC',
          'langcode' => 'ca',
        ],
      ],
      [
        [
          'path' => 'foo',
          'direction' => 'ASC',
          'langcode' => NULL,
        ],
        [
          'path' => 'bar',
          'direction' => 'ASC',
          'langcode' => 'ca',
        ],
        [
          'path' => 'baz',
          'direction' => 'ASC',
          'langcode' => 'ca',
        ],
        [
          'path' => 'qux',
          'direction' => 'DESC',
          'langcode' => 'ca',
        ],
      ],
    ],
  ];
}