|
|
@@ -802,6 +802,42 @@ class Zend_File_Transfer_Adapter_AbstractTest extends PHPUnit_Framework_TestCase
|
|
|
'bar' => array('magicFile' => 'test/file', 'ignoreNoFile' => false, 'useByteString' => true),
|
|
|
), $this->adapter->getOptions('bar'));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ZF-8693
|
|
|
+ */
|
|
|
+ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoaderForDifferentFiles()
|
|
|
+ {
|
|
|
+ $validators = array(
|
|
|
+ array('MimeType', true, array('image/jpeg')), // no files
|
|
|
+ array('FilesSize', true, array('max' => '1MB', 'messages' => 'файл больше 1MБ')), // no files
|
|
|
+ array('Count', true, array('min' => 1, 'max' => '1', 'messages' => 'файл не 1'), 'bar'), // 'bar' from config
|
|
|
+ array('MimeType', true, array('image/jpeg'), 'bar'), // 'bar' from config
|
|
|
+ );
|
|
|
+
|
|
|
+ $this->adapter->addValidators($validators, 'foo'); // set validators to 'foo'
|
|
|
+
|
|
|
+ $test = $this->adapter->getValidators();
|
|
|
+ $this->assertEquals(3, count($test));
|
|
|
+
|
|
|
+ //test files specific validators
|
|
|
+ $test = $this->adapter->getValidators('foo');
|
|
|
+ $this->assertEquals(2, count($test));
|
|
|
+ $mimeType = array_shift($test);
|
|
|
+ $this->assertTrue($mimeType instanceof Zend_Validate_File_MimeType);
|
|
|
+ $filesSize = array_shift($test);
|
|
|
+ $this->assertTrue($filesSize instanceof Zend_Validate_File_FilesSize);
|
|
|
+
|
|
|
+ $test = $this->adapter->getValidators('bar');
|
|
|
+ $this->assertEquals(2, count($test));
|
|
|
+ $filesSize = array_shift($test);
|
|
|
+ $this->assertTrue($filesSize instanceof Zend_Validate_File_Count);
|
|
|
+ $mimeType = array_shift($test);
|
|
|
+ $this->assertTrue($mimeType instanceof Zend_Validate_File_MimeType);
|
|
|
+
|
|
|
+ $test = $this->adapter->getValidators('baz');
|
|
|
+ $this->assertEquals(0, count($test));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class Zend_File_Transfer_Adapter_AbstractTest_MockAdapter extends Zend_File_Transfer_Adapter_Abstract
|