function BaseFieldOverrideTest::testGetClass

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php \Drupal\KernelTests\Core\Field\Entity\BaseFieldOverrideTest::testGetClass()
  2. 10 core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php \Drupal\KernelTests\Core\Field\Entity\BaseFieldOverrideTest::testGetClass()
  3. 11.x 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(), '\\'));
}

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