PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/DevApp/library/ServerLibraries/ZendFramework/1.7/tests/Zend/Dojo/Form/Element/TextBoxTest.php

http://firephp.googlecode.com/
PHP | 160 lines | 91 code | 18 blank | 51 comment | 3 complexity | fd1925b480da50499c990d29c103fe3b MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT, Apache-2.0
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  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.
  14. *
  15. * @category Zend
  16. * @package Zend_Dojo
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: TextBoxTest.php 11973 2008-10-15 16:00:56Z matthew $
  21. */
  22. // Call Zend_Dojo_Form_Element_TextBoxTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_TextBoxTest::main");
  25. }
  26. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  27. /** Zend_Dojo_Form_Element_TextBox */
  28. require_once 'Zend/Dojo/Form/Element/TextBox.php';
  29. /** Zend_View */
  30. require_once 'Zend/View.php';
  31. /** Zend_Registry */
  32. require_once 'Zend/Registry.php';
  33. /** Zend_Dojo_View_Helper_Dojo */
  34. require_once 'Zend/Dojo/View/Helper/Dojo.php';
  35. /**
  36. * Test class for Zend_Dojo_Form_Element_Dijit.
  37. *
  38. * @package Zend_Dojo
  39. * @subpackage UnitTests
  40. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  41. * @license http://framework.zend.com/license/new-bsd New BSD License
  42. */
  43. class Zend_Dojo_Form_Element_TextBoxTest extends PHPUnit_Framework_TestCase
  44. {
  45. /**
  46. * Runs the test methods of this class.
  47. *
  48. * @return void
  49. */
  50. public static function main()
  51. {
  52. $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_TextBoxTest");
  53. $result = PHPUnit_TextUI_TestRunner::run($suite);
  54. }
  55. /**
  56. * Sets up the fixture, for example, open a network connection.
  57. * This method is called before a test is executed.
  58. *
  59. * @return void
  60. */
  61. public function setUp()
  62. {
  63. Zend_Registry::_unsetInstance();
  64. Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
  65. $this->view = $this->getView();
  66. $this->element = $this->getElement();
  67. $this->element->setView($this->view);
  68. }
  69. /**
  70. * Tears down the fixture, for example, close a network connection.
  71. * This method is called after a test is executed.
  72. *
  73. * @return void
  74. */
  75. public function tearDown()
  76. {
  77. }
  78. public function getView()
  79. {
  80. require_once 'Zend/View.php';
  81. $view = new Zend_View();
  82. $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
  83. return $view;
  84. }
  85. public function getElement()
  86. {
  87. $element = new Zend_Dojo_Form_Element_TextBox(
  88. 'foo',
  89. array(
  90. 'value' => 'some text',
  91. 'label' => 'TextBox',
  92. 'trim' => true,
  93. 'propercase' => true,
  94. 'class' => 'someclass',
  95. 'style' => 'width: 100px;',
  96. )
  97. );
  98. return $element;
  99. }
  100. public function testLowercaseAccessorsShouldProxyToDijitParams()
  101. {
  102. $this->assertFalse($this->element->getLowercase());
  103. $this->assertFalse(array_key_exists('lowercase', $this->element->dijitParams));
  104. $this->element->setLowercase(true);
  105. $this->assertTrue($this->element->getLowercase());
  106. $this->assertTrue($this->element->dijitParams['lowercase']);
  107. }
  108. public function testPropercaseAccessorsShouldProxyToDijitParams()
  109. {
  110. $this->assertTrue($this->element->getPropercase());
  111. $this->assertTrue(array_key_exists('propercase', $this->element->dijitParams));
  112. $this->element->setPropercase(false);
  113. $this->assertFalse($this->element->getPropercase());
  114. }
  115. public function testUppercaseAccessorsShouldProxyToDijitParams()
  116. {
  117. $this->assertFalse($this->element->getUppercase());
  118. $this->assertFalse(array_key_exists('uppercase', $this->element->dijitParams));
  119. $this->element->setUppercase(true);
  120. $this->assertTrue($this->element->getUppercase());
  121. $this->assertTrue($this->element->dijitParams['uppercase']);
  122. }
  123. public function testTrimAccessorsShouldProxyToDijitParams()
  124. {
  125. $this->assertTrue($this->element->getTrim());
  126. $this->assertTrue(array_key_exists('trim', $this->element->dijitParams));
  127. $this->element->setTrim(false);
  128. $this->assertFalse($this->element->getTrim());
  129. }
  130. public function testMaxLengthAccessorsShouldProxyToDijitParams()
  131. {
  132. $this->assertNull($this->element->getMaxLength());
  133. $this->assertFalse(array_key_exists('maxLength', $this->element->dijitParams));
  134. $this->element->setMaxLength(20);
  135. $this->assertEquals(20, $this->element->getMaxLength());
  136. $this->assertEquals(20, $this->element->dijitParams['maxLength']);
  137. }
  138. }
  139. // Call Zend_Dojo_Form_Element_TextBoxTest::main() if this source file is executed directly.
  140. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_TextBoxTest::main") {
  141. Zend_Dojo_Form_Element_TextBoxTest::main();
  142. }