function FileValidatorTest::testFileValidateNameLength
This will ensure the filename length is valid.
File
-
modules/
simpletest/ tests/ file.test, line 471
Class
- FileValidatorTest
- This will run tests against the file validation functions (file_validate_*).
Code
function testFileValidateNameLength() {
// Create a new file object.
$file = new stdClass();
// Add a filename with an allowed length and test it.
$file->filename = str_repeat('x', 240);
$this->assertEqual(strlen($file->filename), 240);
$errors = file_validate_name_length($file);
$this->assertEqual(count($errors), 0, 'No errors reported for 240 length filename.', 'File');
// Add a filename with a length too long and test it.
$file->filename = str_repeat('x', 241);
$errors = file_validate_name_length($file);
$this->assertEqual(count($errors), 1, 'An error reported for 241 length filename.', 'File');
// Add a filename with an empty string and test it.
$file->filename = '';
$errors = file_validate_name_length($file);
$this->assertEqual(count($errors), 1, 'An error reported for 0 length filename.', 'File');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.