assertDirectoryIsNotWritable example

/** * {@inheritdoc} */
  protected function setUpSite() {
    // Assert that the expected title is present.     $this->assertEquals('Configure site', $this->cssSelect('main h2')[0]->getText());

    // Test that SiteConfigureForm::buildForm() has made the site directory and     // the settings file non-writable.     $site_directory = $this->container->getParameter('app.root') . '/' . $this->siteDirectory;
    $this->assertDirectoryIsNotWritable($site_directory);
    $this->assertFileIsNotWritable($site_directory . '/settings.php');

    parent::setUpSite();
  }

  /** * {@inheritdoc} */
  protected function visitInstaller() {
    parent::visitInstaller();

    
// Re-enable permissions enforcement.     $settings = Settings::getAll();
    $settings['skip_permissions_hardening'] = FALSE;
    new Settings($settings);

    // Manually trigger the requirements check.     $requirements = $this->checkSystemRequirements();
    $this->assertEquals('Protected', (string) $requirements['configuration_files']['value']);

    // Verify that site directory and the settings.php remain protected when     // automatically enforcing file permissions is enabled.     $this->assertDirectoryIsNotWritable($site_path);
    $this->assertFileIsNotWritable($settings_file);
  }

  /** * Checks system runtime requirements. * * @return array * An array of system requirements. */
  protected function checkSystemRequirements() {
    \Drupal::moduleHandler()->loadInclude('system', 'install');
    
Home | Imprint | This part of the site doesn't use cookies.