function FieldItemNormalizerTest::testNormalizeFieldItemWithoutProperties

Same name in other branches
  1. 10 core/modules/jsonapi/tests/src/Kernel/Normalizer/FieldItemNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\FieldItemNormalizerTest::testNormalizeFieldItemWithoutProperties()
  2. 11.x 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());
}

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