Skip to content

Commit

Permalink
Unit tests for new Zend/Form/Element/File elements
Browse files Browse the repository at this point in the history
  • Loading branch information
cgmartin committed Oct 31, 2012
1 parent 7aaee69 commit 4108486
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 3 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
Expand Down
44 changes: 44 additions & 0 deletions 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);
}
}
44 changes: 44 additions & 0 deletions 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);
}
}
37 changes: 37 additions & 0 deletions 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.