Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[2.1][File Upload] Session Progress fixes #3058

Closed
wants to merge 2 commits into from

2 participants

@cgmartin

Added checks for missing session key and division by zero to Zend\ProgressBar\Upload\SessionProgress.

Moved file progress Form Elements to Form View Helpers. Usage as Elements was awkward, and unnecessary cluttering of the Form object. NOTE: This does not introduce any BC breaks since the File Upload work is only part of the develop branch, and not currently in master.

Example Session Progress usage can be found here: https://github.com/cgmartin/ZF2FileUploadExamples

@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-progressbar
@weierophinney weierophinney Merge branch 'feature/form-upload-progress' into develop 3bb86fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
42 library/Zend/Form/Element/File/ApcProgress.php
@@ -1,42 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Form
- * @subpackage Element
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-namespace Zend\Form\Element\File;
-
-/**
- * @category Zend
- * @package Zend_Form
- * @subpackage Element
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class ApcProgress extends UploadProgress
-{
- /**
- * Get value for name
- *
- * @return string|int
- */
- public function getName()
- {
- return ini_get('apc.rfc1867_name');
- }
-}
View
42 library/Zend/Form/Element/File/SessionProgress.php
@@ -1,42 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Form
- * @subpackage Element
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-namespace Zend\Form\Element\File;
-
-/**
- * @category Zend
- * @package Zend_Form
- * @subpackage Element
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class SessionProgress extends UploadProgress
-{
- /**
- * Get value for name
- *
- * @return string|int
- */
- public function getName()
- {
- return ini_get('session.upload_progress.name');
- }
-}
View
68 library/Zend/Form/Element/File/UploadProgress.php
@@ -1,68 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Form
- * @subpackage Element
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-namespace Zend\Form\Element\File;
-
-use Zend\Form\Exception;
-use Zend\Form\Element\Hidden;
-
-/**
- * @category Zend
- * @package Zend_Form
- * @subpackage Element
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class UploadProgress extends Hidden
-{
- /**
- * Seed attributes
- *
- * @var array
- */
- protected $attributes = array(
- 'type' => 'hidden',
- 'id' => 'progress_key',
- );
-
- /**
- * Retrieve the element value
- *
- * @return mixed
- */
- public function getValue()
- {
- if (!isset($this->value)) {
- $this->value = uniqid();
- }
- return $this->value;
- }
-
- /**
- * Get value for name
- *
- * @return string|int
- */
- public function getName()
- {
- return 'UPLOAD_IDENTIFIER';
- }
-}
View
30 library/Zend/Form/View/Helper/File/FormFileApcProgress.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form
+ */
+
+namespace Zend\Form\View\Helper\File;
+
+/**
+ * A view helper to render the hidden input with a Session progress id
+ * for file uploads progress tracking.
+ *
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage View
+ */
+class FormFileApcProgress extends FormFileUploadProgress
+{
+ /**
+ * @return string
+ */
+ protected function getName()
+ {
+ return ini_get('apc.rfc1867_name');
+ }
+}
View
30 library/Zend/Form/View/Helper/File/FormFileSessionProgress.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form
+ */
+
+namespace Zend\Form\View\Helper\File;
+
+/**
+ * A view helper to render the hidden input with a Session progress id
+ * for file uploads progress tracking.
+ *
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage View
+ */
+class FormFileSessionProgress extends FormFileUploadProgress
+{
+ /**
+ * @return string
+ */
+ protected function getName()
+ {
+ return ini_get('session.upload_progress.name');
+ }
+}
View
74 library/Zend/Form/View/Helper/File/FormFileUploadProgress.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form
+ */
+
+namespace Zend\Form\View\Helper\File;
+
+use Zend\Form\ElementInterface;
+use Zend\Form\View\Helper\FormInput;
+
+/**
+ * A view helper to render the hidden input with a UploadProgress id
+ * for file uploads progress tracking.
+ *
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage View
+ */
+class FormFileUploadProgress extends FormInput
+{
+ /**
+ * Invoke helper as functor
+ *
+ * Proxies to {@link render()}.
+ *
+ * @param ElementInterface|null $element
+ * @return string
+ */
+ public function __invoke(ElementInterface $element = null)
+ {
+ return $this->renderHiddenId();
+ }
+
+ /**
+ * Render a hidden form <input> element with the progress id
+ *
+ * @return string
+ */
+ public function renderHiddenId()
+ {
+ $attributes = array();
+ $attributes['id'] = 'progress_key';
+ $attributes['name'] = $this->getName();
+ $attributes['type'] = 'hidden';
+ $attributes['value'] = $this->getValue();
+
+ return sprintf(
+ '<input %s%s',
+ $this->createAttributesString($attributes),
+ $this->getInlineClosingBracket()
+ );
+ }
+
+ /**
+ * @return string
+ */
+ protected function getName()
+ {
+ return 'UPLOAD_IDENTIFIER';
+ }
+
+ /**
+ * @return string
+ */
+ protected function getValue()
+ {
+ return uniqid();
+ }
+}
View
97 library/Zend/Form/View/HelperConfig.php
@@ -26,53 +26,56 @@ class HelperConfig implements ConfigInterface
* @var array Pre-aliased view helpers
*/
protected $invokables = array(
- 'form' => 'Zend\Form\View\Helper\Form',
- 'formbutton' => 'Zend\Form\View\Helper\FormButton',
- 'formcaptcha' => 'Zend\Form\View\Helper\FormCaptcha',
- 'captchadumb' => 'Zend\Form\View\Helper\Captcha\Dumb',
- 'formcaptchadumb' => 'Zend\Form\View\Helper\Captcha\Dumb',
- 'captchafiglet' => 'Zend\Form\View\Helper\Captcha\Figlet',
- 'formcaptchafiglet' => 'Zend\Form\View\Helper\Captcha\Figlet',
- 'captchaimage' => 'Zend\Form\View\Helper\Captcha\Image',
- 'formcaptchaimage' => 'Zend\Form\View\Helper\Captcha\Image',
- 'captcharecaptcha' => 'Zend\Form\View\Helper\Captcha\ReCaptcha',
- 'formcaptcharecaptcha' => 'Zend\Form\View\Helper\Captcha\ReCaptcha',
- 'formcheckbox' => 'Zend\Form\View\Helper\FormCheckbox',
- 'formcollection' => 'Zend\Form\View\Helper\FormCollection',
- 'formcolor' => 'Zend\Form\View\Helper\FormColor',
- 'formdate' => 'Zend\Form\View\Helper\FormDate',
- 'formdatetime' => 'Zend\Form\View\Helper\FormDateTime',
- 'formdatetimelocal' => 'Zend\Form\View\Helper\FormDateTimeLocal',
- 'formdatetimeselect' => 'Zend\Form\View\Helper\FormDateTimeSelect',
- 'formdateselect' => 'Zend\Form\View\Helper\FormDateSelect',
- 'formelement' => 'Zend\Form\View\Helper\FormElement',
- 'formelementerrors' => 'Zend\Form\View\Helper\FormElementErrors',
- 'formemail' => 'Zend\Form\View\Helper\FormEmail',
- 'formfile' => 'Zend\Form\View\Helper\FormFile',
- 'formhidden' => 'Zend\Form\View\Helper\FormHidden',
- 'formimage' => 'Zend\Form\View\Helper\FormImage',
- 'forminput' => 'Zend\Form\View\Helper\FormInput',
- 'formlabel' => 'Zend\Form\View\Helper\FormLabel',
- 'formmonth' => 'Zend\Form\View\Helper\FormMonth',
- 'formmonthselect' => 'Zend\Form\View\Helper\FormMonthSelect',
- 'formmulticheckbox' => 'Zend\Form\View\Helper\FormMultiCheckbox',
- 'formnumber' => 'Zend\Form\View\Helper\FormNumber',
- 'formpassword' => 'Zend\Form\View\Helper\FormPassword',
- 'formradio' => 'Zend\Form\View\Helper\FormRadio',
- 'formrange' => 'Zend\Form\View\Helper\FormRange',
- 'formreset' => 'Zend\Form\View\Helper\FormReset',
- 'form_reset' => 'Zend\Form\View\Helper\FormReset',
- 'formrow' => 'Zend\Form\View\Helper\FormRow',
- 'form_row' => 'Zend\Form\View\Helper\FormRow',
- 'formsearch' => 'Zend\Form\View\Helper\FormSearch',
- 'formselect' => 'Zend\Form\View\Helper\FormSelect',
- 'formsubmit' => 'Zend\Form\View\Helper\FormSubmit',
- 'formtel' => 'Zend\Form\View\Helper\FormTel',
- 'formtext' => 'Zend\Form\View\Helper\FormText',
- 'formtextarea' => 'Zend\Form\View\Helper\FormTextarea',
- 'formtime' => 'Zend\Form\View\Helper\FormTime',
- 'formurl' => 'Zend\Form\View\Helper\FormUrl',
- 'formweek' => 'Zend\Form\View\Helper\FormWeek',
+ 'form' => 'Zend\Form\View\Helper\Form',
+ 'formbutton' => 'Zend\Form\View\Helper\FormButton',
+ 'formcaptcha' => 'Zend\Form\View\Helper\FormCaptcha',
+ 'captchadumb' => 'Zend\Form\View\Helper\Captcha\Dumb',
+ 'formcaptchadumb' => 'Zend\Form\View\Helper\Captcha\Dumb',
+ 'captchafiglet' => 'Zend\Form\View\Helper\Captcha\Figlet',
+ 'formcaptchafiglet' => 'Zend\Form\View\Helper\Captcha\Figlet',
+ 'captchaimage' => 'Zend\Form\View\Helper\Captcha\Image',
+ 'formcaptchaimage' => 'Zend\Form\View\Helper\Captcha\Image',
+ 'captcharecaptcha' => 'Zend\Form\View\Helper\Captcha\ReCaptcha',
+ 'formcaptcharecaptcha' => 'Zend\Form\View\Helper\Captcha\ReCaptcha',
+ 'formcheckbox' => 'Zend\Form\View\Helper\FormCheckbox',
+ 'formcollection' => 'Zend\Form\View\Helper\FormCollection',
+ 'formcolor' => 'Zend\Form\View\Helper\FormColor',
+ 'formdate' => 'Zend\Form\View\Helper\FormDate',
+ 'formdatetime' => 'Zend\Form\View\Helper\FormDateTime',
+ 'formdatetimelocal' => 'Zend\Form\View\Helper\FormDateTimeLocal',
+ 'formdatetimeselect' => 'Zend\Form\View\Helper\FormDateTimeSelect',
+ 'formdateselect' => 'Zend\Form\View\Helper\FormDateSelect',
+ 'formelement' => 'Zend\Form\View\Helper\FormElement',
+ 'formelementerrors' => 'Zend\Form\View\Helper\FormElementErrors',
+ 'formemail' => 'Zend\Form\View\Helper\FormEmail',
+ 'formfile' => 'Zend\Form\View\Helper\FormFile',
+ 'formfileapcprogress' => 'Zend\Form\View\Helper\File\FormFileApcProgress',
+ 'formfilesessionprogress' => 'Zend\Form\View\Helper\File\FormFileSessionProgress',
+ 'formfileuploadprogress' => 'Zend\Form\View\Helper\File\FormFileUploadProgress',
+ 'formhidden' => 'Zend\Form\View\Helper\FormHidden',
+ 'formimage' => 'Zend\Form\View\Helper\FormImage',
+ 'forminput' => 'Zend\Form\View\Helper\FormInput',
+ 'formlabel' => 'Zend\Form\View\Helper\FormLabel',
+ 'formmonth' => 'Zend\Form\View\Helper\FormMonth',
+ 'formmonthselect' => 'Zend\Form\View\Helper\FormMonthSelect',
+ 'formmulticheckbox' => 'Zend\Form\View\Helper\FormMultiCheckbox',
+ 'formnumber' => 'Zend\Form\View\Helper\FormNumber',
+ 'formpassword' => 'Zend\Form\View\Helper\FormPassword',
+ 'formradio' => 'Zend\Form\View\Helper\FormRadio',
+ 'formrange' => 'Zend\Form\View\Helper\FormRange',
+ 'formreset' => 'Zend\Form\View\Helper\FormReset',
+ 'form_reset' => 'Zend\Form\View\Helper\FormReset',
+ 'formrow' => 'Zend\Form\View\Helper\FormRow',
+ 'form_row' => 'Zend\Form\View\Helper\FormRow',
+ 'formsearch' => 'Zend\Form\View\Helper\FormSearch',
+ 'formselect' => 'Zend\Form\View\Helper\FormSelect',
+ 'formsubmit' => 'Zend\Form\View\Helper\FormSubmit',
+ 'formtel' => 'Zend\Form\View\Helper\FormTel',
+ 'formtext' => 'Zend\Form\View\Helper\FormText',
+ 'formtextarea' => 'Zend\Form\View\Helper\FormTextarea',
+ 'formtime' => 'Zend\Form\View\Helper\FormTime',
+ 'formurl' => 'Zend\Form\View\Helper\FormUrl',
+ 'formweek' => 'Zend\Form\View\Helper\FormWeek',
);
/**
View
13 library/Zend/ProgressBar/Upload/SessionProgress.php
@@ -35,7 +35,8 @@ protected function getUploadProgress($id)
);
}
- $uploadInfo = $_SESSION[ini_get('session.upload_progress.prefix') . $id];
+ $sessionKey = ini_get('session.upload_progress.prefix') . $id;
+ $uploadInfo = (isset($_SESSION[$sessionKey])) ? $_SESSION[$sessionKey] : null;
if (!is_array($uploadInfo)) {
return false;
}
@@ -45,12 +46,15 @@ protected function getUploadProgress($id)
'current' => 0,
'rate' => 0,
'message' => '',
- 'done' => false
+ 'done' => false,
);
$status = $uploadInfo + $status;
$status['total'] = $status['content_length'];
$status['current'] = $status['bytes_processed'];
- $status['rate'] = $status['bytes_processed'] / (time() - $status['start_time']);
+
+ $time = time() - $status['start_time'];
+ $status['rate'] = ($time > 0) ? $status['bytes_processed'] / $time : 0;
+
if (!empty($status['cancel_upload'])) {
$status['done'] = true;
$status['message'] = 'The upload has been canceled';
@@ -66,7 +70,6 @@ protected function getUploadProgress($id)
*/
public function isSessionUploadProgressAvailable()
{
- return (bool) version_compare(PHP_VERSION, '5.4.0rc1', '>=')
- && (bool) ini_get('session.upload_progress.enabled');
+ return (bool) ini_get('session.upload_progress.enabled');
}
}
View
44 tests/ZendTest/Form/Element/File/ApcProgressTest.php
@@ -1,44 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 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\Element\File;
-
-use PHPUnit_Framework_TestCase as TestCase;
-use Zend\Form\Element\File\ApcProgress as ApcProgressElement;
-
-class ApcProgressTest extends TestCase
-{
- public function setUp()
- {
- if (false === ini_get('apc.rfc1867_name')) {
- $this->markTestSkipped('APC module is not active');
- }
- }
-
- public function testAlwaysReturnsApcName()
- {
- $name = ini_get('apc.rfc1867_name');
- $element = new ApcProgressElement('foo');
- $this->assertEquals($name, $element->getName());
- $element->setName('bar');
- $this->assertEquals($name, $element->getName());
- }
-
- public function testValueIsPopulatedWithUniqueId()
- {
- $element = new ApcProgressElement();
- $value1 = $element->getValue();
- $this->assertNotEmpty($value1);
- $element->setValue(null);
- $value2 = $element->getValue();
- $this->assertNotEmpty($value2);
- $this->assertNotEquals($value2, $value1);
- }
-}
View
44 tests/ZendTest/Form/Element/File/SessionProgressTest.php
@@ -1,44 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 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\Element\File;
-
-use PHPUnit_Framework_TestCase as TestCase;
-use Zend\Form\Element\File\SessionProgress as SessionProgressElement;
-
-class SessionProgressTest extends TestCase
-{
- public function setUp()
- {
- if (false === ini_get('session.upload_progress.name')) {
- $this->markTestSkipped('Session Upload Progress feature is not active');
- }
- }
-
- public function testAlwaysReturnsSessionName()
- {
- $name = ini_get('session.upload_progress.name');
- $element = new SessionProgressElement('foo');
- $this->assertEquals($name, $element->getName());
- $element->setName('bar');
- $this->assertEquals($name, $element->getName());
- }
-
- public function testValueIsPopulatedWithUniqueId()
- {
- $element = new SessionProgressElement();
- $value1 = $element->getValue();
- $this->assertNotEmpty($value1);
- $element->setValue(null);
- $value2 = $element->getValue();
- $this->assertNotEmpty($value2);
- $this->assertNotEquals($value2, $value1);
- }
-}
View
37 tests/ZendTest/Form/Element/File/UploadProgressTest.php
@@ -1,37 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 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\Element\File;
-
-use PHPUnit_Framework_TestCase as TestCase;
-use Zend\Form\Element\File\UploadProgress as UploadProgressElement;
-
-class UploadProgressTest extends TestCase
-{
- public function testAlwaysReturnsUploadIdName()
- {
- $name = 'UPLOAD_IDENTIFIER';
- $element = new UploadProgressElement('foo');
- $this->assertEquals($name, $element->getName());
- $element->setName('bar');
- $this->assertEquals($name, $element->getName());
- }
-
- public function testValueIsPopulatedWithUniqueId()
- {
- $element = new UploadProgressElement();
- $value1 = $element->getValue();
- $this->assertNotEmpty($value1);
- $element->setValue(null);
- $value2 = $element->getValue();
- $this->assertNotEmpty($value2);
- $this->assertNotEquals($value2, $value1);
- }
-}
View
42 tests/ZendTest/Form/View/Helper/File/FormFileApcProgressTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 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\View\Helper;
+
+use Zend\Form\View\Helper\File\FormFileApcProgress;
+
+/**
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage UnitTest
+ */
+class FormFileApcProgressTest extends CommonTestCase
+{
+ public function setUp()
+ {
+ $this->helper = new FormFileApcProgress();
+ parent::setUp();
+ }
+
+ public function testReturnsNameIdAndValueAttributes()
+ {
+ $name = ini_get('apc.rfc1867_name');
+ if (false === $name) {
+ $this->markTestSkipped('APC module is not active');
+ }
+
+ $markup = $this->helper->__invoke();
+ $this->assertContains('<input ', $markup);
+ $this->assertContains('type="hidden"', $markup);
+ $this->assertContains('id="progress_key"', $markup);
+ $this->assertContains('name="' . $name . '"', $markup);
+ $this->assertContains('value="', $markup);
+ }
+}
View
42 tests/ZendTest/Form/View/Helper/File/FormFileSessionProgressTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 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\View\Helper;
+
+use Zend\Form\View\Helper\File\FormFileSessionProgress;
+
+/**
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage UnitTest
+ */
+class FormFileSessionProgressTest extends CommonTestCase
+{
+ public function setUp()
+ {
+ $this->helper = new FormFileSessionProgress();
+ parent::setUp();
+ }
+
+ public function testReturnsNameIdAndValueAttributes()
+ {
+ $name = ini_get('session.upload_progress.name');
+ if (false === $name) {
+ $this->markTestSkipped('Session Upload Progress feature is not active');
+ }
+
+ $markup = $this->helper->__invoke();
+ $this->assertContains('<input ', $markup);
+ $this->assertContains('type="hidden"', $markup);
+ $this->assertContains('id="progress_key"', $markup);
+ $this->assertContains('name="' . $name . '"', $markup);
+ $this->assertContains('value="', $markup);
+ }
+}
View
37 tests/ZendTest/Form/View/Helper/File/FormFileUploadProgressTest.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 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\View\Helper;
+
+use Zend\Form\View\Helper\File\FormFileUploadProgress;
+
+/**
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage UnitTest
+ */
+class FormFileUploadProgressTest extends CommonTestCase
+{
+ public function setUp()
+ {
+ $this->helper = new FormFileUploadProgress();
+ parent::setUp();
+ }
+
+ public function testReturnsNameIdAndValueAttributes()
+ {
+ $markup = $this->helper->__invoke();
+ $this->assertContains('<input ', $markup);
+ $this->assertContains('type="hidden"', $markup);
+ $this->assertContains('id="progress_key"', $markup);
+ $this->assertContains('name="UPLOAD_IDENTIFIER"', $markup);
+ $this->assertContains('value="', $markup);
+ }
+}
Something went wrong with that request. Please try again.