function ValidatorTest::testFileValidateIsImage

This ensures a specific file is actually an image.

File

drupal/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php, line 50
Definition of Drupal\file\Tests\ValidatorTest.

Class

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

Namespace

Drupal\file\Tests

Code

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