This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for checkobx helper, update readme
- Loading branch information
neilime
committed
May 11, 2014
1 parent
8a146da
commit 6804967
Showing
2 changed files
with
61 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 42 additions & 31 deletions
73
tests/TwbBundleTest/Form/View/Helper/TwbBundleFormCheckboxTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,42 @@ | ||
<?php | ||
namespace TwbBundleTest\Form\View\Helper; | ||
class TwbBundleFormCheckboxTest extends \PHPUnit_Framework_TestCase{ | ||
/** | ||
* @var \TwbBundle\Form\View\Helper\TwbBundleFormCheckbox | ||
*/ | ||
protected $formCheckboxHelper; | ||
|
||
/** | ||
* @see \PHPUnit_Framework_TestCase::setUp() | ||
*/ | ||
public function setUp(){ | ||
$oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); | ||
$oRenderer = new \Zend\View\Renderer\PhpRenderer(); | ||
$this->formCheckboxHelper = $oViewHelperPluginManager->get('formCheckbox')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testRenderElementWithWrongElement(){ | ||
$this->formCheckboxHelper->render(new \Zend\Form\Element()); | ||
} | ||
|
||
/** | ||
* @expectedException \LogicException | ||
*/ | ||
public function testRenderElementWithEmptyName(){ | ||
$this->formCheckboxHelper->render(new \Zend\Form\Element\Checkbox('')); | ||
} | ||
} | ||
<?php | ||
|
||
namespace TwbBundleTest\Form\View\Helper; | ||
|
||
class TwbBundleFormCheckboxTest extends \PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* @var \TwbBundle\Form\View\Helper\TwbBundleFormCheckbox | ||
*/ | ||
protected $formCheckboxHelper; | ||
|
||
/** | ||
* @see \PHPUnit_Framework_TestCase::setUp() | ||
*/ | ||
public function setUp() { | ||
$oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); | ||
$oRenderer = new \Zend\View\Renderer\PhpRenderer(); | ||
$this->formCheckboxHelper = $oViewHelperPluginManager->get('formCheckbox')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testRenderElementWithWrongElement() { | ||
$this->formCheckboxHelper->render(new \Zend\Form\Element()); | ||
} | ||
|
||
/** | ||
* @expectedException \LogicException | ||
*/ | ||
public function testRenderElementWithEmptyName() { | ||
$this->formCheckboxHelper->render(new \Zend\Form\Element\Checkbox('')); | ||
} | ||
|
||
public function testRenderWithLabelPrepend() { | ||
$this->assertEquals('<input type="hidden" name="prepend" value="0"><label>Prepend label <input type="checkbox" name="prepend" value="1"></label>', $this->formCheckboxHelper->render(new \Zend\Form\Element\Checkbox('prepend', array( | ||
'label' => 'Prepend label', | ||
'label_options' => array('position' => \Zend\Form\View\Helper\FormRow::LABEL_PREPEND) | ||
)))); | ||
} | ||
|
||
} |