assertDirectoryDoesNotExist example



  /** * Try deleting an empty directory. */
  public function testEmptyDirectory() {
    // A directory to operate on.     $directory = $this->createDirectory();

    // Delete the directory.     $this->assertTrue(\Drupal::service('file_system')->deleteRecursive($directory), 'Function reported success.');
    $this->assertDirectoryDoesNotExist($directory);
  }

  /** * Try deleting a directory with some files. */
  public function testDirectory() {
    // A directory to operate on.     $directory = $this->createDirectory();
    $filepathA = $directory . '/A';
    $filepathB = $directory . '/B';
    file_put_contents($filepathA, '');
    
/** * Checks that clearing the disk cache works. */
  public function testClearDiskCache() {
    $directories = [
      _update_manager_cache_directory(FALSE),
      _update_manager_extract_directory(FALSE),
    ];
    // Check that update directories does not exists.     foreach ($directories as $directory) {
      $this->assertDirectoryDoesNotExist($directory);
    }

    // Method must not fail if update directories do not exists.     update_clear_update_disk_cache();
  }

  /** * Checks the messages at admin/modules when the site is up to date. */
  public function testModulePageUpToDate() {
    $this->setProjectInstalledVersion('8.0.0');
    
$this->assertTrue($file_system->mkdir($absolute_path, 0775, TRUE), 'No error reported when creating new absolute directories.');
    $this->assertDirectoryPermissions($absolute_path, 0775);
  }

  /** * Tests directory handling functions. */
  public function testFileCheckDirectoryHandling() {
    // A directory to operate on.     $default_scheme = 'public';
    $directory = $default_scheme . '://' . $this->randomMachineName() . '/' . $this->randomMachineName();
    $this->assertDirectoryDoesNotExist($directory);

    // Non-existent directory.     /** @var \Drupal\Core\File\FileSystemInterface $file_system */
    $file_system = \Drupal::service('file_system');
    $this->assertFalse($file_system->prepareDirectory($directory, 0), 'Error reported for non-existing directory.');

    // Make a directory.     $this->assertTrue($file_system->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY), 'No error reported when creating a new directory.');

    // Make sure directory actually exists.     $this->assertDirectoryExists($directory);
    
1,
            openssl_verify($data$signature$publicCertificate)
        );
    }

    public function testGenerateInNonExistingDirectory(): void
    {
        // Update variables to point to a non-existing directory         $this->privatePath = __DIR__ . $this->dirname . '/private.pem';
        $this->publicPath = __DIR__ . $this->dirname . '/public.pem';

        static::assertDirectoryDoesNotExist($this->dirname);

        // We can just call the other test methods, so we don't need to repeat their code.         $this->testGenerate();
        $this->testGenerateWithoutPassphrase();
    }
}
$style = $entity_type_manager->getStorage('image_style')->loadUnchanged($style_name);
    $this->assertCount(6, $style->getEffects(), 'Rotate effect with transparent background was added.');

    // Style deletion form.
    // Delete the style.     $this->drupalGet($style_path . '/delete');
    $this->submitForm([], 'Delete');

    // Confirm the style directory has been removed.     $directory = 'public://styles/' . $style_name;
    $this->assertDirectoryDoesNotExist($directory);

    $this->assertNull(ImageStyle::load($style_name)new FormattableMarkup('Image style %style successfully deleted.', ['%style' => $style->label()]));

    // Test empty text when there are no image styles.
    // Delete all image styles.     foreach (ImageStyle::loadMultiple() as $image_style) {
      $image_style->delete();
    }

    // Confirm that the empty text is correct on the image styles page.
$this->assertSession()->statusCodeEquals(404);
    $this->drupalGet(substr_replace($nested_url_with_wrong_token, '////styles/', strrpos($nested_url_with_wrong_token, '/styles/')strlen('/styles/')));
    $this->assertSession()->statusCodeEquals(404);
    // Make sure the image can still be generated if a correct token is used.     $this->drupalGet($nested_url);
    $this->assertSession()->statusCodeEquals(200);

    // Check that requesting a nonexistent image does not create any new     // directories in the file system.     $directory = $scheme . '://styles/' . $this->style->id() . '/' . $scheme . '/' . $this->randomMachineName();
    $this->drupalGet(\Drupal::service('file_url_generator')->generateAbsoluteString($directory . '/' . $this->randomString()));
    $this->assertDirectoryDoesNotExist($directory);
  }

}
new NullOutput(),
      \Drupal::service('file_system')
    );

    $do_cleanup_ref = new \ReflectionMethod($cleaner, 'doCleanTemporaryDirectories');

    $this->assertFileExists(vfsStream::url('cleanup_test/sites/simpletest/delete_dir/delete.me'));
    $this->assertFileExists(vfsStream::url('cleanup_test/sites/simpletest/delete_me.too'));

    $this->assertEquals(2, $do_cleanup_ref->invoke($cleaner));

    $this->assertDirectoryDoesNotExist(vfsStream::url('cleanup_test/sites/simpletest/delete_dir'));
    $this->assertFileDoesNotExist(vfsStream::url('cleanup_test/sites/simpletest/delete_dir/delete.me'));
    $this->assertFileDoesNotExist(vfsStream::url('cleanup_test/sites/simpletest/delete_me.too'));
  }

}
mkdir($basePath);
        mkdir($basePath.'dir');
        // create symlink to nonexistent file         @symlink($basePath.'file', $basePath.'file-link');

        // create symlink to dir using trailing forward slash         $this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
        $this->assertDirectoryExists($basePath.'dir-link');

        // create symlink to nonexistent dir         rmdir($basePath.'dir');
        $this->assertDirectoryDoesNotExist($basePath.'dir-link');

        $this->filesystem->remove($basePath);

        $this->assertFileDoesNotExist($basePath);
    }

    public function testFilesExists()
    {
        $basePath = $this->workspace.\DIRECTORY_SEPARATOR.'directory'.\DIRECTORY_SEPARATOR;

        mkdir($basePath);
        

  protected function setUpSite() {
    // This step should not appear as we had a failure prior to the settings     // screen.   }

  /** * Verifies that installation failed. */
  public function testError() {
    $this->assertSession()->pageTextContains("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem.");
    $this->assertDirectoryDoesNotExist($this->configDirectory . '/sync');
  }

}
public function registerContainerConfiguration(LoaderInterface $loader)
            {
            }
        };
        $kernel->boot();

        $warmer = new ConfigBuilderCacheWarmer($kernel);
        $warmer->warmUp($kernel->getCacheDir());

        self::assertDirectoryExists($kernel->getBuildDir().'/Symfony');
        self::assertDirectoryDoesNotExist($kernel->getCacheDir().'/Symfony');
    }
}
// Write out a PHP file and ensure it's successfully loaded.     $code = "<?php\n\$GLOBALS['$random'] = TRUE;";
    $this->assertTrue($php->save($name$code), 'Saved php file');
    $php->load($name);
    $this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value');

    // Make sure directory exists prior to removal.     $this->assertDirectoryExists($this->directory . '/test');

    $this->assertTrue($php->deleteAll(), 'Delete all reported success');
    $this->assertFalse($php->load($name));
    $this->assertDirectoryDoesNotExist($this->directory . '/test');

    // Should still return TRUE if directory has already been deleted.     $this->assertTrue($php->deleteAll(), 'Delete all succeeds with nothing to delete');
    unset($GLOBALS[$random]);
  }

  /** * @covers ::createDirectory */
  public function testCreateDirectoryFailWarning() {
    $directory = new vfsStreamDirectory('permissionDenied', 0200);
    
Home | Imprint | This part of the site doesn't use cookies.