public function ImageFieldDefaultImagesTest::testInvalidDefaultImage in Drupal 10
Same name and namespace in other branches
- 8 core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php \Drupal\Tests\image\Functional\ImageFieldDefaultImagesTest::testInvalidDefaultImage()
- 9 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 262
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']);
}