FileTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Form
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. // Call Zend_Form_Element_FileTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_FileTest::main");
  25. }
  26. require_once 'Zend/Form/Element/File.php';
  27. require_once 'Zend/File/Transfer/Adapter/Abstract.php';
  28. require_once 'Zend/Validate/File/Upload.php';
  29. require_once 'Zend/Form/SubForm.php';
  30. require_once 'Zend/Form.php';
  31. require_once 'Zend/Registry.php';
  32. require_once 'Zend/View.php';
  33. /**
  34. * Test class for Zend_Form_Element_File
  35. *
  36. * @category Zend
  37. * @package Zend_Form
  38. * @subpackage UnitTests
  39. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @group Zend_Form
  42. */
  43. class Zend_Form_Element_FileTest extends PHPUnit_Framework_TestCase
  44. {
  45. /**
  46. * @var Zend_Form_Element_File
  47. */
  48. protected $element;
  49. /**
  50. * @var bool
  51. */
  52. protected $_errorOccurred = false;
  53. /**
  54. * Runs the test methods of this class.
  55. *
  56. * @return void
  57. */
  58. public static function main()
  59. {
  60. $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_FileTest");
  61. $result = PHPUnit_TextUI_TestRunner::run($suite);
  62. }
  63. /**
  64. * Sets up the fixture, for example, open a network connection.
  65. * This method is called before a test is executed.
  66. *
  67. * @return void
  68. */
  69. public function setUp()
  70. {
  71. Zend_Registry::_unsetInstance();
  72. Zend_Form::setDefaultTranslator(null);
  73. $this->element = new Zend_Form_Element_File('foo');
  74. }
  75. /**
  76. * Tears down the fixture, for example, close a network connection.
  77. * This method is called after a test is executed.
  78. *
  79. * @return void
  80. */
  81. public function tearDown()
  82. {
  83. }
  84. public function testElementShouldProxyToParentForDecoratorPluginLoader()
  85. {
  86. $loader = $this->element->getPluginLoader('decorator');
  87. $paths = $loader->getPaths('Zend_Form_Decorator');
  88. $this->assertTrue(is_array($paths));
  89. $loader = new Zend_Loader_PluginLoader;
  90. $this->element->setPluginLoader($loader, 'decorator');
  91. $test = $this->element->getPluginLoader('decorator');
  92. $this->assertSame($loader, $test);
  93. }
  94. public function testElementShouldProxyToParentWhenSettingDecoratorPrefixPaths()
  95. {
  96. $this->element->addPrefixPath('Foo_Decorator', 'Foo/Decorator/', 'decorator');
  97. $loader = $this->element->getPluginLoader('decorator');
  98. $paths = $loader->getPaths('Foo_Decorator');
  99. $this->assertTrue(is_array($paths));
  100. }
  101. public function testElementShouldAddToAllPluginLoadersWhenAddingNullPrefixPath()
  102. {
  103. $this->element->addPrefixPath('Foo', 'Foo');
  104. foreach (array('validate', 'filter', 'decorator', 'transfer_adapter') as $type) {
  105. $loader = $this->element->getPluginLoader($type);
  106. $string = str_replace('_', ' ', $type);
  107. $string = ucwords($string);
  108. $string = str_replace(' ', '_', $string);
  109. $prefix = 'Foo_' . $string;
  110. $paths = $loader->getPaths($prefix);
  111. $this->assertTrue(is_array($paths), "Failed asserting paths found for prefix $prefix");
  112. }
  113. }
  114. public function testElementShouldUseHttpTransferAdapterByDefault()
  115. {
  116. $adapter = $this->element->getTransferAdapter();
  117. $this->assertTrue($adapter instanceof Zend_File_Transfer_Adapter_Http);
  118. }
  119. public function testElementShouldAllowSpecifyingAdapterUsingConcreteInstance()
  120. {
  121. $adapter = new Zend_Form_Element_FileTest_MockAdapter();
  122. $this->element->setTransferAdapter($adapter);
  123. $test = $this->element->getTransferAdapter();
  124. $this->assertSame($adapter, $test);
  125. }
  126. /**
  127. * @expectedException Zend_Form_Element_Exception
  128. */
  129. public function testElementShouldThrowExceptionWhenAddingAdapterOfInvalidType()
  130. {
  131. $this->element->setTransferAdapter(new stdClass);
  132. }
  133. public function testShouldRegisterPluginLoaderWithFileTransferAdapterPathByDefault()
  134. {
  135. $loader = $this->element->getPluginLoader('transfer_adapter');
  136. $this->assertTrue($loader instanceof Zend_Loader_PluginLoader_Interface);
  137. $paths = $loader->getPaths('Zend_File_Transfer_Adapter');
  138. $this->assertTrue(is_array($paths));
  139. }
  140. public function testElementShouldAllowSpecifyingAdapterUsingPluginLoader()
  141. {
  142. $this->element->addPrefixPath('Zend_Form_Element_FileTest_Adapter', dirname(__FILE__) . '/_files/TransferAdapter', 'transfer_adapter');
  143. $this->element->setTransferAdapter('Foo');
  144. $test = $this->element->getTransferAdapter();
  145. $this->assertTrue($test instanceof Zend_Form_Element_FileTest_Adapter_Foo);
  146. }
  147. public function testValidatorAccessAndMutationShouldProxyToAdapter()
  148. {
  149. $this->testElementShouldAllowSpecifyingAdapterUsingConcreteInstance();
  150. $this->element->addValidator('Count', false, 1)
  151. ->addValidators(array(
  152. 'Extension' => 'jpg',
  153. new Zend_Validate_File_Upload(),
  154. ));
  155. $validators = $this->element->getValidators();
  156. $test = $this->element->getTransferAdapter()->getValidators();
  157. $this->assertEquals($validators, $test);
  158. $this->assertTrue(is_array($test));
  159. $this->assertEquals(3, count($test));
  160. $validator = $this->element->getValidator('count');
  161. $test = $this->element->getTransferAdapter()->getValidator('count');
  162. $this->assertNotNull($validator);
  163. $this->assertSame($validator, $test);
  164. $this->element->removeValidator('Extension');
  165. $this->assertFalse($this->element->getTransferAdapter()->hasValidator('Extension'));
  166. $this->element->setValidators(array(
  167. 'Upload',
  168. array('validator' => 'Extension', 'options' => 'jpg'),
  169. array('validator' => 'Count', 'options' => 1),
  170. ));
  171. $validators = $this->element->getValidators();
  172. $test = $this->element->getTransferAdapter()->getValidators();
  173. $this->assertSame($validators, $test);
  174. $this->assertTrue(is_array($test));
  175. $this->assertEquals(3, count($test), var_export($test, 1));
  176. $this->element->clearValidators();
  177. $validators = $this->element->getValidators();
  178. $this->assertTrue(is_array($validators));
  179. $this->assertEquals(0, count($validators));
  180. $test = $this->element->getTransferAdapter()->getValidators();
  181. $this->assertSame($validators, $test);
  182. }
  183. public function testValidationShouldProxyToAdapter()
  184. {
  185. $this->markTestIncomplete('Unsure how to accurately test');
  186. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter);
  187. $this->element->addValidator('Regex', '/([a-z0-9]{13})$/i');
  188. $this->assertTrue($this->element->isValid('foo.jpg'));
  189. }
  190. public function testDestinationMutatorsShouldProxyToTransferAdapter()
  191. {
  192. $adapter = new Zend_Form_Element_FileTest_MockAdapter();
  193. $this->element->setTransferAdapter($adapter);
  194. $this->element->setDestination(dirname(__FILE__));
  195. $this->assertEquals(dirname(__FILE__), $this->element->getDestination());
  196. $this->assertEquals(dirname(__FILE__), $this->element->getTransferAdapter()->getDestination('foo'));
  197. }
  198. public function testSettingMultipleFiles()
  199. {
  200. $this->element->setMultiFile(3);
  201. $this->assertEquals(3, $this->element->getMultiFile());
  202. }
  203. public function testFileInSubSubSubform()
  204. {
  205. $form = new Zend_Form();
  206. $element = new Zend_Form_Element_File('file1');
  207. $element2 = new Zend_Form_Element_File('file2');
  208. $subform0 = new Zend_Form_SubForm();
  209. $subform0->addElement($element);
  210. $subform0->addElement($element2);
  211. $subform1 = new Zend_Form_SubForm();
  212. $subform1->addSubform($subform0, 'subform0');
  213. $subform2 = new Zend_Form_SubForm();
  214. $subform2->addSubform($subform1, 'subform1');
  215. $subform3 = new Zend_Form_SubForm();
  216. $subform3->addSubform($subform2, 'subform2');
  217. $form->addSubform($subform3, 'subform3');
  218. $form->setView(new Zend_View());
  219. $output = (string) $form;
  220. $this->assertContains('name="file1"', $output);
  221. $this->assertContains('name="file2"', $output);
  222. }
  223. public function testMultiFileInSubSubSubform()
  224. {
  225. $form = new Zend_Form();
  226. $element = new Zend_Form_Element_File('file');
  227. $element->setMultiFile(2);
  228. $subform0 = new Zend_Form_SubForm();
  229. $subform0->addElement($element);
  230. $subform1 = new Zend_Form_SubForm();
  231. $subform1->addSubform($subform0, 'subform0');
  232. $subform2 = new Zend_Form_SubForm();
  233. $subform2->addSubform($subform1, 'subform1');
  234. $subform3 = new Zend_Form_SubForm();
  235. $subform3->addSubform($subform2, 'subform2');
  236. $form->addSubform($subform3, 'subform3');
  237. $form->setView(new Zend_View());
  238. $output = (string) $form;
  239. $this->assertContains('name="file[]"', $output);
  240. $this->assertEquals(2, substr_count($output, 'file[]'));
  241. }
  242. public function testMultiFileWithOneFile()
  243. {
  244. $form = new Zend_Form();
  245. $element = new Zend_Form_Element_File('file');
  246. $element->setMultiFile(1);
  247. $subform0 = new Zend_Form_SubForm();
  248. $subform0->addElement($element);
  249. $subform1 = new Zend_Form_SubForm();
  250. $subform1->addSubform($subform0, 'subform0');
  251. $subform2 = new Zend_Form_SubForm();
  252. $subform2->addSubform($subform1, 'subform1');
  253. $subform3 = new Zend_Form_SubForm();
  254. $subform3->addSubform($subform2, 'subform2');
  255. $form->addSubform($subform3, 'subform3');
  256. $form->setView(new Zend_View());
  257. $output = (string) $form;
  258. $this->assertNotContains('name="file[]"', $output);
  259. }
  260. public function testSettingMaxFileSize()
  261. {
  262. $max = $this->_convertIniToInteger(trim(ini_get('upload_max_filesize')));
  263. $this->assertEquals(0, $this->element->getMaxFileSize());
  264. $this->element->setMaxFileSize($max);
  265. $this->assertEquals($max, $this->element->getMaxFileSize());
  266. $this->_errorOccurred = false;
  267. set_error_handler(array($this, 'errorHandlerIgnore'));
  268. $this->element->setMaxFileSize(999999999999);
  269. if (!$this->_errorOccurred) {
  270. $this->fail('INI exception expected');
  271. }
  272. restore_error_handler();
  273. }
  274. public function testAutoGetPostMaxSize()
  275. {
  276. $this->element->setMaxFileSize(-1);
  277. $this->assertNotEquals(-1, $this->element->getMaxFileSize());
  278. }
  279. public function testTranslatingValidatorErrors()
  280. {
  281. require_once 'Zend/Translate.php';
  282. $translate = new Zend_Translate('array', array('unused', 'foo' => 'bar'), 'en');
  283. $this->element->setTranslator($translate);
  284. $adapter = $this->element->getTranslator();
  285. $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
  286. $adapter = $this->element->getTransferAdapter();
  287. $adapter = $adapter->getTranslator();
  288. $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
  289. $this->assertFalse($this->element->translatorIsDisabled());
  290. $this->element->setDisableTranslator($translate);
  291. $this->assertTrue($this->element->translatorIsDisabled());
  292. }
  293. public function testFileNameWithoutPath()
  294. {
  295. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
  296. $this->element->setDestination(dirname(__FILE__));
  297. $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName('foo', true));
  298. $this->assertEquals('foo.jpg', $this->element->getFileName('foo', false));
  299. }
  300. public function testEmptyFileName()
  301. {
  302. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
  303. $this->element->setDestination(dirname(__FILE__));
  304. $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName());
  305. }
  306. public function testIsReceived()
  307. {
  308. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
  309. $this->assertEquals(false, $this->element->isReceived());
  310. }
  311. public function testIsUploaded()
  312. {
  313. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
  314. $this->assertEquals(true, $this->element->isUploaded());
  315. }
  316. public function testIsFiltered()
  317. {
  318. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
  319. $this->assertEquals(true, $this->element->isFiltered());
  320. }
  321. public function testDefaultDecorators()
  322. {
  323. $this->element->clearDecorators();
  324. $this->assertEquals(array(), $this->element->getDecorators());
  325. $this->element->setDisableLoadDefaultDecorators(true);
  326. $this->element->loadDefaultDecorators();
  327. $this->assertEquals(array(), $this->element->getDecorators());
  328. $this->element->setDisableLoadDefaultDecorators(false);
  329. $this->element->loadDefaultDecorators();
  330. $this->assertNotEquals(array(), $this->element->getDecorators());
  331. }
  332. public function testValueGetAndSet()
  333. {
  334. $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
  335. $this->assertEquals(null, $this->element->getValue());
  336. $this->element->setValue('something');
  337. $this->assertEquals(null, $this->element->getValue());
  338. }
  339. public function testMarkerInterfaceForFileElement()
  340. {
  341. $this->element->setDecorators(array('ViewHelper'));
  342. $this->assertEquals(1, count($this->element->getDecorators()));
  343. try {
  344. $content = $this->element->render(new Zend_View());
  345. $this->fail();
  346. } catch (Zend_Form_Element_Exception $e) {
  347. $this->assertContains('No file decorator found', $e->getMessage());
  348. }
  349. }
  350. public function testFileSize()
  351. {
  352. $element = new Zend_Form_Element_File('baz');
  353. $adapter = new Zend_Form_Element_FileTest_MockAdapter();
  354. $element->setTransferAdapter($adapter);
  355. $this->assertEquals('1.14kB', $element->getFileSize('baz.text'));
  356. $adapter->setOptions(array('useByteString' => false));
  357. $this->assertEquals(1172, $element->getFileSize('baz.text'));
  358. }
  359. public function testMimeType()
  360. {
  361. $element = new Zend_Form_Element_File('baz');
  362. $adapter = new Zend_Form_Element_FileTest_MockAdapter();
  363. $element->setTransferAdapter($adapter);
  364. $this->assertEquals('text/plain', $element->getMimeType('baz.text'));
  365. }
  366. public function testAddedErrorsAreDisplayed()
  367. {
  368. Zend_Form::setDefaultTranslator(null);
  369. $element = new Zend_Form_Element_File('baz');
  370. $element->addError('TestError3');
  371. $adapter = new Zend_Form_Element_FileTest_MockAdapter();
  372. $element->setTransferAdapter($adapter);
  373. $this->assertTrue($element->hasErrors());
  374. $messages = $element->getMessages();
  375. $this->assertContains('TestError3', $messages);
  376. }
  377. public function testGetTranslatorRetrievesGlobalDefaultWhenAvailable()
  378. {
  379. $this->assertNull($this->element->getTranslator());
  380. $translator = new Zend_Translate('array', array('foo' => 'bar'));
  381. require_once 'Zend/Form.php';
  382. Zend_Form::setDefaultTranslator($translator);
  383. $received = $this->element->getTranslator();
  384. $this->assertSame($translator->getAdapter(), $received);
  385. }
  386. public function testDefaultDecoratorsContainDescription()
  387. {
  388. $element = new Zend_Form_Element_File('baz');
  389. $decorators = $element->getDecorator('Description');
  390. $this->assertTrue($decorators instanceof Zend_Form_Decorator_Description);
  391. }
  392. private function _convertIniToInteger($setting)
  393. {
  394. if (!is_numeric($setting)) {
  395. $type = strtoupper(substr($setting, -1));
  396. $setting = (integer) substr($setting, 0, -1);
  397. switch ($type) {
  398. case 'M' :
  399. $setting *= 1024;
  400. break;
  401. case 'G' :
  402. $setting *= 1024 * 1024;
  403. break;
  404. default :
  405. break;
  406. }
  407. }
  408. return (integer) $setting;
  409. }
  410. /**
  411. * Ignores a raised PHP error when in effect, but throws a flag to indicate an error occurred
  412. *
  413. * @param integer $errno
  414. * @param string $errstr
  415. * @param string $errfile
  416. * @param integer $errline
  417. * @param array $errcontext
  418. * @return void
  419. */
  420. public function errorHandlerIgnore($errno, $errstr, $errfile, $errline, array $errcontext)
  421. {
  422. $this->_errorOccurred = true;
  423. }
  424. /**
  425. * Prove the fluent interface on Zend_Form_Element_File::loadDefaultDecorators
  426. *
  427. * @link http://framework.zend.com/issues/browse/ZF-9913
  428. * @return void
  429. */
  430. public function testFluentInterfaceOnLoadDefaultDecorators()
  431. {
  432. $this->assertSame($this->element, $this->element->loadDefaultDecorators());
  433. }
  434. /**
  435. * @group ZF-12173
  436. */
  437. public function testElementShouldAllowAdapterWithBackslahes()
  438. {
  439. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  440. $this->markTestSkipped(
  441. __CLASS__ . '::' . __METHOD__ . ' requires PHP 5.3.0 or greater'
  442. );
  443. return;
  444. }
  445. $this->element->addPrefixPath(
  446. 'Zend\Form\Element\FileTest\Adapter',
  447. dirname(__FILE__) . '/_files/TransferAdapter',
  448. 'transfer_adapter'
  449. );
  450. $this->element->setTransferAdapter('Bar');
  451. $test = $this->element->getTransferAdapter();
  452. $expectedType = 'Zend\Form\Element\FileTest\Adapter\Bar';
  453. $this->assertTrue(
  454. $test instanceof $expectedType
  455. );
  456. }
  457. /**
  458. * @group ZF-12210
  459. */
  460. public function testAutoInsertNotEmptyValidator()
  461. {
  462. $this->testElementShouldAllowSpecifyingAdapterUsingConcreteInstance();
  463. $this->element->setRequired(true);
  464. // Test before validation
  465. $this->assertNull($this->element->getValidator('NotEmpty'));
  466. // Test after validation
  467. $this->element->isValid('foo.jpg');
  468. $this->assertTrue(
  469. $this->element->getValidator('NotEmpty') instanceof Zend_Validate_NotEmpty
  470. );
  471. }
  472. /**
  473. * @group GH-247
  474. */
  475. public function testCallbackFunctionAtHtmlTag()
  476. {
  477. $this->assertEquals(
  478. array(
  479. 'callback' => array(
  480. 'Zend_Form_Element_File',
  481. 'resolveElementId',
  482. ),
  483. ),
  484. $this->element->getDecorator('HtmlTag')->getOption('id')
  485. );
  486. }
  487. /**
  488. * @group GH-247
  489. */
  490. public function testDefaultDecoratorOrder()
  491. {
  492. $expected = array(
  493. 'Zend_Form_Decorator_File',
  494. 'Zend_Form_Decorator_Errors',
  495. 'Zend_Form_Decorator_Description',
  496. 'Zend_Form_Decorator_HtmlTag',
  497. 'Zend_Form_Decorator_Label',
  498. );
  499. $this->assertEquals(
  500. $expected,
  501. array_keys($this->element->getDecorators())
  502. );
  503. }
  504. }
  505. class Zend_Form_Element_FileTest_MockAdapter extends Zend_File_Transfer_Adapter_Abstract
  506. {
  507. public $received = false;
  508. public function __construct()
  509. {
  510. $testfile = dirname(__FILE__) . '/../../File/Transfer/Adapter/_files/test.txt';
  511. $this->_files = array(
  512. 'foo' => array(
  513. 'name' => 'foo.jpg',
  514. 'type' => 'image/jpeg',
  515. 'size' => 126976,
  516. 'tmp_name' => '/tmp/489127ba5c89c',
  517. 'options' => array('ignoreNoFile' => false, 'useByteString' => true),
  518. 'validated' => false,
  519. 'received' => false,
  520. 'filtered' => false,
  521. 'validators' => array(),
  522. ),
  523. 'bar' => array(
  524. 'name' => 'bar.png',
  525. 'type' => 'image/png',
  526. 'size' => 91136,
  527. 'tmp_name' => '/tmp/489128284b51f',
  528. 'options' => array('ignoreNoFile' => false, 'useByteString' => true),
  529. 'validated' => false,
  530. 'received' => false,
  531. 'filtered' => false,
  532. 'validators' => array(),
  533. ),
  534. 'baz' => array(
  535. 'name' => 'baz.text',
  536. 'type' => 'text/plain',
  537. 'size' => 1172,
  538. 'tmp_name' => $testfile,
  539. 'options' => array('ignoreNoFile' => false, 'useByteString' => true),
  540. 'validated' => false,
  541. 'received' => false,
  542. 'filtered' => false,
  543. 'validators' => array(),
  544. ),
  545. 'file_1_' => array(
  546. 'name' => 'baz.text',
  547. 'type' => 'text/plain',
  548. 'size' => 1172,
  549. 'tmp_name' => '/tmp/4891286cceff3',
  550. 'options' => array('ignoreNoFile' => false, 'useByteString' => true),
  551. 'validated' => false,
  552. 'received' => false,
  553. 'filtered' => false,
  554. 'validators' => array(),
  555. ),
  556. 'file_2_' => array(
  557. 'name' => 'baz.text',
  558. 'type' => 'text/plain',
  559. 'size' => 1172,
  560. 'tmp_name' => '/tmp/4891286cceff3',
  561. 'options' => array('ignoreNoFile' => false, 'useByteString' => true),
  562. 'validated' => false,
  563. 'received' => false,
  564. 'filtered' => false,
  565. 'validators' => array(),
  566. ),
  567. );
  568. }
  569. public function send($options = null)
  570. {
  571. return;
  572. }
  573. public function receive($options = null)
  574. {
  575. $this->received = true;
  576. return;
  577. }
  578. public function isSent($file = null)
  579. {
  580. return false;
  581. }
  582. public function isReceived($file = null)
  583. {
  584. return $this->received;
  585. }
  586. public function isUploaded($files = null)
  587. {
  588. return true;
  589. }
  590. public function isFiltered($files = null)
  591. {
  592. return true;
  593. }
  594. public static function getProgress()
  595. {
  596. return;
  597. }
  598. }
  599. // Call Zend_Form_Element_FileTest::main() if this source file is executed directly.
  600. if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_FileTest::main") {
  601. Zend_Form_Element_FileTest::main();
  602. }