You are here

private function CoreUpdateTest::assertReadOnlyFileSystemError in Automatic Updates 8.2

Asserts that the update is prevented if the filesystem isn't writable.

Parameters

string $template: The project template used to build the test site. See ::createTestSite() for the possible values.

string $url: A URL where we can see the error message which is raised when parts of the file system are not writable. This URL will be visited twice: once for the web root, and once for the vendor directory.

2 calls to CoreUpdateTest::assertReadOnlyFileSystemError()
CoreUpdateTest::testApi in tests/src/Build/CoreUpdateTest.php
Tests an end-to-end core update via the API.
CoreUpdateTest::testUi in tests/src/Build/CoreUpdateTest.php
Tests an end-to-end core update via the UI.

File

tests/src/Build/CoreUpdateTest.php, line 233

Class

CoreUpdateTest
Tests an end-to-end update of Drupal core.

Namespace

Drupal\Tests\automatic_updates\Build

Code

private function assertReadOnlyFileSystemError(string $template, string $url) : void {
  $directories = [
    'Drupal' => rtrim($this
      ->getWebRoot(), './'),
  ];

  // The location of the vendor directory depends on which project template
  // was used to build the test site.
  if ($template === 'drupal/recommended-project') {
    $directories['vendor'] = $this
      ->getWorkspaceDirectory() . '/vendor';
  }
  elseif ($template === 'drupal/legacy-project') {
    $directories['vendor'] = $directories['Drupal'] . '/vendor';
  }
  $assert_session = $this
    ->getMink()
    ->assertSession();
  foreach ($directories as $type => $path) {
    chmod($path, 0555);
    $this
      ->assertDirectoryIsNotWritable($path);
    $this
      ->visit($url);
    $assert_session
      ->pageTextContains("The {$type} directory \"{$path}\" is not writable.");
    chmod($path, 0755);
    $this
      ->assertDirectoryIsWritable($path);
  }
}