ConfigFieldDefinitionTest.php in Zircon Profile 8
File
core/modules/field/src/Tests/ConfigFieldDefinitionTest.php
View source
<?php
namespace Drupal\field\Tests;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
class ConfigFieldDefinitionTest extends FieldUnitTestBase {
protected $entityManager;
private $entityType;
private $bundle;
protected function setUp() {
parent::setUp();
$this->entityType = 'entity_test';
$this->bundle = 'entity_test';
$this
->createFieldWithStorage('', $this->entityType, $this->bundle);
$this->entityManager = $this->container
->get('entity.manager');
$this
->createFieldWithStorage('_rev', 'entity_test_rev', 'entity_test_rev');
}
public function testBundleFieldDefinition() {
$definitions = $this->entityManager
->getFieldDefinitions($this->entityType, $this->bundle);
$this
->assertTrue(isset($definitions[$this->fieldTestData->field
->getName()]));
$this
->assertTrue($definitions[$this->fieldTestData->field
->getName()] instanceof FieldDefinitionInterface);
$this
->assertFalse(isset($definitions[$this->fieldTestData->field_rev
->getName()]));
}
public function testFieldStorageDefinition() {
$field_storage_definitions = $this->entityManager
->getFieldStorageDefinitions($this->entityType);
$this
->assertTrue(isset($field_storage_definitions[$this->fieldTestData->field
->getName()]));
$this
->assertTrue($field_storage_definitions[$this->fieldTestData->field
->getName()] instanceof FieldStorageDefinitionInterface);
$this
->assertFalse(isset($field_storage_definitions[$this->fieldTestData->field_rev
->getName()]));
}
}