Browse files

Unit tests for new Zend/Form/Element/File elements

  • Loading branch information...
1 parent 7aaee69 commit 4108486fffcff5e68adb75eb0eec0660b0c8061d @cgmartin committed Oct 4, 2012
View
2 .../Zend/Form/Element/Upload/ApcProgress.php → ...ry/Zend/Form/Element/File/ApcProgress.php
@@ -19,7 +19,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\Form\Element\Upload;
+namespace Zend\Form\Element\File;
/**
* @category Zend
View
2 ...d/Form/Element/Upload/SessionProgress.php → ...end/Form/Element/File/SessionProgress.php
@@ -19,7 +19,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\Form\Element\Upload;
+namespace Zend\Form\Element\File;
/**
* @category Zend
View
2 ...nd/Form/Element/Upload/UploadProgress.php → ...Zend/Form/Element/File/UploadProgress.php
@@ -19,7 +19,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\Form\Element\Upload;
+namespace Zend\Form\Element\File;
use Zend\Form\Exception;
use Zend\Form\Element\Hidden;
View
44 tests/ZendTest/Form/Element/File/ApcProgressTest.php
@@ -0,0 +1,44 @@
+<?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
@@ -0,0 +1,44 @@
+<?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
@@ -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\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);
+ }
+}

0 comments on commit 4108486

Please sign in to comment.