public function BmTestProfiles::testFilenameOptions in Backup and Migrate 7.3
Confirm the backup filename processes work as expected.
File
- tests/
BmTestProfiles.test, line 95 - Tests the profiles functionality.
Class
- BmTestProfiles
- Test that the front page still loads.
Code
public function testFilenameOptions() {
// Load the profile. This will be interacted with directly because otherwise
// the number of form fields will likely make it impossible to execute
// properly due to the max_input_vars setting defaulting to 1000.
$profile = $this
->getProfile();
// Run a backup.
$this
->runBackup();
// Confirm that there is only one file and it has a timestamp of some sort.
$files1 = $this
->listBackupFiles();
$this
->verbose($files1);
$this
->assertTrue(count($files1) === 1, 'One backup file was found.');
$this
->assertFileTimestamp(array_shift($files1));
// Run another backup.
$this
->runBackup();
// Confirm that there are two backup files.
$files1b = $this
->listBackupFiles();
$this
->verbose($files1b);
$this
->assertTrue(count($files1b) === 2, 'Two backup files were found.');
// Cleanup before the next test - purge existing backups.
$this
->deleteBackups();
// Change settings to "create separate backups".
$profile->append_timestamp = 0;
$profile
->save();
// Run a backup.
$this
->runBackup();
// Confirm that separate files are retained.
$files2 = $this
->listBackupFiles();
$this
->verbose($files2);
$this
->assertTrue(count($files2) === 1, 'One backup file was found.');
$this
->assertNoFileTimestamp(array_shift($files2));
// Run another backup.
$this
->runBackup();
// Confirm that separate files are retained.
$files2b = $this
->listBackupFiles();
$this
->verbose($files2b);
$this
->assertTrue(count($files2b) === 2, 'Two backup files were found.');
// Cleanup before the next test - purge existing backups.
$this
->deleteBackups();
// Change settings to "overwrite".
$profile->append_timestamp = 2;
$profile
->save();
// Run a backup.
$this
->runBackup();
// Confirm that a new file was created.
$files3 = $this
->listBackupFiles();
$this
->verbose($files3);
$this
->assertTrue(count($files3) === 1, 'One backup file was found.');
$this
->assertNoFileTimestamp(array_shift($files3));
// Run the backup again.
$this
->runBackup();
// Confirm that a new file was not created.
$files3b = $this
->listBackupFiles();
$this
->verbose($files3b);
$this
->assertTrue(count($files3b) === 1, 'One backup file was found.');
// Cleanup - purge all backups.
$this
->deleteBackups();
}