class FieldStorageGetPropertyDefinitionTest
Tests getting property definitions from field storages.
Attributes
#[Group('Field')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Field\FieldStorageGetPropertyDefinitionTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of FieldStorageGetPropertyDefinitionTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldStorageGetPropertyDefinitionTest.php, line 18
Namespace
Drupal\KernelTests\Core\FieldView source
class FieldStorageGetPropertyDefinitionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'field',
'field_test',
];
/**
* Tests getPropertyDefinition().
*/
public function testGetPropertyDefinition() : void {
$this->assertInstanceOf(DataDefinitionInterface::class, BaseFieldDefinition::create('string')->getFieldStorageDefinition()
->getPropertyDefinition('value'));
$this->assertInstanceOf(DataDefinitionInterface::class, FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'type' => 'test_field',
])->getPropertyDefinition('value'));
}
/**
* Tests BaseFieldDefinition::getPropertyDefinition() with null.
*/
public function testBaseFieldGetPropertyDefinitionWithNull() : void {
$this->expectDeprecation('Calling Drupal\\Core\\Field\\BaseFieldDefinition::getPropertyDefinition() with a non-string $name is deprecated in drupal:11.3.0 and throws an exception in drupal:12.0.0. See https://www.drupal.org/node/3557373');
$this->assertNull(BaseFieldDefinition::create('string')->getPropertyDefinition(NULL));
}
/**
* Tests FieldStorageConfig::getPropertyDefinition() with null.
*/
public function testFieldStorageConfigGetPropertyDefinitionWithNull() : void {
$this->expectDeprecation('Calling Drupal\\field\\Entity\\FieldStorageConfig::getPropertyDefinition() with a non-string $name is deprecated in drupal:11.3.0 and throws an exception in drupal:12.0.0. See https://www.drupal.org/node/3557373');
$this->assertNull(FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'type' => 'test_field',
])->getPropertyDefinition(NULL));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.