/**
  * Set the files under validation.
  *
  * @param  array  $files
  * @return BaseValidator
  */
 public function setFiles(array $files)
 {
     return $this->validator->setFiles($files);
 }
Exemple #2
0
 /**
  * Also covers the "Mimes" validation rule.
  */
 public function testValidateImage()
 {
     $trans = $this->getRealTranslator();
     $file = $this->getMock('Symfony\\Component\\HttpFoundation\\File\\File', array('guessExtension'), array(__FILE__, false));
     $file->expects($this->any())->method('guessExtension')->will($this->returnValue('php'));
     $v = new Validator($trans, array(), array('x' => 'Image'));
     $v->setFiles(array('x' => $file));
     $this->assertFalse($v->passes());
     $v = new Validator($trans, array(), array('x' => 'Image'));
     $file2 = $this->getMock('Symfony\\Component\\HttpFoundation\\File\\File', array('guessExtension'), array(__FILE__, false));
     $file2->expects($this->any())->method('guessExtension')->will($this->returnValue('jpeg'));
     $v->setFiles(array('x' => $file2));
     $this->assertTrue($v->passes());
     $file3 = $this->getMock('Symfony\\Component\\HttpFoundation\\File\\File', array('guessExtension'), array(__FILE__, false));
     $file3->expects($this->any())->method('guessExtension')->will($this->returnValue('gif'));
     $v->setFiles(array('x' => $file3));
     $this->assertTrue($v->passes());
     $file4 = $this->getMock('Symfony\\Component\\HttpFoundation\\File\\File', array('guessExtension'), array(__FILE__, false));
     $file4->expects($this->any())->method('guessExtension')->will($this->returnValue('bmp'));
     $v->setFiles(array('x' => $file4));
     $this->assertTrue($v->passes());
     $file5 = $this->getMock('Symfony\\Component\\HttpFoundation\\File\\File', array('guessExtension'), array(__FILE__, false));
     $file5->expects($this->any())->method('guessExtension')->will($this->returnValue('png'));
     $v->setFiles(array('x' => $file5));
     $this->assertTrue($v->passes());
 }