function FileValidatorTest::testFileValidateIsImage

7.x file.test FileValidatorTest::testFileValidateIsImage()

This ensures a specific file is actually an image.

File

drupal-7.x/modules/simpletest/tests/file.test, line 401
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileValidatorTest
This will run tests against the file validation functions (file_validate_*).

Code

function testFileValidateIsImage() {
  $this->assertTrue(file_exists($this->image->uri), 'The image being tested exists.', 'File');
  $errors = file_validate_is_image($this->image);
  $this->assertEqual(count($errors), 0, 'No error reported for our image file.', 'File');

  $this->assertTrue(file_exists($this->non_image->uri), 'The non-image being tested exists.', 'File');
  $errors = file_validate_is_image($this->non_image);
  $this->assertEqual(count($errors), 1, 'An error reported for our non-image file.', 'File');
}