NormalizerTestBase.php

Same filename in this branch
  1. 8.9.x core/modules/serialization/src/Tests/NormalizerTestBase.php
  2. 8.9.x core/modules/hal/tests/src/Kernel/NormalizerTestBase.php
Same filename in other branches
  1. 9 core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php
  2. 9 core/modules/hal/tests/src/Kernel/NormalizerTestBase.php
  3. 10 core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php
  4. 11.x core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php

Namespace

Drupal\Tests\serialization\Kernel

File

core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php

View source
<?php

namespace Drupal\Tests\serialization\Kernel;

use Drupal\KernelTests\KernelTestBase;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;

/**
 * Helper base class to set up some test fields for serialization testing.
 */
abstract class NormalizerTestBase extends KernelTestBase {
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    public static $modules = [
        'serialization',
        'system',
        'field',
        'entity_test',
        'text',
        'filter',
        'user',
    ];
    protected function setUp() {
        parent::setUp();
        $this->installEntitySchema('entity_test_mulrev');
        $this->installEntitySchema('user');
        $this->installConfig([
            'field',
        ]);
        \Drupal::service('router.builder')->rebuild();
        \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();
    }

}

Classes

Title Deprecated Summary
NormalizerTestBase Helper base class to set up some test fields for serialization testing.

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