You are here

abstract class NormalizerTestBase in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php \Drupal\Tests\serialization\Kernel\NormalizerTestBase
  2. 9 core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php \Drupal\Tests\serialization\Kernel\NormalizerTestBase

Helper base class to set up some test fields for serialization testing.

Hierarchy

Expanded class hierarchy of NormalizerTestBase

File

core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php, line 12

Namespace

Drupal\Tests\serialization\Kernel
View source
abstract class NormalizerTestBase extends KernelTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'serialization',
    'system',
    'field',
    'entity_test',
    'text',
    'filter',
    'user',
  ];
  protected function setUp() : void {
    parent::setUp();
    $this
      ->installEntitySchema('entity_test_mulrev');
    $this
      ->installEntitySchema('user');
    $this
      ->installConfig([
      'field',
    ]);
    \Drupal::moduleHandler()
      ->invoke('rest', 'install');

    // Auto-create a field for testing.
    FieldStorageConfig::create([
      'entity_type' => 'entity_test_mulrev',
      'field_name' => 'field_test_text',
      'type' => 'text',
      'cardinality' => 1,
      'translatable' => FALSE,
    ])
      ->save();
    FieldConfig::create([
      'entity_type' => 'entity_test_mulrev',
      'field_name' => 'field_test_text',
      'bundle' => 'entity_test_mulrev',
      'label' => 'Test text-field',
      'widget' => [
        'type' => 'text_textfield',
        'weight' => 0,
      ],
    ])
      ->save();
  }

}

Members