You are here

public function FieldItemNormalizerTest::testNormalizeFieldItemWithoutProperties in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Kernel/Normalizer/FieldItemNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\FieldItemNormalizerTest::testNormalizeFieldItemWithoutProperties()

Tests a field item that has no properties.

@covers ::normalize

File

core/modules/jsonapi/tests/src/Kernel/Normalizer/FieldItemNormalizerTest.php, line 60

Class

FieldItemNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\FieldItemNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

public function testNormalizeFieldItemWithoutProperties() : void {
  $item = $this
    ->prophesize(FieldItemInterface::class);
  $item
    ->getProperties(TRUE)
    ->willReturn([]);
  $item
    ->getValue()
    ->willReturn('Direct call to getValue');
  $result = $this->normalizer
    ->normalize($item
    ->reveal(), 'api_json');
  assert($result instanceof CacheableNormalization);
  $this
    ->assertSame('Direct call to getValue', $result
    ->getNormalization());
}