function FileIsImageConstraintValidatorTest::setUp

Same name and namespace in other branches
  1. 11.x core/modules/file/tests/src/Kernel/Plugin/Validation/Constraint/FileIsImageConstraintValidatorTest.php \Drupal\Tests\file\Kernel\Plugin\Validation\Constraint\FileIsImageConstraintValidatorTest::setUp()

Overrides FileValidatorTestBase::setUp

File

core/modules/file/tests/src/Kernel/Plugin/Validation/Constraint/FileIsImageConstraintValidatorTest.php, line 36

Class

FileIsImageConstraintValidatorTest
Tests the FileIsImageConstraintValidator.

Namespace

Drupal\Tests\file\Kernel\Plugin\Validation\Constraint

Code

protected function setUp() : void {
  parent::setUp();
  $this->image = File::create();
  $this->image
    ->setFileUri('core/misc/druplicon.png');
  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = \Drupal::service('file_system');
  $this->image
    ->setFilename($file_system->basename($this->image
    ->getFileUri()));
  $this->nonImage = File::create();
  $this->nonImage
    ->setFileUri('core/assets/vendor/jquery/jquery.min.js');
  $this->nonImage
    ->setFilename($file_system->basename($this->nonImage
    ->getFileUri()));
}

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