Skip to content

Commit 531f4eb

Browse files
committed
zendframework#4996 broke File filters management
1 parent bf5d9b3 commit 531f4eb

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

tests/ZendTest/Form/FormTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,4 +1676,19 @@ public function testPreferFormInputFilterFlagIsEnabledByDefault()
16761676
{
16771677
$this->assertTrue($this->form->getPreferFormInputFilter());
16781678
}
1679+
1680+
public function testFileInputFilterNotOverwritten()
1681+
{
1682+
$form = new TestAsset\FileInputFilterProviderForm();
1683+
1684+
$formInputFilter = $form->getInputFilter();
1685+
$fieldsetInputFilter = $formInputFilter->get('file_fieldset');
1686+
$fileFilter = $fieldsetInputFilter->get('file_field');
1687+
1688+
$this->assertInstanceOf('Zend\InputFilter\FileInput', $fileFilter);
1689+
1690+
$chain = $fileFilter->getFilterChain();
1691+
1692+
$this->assertCount(1, $chain);
1693+
}
16791694
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
* @package Zend_Form
9+
*/
10+
11+
namespace ZendTest\Form\TestAsset;
12+
13+
use Zend\Form\Fieldset;
14+
use Zend\InputFilter\InputFilterProviderInterface;
15+
16+
class FileInputFilterProviderFieldset extends Fieldset implements InputFilterProviderInterface
17+
{
18+
public function __construct($name = null, $options = array())
19+
{
20+
parent::__construct($name, $options);
21+
22+
$this->add(array(
23+
'type' => 'file',
24+
'name' => 'file_field',
25+
'options' => array(
26+
'label' => 'File Label',
27+
),
28+
));
29+
30+
}
31+
32+
public function getInputFilterSpecification()
33+
{
34+
return array(
35+
'file_field' => array(
36+
'filters' => array(
37+
array(
38+
'name' => 'filerenameupload',
39+
'options' => array(
40+
'target' => __FILE__,
41+
'randomize' => true,
42+
),
43+
),
44+
),
45+
),
46+
);
47+
}
48+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
* @package Zend_Form
9+
*/
10+
11+
namespace ZendTest\Form\TestAsset;
12+
13+
use Zend\Form\Form;
14+
use Zend\InputFilter\InputFilterProviderInterface;
15+
16+
class FileInputFilterProviderForm extends Form
17+
{
18+
public function __construct($name = null, $options = array())
19+
{
20+
parent::__construct($name, $options);
21+
22+
$this->add(array(
23+
'type' => __NAMESPACE__ . '\FileInputFilterProviderFieldset',
24+
'name' => 'file_fieldset',
25+
));
26+
}
27+
}

0 commit comments

Comments
 (0)