You are here

public function ValidatorTest::testFileValidateIsImage in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/ValidatorTest.php \Drupal\Tests\file\Kernel\ValidatorTest::testFileValidateIsImage()
  2. 9 core/modules/file/tests/src/Kernel/ValidatorTest.php \Drupal\Tests\file\Kernel\ValidatorTest::testFileValidateIsImage()

This ensures a specific file is actually an image.

File

core/modules/file/tests/src/Kernel/ValidatorTest.php, line 141

Class

ValidatorTest
Tests the functions used to validate uploaded files.

Namespace

Drupal\Tests\file\Kernel

Code

public function testFileValidateIsImage() {
  $this
    ->assertFileExists($this->image
    ->getFileUri());
  $errors = file_validate_is_image($this->image);
  $this
    ->assertCount(0, $errors, 'No error reported for our image file.');
  $this
    ->assertFileExists($this->nonImage
    ->getFileUri());
  $errors = file_validate_is_image($this->nonImage);
  $this
    ->assertCount(1, $errors, 'An error reported for our non-image file.');
}