Permalink
Browse files

merged branch hason/crawler (PR #5407)

This PR was merged into the master branch.

Commits
-------

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

Discussion
----------

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

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

For description see #4674 (#4674 (comment))

Related PRs:

Behat/MinkBrowserKitDriver#1
https://github.com/Behat/MinkGoutteDriver/pull/7
FriendsOfPHP/Goutte#77

---------------------------------------------------------------------------

by stof at 2012-10-13T21:53:27Z

@fabpot anything missing here ?
  • Loading branch information...
2 parents eb17646 + c902966 commit 0fc0fb3b9ca37981fdd3b9ac1621a08c4498a8df @fabpot fabpot committed Oct 14, 2012
@@ -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
-----
@@ -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
@@ -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 0fc0fb3

Please sign in to comment.