You are here

public function FieldNormalizerValueTest::testRasterizeValue in JSON:API 8

@covers ::rasterizeValue @covers ::__construct @dataProvider rasterizeValueProvider

File

tests/src/Unit/Normalizer/Value/FieldNormalizerValueTest.php, line 48

Class

FieldNormalizerValueTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\Value\FieldNormalizerValue @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\Normalizer\Value

Code

public function testRasterizeValue($values, $cardinality, $expected) {
  $object = new FieldNormalizerValue(AccessResult::allowed()
    ->cachePerUser()
    ->addCacheTags([
    'field:foo',
  ]), $values, $cardinality, 'attributes');
  $this
    ->assertEquals($expected, $object
    ->rasterizeValue());
  $this
    ->assertSame([
    'ccfoo',
    'user',
  ], $object
    ->getCacheContexts());
  $this
    ->assertSame([
    'ctfoo',
    'field:foo',
  ], $object
    ->getCacheTags());
  $this
    ->assertSame(15, $object
    ->getCacheMaxAge());
}