Skip to content

Commit 0fc0fb3

Browse files
committed
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 ?
2 parents eb17646 + c902966 commit 0fc0fb3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Symfony/Component/DomCrawler/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
2.2.0
5+
-----
6+
7+
* added a way to set raw path to the file in FileFormField - necessary for
8+
simulating HTTP requests
9+
410
2.1.0
511
-----
612

src/Symfony/Component/DomCrawler/Field/FileFormField.php

+10
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ public function setValue($value)
7676
$this->value = array('name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size);
7777
}
7878

79+
/**
80+
* Sets path to the file as string for simulating HTTP request
81+
*
82+
* @param string $path The path to the file
83+
*/
84+
public function setFilePath($path)
85+
{
86+
parent::setValue($path);
87+
}
88+
7989
/**
8090
* Initializes the form field.
8191
*

src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,14 @@ public function testSetErrorCode()
8484
$this->assertTrue(true, '->setErrorCode() throws a \InvalidArgumentException if the error code is not valid');
8585
}
8686
}
87+
88+
public function testSetRawFilePath()
89+
{
90+
$node = $this->createNode('input', '', array('type' => 'file'));
91+
$field = new FileFormField($node);
92+
$field->setFilePath(__FILE__);
93+
94+
$this->assertEquals(__FILE__, $field->getValue());
95+
}
96+
8797
}

0 commit comments

Comments
 (0)