/**
  * Ensures that setFiles() returns expected value
  *
  * @return void
  */
 public function testSetFiles()
 {
     $files = array('test' => array('name' => 'test1', 'type' => 'text', 'size' => 200, 'tmp_name' => 'tmp_test1', 'error' => 0), 'test2' => array('name' => 'test2', 'type' => 'text2', 'size' => 202, 'tmp_name' => 'tmp_test2', 'error' => 1));
     $_FILES = array('test' => array('name' => 'test3', 'type' => 'text3', 'size' => 203, 'tmp_name' => 'tmp_test3', 'error' => 2));
     $validator = new Zend_Validate_File_Upload();
     $validator->setFiles(array());
     $this->assertEquals($_FILES, $validator->getFiles());
     $validator->setFiles();
     $this->assertEquals($_FILES, $validator->getFiles());
     $validator->setFiles($files);
     $this->assertEquals($files, $validator->getFiles());
 }
 /**
  * @group ZF-10738
  */
 public function testGetFilesReturnsEmptyArrayAfterSetFilesIsCalledWithNull()
 {
     $validator = new Zend_Validate_File_Upload();
     $validator->setFiles(NULL);
     $this->assertEquals(array(), $validator->getFiles());
 }
 /**
  * Checks if the files are valid
  *
  * @param  string|array $files (Optional) Files to check
  * @return boolean      True if all checks are valid
  */
 public function isValid($files = null)
 {
     // Workaround for WebServer not conforming HTTP and omitting CONTENT_LENGTH
     $content = 0;
     if (isset($_SERVER['CONTENT_LENGTH'])) {
         $content = $_SERVER['CONTENT_LENGTH'];
     } else {
         if (!empty($_POST)) {
             $content = serialize($_POST);
         }
     }
     // Workaround for a PHP error returning empty $_FILES when form data exceeds php settings
     if (empty($this->_files) && $content > 0) {
         if (is_array($files)) {
             $files = current($files);
         }
         $temp = array($files => array('name' => $files, 'error' => 1));
         $validator = new Zend_Validate_File_Upload();
         $validator->setFiles($temp)->isValid($files, null);
         $this->_messages += $validator->getMessages();
         return false;
     }
     return parent::isValid($files);
 }