function ConfigEntityNormalizerTest::testNormalize

Same name and namespace in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ConfigEntityNormalizerTest::testNormalize()
  2. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ConfigEntityNormalizerTest::testNormalize()
  3. 11.x 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 26

Class

ConfigEntityNormalizerTest
@coversDefaultClass \Drupal\serialization\Normalizer\ConfigEntityNormalizer[[api-linebreak]] @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function testNormalize() : void {
  $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));
}

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