You are here

public function FileStorageReadOnlyTest::testDeleteAll in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php \Drupal\Tests\Component\PhpStorage\FileStorageReadOnlyTest::testDeleteAll()

@covers ::deleteAll

File

core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php, line 92
Contains \Drupal\Tests\Component\PhpStorage\FileStorageReadOnlyTest.

Class

FileStorageReadOnlyTest
@coversDefaultClass \Drupal\Component\PhpStorage\FileReadOnlyStorage

Namespace

Drupal\Tests\Component\PhpStorage

Code

public function testDeleteAll() {
  $php = new FileStorage($this->standardSettings);
  $name = $this
    ->randomMachineName() . '/' . $this
    ->randomMachineName() . '.php';

  // Find a global that doesn't exist.
  do {
    $random = mt_rand(10000, 100000);
  } while (isset($GLOBALS[$random]));

  // Write our the file so we can test deleting.
  $code = "<?php\n\$GLOBALS[{$random}] = TRUE;";
  $this
    ->assertTrue($php
    ->save($name, $code));
  $php_read = new FileReadOnlyStorage($this->readonlyStorage);
  $this
    ->assertFalse($php_read
    ->deleteAll());

  // Make sure directory exists prior to removal.
  $this
    ->assertTrue(file_exists($this->directory . '/test'), 'File storage directory does not exist.');
}