public function ImageFieldDefaultImagesTest::testInvalidDefaultImage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php \Drupal\Tests\image\Functional\ImageFieldDefaultImagesTest::testInvalidDefaultImage()
Tests image field and field storage having an invalid default image.
File
- core/
modules/ image/ tests/ src/ Functional/ ImageFieldDefaultImagesTest.php, line 263
Class
- ImageFieldDefaultImagesTest
- Tests setting up default images both to the field and field storage.
Namespace
Drupal\Tests\image\FunctionalCode
public function testInvalidDefaultImage() {
$field_storage = FieldStorageConfig::create([
'field_name' => mb_strtolower($this
->randomMachineName()),
'entity_type' => 'node',
'type' => 'image',
'settings' => [
'default_image' => [
'uuid' => 100000,
],
],
]);
$field_storage
->save();
$settings = $field_storage
->getSettings();
// The non-existent default image should not be saved.
$this
->assertNull($settings['default_image']['uuid']);
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'label' => $this
->randomMachineName(),
'settings' => [
'default_image' => [
'uuid' => 100000,
],
],
]);
$field
->save();
$settings = $field
->getSettings();
// The non-existent default image should not be saved.
$this
->assertNull($settings['default_image']['uuid']);
}