Esempio n. 1
0
 public function testZF3891()
 {
     $files = array('name' => 'testsize.mo', 'type' => 'text', 'size' => 200, 'tmp_name' => __DIR__ . '/_files/testsize.mo', 'error' => 0);
     $validator = new File\Extension(array('MO', 'case' => true));
     $this->assertEquals(false, $validator->isValid(__DIR__ . '/_files/testsize.mo', $files));
     $validator = new File\Extension(array('MO', 'case' => false));
     $this->assertEquals(true, $validator->isValid(__DIR__ . '/_files/testsize.mo', $files));
 }
 public function validatorsFile($file, $ext)
 {
     $validator = new Extension(array($ext));
     //$validator->setMessage('L\'extension du fichier doit être bib.', Extension::FALSE_EXTENSION);
     if ($validator->isValid($file)) {
         return true;
     }
     return false;
 }
Esempio n. 3
0
 /**
  * @group ZF-11258
  */
 public function testZF11258()
 {
     $validator = new File\Extension('gif');
     $this->assertFalse($validator->isValid(__DIR__ . '/_files/nofile.mo'));
     $this->assertTrue(array_key_exists('fileExtensionNotFound', $validator->getMessages()));
     $this->assertContains("'nofile.mo'", current($validator->getMessages()));
 }
Esempio n. 4
0
 /**
  * @param array $file
  * @return bool
  */
 private function isValidFile(array $file)
 {
     $validator = new Extension(self::getAllowedExtensions());
     if (!$validator->isValid($file)) {
         return false;
     }
     // other validators if needed
     return true;
 }
Esempio n. 5
0
 public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
 {
     $validator = new File\Extension('foo');
     $this->assertFalse($validator->isValid(''));
     $this->assertArrayHasKey(File\Extension::NOT_FOUND, $validator->getMessages());
     $filesArray = array('name' => '', 'size' => 0, 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'type' => '');
     $this->assertFalse($validator->isValid($filesArray));
     $this->assertArrayHasKey(File\Extension::NOT_FOUND, $validator->getMessages());
 }