installEntitySchema('user'); $this->installEntitySchema('entity_test'); // If the concrete test sub-class installs the Node or Comment modules, // ensure that the node and comment entity schema are created before the // field configurations are installed. This is because the entity tables // need to be created before the body field storage tables. This prevents // trying to create the body field tables twice. $class = get_class($this); while ($class) { if (property_exists($class, 'modules')) { // Only check the modules, if the $modules property was not inherited. $rp = new \ReflectionProperty($class, 'modules'); if ($rp->class == $class) { foreach (array_intersect(['node', 'comment'], $class::$modules) as $module) { $this->installEntitySchema($module); } } } $class = get_parent_class($class); } $this->installConfig(['field', 'language']); \Drupal::service('router.builder')->rebuild(); // Add German as a language. ConfigurableLanguage::create([ 'id' => 'de', 'label' => 'Deutsch', 'weight' => -1, ])->save(); // Create the test text field. FieldStorageConfig::create([ 'field_name' => 'field_test_text', 'entity_type' => 'entity_test', 'type' => 'text', ])->save(); FieldConfig::create([ 'entity_type' => 'entity_test', 'field_name' => 'field_test_text', 'bundle' => 'entity_test', 'translatable' => FALSE, ])->save(); // Create the test translatable field. FieldStorageConfig::create([ 'field_name' => 'field_test_translatable_text', 'entity_type' => 'entity_test', 'type' => 'text', ])->save(); FieldConfig::create([ 'entity_type' => 'entity_test', 'field_name' => 'field_test_translatable_text', 'bundle' => 'entity_test', 'translatable' => TRUE, ])->save(); // Create the test entity reference field. FieldStorageConfig::create([ 'field_name' => 'field_test_entity_reference', 'entity_type' => 'entity_test', 'type' => 'entity_reference', 'settings' => [ 'target_type' => 'entity_test', ], ])->save(); FieldConfig::create([ 'entity_type' => 'entity_test', 'field_name' => 'field_test_entity_reference', 'bundle' => 'entity_test', 'translatable' => TRUE, ])->save(); $this->serializer = $this->container->get('serializer'); } }