You are here

protected function BmTestBase::fileHasTimestamp in Backup and Migrate 7.3

Work out whether a backup filename includes a timestamp.

Parameters

object $file: The backup file to examine.

Return value

mixed Returns 1 if found, 0 if not found, FALSE if an error occurs.

2 calls to BmTestBase::fileHasTimestamp()
BmTestBase::assertFileTimestamp in tests/BmTestBase.test
Confirm that a backup filename includes a timestamp.
BmTestBase::assertNoFileTimestamp in tests/BmTestBase.test
Confirm that a backup filename does not include a timestamp.

File

tests/BmTestBase.test, line 206
Shared functionality to make the rest of the tests simpler.

Class

BmTestBase
Base class for testing a module's custom tags.

Code

protected function fileHasTimestamp($file) {
  require_once dirname(__FILE__) . '/../includes/files.inc';

  // Get the default filename, this is used later.
  $default_filename = _backup_migrate_default_filename();
  $ext = implode('.', $file->ext);
  $pattern = "/{$default_filename}-(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d)-(\\d\\d)-(\\d\\d).{$ext}/";
  return preg_match($pattern, $file->file_info['filename']);
}