Example #1
0
 /**
  * @covers ::__constructor
  * @covers ::createTempFile
  */
 public function testPrefix()
 {
     $path = $this->adapter->createTempFile();
     $this->assertStringStartsWith('abc', basename($path));
     // Test another to be sure
     $new_adapter = new TempFileAdapter('/tmp/', 'bca');
     $path = $new_adapter->createTempFile();
     $this->assertStringStartsWith('bca', basename($path));
 }
Example #2
0
 /**
  * Construct a manager
  *
  * @param \Drupal\Core\File\FileSystem $filesystem A file path or stream URL for the temp directory
  * @param string $dir The directory to save to.
  * @param string $prefix A string prefix to add to each created file.
  */
 public function __construct(FileSystem $filesystem, $dir = 'temporary://', $prefix = 'bam')
 {
     // Set the prefix and initialize the temp file tracking.
     parent::__construct($dir, $prefix);
     $this->filesystem = $filesystem;
 }