public function AuditFilesNotOnServerTest::testFileEntityCanBeDeleted in Audit Files 8.3
Same name and namespace in other branches
- 8.2 tests/src/Functional/AuditFilesNotOnServerTest.php \Drupal\Tests\auditfiles\Functional\AuditFilesNotOnServerTest::testFileEntityCanBeDeleted()
Tests that an orphan file can be deleted.
An "orphan" file is one in the file system that has no corresponding record in the database.
File
- tests/
src/ Functional/ AuditFilesNotOnServerTest.php, line 97
Class
- AuditFilesNotOnServerTest
- Tests that the "Not on server" report is reachable with no errors.
Namespace
Drupal\Tests\auditfiles\FunctionalCode
public function testFileEntityCanBeDeleted() {
// Form to test.
$path = Url::fromRoute('auditfiles.audit_files_notonserver');
// Establish session.
$session = $this
->assertSession();
// Log in as admin user.
$this
->drupalLogin($this->user);
// Load the report page.
$this
->drupalGet($path);
// Check for the report title.
$session
->pageTextContains("Not on server");
$session
->pageTextContains("Found at least 3 files in the database that are not on the server.");
$session
->elementExists('css', '#audit-files-not-on-server');
$session
->elementExists('css', '#edit-files-1');
// Check box for file ID to delete from database, and delete.
$edit = [
'edit-files-1' => TRUE,
];
$this
->submitForm($edit, 'Delete selected items from the database');
// Check for correct confirmation page and submit.
$session
->pageTextContains("Delete these items from the database?");
$session
->pageTextContains("example_0.png and all usages will be deleted from the database.");
$edit = [];
$this
->submitForm($edit, 'Confirm');
// Check that target file is no longer listed.
$session
->pageTextContains("Not on server");
$session
->pageTextContains("Sucessfully deleted File ID : 1 from the file_managed table.");
$session
->pageTextContains("Found at least 2 files in the database that are not on the server.");
$session
->elementNotExists('css', '#edit-files-1');
}