You are here

public function FileValidatorTest::testBinaryFormat in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/Constraints/FileValidatorTest.php \Symfony\Component\Validator\Tests\Constraints\FileValidatorTest::testBinaryFormat()

@dataProvider provideBinaryFormatTests

File

vendor/symfony/validator/Tests/Constraints/FileValidatorTest.php, line 267

Class

FileValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testBinaryFormat($bytesWritten, $limit, $binaryFormat, $sizeAsString, $limitAsString, $suffix) {
  fseek($this->file, $bytesWritten - 1, SEEK_SET);
  fwrite($this->file, '0');
  fclose($this->file);
  $constraint = new File(array(
    'maxSize' => $limit,
    'binaryFormat' => $binaryFormat,
    'maxSizeMessage' => 'myMessage',
  ));
  $this->validator
    ->validate($this
    ->getFile($this->path), $constraint);
  $this
    ->buildViolation('myMessage')
    ->setParameter('{{ limit }}', $limitAsString)
    ->setParameter('{{ size }}', $sizeAsString)
    ->setParameter('{{ suffix }}', $suffix)
    ->setParameter('{{ file }}', '"' . $this->path . '"')
    ->setCode(File::TOO_LARGE_ERROR)
    ->assertRaised();
}