protected function ToolkitSetupTrait::prepareImageFileHandling in ImageMagick 8.3
Same name and namespace in other branches
- 8.2 tests/src/Kernel/ToolkitSetupTrait.php \Drupal\Tests\imagemagick\Kernel\ToolkitSetupTrait::prepareImageFileHandling()
Prepares image files for test handling.
This method is only working for functional tests. Kernel tests use a vfsStream virtual file system, that is not compatible with invocation by ImageMagick executables that require a physical file passed in as a real path.
7 calls to ToolkitSetupTrait::prepareImageFileHandling()
- EventSubscriberTest::testEventSubscriber in tests/
src/ Functional/ EventSubscriberTest.php - Test module's event subscriber.
- EventSubscriberTest::testGifCoalesce in tests/
src/ Functional/ EventSubscriberTest.php - Test coalescence of Animated GIFs.
- ToolkitImagemagickFileMetadataTest::testFileMetadata in tests/
src/ Functional/ ToolkitImagemagickFileMetadataTest.php - Test image toolkit integration with file metadata manager.
- ToolkitImagemagickFileMetadataTest::testSourceLocalPath in tests/
src/ Functional/ ToolkitImagemagickFileMetadataTest.php - Tests getSourceLocalPath() for re-creating local path.
- ToolkitImagemagickTest::testDoubleCropping in tests/
src/ Functional/ ToolkitImagemagickTest.php - Tests that double cropping returns an image of expected dimensions.
File
- tests/
src/ Kernel/ ToolkitSetupTrait.php, line 121
Class
- ToolkitSetupTrait
- Trait to manage toolkit setup tasks common across tests.
Namespace
Drupal\Tests\imagemagick\KernelCode
protected function prepareImageFileHandling() : void {
if (!$this instanceof BrowserTestBase) {
$this
->fail(__CLASS__ . " is not a BrowserTestBase test class, and file system cannot be initialised properly for calling ImageMagick executables.");
}
$this->fileSystem = \Drupal::service('file_system');
// Prepare a directory for test file results.
$this->testDirectory = 'public://imagetest';
$this->fileSystem
->deleteRecursive($this->testDirectory);
$this->fileSystem
->prepareDirectory($this->testDirectory, FileSystemInterface::CREATE_DIRECTORY);
// Prepare a copy of test files.
$this
->getTestFiles('image');
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$original = \Drupal::root() . '/core/tests/fixtures/files';
$files = $file_system
->scanDirectory($original, '/img-.*/');
foreach ($files as $file) {
$file_system
->copy($file->uri, 'public://');
}
}