You are here

public function FileStorageTest::testCreateDirectoryFailWarning in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php \Drupal\Tests\Component\PhpStorage\FileStorageTest::testCreateDirectoryFailWarning()

@covers ::createDirectory

File

core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php, line 95

Class

FileStorageTest
@coversDefaultClass \Drupal\Component\PhpStorage\FileStorage @group Drupal @group PhpStorage

Namespace

Drupal\Tests\Component\PhpStorage

Code

public function testCreateDirectoryFailWarning() {
  $directory = new vfsStreamDirectory('permissionDenied', 0200);
  $storage = new FileStorage([
    'directory' => $directory
      ->url(),
    'bin' => 'test',
  ]);
  $code = "<?php\n echo 'here';";
  $this
    ->expectException(Warning::class);
  $this
    ->expectExceptionMessage('mkdir(): Permission Denied');
  $storage
    ->save('subdirectory/foo.php', $code);
}