public function FieldApiTest::xcreateContentType in Field Formatter Filter 2.0.x
Same name and namespace in other branches
- 8 tests/src/Kernel/FieldApiTest.php \Drupal\Tests\field_formatter_filter\Kernel\FieldApiTest::xcreateContentType()
Create our test content type.
This operates completely through the API operations available for configuring views modes and widget settings.
Parameters
string $bundle:
See also
\Drupal\Tests\field_ui\Kernel\EntityDisplayTest
File
- tests/
src/ Kernel/ FieldApiTest.php, line 170
Class
- FieldApiTest
- Tests applying the filter formatter to a node.
Namespace
Drupal\Tests\field_formatter_filter\KernelCode
public function xcreateContentType(array $values = []) {
$bundle = $values['type'];
// Create a node bundle.
$entity_type = 'node';
$type = NodeType::create([
'type' => $bundle,
]);
// To avoid too many dependencies,
// -- just toggle off the 'display user' for view modes.
$type
->set('display_submitted', FALSE);
$type
->save();
node_add_body_field($type);
// Presave its view modes - the default display and form display.
// I think this helps ensure defaults are in place.
//
// Deprecated: entity_get_display($entity_type, $bundle, 'default')->save();
\Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load("{$entity_type}.{$bundle}.default")
->save();
// Deprecated: entity_get_form_display($entity_type, $bundle, 'default')->save();
\Drupal::entityTypeManager()
->getStorage('entity_form_display')
->load("{$entity_type}.{$bundle}.default")
->save();
// Pre-save its teaser view mode. Same as above, but uses a static call?
EntityViewDisplay::load("{$entity_type}.{$bundle}.teaser")
->save();
}