Skip to content

Commit

Permalink
zendframework#4996 broke File filters management
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Aug 30, 2013
1 parent bf5d9b3 commit 531f4eb
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ZendTest/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1676,4 +1676,19 @@ public function testPreferFormInputFilterFlagIsEnabledByDefault()
{
$this->assertTrue($this->form->getPreferFormInputFilter());
}

public function testFileInputFilterNotOverwritten()
{
$form = new TestAsset\FileInputFilterProviderForm();

$formInputFilter = $form->getInputFilter();
$fieldsetInputFilter = $formInputFilter->get('file_fieldset');
$fileFilter = $fieldsetInputFilter->get('file_field');

$this->assertInstanceOf('Zend\InputFilter\FileInput', $fileFilter);

$chain = $fileFilter->getFilterChain();

$this->assertCount(1, $chain);
}
}
48 changes: 48 additions & 0 deletions tests/ZendTest/Form/TestAsset/FileInputFilterProviderFieldset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Form
*/

namespace ZendTest\Form\TestAsset;

use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;

class FileInputFilterProviderFieldset extends Fieldset implements InputFilterProviderInterface
{
public function __construct($name = null, $options = array())
{
parent::__construct($name, $options);

$this->add(array(
'type' => 'file',
'name' => 'file_field',
'options' => array(
'label' => 'File Label',
),
));

}

public function getInputFilterSpecification()
{
return array(
'file_field' => array(
'filters' => array(
array(
'name' => 'filerenameupload',
'options' => array(
'target' => __FILE__,
'randomize' => true,
),
),
),
),
);
}
}
27 changes: 27 additions & 0 deletions tests/ZendTest/Form/TestAsset/FileInputFilterProviderForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Form
*/

namespace ZendTest\Form\TestAsset;

use Zend\Form\Form;
use Zend\InputFilter\InputFilterProviderInterface;

class FileInputFilterProviderForm extends Form
{
public function __construct($name = null, $options = array())
{
parent::__construct($name, $options);

$this->add(array(
'type' => __NAMESPACE__ . '\FileInputFilterProviderFieldset',
'name' => 'file_fieldset',
));
}
}

0 comments on commit 531f4eb

Please sign in to comment.