protected function SchemataBrowserTestBase::setUp in Schemata 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ SchemataBrowserTestBase.php, line 62
Class
- SchemataBrowserTestBase
- Sets up functional testing for Schemata.
Namespace
Drupal\Tests\schemata\FunctionalCode
protected function setUp() {
parent::setUp();
$this->entityTypeManager = $this->container
->get('entity_type.manager');
$this->schemaFactory = $this->container
->get('schemata.schema_factory');
if (!NodeType::load('camelids')) {
// Create a "Camelids" node type.
NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
])
->save();
}
// Create a "Camelids" vocabulary.
$vocabulary = Vocabulary::create([
'name' => 'Camelids',
'vid' => 'camelids',
]);
$vocabulary
->save();
$entity_types = [
'node',
'taxonomy_term',
];
foreach ($entity_types as $entity_type) {
// Add access-protected field.
FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_' . $entity_type,
'type' => 'text',
])
->setCardinality(1)
->save();
FieldConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_' . $entity_type,
'bundle' => 'camelids',
])
->setLabel('Test field')
->setTranslatable(FALSE)
->save();
}
$this->container
->get('router.builder')
->rebuild();
$this
->drupalLogin($this
->drupalCreateUser([
'access schemata data models',
]));
}