You are here

public function FileStorageTest::testCreateDirectoryFailWarning in Drupal 9

Same name and namespace in other branches
  1. 8 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 97

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
    ->expectWarning();
  $this
    ->expectWarningMessage('mkdir(): Permission Denied');
  $storage
    ->save('subdirectory/foo.php', $code);
}