function BaseFieldOverrideTest::testInheritedProperties

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php \Drupal\KernelTests\Core\Field\Entity\BaseFieldOverrideTest::testInheritedProperties()

Tests that some properties are inherited from the BaseFieldDefinition.

@covers ::isReadOnly @covers ::isComputed @covers ::isInternal @covers ::getUniqueIdentifier

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Field\Entity

Code

public function testInheritedProperties() : void {
    $base_field = BaseFieldDefinition::create('string')->setName('Test Field')
        ->setTargetEntityTypeId('entity_test')
        ->setReadOnly(TRUE)
        ->setInternal(TRUE)
        ->setComputed(FALSE);
    // Getters of the properties to check.
    $methods = [
        'getUniqueIdentifier',
        'getClass',
        'isComputed',
        'isReadOnly',
        'isInternal',
    ];
    $override = BaseFieldOverride::createFromBaseFieldDefinition($base_field, 'test_bundle');
    foreach ($methods as $method) {
        $this->assertEquals($base_field->{$method}(), $override->{$method}());
    }
}

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