function EntityReferenceFieldItemNormalizerTest::testDenormalizeWithEmptyUuid

Same name in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest::testDenormalizeWithEmptyUuid()
  2. 11.x core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest::testDenormalizeWithEmptyUuid()

@covers ::denormalize

File

core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php, line 400

Class

EntityReferenceFieldItemNormalizerTest
@coversDefaultClass \Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function testDenormalizeWithEmptyUuid() : void {
    $this->expectException(InvalidArgumentException::class);
    $this->expectExceptionMessage('If provided "target_uuid" cannot be empty for field "field_reference".');
    $data = [
        'target_id' => 'test',
        'target_type' => 'test_type',
        'target_uuid' => '',
    ];
    $this->fieldItem
        ->getName()
        ->willReturn('field_reference')
        ->shouldBeCalled();
    $this->assertDenormalize($data);
}

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