Issue #3131088 by Spokje, longwave: Replace assertions involving calls to file_exists with assertFileExists()/assertFileNotExists() or assertDirectoryExists()/assertDirectoryNotExists()

merge-requests/2419/head
catch 2020-04-27 14:13:40 +01:00
parent 610d4b6307
commit 222e10447b
29 changed files with 134 additions and 137 deletions

View File

@ -33,8 +33,8 @@ class CopyTest extends FileManagedUnitTestBase {
$this->assertDifferentFile($source, $result);
$this->assertEqual($result->getFileUri(), $desired_uri, 'The copied file entity has the desired filepath.');
$this->assertTrue(file_exists($source->getFileUri()), 'The original file still exists.');
$this->assertTrue(file_exists($result->getFileUri()), 'The copied file exists.');
$this->assertFileExists($source->getFileUri());
$this->assertFileExists($result->getFileUri());
// Reload the file from the database and check that the changes were
// actually saved.

View File

@ -22,7 +22,7 @@ class DeleteTest extends FileManagedUnitTestBase {
$this->assertFileExists($file->getFileUri());
$file->delete();
$this->assertFileHooksCalled(['delete']);
$this->assertFalse(file_exists($file->getFileUri()), 'Test file has actually been deleted.');
$this->assertFileNotExists($file->getFileUri());
$this->assertNull(File::load($file->id()), 'File was removed from the database.');
}
@ -43,7 +43,7 @@ class DeleteTest extends FileManagedUnitTestBase {
$file_usage->delete($file, 'testing', 'test', 1);
$usage = $file_usage->listUsage($file);
$this->assertEqual($usage['testing']['test'], [1 => 1], 'Test file is still in use.');
$this->assertTrue(file_exists($file->getFileUri()), 'File still exists on the disk.');
$this->assertFileExists($file->getFileUri());
$this->assertNotEmpty(File::load($file->id()), 'File still exists in the database.');
// Clear out the call to hook_file_load().
@ -53,7 +53,7 @@ class DeleteTest extends FileManagedUnitTestBase {
$usage = $file_usage->listUsage($file);
$this->assertFileHooksCalled(['load', 'update']);
$this->assertTrue(empty($usage), 'File usage data was removed.');
$this->assertTrue(file_exists($file->getFileUri()), 'File still exists on the disk.');
$this->assertFileExists($file->getFileUri());
$file = File::load($file->id());
$this->assertNotEmpty($file, 'File still exists in the database.');
$this->assertTrue($file->isTemporary(), 'File is temporary.');
@ -73,7 +73,7 @@ class DeleteTest extends FileManagedUnitTestBase {
// file_cron() loads
$this->assertFileHooksCalled(['delete']);
$this->assertFalse(file_exists($file->getFileUri()), 'File has been deleted after its last usage was removed.');
$this->assertFileNotExists($file->getFileUri());
$this->assertNull(File::load($file->id()), 'File was removed from the database.');
}
@ -84,7 +84,7 @@ class DeleteTest extends FileManagedUnitTestBase {
$file = $this->createFile();
// Delete the file, but leave it in the file_managed table.
\Drupal::service('file_system')->delete($file->getFileUri());
$this->assertFalse(file_exists($file->getFileUri()), 'File is deleted from the filesystem.');
$this->assertFileNotExists($file->getFileUri());
$this->assertInstanceOf(File::class, File::load($file->id()));
// Call file_cron() to clean up the file. Make sure the changed timestamp

View File

@ -27,7 +27,7 @@ class MoveTest extends FileManagedUnitTestBase {
// Check the return status and that the contents changed.
$this->assertNotFalse($result, 'File moved successfully.');
$this->assertFalse(file_exists($source->getFileUri()));
$this->assertFileNotExists($source->getFileUri());
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file correctly written.');
// Check that the correct hooks were called.
@ -59,7 +59,7 @@ class MoveTest extends FileManagedUnitTestBase {
// Check the return status and that the contents changed.
$this->assertNotFalse($result, 'File moved successfully.');
$this->assertFalse(file_exists($source->getFileUri()));
$this->assertFileNotExists($source->getFileUri());
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file correctly written.');
// Check that the correct hooks were called.
@ -94,7 +94,7 @@ class MoveTest extends FileManagedUnitTestBase {
// Look at the results.
$this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file were overwritten.');
$this->assertFalse(file_exists($source->getFileUri()));
$this->assertFileNotExists($source->getFileUri());
$this->assertNotEmpty($result, 'File moved successfully.');
// Check that the correct hooks were called.
@ -147,7 +147,7 @@ class MoveTest extends FileManagedUnitTestBase {
// Check the return status and that the contents did not change.
$this->assertFalse($result, 'File move failed.');
$this->assertTrue(file_exists($source->getFileUri()));
$this->assertFileExists($source->getFileUri());
$this->assertEqual($contents, file_get_contents($target->getFileUri()), 'Contents of file were not altered.');
// Check that no hooks were called while failing.

View File

@ -163,7 +163,7 @@ class UsageTest extends FileManagedUnitTestBase {
])
->condition('fid', $temp_old->id())
->execute();
$this->assertTrue(file_exists($temp_old->getFileUri()), 'Old temp file was created correctly.');
$this->assertFileExists($temp_old->getFileUri());
// Temporary file that is new.
$temp_new = file_save_data('');
@ -171,7 +171,7 @@ class UsageTest extends FileManagedUnitTestBase {
->fields(['status' => 0])
->condition('fid', $temp_new->id())
->execute();
$this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was created correctly.');
$this->assertFileExists($temp_new->getFileUri());
// Permanent file that is old.
$perm_old = file_save_data('');
@ -179,11 +179,11 @@ class UsageTest extends FileManagedUnitTestBase {
->fields(['changed' => REQUEST_TIME - $this->config('system.file')->get('temporary_maximum_age') - 1])
->condition('fid', $temp_old->id())
->execute();
$this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was created correctly.');
$this->assertFileExists($perm_old->getFileUri());
// Permanent file that is new.
$perm_new = file_save_data('');
$this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was created correctly.');
$this->assertFileExists($perm_new->getFileUri());
return [$temp_old, $temp_new, $perm_old, $perm_new];
}
@ -195,10 +195,10 @@ class UsageTest extends FileManagedUnitTestBase {
// Run cron and then ensure that only the old, temp file was deleted.
$this->container->get('cron')->run();
$this->assertFalse(file_exists($temp_old->getFileUri()), 'Old temp file was correctly removed.');
$this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was correctly ignored.');
$this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was correctly ignored.');
$this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was correctly ignored.');
$this->assertFileNotExists($temp_old->getFileUri());
$this->assertFileExists($temp_new->getFileUri());
$this->assertFileExists($perm_old->getFileUri());
$this->assertFileExists($perm_new->getFileUri());
}
/**
@ -214,10 +214,10 @@ class UsageTest extends FileManagedUnitTestBase {
// Run cron and then ensure that no file was deleted.
$this->container->get('cron')->run();
$this->assertTrue(file_exists($temp_old->getFileUri()), 'Old temp file was correctly ignored.');
$this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was correctly ignored.');
$this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was correctly ignored.');
$this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was correctly ignored.');
$this->assertFileExists($temp_old->getFileUri());
$this->assertFileExists($temp_new->getFileUri());
$this->assertFileExists($perm_old->getFileUri());
$this->assertFileExists($perm_new->getFileUri());
}
/**
@ -233,10 +233,10 @@ class UsageTest extends FileManagedUnitTestBase {
// Run cron and then ensure that more files were deleted.
$this->container->get('cron')->run();
$this->assertTrue(file_exists($temp_old->getFileUri()), 'Old temp file was correctly ignored.');
$this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was correctly ignored.');
$this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was correctly ignored.');
$this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was correctly ignored.');
$this->assertFileExists($temp_old->getFileUri());
$this->assertFileExists($temp_new->getFileUri());
$this->assertFileExists($perm_old->getFileUri());
$this->assertFileExists($perm_new->getFileUri());
}
/**

View File

@ -56,11 +56,11 @@ class ValidatorTest extends FileManagedUnitTestBase {
* This ensures a specific file is actually an image.
*/
public function testFileValidateIsImage() {
$this->assertTrue(file_exists($this->image->getFileUri()), 'The image being tested exists.', 'File');
$this->assertFileExists($this->image->getFileUri());
$errors = file_validate_is_image($this->image);
$this->assertEqual(count($errors), 0, 'No error reported for our image file.', 'File');
$this->assertTrue(file_exists($this->nonImage->getFileUri()), 'The non-image being tested exists.', 'File');
$this->assertFileExists($this->nonImage->getFileUri());
$errors = file_validate_is_image($this->nonImage);
$this->assertEqual(count($errors), 1, 'An error reported for our non-image file.', 'File');
}

View File

@ -47,7 +47,7 @@ class FileMoveTest extends BrowserTestBase {
$style->createDerivative($original_uri, $derivative_uri);
// Check if derivative image exists.
$this->assertTrue(file_exists($derivative_uri), 'Make sure derivative image is generated successfully.');
$this->assertFileExists($derivative_uri);
// Clone the object so we don't have to worry about the function changing
// our reference copy.
@ -55,10 +55,10 @@ class FileMoveTest extends BrowserTestBase {
$result = file_move(clone $file, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
// Check if image has been moved.
$this->assertTrue(file_exists($result->getFileUri()), 'Make sure image is moved successfully.');
$this->assertFileExists($result->getFileUri());
// Check if derivative image has been flushed.
$this->assertFalse(file_exists($derivative_uri), 'Make sure derivative image has been flushed.');
$this->assertFileNotExists($derivative_uri);
}
}

View File

@ -78,10 +78,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="120" height="60" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 120);
$this->assertEqual($image_file->getHeight(), 60);
@ -99,10 +99,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="60" height="120" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 60);
$this->assertEqual($image_file->getHeight(), 120);
@ -121,10 +121,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 45);
$this->assertEqual($image_file->getHeight(), 90);
@ -143,10 +143,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 45);
$this->assertEqual($image_file->getHeight(), 90);
@ -161,10 +161,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 45);
$this->assertEqual($image_file->getHeight(), 90);
@ -182,10 +182,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
// Add a crop effect.
$effect = [
@ -201,10 +201,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$style->addImageEffect($effect);
$style->save();
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="30" height="30" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 30);
$this->assertEqual($image_file->getHeight(), 30);
@ -224,10 +224,10 @@ class ImageDimensionsTest extends BrowserTestBase {
// @todo Uncomment this once
// https://www.drupal.org/project/drupal/issues/2670966 is resolved.
// $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="41" height="41" alt="" class="image-style-test" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
// @todo Uncomment this once
// https://www.drupal.org/project/drupal/issues/2670966 is resolved.
@ -268,10 +268,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$generated_uri = 'public://styles/test_uri/public/' . $file_system->basename($original_uri);
$url = file_url_transform_relative($style->buildUrl($original_uri));
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="100" height="100" alt="" class="image-style-test-uri" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 100);
$this->assertEqual($image_file->getHeight(), 100);
@ -282,10 +282,10 @@ class ImageDimensionsTest extends BrowserTestBase {
$url = file_url_transform_relative($style->buildUrl($original_uri));
$variables['#uri'] = $original_uri;
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="50" height="50" alt="" class="image-style-test-uri" />');
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 50);
$this->assertEqual($image_file->getHeight(), 50);

View File

@ -38,7 +38,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
// Create a node with a valid image.
$node = $this->uploadNodeImage($image_files[0], $field_name, 'article', $alt);
$this->assertTrue(file_exists($expected_path . '/' . $image_files[0]->filename));
$this->assertFileExists($expected_path . '/' . $image_files[0]->filename);
// Remove the image.
$this->drupalPostForm('node/' . $node . '/edit', [], t('Remove'));
@ -61,7 +61,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
'files[' . $field_name . '_0]' => $file_system->realpath($zero_size_image->uri),
];
$this->drupalPostForm('node/' . $node . '/edit', $edit, t('Upload'));
$this->assertFalse(file_exists($expected_path . '/' . $zero_size_image->filename));
$this->assertFileNotExists($expected_path . '/' . $zero_size_image->filename);
// Try uploading an invalid image.
$invalid_image = $invalid_image_files['invalid-img-test.png'];
@ -69,7 +69,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
'files[' . $field_name . '_0]' => $file_system->realpath($invalid_image->uri),
];
$this->drupalPostForm('node/' . $node . '/edit', $edit, t('Upload'));
$this->assertFalse(file_exists($expected_path . '/' . $invalid_image->filename));
$this->assertFileNotExists($expected_path . '/' . $invalid_image->filename);
// Upload a valid image again.
$valid_image = $image_files[0];
@ -77,7 +77,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
'files[' . $field_name . '_0]' => $file_system->realpath($valid_image->uri),
];
$this->drupalPostForm('node/' . $node . '/edit', $edit, t('Upload'));
$this->assertTrue(file_exists($expected_path . '/' . $valid_image->filename));
$this->assertFileExists($expected_path . '/' . $valid_image->filename);
}
/**

View File

@ -164,7 +164,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// Get the URL of a file that has not been generated and try to create it.
$generated_uri = $this->style->buildUri($original_uri);
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$generate_url = $this->style->buildUrl($original_uri, $clean_url);
// Make sure that language prefix is never added to the image style URL.
@ -203,7 +203,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// Fetch the URL that generates the file.
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$this->assertFileExists($generated_uri);
// assertRaw can't be used with string containing non UTF-8 chars.
$this->assertNotEmpty(file_get_contents($generated_uri), 'URL returns expected file.');
$image = $this->container->get('image.factory')->get($generated_uri);
@ -243,7 +243,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
$file_noaccess = array_shift($files);
$original_uri_noaccess = $file_system->copy($file_noaccess->uri, $scheme . '://', FileSystemInterface::EXISTS_RENAME);
$generated_uri_noaccess = $scheme . '://styles/' . $this->style->id() . '/' . $scheme . '/' . $file_system->basename($original_uri_noaccess);
$this->assertFalse(file_exists($generated_uri_noaccess), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri_noaccess);
$generate_url_noaccess = $this->style->buildUrl($original_uri_noaccess);
$this->drupalGet($generate_url_noaccess);
@ -291,7 +291,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// is not present in the URL but that the image is still accessible.
$this->config('image.settings')->set('suppress_itok_output', TRUE)->save();
$generated_uri = $this->style->buildUri($original_uri);
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->assertFileNotExists($generated_uri);
$generate_url = $this->style->buildUrl($original_uri, $clean_url);
$this->assertStringNotContainsString(IMAGE_DERIVATIVE_TOKEN . '=', $generate_url, 'The security token does not appear in the image style URL.');
$this->drupalGet($generate_url);
@ -324,7 +324,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// directories in the file system.
$directory = $scheme . '://styles/' . $this->style->id() . '/' . $scheme . '/' . $this->randomMachineName();
$this->drupalGet(file_create_url($directory . '/' . $this->randomString()));
$this->assertFalse(file_exists($directory), 'New directory was not created in the filesystem when requesting an unauthorized image.');
$this->assertDirectoryNotExists($directory);
}
}

View File

@ -501,7 +501,7 @@ class FileUploadTest extends ResourceTestBase {
// Check the actual file data. It should have been written to the configured
// directory, not /foobar/directory/example.txt.
$this->assertSame($this->testFileData, file_get_contents('public://foobar/example_2.txt'));
$this->assertFalse(file_exists('../../example_2.txt'));
$this->assertFileNotExists('../../example_2.txt');
// Check a path from the root. Extensions have to be empty to allow a file
// with no extension to pass validation.
@ -575,7 +575,7 @@ class FileUploadTest extends ResourceTestBase {
// Make sure that no file was saved.
$this->assertEmpty(File::load(1));
$this->assertFalse(file_exists('public://foobar/example.txt'));
$this->assertFileNotExists('public://foobar/example.txt');
}
/**
@ -598,7 +598,7 @@ class FileUploadTest extends ResourceTestBase {
// Make sure that no file was saved.
$this->assertEmpty(File::load(1));
$this->assertFalse(file_exists('public://foobar/example.txt'));
$this->assertFileNotExists('public://foobar/example.txt');
}
/**
@ -625,7 +625,7 @@ class FileUploadTest extends ResourceTestBase {
// Override the expected filesize.
$expected['data']['attributes']['filesize'] = strlen($php_string);
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example.php.txt'));
$this->assertFileExists('public://foobar/example.php.txt');
// Add php as an allowed format. Allow insecure uploads still being FALSE
// should still not allow this. So it should still have a .txt extension
@ -639,8 +639,8 @@ class FileUploadTest extends ResourceTestBase {
// Override the expected filesize.
$expected['data']['attributes']['filesize'] = strlen($php_string);
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example_2.php.txt'));
$this->assertFalse(file_exists('public://foobar/example_2.php'));
$this->assertFileExists('public://foobar/example_2.php.txt');
$this->assertFileNotExists('public://foobar/example_2.php');
// Allow .doc file uploads and ensure even a mis-configured apache will not
// fallback to php because the filename will be munged.
@ -656,8 +656,8 @@ class FileUploadTest extends ResourceTestBase {
// The file mime should be 'application/msword'.
$expected['data']['attributes']['filemime'] = 'application/msword';
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example_3.php_.doc'));
$this->assertFalse(file_exists('public://foobar/example_3.php.doc'));
$this->assertFileExists('public://foobar/example_3.php_.doc');
$this->assertFileNotExists('public://foobar/example_3.php.doc');
// Now allow insecure uploads.
\Drupal::configFactory()
@ -675,7 +675,7 @@ class FileUploadTest extends ResourceTestBase {
// The file mime should also now be PHP.
$expected['data']['attributes']['filemime'] = 'application/x-httpd-php';
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example_4.php'));
$this->assertFileExists('public://foobar/example_4.php');
}
/**
@ -695,7 +695,7 @@ class FileUploadTest extends ResourceTestBase {
$expected = $this->getExpectedDocument(1, 'example.txt', TRUE);
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example.txt'));
$this->assertFileExists('public://foobar/example.txt');
}
/**

View File

@ -62,8 +62,8 @@ class LocaleTranslationDownloadTest extends LocaleUpdateBase {
$result = locale_translation_download_source($source_file, 'translations://');
$this->assertEquals('translations://contrib_module_one-8.x-1.1.de._po', $result->uri);
$this->assertFalse(file_exists('translations://contrib_module_one-8.x-1.1.de_0._po'));
$this->assertTrue(file_exists('translations://contrib_module_one-8.x-1.1.de._po'));
$this->assertFileNotExists('translations://contrib_module_one-8.x-1.1.de_0._po');
$this->assertFileExists('translations://contrib_module_one-8.x-1.1.de._po');
$this->assertStringNotContainsString('__old_content__', file_get_contents('translations://contrib_module_one-8.x-1.1.de._po'));
}

View File

@ -7,7 +7,6 @@ use Drupal\Core\Database\Database;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Component\Render\FormattableMarkup;
/**
* Adds a new locale and translates its name. Checks the validation of
@ -266,13 +265,13 @@ class LocaleTranslationUiTest extends BrowserTestBase {
$locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: [];
$js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
$this->assertTrue($result = file_exists($js_file), new FormattableMarkup('JavaScript file created: %file', ['%file' => $result ? $js_file : 'not found']));
$this->assertFileExists($js_file);
// Test JavaScript translation rebuilding.
\Drupal::service('file_system')->delete($js_file);
$this->assertTrue($result = !file_exists($js_file), new FormattableMarkup('JavaScript file deleted: %file', ['%file' => $result ? $js_file : 'found']));
$this->assertFileNotExists($js_file);
_locale_rebuild_js($langcode);
$this->assertTrue($result = file_exists($js_file), new FormattableMarkup('JavaScript file rebuilt: %file', ['%file' => $result ? $js_file : 'not found']));
$this->assertFileExists($js_file);
}
/**

View File

@ -370,7 +370,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// Check the actual file data. It should have been written to the configured
// directory, not /foobar/directory/example.txt.
$this->assertSame($this->testFileData, file_get_contents('public://foobar/example_2.txt'));
$this->assertFalse(file_exists('../../example_2.txt'));
$this->assertFileNotExists('../../example_2.txt');
// Check a path from the root. Extensions have to be empty to allow a file
// with no extension to pass validation.
@ -453,7 +453,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// Make sure that no file was saved.
$this->assertEmpty(File::load(1));
$this->assertFalse(file_exists('public://foobar/example.txt'));
$this->assertFileNotExists('public://foobar/example.txt');
}
/**
@ -479,7 +479,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// Make sure that no file was saved.
$this->assertEmpty(File::load(1));
$this->assertFalse(file_exists('public://foobar/example.txt'));
$this->assertFileNotExists('public://foobar/example.txt');
}
/**
@ -508,7 +508,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// Override the expected filesize.
$expected['filesize'][0]['value'] = strlen($php_string);
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example.php.txt'));
$this->assertFileExists('public://foobar/example.php.txt');
// Add php as an allowed format. Allow insecure uploads still being FALSE
// should still not allow this. So it should still have a .txt extension
@ -522,8 +522,8 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// Override the expected filesize.
$expected['filesize'][0]['value'] = strlen($php_string);
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example_2.php.txt'));
$this->assertFalse(file_exists('public://foobar/example_2.php'));
$this->assertFileExists('public://foobar/example_2.php.txt');
$this->assertFileNotExists('public://foobar/example_2.php');
// Allow .doc file uploads and ensure even a mis-configured apache will not
// fallback to php because the filename will be munged.
@ -539,8 +539,8 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// The file mime should be 'application/msword'.
$expected['filemime'][0]['value'] = 'application/msword';
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example_3.php_.doc'));
$this->assertFalse(file_exists('public://foobar/example_3.php.doc'));
$this->assertFileExists('public://foobar/example_3.php_.doc');
$this->assertFileNotExists('public://foobar/example_3.php.doc');
// Now allow insecure uploads.
\Drupal::configFactory()
@ -558,7 +558,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
// The file mime should also now be PHP.
$expected['filemime'][0]['value'] = 'application/x-httpd-php';
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example_4.php'));
$this->assertFileExists('public://foobar/example_4.php');
}
/**
@ -581,7 +581,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
$expected = $this->getExpectedNormalizedEntity(1, 'example.txt', TRUE);
$this->assertResponseData($expected, $response);
$this->assertTrue(file_exists('public://foobar/example.txt'));
$this->assertFileExists('public://foobar/example.txt');
}
/**

View File

@ -141,7 +141,7 @@ class HtaccessTest extends BrowserTestBase {
* The expected response code. For example: 200, 403 or 404.
*/
protected function assertFileAccess($path, $response_code) {
$this->assertTrue(file_exists(\Drupal::root() . '/' . $path), "The file $path exists.");
$this->assertFileExists(\Drupal::root() . '/' . $path);
$this->drupalGet($path);
$this->assertResponse($response_code, "Response code to $path is $response_code.");
}

