public static function SvgFormatterTest::generateTestSvgFile in SVG Formatter 8
Generates test SVG file.
Return value
\Drupal\file\FileInterface|false The creaed file entity.
1 call to SvgFormatterTest::generateTestSvgFile()
- SvgFormatterTest::createMediaEntity in tests/src/ Functional/ SvgFormatterTest.php 
- Creates a media entity.
File
- tests/src/ Functional/ SvgFormatterTest.php, line 116 
Class
- SvgFormatterTest
- Simple test to ensure that basic functionality of the module works.
Namespace
Drupal\Tests\svg_formatter\FunctionalCode
public static function generateTestSvgFile() {
  $extension = 'svg';
  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = \Drupal::service('file_system');
  $tmp_file = $file_system
    ->tempnam('temporary://', 'generateImage_');
  $destination = $tmp_file . '.' . $extension;
  try {
    $file_system
      ->move($tmp_file, $destination);
  } catch (FileException $e) {
    // Ignore failed move.
  }
  $source_file = file_save_data(self::SVG_DATA, $destination, FileSystemInterface::EXISTS_REPLACE);
  return $source_file;
}