word)) { unset($this->word); } $this->element = new Zend_Form_Element_Captcha( 'captchaF', array( 'captcha' => array( 'Figlet', 'sessionClass' => 'Zend_Captcha_FigletTest_SessionContainer' ) ) ); $this->captcha = $this->element->getCaptcha(); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @return void */ public function tearDown() { } public function testCaptchaAdapterCreated() { $this->assertTrue($this->element->getCaptcha() instanceof Zend_Captcha_Adapter); } public function getView() { require_once 'Zend/View.php'; $view = new Zend_View(); $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper'); return $view; } public function testCaptchaIsRendered() { $html = $this->element->render($this->getView()); $this->assertContains($this->element->getName(), $html); } public function testCaptchaHasIdAndInput() { $html = $this->element->render($this->getView()); $expect = sprintf('type="hidden" name="%s\[id\]" value="%s"', $this->element->getName(), $this->captcha->getId()); $this->assertRegexp("/]*?$expect/", $html, $html); $expect = sprintf('type="text" name="%s\[input\]"', $this->element->getName()); $this->assertRegexp("/]*?$expect/", $html, $html); } /* * @group ZF-8268 */ public function testLabelIdIsCorrect() { require_once 'Zend/Form.php'; $form = new Zend_Form(); $form->setElementsBelongTo('comment'); $this->element->setLabel("My Captcha"); $form->addElement($this->element); $html = $form->render($this->getView()); $expect = sprintf('for="comment-%s-input"', $this->element->getName()); $this->assertRegexp("/