[DomCrawler] Added ability to set file as raw path to file field
This commit is contained in:
parent
c0673d77d0
commit
c9029664ad
@ -1,6 +1,12 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
2.2.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added a way to set raw path to the file in FileFormField - necessary for
|
||||||
|
simulating HTTP requests
|
||||||
|
|
||||||
2.1.0
|
2.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -76,6 +76,16 @@ class FileFormField extends FormField
|
|||||||
$this->value = array('name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size);
|
$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.
|
* Initializes the form field.
|
||||||
*
|
*
|
||||||
|
@ -84,4 +84,14 @@ class FileFormFieldTest extends FormFieldTestCase
|
|||||||
$this->assertTrue(true, '->setErrorCode() throws a \InvalidArgumentException if the error code is not valid');
|
$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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user