You are here

public function EntityReferenceFieldItemNormalizerTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php, line 48
Contains \Drupal\Tests\serialization\Unit\Normalizer\EntityReferenceFieldItemNormalizerTest.

Class

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

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function setUp() {
  $this->normalizer = new EntityReferenceFieldItemNormalizer();
  $this->serializer = $this
    ->prophesize(Serializer::class);

  // Set up the serializer to return an entity property.
  $this->serializer
    ->normalize(Argument::cetera())
    ->willReturn([
    'value' => 'test',
  ]);
  $this->normalizer
    ->setSerializer($this->serializer
    ->reveal());
  $this->fieldItem = $this
    ->prophesize(EntityReferenceItem::class);
  $this->fieldItem
    ->getIterator()
    ->willReturn(new \ArrayIterator([
    'target_id' => [],
  ]));
}