protected function ImageFormatterTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/image/tests/src/Kernel/ImageFormatterTest.php \Drupal\Tests\image\Kernel\ImageFormatterTest::setUp()
- 9 core/modules/image/tests/src/Kernel/ImageFormatterTest.php \Drupal\Tests\image\Kernel\ImageFormatterTest::setUp()
File
- core/
modules/ image/ tests/ src/ Kernel/ ImageFormatterTest.php, line 51
Class
- ImageFormatterTest
- Tests the image field rendering using entity fields of the image field type.
Namespace
Drupal\Tests\image\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'field',
]);
$this
->installEntitySchema('entity_test');
$this
->installEntitySchema('file');
$this
->installSchema('file', [
'file_usage',
]);
$this->entityType = 'entity_test';
$this->bundle = $this->entityType;
$this->fieldName = mb_strtolower($this
->randomMachineName());
FieldStorageConfig::create([
'entity_type' => $this->entityType,
'field_name' => $this->fieldName,
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
])
->save();
FieldConfig::create([
'entity_type' => $this->entityType,
'field_name' => $this->fieldName,
'bundle' => $this->bundle,
'settings' => [
'file_extensions' => 'jpg',
],
])
->save();
$this->display = \Drupal::service('entity_display.repository')
->getViewDisplay($this->entityType, $this->bundle)
->setComponent($this->fieldName, [
'type' => 'image',
'label' => 'hidden',
]);
$this->display
->save();
}