function BackupMigrateUnitTest::testCleanFileName in Backup and Migrate 5
File
- tests/BackupMigrateUnitTest.test, line 261
Class
- BackupMigrateUnitTest
- Unit tests for Backup and Migrate module.
Code
function testCleanFileName() {
$safe_pattern = "/[A-Za-z0-9\\-\\_\\.]+/";
$unsafe_name = "@#/\$he*ll&o, world!";
$safe_name = _backup_migrate_clean_filename($unsafe_name);
$this
->assertTrue(preg_match($safe_pattern, $safe_name), t('Testing that filename does not contain unsafe characters'));
$this
->assertEqual($safe_name, "helloworld", t('Testing that filename is consistent with input'));
$unsafe_name = str_repeat("abc", 50);
$safe_name = _backup_migrate_clean_filename($unsafe_name);
$this
->assertTrue(strlen($safe_name) <= 50, t('Testing that filename is not too long'));
$safe_name = _backup_migrate_clean_filename("");
$this
->assertTrue(strlen($safe_name) > 1, t('Testing that filename is not non existant'));
}