View File

@ -34,7 +34,7 @@ class SystemListingTest extends KernelTestBase {
foreach ($expected_directories as $module => $directories) {
foreach ($directories as $directory) {
$filename = "$directory/$module/$module.info.yml";
$this->assertTrue(file_exists($this->root . '/' . $filename), new FormattableMarkup('@filename exists.', ['@filename' => $filename]));
$this->assertFileExists($this->root . '/' . $filename);
}
}

View File

@ -73,7 +73,7 @@ class UpdateUploadTest extends UpdateTestBase {
$updaters = drupal_get_updaters();
$moduleUpdater = $updaters['module']['class'];
$installedInfoFilePath = $this->container->get('update.root') . '/' . $moduleUpdater::getRootDirectoryRelativePath() . '/update_test_new_module/update_test_new_module.info.yml';
$this->assertFalse(file_exists($installedInfoFilePath), 'The new module does not exist in the filesystem before it is installed with the Update Manager.');
$this->assertFileNotExists($installedInfoFilePath);
$validArchiveFile = __DIR__ . '/../../update_test_new_module/8.x-1.0/update_test_new_module.tar.gz';
$edit = [
'files[project_upload]' => $validArchiveFile,
@ -85,7 +85,7 @@ class UpdateUploadTest extends UpdateTestBase {
// Check for a success message on the page, and check that the installed
// module now exists in the expected place in the filesystem.
$this->assertRaw(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
$this->assertTrue(file_exists($installedInfoFilePath), 'The new module exists in the filesystem after it is installed with the Update Manager.');
$this->assertFileExists($installedInfoFilePath);
// Ensure the links are relative to the site root and not
// core/authorize.php.
$this->assertLink(t('Install another module'));

View File

@ -61,7 +61,7 @@ class FormValuesTest extends WebDriverTestBase {
// Verify that AJAX elements with invalid callbacks return error code 500.
// Ensure the test error log is empty before these tests.
$this->assertFalse(file_exists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'), 'PHP error.log is empty.');
$this->assertFileNotExists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
// We don't need to check for the X-Drupal-Ajax-Token header with these
// invalid requests.
$this->assertAjaxHeader = FALSE;
@ -75,7 +75,7 @@ class FormValuesTest extends WebDriverTestBase {
// The select element is enabled as the response is receieved.
$this->assertSession()->waitForElement('css', "select[name=\"$element_name\"]:enabled");
$this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'), 'PHP error.log is not empty.');
$this->assertFileExists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
$this->assertStringContainsString('"The specified #ajax callback is empty or not callable."', file_get_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'));
// The exceptions are expected. Do not interpret them as a test failure.
// Not using File API; a potential error must trigger a PHP warning.

View File

@ -303,9 +303,7 @@ class UncaughtExceptionTest extends BrowserTestBase {
*/
protected function assertErrorLogged($error_message) {
$error_log_filename = DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log';
if (!file_exists($error_log_filename)) {
$this->fail('No error logged yet.');
}
$this->assertFileExists($error_log_filename);
$content = file_get_contents($error_log_filename);
$rows = explode(PHP_EOL, $content);
@ -334,7 +332,7 @@ class UncaughtExceptionTest extends BrowserTestBase {
protected function assertNoErrorsLogged() {
// Since PHP only creates the error.log file when an actual error is
// triggered, it is sufficient to check whether the file exists.
$this->assertFalse(file_exists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'), 'PHP error.log is empty.');
$this->assertFileNotExists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
}
/**

View File

@ -651,7 +651,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
*/
public function testInstall() {
$htaccess_filename = $this->tempFilesDirectory . '/.htaccess';
$this->assertTrue(file_exists($htaccess_filename), "$htaccess_filename exists");
$this->assertFileExists($htaccess_filename);
}
/**

View File

@ -27,8 +27,8 @@ class FileCopyTest extends FileTestBase {
$new_filepath = \Drupal::service('file_system')->copy($uri, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
$this->assertNotFalse($new_filepath, 'Copy was successful.');
$this->assertEqual($new_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($uri), 'Original file remains.');
$this->assertTrue(file_exists($new_filepath), 'New file exists.');
$this->assertFileExists($uri);
$this->assertFileExists($new_filepath);
$this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE));
// Copying with rename.
@ -37,8 +37,8 @@ class FileCopyTest extends FileTestBase {
$newer_filepath = \Drupal::service('file_system')->copy($uri, $desired_filepath, FileSystemInterface::EXISTS_RENAME);
$this->assertNotFalse($newer_filepath, 'Copy was successful.');
$this->assertNotEqual($newer_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($uri), 'Original file remains.');
$this->assertTrue(file_exists($newer_filepath), 'New file exists.');
$this->assertFileExists($uri);
$this->assertFileExists($newer_filepath);
$this->assertFilePermissions($newer_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE));
// TODO: test copying to a directory (rather than full directory/file path)
@ -51,7 +51,7 @@ class FileCopyTest extends FileTestBase {
public function testNonExistent() {
// Copy non-existent file
$desired_filepath = $this->randomMachineName();
$this->assertFalse(file_exists($desired_filepath), "Randomly named file doesn't exist.");
$this->assertFileNotExists($desired_filepath);
$this->expectException(FileNotExistsException::class);
$new_filepath = \Drupal::service('file_system')->copy($desired_filepath, $this->randomMachineName());
$this->assertFalse($new_filepath, 'Copying a missing file fails.');
@ -70,27 +70,27 @@ class FileCopyTest extends FileTestBase {
$new_filepath = $file_system->copy($uri, $uri, FileSystemInterface::EXISTS_RENAME);
$this->assertNotFalse($new_filepath, 'Copying onto itself with renaming works.');
$this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.');
$this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.');
$this->assertTrue(file_exists($new_filepath), 'Copied file exists after copying onto itself.');
$this->assertFileExists($uri);
$this->assertFileExists($new_filepath);
$this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE));
// Copy the file onto itself without renaming fails.
$this->expectException(FileExistsException::class);
$new_filepath = $file_system->copy($uri, $uri, FileSystemInterface::EXISTS_ERROR);
$this->assertFalse($new_filepath, 'Copying onto itself without renaming fails.');
$this->assertTrue(file_exists($uri), 'File exists after copying onto itself.');
$this->assertFileExists($uri);
// Copy the file into same directory without renaming fails.
$new_filepath = $file_system->copy($uri, $file_system->dirname($uri), FileSystemInterface::EXISTS_ERROR);
$this->assertFalse($new_filepath, 'Copying onto itself fails.');
$this->assertTrue(file_exists($uri), 'File exists after copying onto itself.');
$this->assertFileExists($uri);
// Copy the file into same directory with renaming works.
$new_filepath = $file_system->copy($uri, $file_system->dirname($uri), FileSystemInterface::EXISTS_RENAME);
$this->assertNotFalse($new_filepath, 'Copying into same directory works.');
$this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.');
$this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.');
$this->assertTrue(file_exists($new_filepath), 'Copied file exists after copying onto itself.');
$this->assertFileExists($uri);
$this->assertFileExists($new_filepath);
$this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE));
}

View File

@ -19,7 +19,7 @@ class FileDeleteRecursiveTest extends FileTestBase {
// Delete the file.
$this->assertTrue(\Drupal::service('file_system')->deleteRecursive($filepath), 'Function reported success.');
$this->assertFalse(file_exists($filepath), 'Test file has been deleted.');
$this->assertFileNotExists($filepath);
}
/**
@ -31,7 +31,7 @@ class FileDeleteRecursiveTest extends FileTestBase {
// Delete the directory.
$this->assertTrue(\Drupal::service('file_system')->deleteRecursive($directory), 'Function reported success.');
$this->assertFalse(file_exists($directory), 'Directory has been deleted.');
$this->assertDirectoryNotExists($directory);
}
/**
@ -47,9 +47,9 @@ class FileDeleteRecursiveTest extends FileTestBase {
// Delete the directory.
$this->assertTrue(\Drupal::service('file_system')->deleteRecursive($directory), 'Function reported success.');
$this->assertFalse(file_exists($filepathA), 'Test file A has been deleted.');
$this->assertFalse(file_exists($filepathB), 'Test file B has been deleted.');
$this->assertFalse(file_exists($directory), 'Directory has been deleted.');
$this->assertFileNotExists($filepathA);
$this->assertFileNotExists($filepathB);
$this->assertDirectoryNotExists($directory);
}
/**
@ -66,10 +66,10 @@ class FileDeleteRecursiveTest extends FileTestBase {
// Delete the directory.
$this->assertTrue(\Drupal::service('file_system')->deleteRecursive($directory), 'Function reported success.');
$this->assertFalse(file_exists($filepathA), 'Test file A has been deleted.');
$this->assertFalse(file_exists($filepathB), 'Test file B has been deleted.');
$this->assertFalse(file_exists($subdirectory), 'Subdirectory has been deleted.');
$this->assertFalse(file_exists($directory), 'Directory has been deleted.');
$this->assertFileNotExists($filepathA);
$this->assertFileNotExists($filepathB);
$this->assertDirectoryNotExists($subdirectory);
$this->assertDirectoryNotExists($directory);
}
}

View File

@ -20,7 +20,7 @@ class FileDeleteTest extends FileTestBase {
// Delete a regular file
$this->assertTrue(\Drupal::service('file_system')->delete($uri), 'Deleted worked.');
$this->assertFalse(file_exists($uri), 'Test file has actually been deleted.');
$this->assertFileNotExists($uri);
}
/**
@ -46,7 +46,7 @@ class FileDeleteTest extends FileTestBase {
catch (NotRegularFileException $e) {
// Ignore.
}
$this->assertTrue(file_exists($directory), 'Directory has not been deleted.');
$this->assertDirectoryExists($directory);
}
}

View File

@ -29,19 +29,19 @@ class FileMoveTest extends FileTestBase {
$new_filepath = $file_system->move($uri, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
$this->assertNotFalse($new_filepath, 'Move was successful.');
$this->assertEqual($new_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($new_filepath), 'File exists at the new location.');
$this->assertFalse(file_exists($uri), 'No file remains at the old location.');
$this->assertFileExists($new_filepath);
$this->assertFileNotExists($uri);
$this->assertFilePermissions($new_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE));
// Moving with rename.
$desired_filepath = 'public://' . $this->randomMachineName();
$this->assertTrue(file_exists($new_filepath), 'File exists before moving.');
$this->assertFileExists($new_filepath);
$this->assertNotFalse(file_put_contents($desired_filepath, ' '), 'Created a file so a rename will have to happen.');
$newer_filepath = $file_system->move($new_filepath, $desired_filepath, FileSystemInterface::EXISTS_RENAME);
$this->assertNotFalse($newer_filepath, 'Move was successful.');
$this->assertNotEqual($newer_filepath, $desired_filepath, 'Returned expected filepath.');
$this->assertTrue(file_exists($newer_filepath), 'File exists at the new location.');
$this->assertFalse(file_exists($new_filepath), 'No file remains at the old location.');
$this->assertFileExists($newer_filepath);
$this->assertFileNotExists($new_filepath);
$this->assertFilePermissions($newer_filepath, Settings::get('file_chmod_file', FileSystem::CHMOD_FILE));
// TODO: test moving to a directory (rather than full directory/file path)
@ -70,13 +70,13 @@ class FileMoveTest extends FileTestBase {
$this->expectException(FileException::class);
$new_filepath = $file_system->move($uri, $uri, FileSystemInterface::EXISTS_REPLACE);
$this->assertFalse($new_filepath, 'Moving onto itself without renaming fails.');
$this->assertTrue(file_exists($uri), 'File exists after moving onto itself.');
$this->assertFileExists($uri);
// Move the file onto itself with renaming will result in a new filename.
$new_filepath = $file_system->move($uri, $uri, FileSystemInterface::EXISTS_RENAME);
$this->assertNotFalse($new_filepath, 'Moving onto itself with renaming works.');
$this->assertFalse(file_exists($uri), 'Original file has been removed.');
$this->assertTrue(file_exists($new_filepath), 'File exists after moving onto itself.');
$this->assertFileNotExists($uri);
$this->assertFileExists($new_filepath);
}
}

View File

@ -18,8 +18,8 @@ class PharWrapperTest extends KernelTestBase {
$base = $this->getDrupalRoot() . '/core/tests/fixtures/files';
// Ensure that file operations via the phar:// stream wrapper work for phar
// files with the .phar extension.
$this->assertFalse(file_exists("phar://$base/phar-1.phar/no-such-file.php"));
$this->assertTrue(file_exists("phar://$base/phar-1.phar/index.php"));
$this->assertFileNotExists("phar://$base/phar-1.phar/no-such-file.php");
$this->assertFileExists("phar://$base/phar-1.phar/index.php");
$file_contents = file_get_contents("phar://$base/phar-1.phar/index.php");
$expected_hash = 'c7e7904ea573c5ebea3ef00bb08c1f86af1a45961fbfbeb1892ff4a98fd73ad5';
$this->assertSame($expected_hash, hash('sha256', $file_contents));

View File

@ -81,7 +81,7 @@ class ReadOnlyStreamWrapperTest extends FileTestBase {
$this->assertFalse(@rename($uri, $this->scheme . '://newname.txt'), 'Unable to rename files using the read-only stream wrapper.');
// Test the unlink() function
$this->assertTrue(@$file_system->unlink($uri), 'Able to unlink file using read-only stream wrapper.');
$this->assertTrue(file_exists($filepath), 'Unlink File was not actually deleted.');
$this->assertFileExists($filepath);
// Test the mkdir() function by attempting to create a directory.
$dirname = $this->randomMachineName();

View File

@ -44,7 +44,7 @@ class ThemeSettingsTest extends KernelTestBase {
public function testDefaultConfig() {
$name = 'test_basetheme';
$path = $this->availableThemes[$name]->getPath();
$this->assertTrue(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml"));
$this->assertFileExists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml");
$this->container->get('theme_installer')->install([$name]);
$this->assertIdentical(theme_get_setting('base', $name), 'only');
}
@ -55,7 +55,7 @@ class ThemeSettingsTest extends KernelTestBase {
public function testNoDefaultConfig() {
$name = 'stark';
$path = $this->availableThemes[$name]->getPath();
$this->assertFalse(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml"));
$this->assertFileNotExists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml");
$this->container->get('theme_installer')->install([$name]);
$this->assertNotNull(theme_get_setting('features.favicon', $name));
}

View File

@ -108,7 +108,7 @@ class FileStorageReadOnlyTest extends PhpStorageTestBase {
$this->assertFalse($php_read->deleteAll());
// Make sure directory exists prior to removal.
$this->assertTrue(file_exists($this->directory . '/test'), 'File storage directory does not exist.');
$this->assertDirectoryExists($this->directory . '/test');
}
}

View File

@ -78,11 +78,11 @@ class FileStorageTest extends PhpStorageTestBase {
$this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value');
// Make sure directory exists prior to removal.
$this->assertTrue(file_exists($this->directory . '/test'), 'File storage directory does not exist.');
$this->assertDirectoryExists($this->directory . '/test');
$this->assertTrue($php->deleteAll(), 'Delete all reported success');
$this->assertFalse($php->load($name));
$this->assertFalse(file_exists($this->directory . '/test'), 'File storage directory does not exist after call to deleteAll()');
$this->assertDirectoryNotExists($this->directory . '/test');
// Should still return TRUE if directory has already been deleted.
$this->assertTrue($php->deleteAll(), 'Delete all succeeds with nothing to delete');

View File

@ -91,7 +91,7 @@ abstract class MTimeProtectedFileStorageBase extends PhpStorageTestBase {
// Ensure the file exists and that it and the containing directory have
// minimal permissions. fileperms() can return high bits unrelated to
// permissions, so mask with 0777.
$this->assertTrue(file_exists($expected_filename));
$this->assertFileExists($expected_filename);
$this->assertSame(0444, fileperms($expected_filename) & 0777);
$this->assertSame(0777, fileperms($expected_directory) & 0777);