namespace Drupal\Tests\Component\PhpStorage;
use Drupal\Component\PhpStorage\FileStorage;
+use Drupal\Component\Utility\Random;
+use org\bovigo\vfs\vfsStreamDirectory;
+use PHPUnit_Framework_Error_Warning;
/**
* @coversDefaultClass \Drupal\Component\PhpStorage\FileStorage
* @covers ::deleteAll
*/
public function testDeleteAll() {
+ // Random generator.
+ $random_generator = new Random();
// Write out some files.
$php = new FileStorage($this->standardSettings);
- $name = $this->randomMachineName() . '/' . $this->randomMachineName() . '.php';
+ $name = $random_generator->name(8, TRUE) . '/' . $random_generator->name(8, TRUE) . '.php';
// Find a global that doesn't exist.
do {
unset($GLOBALS[$random]);
}
+ /**
+ * @covers ::createDirectory
+ */
+ public function testCreateDirectoryFailWarning() {
+ $directory = new vfsStreamDirectory('permissionDenied', 0200);
+ $storage = new FileStorage([
+ 'directory' => $directory->url(),
+ 'bin' => 'test',
+ ]);
+ $code = "<?php\n echo 'here';";
+ $this->setExpectedException(PHPUnit_Framework_Error_Warning::class, 'mkdir(): Permission Denied');
+ $storage->save('subdirectory/foo.php', $code);
+ }
+
}