checkSystemRequirements example


  protected function setUp(): void {
    parent::setUp();
    $this->setInstallProfile('standard');
  }

  /** * Tests if settings are set, there are not warnings. */
  public function testSettingsExist() {
    $this->setSetting('file_temp_path', $this->randomMachineName());
    $requirements = $this->checkSystemRequirements();
    $this->assertArrayNotHasKey('temp_directory', $requirements);
  }

  /** * Checks system runtime requirements. * * @return array * An array of system requirements. */
  protected function checkSystemRequirements() {
    $this->container->get('module_handler')->loadInclude('system', 'install');
    
$site_path = $this->kernel->getSitePath();
    $settings_file = $this->settingsFile($site_path);

    // First, we check based on what the initial install has set.     $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')new FormattableMarkup('Verified permissions for @file.', ['@file' => $site_path]));

    // We intentionally don't check for settings.local.php as that file is     // not created by Drupal.     $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE)new FormattableMarkup('Verified permissions for @file.', ['@file' => $settings_file]));

    $this->makeWritable($site_path);
    $this->checkSystemRequirements();

    $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir')new FormattableMarkup('Verified permissions for @file after manual permissions change.', ['@file' => $site_path]));
    $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE)new FormattableMarkup('Verified permissions for @file after manual permissions change.', ['@file' => $settings_file]));
  }

  /** * Tests writable files remain writable when directory hardening is disabled. */
  public function testSitesDirectoryHardeningConfig() {
    $site_path = $this->kernel->getSitePath();
    $settings_file = $this->settingsFile($site_path);

    
Home | Imprint | This part of the site doesn't use cookies.