예제 #1
0
 /**
  * Builds a new instance of this object from an array
  *
  * This is directly geared toward interpreting the $_FILES array
  *
  * @param array $input The source data
  * @return \r8\Input\Files
  */
 public static function fromArray(array $input)
 {
     $result = array();
     foreach ($input as $key => $value) {
         if (is_array($value)) {
             $result[$key] = \r8\Input\File::fromArray($value);
         }
     }
     return new self($result);
 }
예제 #2
0
파일: File.php 프로젝트: Nycto/Round-Eights
 public function testFromArray_InvalidArray()
 {
     try {
         \r8\Input\File::fromArray(array());
         $this->fail("An expected exception was not thrown");
     } catch (\r8\Exception\Argument $err) {
         $this->assertSame("The following indexes are required and missing: name, tmp_name, error", $err->getMessage());
     }
     try {
         \r8\Input\File::fromArray(array('name' => 'File Name', 'tmp_name' => '/tmp/example.txt'));
         $this->fail("An expected exception was not thrown");
     } catch (\r8\Exception\Argument $err) {
         $this->assertSame("The following indexes are required and missing: error", $err->getMessage());
     }
     try {
         \r8\Input\File::fromArray(array('name' => 'File Name'));
         $this->fail("An expected exception was not thrown");
     } catch (\r8\Exception\Argument $err) {
         $this->assertSame("The following indexes are required and missing: tmp_name, error", $err->getMessage());
     }
 }