You are here

public function ConfigEntityNormalizerTest::testNormalize in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ConfigEntityNormalizerTest::testNormalize()
  2. 9 core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ConfigEntityNormalizerTest::testNormalize()

Tests the normalize() method.

@covers ::normalize

File

core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php, line 24

Class

ConfigEntityNormalizerTest
@coversDefaultClass \Drupal\serialization\Normalizer\ConfigEntityNormalizer @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function testNormalize() {
  $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')
    ->will($this
    ->returnValue($test_export_properties));
  $this
    ->assertSame([
    'test' => 'test',
  ], $normalizer
    ->normalize($config_entity));
}