Adding enclosures now treats type and length parameters as optional for Atom, but...
[zend.git] / tests / Zend / Captcha / DumbTest.php
blob346162cdfa2a536e2b83c3080b93a18f9d73e9d1
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Captcha
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id$
23 // Call Zend_Captcha_DumbTest::main() if this source file is executed directly.
24 if (!defined("PHPUnit_MAIN_METHOD")) {
25 define("PHPUnit_MAIN_METHOD", "Zend_Captcha_DumbTest::main");
28 require_once dirname(__FILE__) . '/../../TestHelper.php';
30 require_once 'Zend/Form/Element/Captcha.php';
31 require_once 'Zend/View.php';
33 /**
34 * @category Zend
35 * @package Zend_Captcha
36 * @subpackage UnitTests
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
39 * @group Zend_Captcha
41 class Zend_Captcha_DumbTest extends PHPUnit_Framework_TestCase
43 /**
44 * Runs the test methods of this class.
46 * @return void
48 public static function main()
50 $suite = new PHPUnit_Framework_TestSuite("Zend_Captcha_DumbTest");
51 $result = PHPUnit_TextUI_TestRunner::run($suite);
54 /**
55 * Sets up the fixture, for example, open a network connection.
56 * This method is called before a test is executed.
58 * @return void
60 public function setUp()
62 if (isset($this->word)) {
63 unset($this->word);
66 $this->element = new Zend_Form_Element_Captcha(
67 'captchaD',
68 array(
69 'captcha' => array(
70 'Dumb',
71 'sessionClass' => 'Zend_Captcha_DumbTest_SessionContainer'
75 $this->captcha = $this->element->getCaptcha();
78 /**
79 * Tears down the fixture, for example, close a network connection.
80 * This method is called after a test is executed.
82 * @return void
84 public function tearDown()
88 public function testRendersWordInReverse()
90 $id = $this->captcha->generate('test');
91 $word = $this->captcha->getWord();
92 $html = $this->captcha->render(new Zend_View);
93 $this->assertContains(strrev($word), $html);
94 $this->assertNotContains($word, $html);
98 class Zend_Captcha_DumbTest_SessionContainer
100 protected static $_word;
102 public function __get($name)
104 if ('word' == $name) {
105 return self::$_word;
108 return null;
111 public function __set($name, $value)
113 if ('word' == $name) {
114 self::$_word = $value;
115 } else {
116 $this->$name = $value;
120 public function __isset($name)
122 if (('word' == $name) && (null !== self::$_word)) {
123 return true;
126 return false;
129 public function __call($method, $args)
131 switch ($method) {
132 case 'setExpirationHops':
133 case 'setExpirationSeconds':
134 $this->$method = array_shift($args);
135 break;
136 default:
141 // Call Zend_Captcha_DumbTest::main() if this source file is executed directly.
142 if (PHPUnit_MAIN_METHOD == "Zend_Captcha_DumbTest::main") {
143 Zend_Captcha_DumbTest::main();