You are here

public function BaseFieldOverrideTest::testGetClass in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php \Drupal\KernelTests\Core\Field\Entity\BaseFieldOverrideTest::testGetClass()
  2. 9 core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php \Drupal\KernelTests\Core\Field\Entity\BaseFieldOverrideTest::testGetClass()

@covers ::getClass

@dataProvider getClassTestCases

File

core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php, line 41

Class

BaseFieldOverrideTest
@coversDefaultClass \Drupal\Core\Field\Entity\BaseFieldOverride @group Field

Namespace

Drupal\KernelTests\Core\Field\Entity

Code

public function testGetClass($field_type, $base_field_class, $expected_override_class) {
  $base_field = BaseFieldDefinition::create($field_type)
    ->setName('Test Field')
    ->setTargetEntityTypeId('entity_test');
  if ($base_field_class) {
    $base_field
      ->setClass($base_field_class);
  }
  $override = BaseFieldOverride::createFromBaseFieldDefinition($base_field, 'test_bundle');
  $this
    ->assertEquals($expected_override_class, ltrim($override
    ->getClass(), '\\'));
}