You are here

public function FileValidatorTest::testValidMimeType 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::testValidMimeType()

File

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

Class

FileValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testValidMimeType() {
  $file = $this
    ->getMockBuilder('Symfony\\Component\\HttpFoundation\\File\\File')
    ->setConstructorArgs(array(
    __DIR__ . '/Fixtures/foo',
  ))
    ->getMock();
  $file
    ->expects($this
    ->once())
    ->method('getPathname')
    ->will($this
    ->returnValue($this->path));
  $file
    ->expects($this
    ->once())
    ->method('getMimeType')
    ->will($this
    ->returnValue('image/jpg'));
  $constraint = new File(array(
    'mimeTypes' => array(
      'image/png',
      'image/jpg',
    ),
  ));
  $this->validator
    ->validate($file, $constraint);
  $this
    ->assertNoViolation();
}