function LegacyValidatorTest::testFileValidateIsImage

Same name in other branches
  1. 10 core/modules/file/tests/src/Kernel/LegacyValidatorTest.php \Drupal\Tests\file\Kernel\LegacyValidatorTest::testFileValidateIsImage()

This ensures a specific file is actually an image.

File

core/modules/file/tests/src/Kernel/LegacyValidatorTest.php, line 148

Class

LegacyValidatorTest
Tests the functions used to validate uploaded files.

Namespace

Drupal\Tests\file\Kernel

Code

public function testFileValidateIsImage() {
    $this->assertFileExists($this->image
        ->getFileUri());
    $this->expectDeprecation('file_validate_is_image() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use the \'file.validator\' service instead. See https://www.drupal.org/node/3363700');
    $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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.