function ImageFieldDefaultImagesTest::testInvalidDefaultImage
Same name in other branches
- 9 core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php \Drupal\Tests\image\Functional\ImageFieldDefaultImagesTest::testInvalidDefaultImage()
- 10 core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php \Drupal\Tests\image\Functional\ImageFieldDefaultImagesTest::testInvalidDefaultImage()
- 11.x 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 379
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']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.