ConfigEntityNormalizer example

$test_export_properties = [
      'test' => 'test',
      '_core' => [
        'default_config_hash' => $this->randomMachineName(),
        $this->randomMachineName() => 'some random key',
      ],
    ];

    $entity_field_manager = $this->createMock(EntityFieldManagerInterface::class);
    $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
    $entity_type_repository = $this->createMock(EntityTypeRepositoryInterface::class);
    $normalizer = new ConfigEntityNormalizer(
      $entity_type_manager,
      $entity_type_repository,
      $entity_field_manager
    );

    $config_entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
    $config_entity->expects($this->once())
      ->method('toArray')
      ->willReturn($test_export_properties);

    $this->assertSame(['test' => 'test']$normalizer->normalize($config_entity));
  }
Home | Imprint | This part of the site doesn't use cookies.