Permalink
Browse files

[DomCrawler] Added ability to set file as raw path to file field

  • Loading branch information...
hason committed Aug 31, 2012
1 parent c0673d7 commit c9029664ad3c307f81efa9d3322170a96fca9398
@@ -1,6 +1,12 @@
CHANGELOG
=========
+2.2.0
+-----
+
+ * added a way to set raw path to the file in FileFormField - necessary for
+ simulating HTTP requests
+
2.1.0
-----
@@ -76,6 +76,16 @@ public function setValue($value)
$this->value = array('name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size);
}
+ /**
+ * Sets path to the file as string for simulating HTTP request
+ *
+ * @param string $path The path to the file
+ */
+ public function setFilePath($path)
+ {
+ parent::setValue($path);
+ }
+
/**
* Initializes the form field.
*
@@ -84,4 +84,14 @@ public function testSetErrorCode()
$this->assertTrue(true, '->setErrorCode() throws a \InvalidArgumentException if the error code is not valid');
}
}
+
+ public function testSetRawFilePath()
+ {
+ $node = $this->createNode('input', '', array('type' => 'file'));
+ $field = new FileFormField($node);
+ $field->setFilePath(__FILE__);
+
+ $this->assertEquals(__FILE__, $field->getValue());
+ }
+
}

0 comments on commit c902966

Please sign in to comment.