Commit 8e265e8f authored by catch's avatar catch
Browse files

Issue #3131090 by longwave: Replace assertions involving calls to is_dir with...

Issue #3131090 by longwave: Replace assertions involving calls to is_dir with assertDirectoryExists()/assertDirectoryNotExists()

(cherry picked from commit 610d4b63)
parent a90aa996
......@@ -58,7 +58,7 @@ public function testInstallProfileConfigOverwrite() {
// file directly, because the install profile default system.cron.yml
// configuration file was used to create the active configuration.
$config_dir = drupal_get_path('module', 'system') . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
$this->assertTrue(is_dir($config_dir));
$this->assertDirectoryExists($config_dir);
$source_storage = new FileStorage($config_dir);
$data = $source_storage->read($config_name);
$this->assertIdentical($data, $expected_original_data);
......
......@@ -374,7 +374,7 @@ public function testDrupalMovingUploadedFileError() {
// Create a directory and make it not writable.
$test_directory = 'test_drupal_move_uploaded_file_fail';
\Drupal::service('file_system')->mkdir('temporary://' . $test_directory, 0000);
$this->assertTrue(is_dir('temporary://' . $test_directory));
$this->assertDirectoryExists('temporary://' . $test_directory);
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
......
......@@ -389,7 +389,7 @@ public function testDrupalMovingUploadedFileError() {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$file_system->mkdir('temporary://' . $test_directory, 0000);
$this->assertTrue(is_dir('temporary://' . $test_directory));
$this->assertDirectoryExists('temporary://' . $test_directory);
$edit = [
'file_subdir' => $test_directory,
......
......@@ -287,7 +287,7 @@ public function testStyle() {
// Confirm the style directory has been removed.
$directory = 'public://styles/' . $style_name;
$this->assertFalse(is_dir($directory), new FormattableMarkup('Image style %style directory removed on style deletion.', ['%style' => $style->label()]));
$this->assertDirectoryNotExists($directory);
$this->assertNull(ImageStyle::load($style_name), new FormattableMarkup('Image style %style successfully deleted.', ['%style' => $style->label()]));
......
......@@ -60,7 +60,7 @@ protected function setUpSite() {
*/
public function testError() {
$this->assertText("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem.");
$this->assertFalse(file_exists($this->configDirectory . '/sync') && is_dir($this->configDirectory . '/sync'), "The directory {$this->configDirectory}/sync does not exist.");
$this->assertDirectoryNotExists($this->configDirectory . '/sync');
}
}
......@@ -41,7 +41,7 @@ protected function prepareEnvironment() {
public function testInstaller() {
$this->assertUrl('user/1');
$this->assertResponse(200);
$this->assertTrue(file_exists($this->syncDirectory) && is_dir($this->syncDirectory), "The directory {$this->syncDirectory} exists.");
$this->assertDirectoryExists($this->syncDirectory);
}
}
......@@ -42,7 +42,7 @@ public function testFileCheckLocalDirectoryHandling() {
$child = $this->randomMachineName();
// Files directory already exists.
$this->assertTrue(is_dir($directory), t('Files directory already exists.'), 'File');
$this->assertDirectoryExists($directory);
// Make files directory writable only.
$old_mode = fileperms($directory);
......@@ -54,8 +54,8 @@ public function testFileCheckLocalDirectoryHandling() {
$this->assertTrue($file_system->mkdir($child_path, 0775, TRUE), t('No error reported when creating new local directories.'), 'File');
// Ensure new directories also exist.
$this->assertTrue(is_dir($parent_path), t('New parent directory actually exists.'), 'File');
$this->assertTrue(is_dir($child_path), t('New child directory actually exists.'), 'File');
$this->assertDirectoryExists($parent_path);
$this->assertDirectoryExists($child_path);
// Check that new directory permissions were set properly.
$this->assertDirectoryPermissions($parent_path, 0775);
......@@ -77,7 +77,7 @@ public function testFileCheckDirectoryHandling() {
// A directory to operate on.
$default_scheme = 'public';
$directory = $default_scheme . '://' . $this->randomMachineName() . '/' . $this->randomMachineName();
$this->assertFalse(is_dir($directory), 'Directory does not exist prior to testing.');
$this->assertDirectoryNotExists($directory);
// Non-existent directory.
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
......@@ -88,7 +88,7 @@ public function testFileCheckDirectoryHandling() {
$this->assertTrue($file_system->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY), 'No error reported when creating a new directory.', 'File');
// Make sure directory actually exists.
$this->assertTrue(is_dir($directory), 'Directory actually exists.', 'File');
$this->assertDirectoryExists($directory);
$file_system = \Drupal::service('file_system');
if (substr(PHP_OS, 0, 3) != 'WIN') {
// PHP on Windows doesn't support any kind of useful read-only mode for
......
......@@ -161,7 +161,8 @@ public function createDirectory($path = NULL) {
if (!isset($path)) {
$path = 'public://' . $this->randomMachineName();
}
$this->assertTrue(\Drupal::service('file_system')->mkdir($path) && is_dir($path), 'Directory was created successfully.');
$this->assertTrue(\Drupal::service('file_system')->mkdir($path));
$this->assertDirectoryExists($path);
return $path;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment