class SettingsConfigValidationTest
Same name and namespace in other branches
- 11.x core/modules/image/tests/src/Kernel/SettingsConfigValidationTest.php \Drupal\Tests\image\Kernel\SettingsConfigValidationTest
@group image
Hierarchy
- class \Drupal\Tests\image\Kernel\SettingsConfigValidationTest
Expanded class hierarchy of SettingsConfigValidationTest
File
-
core/
modules/ image/ tests/ src/ Kernel/ SettingsConfigValidationTest.php, line 13
Namespace
Drupal\Tests\image\KernelView source
class SettingsConfigValidationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'image',
];
/**
* Tests that the preview_image setting must be an existing image file.
*/
public function testPreviewImagePathIsValidated() : void {
$this->installConfig('image');
// Drupal does not have a hard dependency on the fileinfo extension and
// implements an extension-based mimetype guesser. Therefore, we must use
// an incorrect extension here instead of writing text to a supposed PNG
// file and depending on a check of the file contents.
$file = sys_get_temp_dir() . '/fake_image.png.txt';
file_put_contents($file, 'Not an image!');
$this->expectException(SchemaIncompleteException::class);
$this->expectExceptionMessage('[preview_image] This file is not a valid image.');
$this->config('image.settings')
->set('preview_image', $file)
->save();
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary |
---|---|---|---|---|
ConfigTestTrait::configImporter | protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait::copyConfig | protected | function | Copies configuration objects from source storage to target storage. | |
ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. | |
ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. | |
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. |
SettingsConfigValidationTest::$modules | protected static | property | Modules to install. | |
SettingsConfigValidationTest::testPreviewImagePathIsValidated | public | function | Tests that the preview_image setting must be an existing image file. | |
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait::checkModuleRequirements | Deprecated | private | function | Checks missing module requirements. |
TestRequirementsTrait::checkRequirements | Deprecated | protected | function | Check module requirements for the Drupal use case. |
TestRequirementsTrait::getDrupalRoot | protected static | function | Returns the Drupal root directory. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.