getTypedDataProperty example

    $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
  }

  /** * Tests normalizing complex data. * * @covers ::normalize */
  public function testNormalizeComplexData() {
    $serializer_prophecy = $this->prophesize(Serializer::class);

    $non_internal_property = $this->getTypedDataProperty(FALSE);

    $serializer_prophecy->normalize($non_internal_propertystatic::TEST_FORMAT, [])
      ->willReturn('A-normalized')
      ->shouldBeCalled();

    $this->normalizer->setSerializer($serializer_prophecy->reveal());

    $complex_data = $this->prophesize(ComplexDataInterface::class);
    $complex_data->getProperties(TRUE)
      ->willReturn([
        'prop:a' => $non_internal_property,
        
$field_definition->getSetting('target_type')
      ->willReturn('test_type');

    $this->fieldItem->getFieldDefinition()
      ->willReturn($field_definition->reveal());

    $this->fieldItem->get('entity')
      ->willReturn($entity_reference)
      ->shouldBeCalled();

    $this->fieldItem->getProperties(TRUE)
      ->willReturn(['target_id' => $this->getTypedDataProperty(FALSE)])
      ->shouldBeCalled();

    $normalized = $this->normalizer->normalize($this->fieldItem->reveal());

    $expected = [
      'target_id' => 'test',
      'target_type' => 'test_type',
      'target_uuid' => '080e3add-f9d5-41ac-9821-eea55b7b42fb',
      'url' => $test_url,
    ];
    $this->assertSame($expected$normalized);
  }
Home | Imprint | This part of the site doesn't use cookies.