public function AuditFilesNotInDatabaseTest::testFileCanBeAdded in Audit Files 8.3
Same name and namespace in other branches
- 8.2 tests/src/Functional/AuditFilesNotInDatabaseTest.php \Drupal\Tests\auditfiles\Functional\AuditFilesNotInDatabaseTest::testFileCanBeAdded()
Tests that orphan file system files can be added to the database.
An "orphan" file is one in the file system that has no corresponding record in the database.
File
- tests/
src/ Functional/ AuditFilesNotInDatabaseTest.php, line 152
Class
- AuditFilesNotInDatabaseTest
- Tests that the "Not in Database" report is reachable with no errors.
Namespace
Drupal\Tests\auditfiles\FunctionalCode
public function testFileCanBeAdded() {
// Form to test.
$path = Url::fromRoute('auditfiles.notindatabase');
// 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 in database");
$session
->elementExists('css', '#edit-files-image-1png');
// Check box for file to add to database, and submit form.
$edit = [
'edit-files-image-1png' => TRUE,
];
$this
->submitForm($edit, 'Add selected items to the database');
// Check for correct confirmation page and submit.
$session
->pageTextContains("Add these files to the database?");
$edit = [];
$this
->submitForm($edit, 'Confirm');
// Check that target file is no longer listed.
$session
->pageTextContains("Not in database");
$session
->pageTextContains("Sucessfully added image-1.png to the database.");
$session
->elementNotExists('css', '#edit-files-image-1png');
}