Skip to content
Browse files

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

  • Loading branch information...
1 parent c0673d7 commit c9029664ad3c307f81efa9d3322170a96fca9398 @hason hason committed Aug 31, 2012
View
6 src/Symfony/Component/DomCrawler/CHANGELOG.md
@@ -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
-----
View
10 src/Symfony/Component/DomCrawler/Field/FileFormField.php
@@ -77,6 +77,16 @@ public function setValue($value)
}
/**
+ * 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.
*
* @throws \LogicException When node type is incorrect
View
10 src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php
@@ -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.
Something went wrong with that request. Please try again.