ParameterTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_CodeGenerator
  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. */
  21. /**
  22. * @see TestHelper
  23. */
  24. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  25. /** requires */
  26. require_once 'Zend/Reflection/Parameter.php';
  27. require_once 'Zend/CodeGenerator/Php/Parameter.php';
  28. require_once '_files/TestSampleSingleClass.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_CodeGenerator
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. *
  36. * @group Zend_CodeGenerator_Php
  37. */
  38. class Zend_CodeGenerator_Php_ParameterTest extends PHPUnit_Framework_TestCase
  39. {
  40. /**
  41. * @var Zend_CodeGenerator_Php_Parameter
  42. */
  43. protected $_parameter = null;
  44. public function setup()
  45. {
  46. $this->_parameter = new Zend_CodeGenerator_Php_Parameter();
  47. }
  48. public function teardown()
  49. {
  50. $this->_parameter = null;
  51. }
  52. public function testTypeGetterAndSetterPersistValue()
  53. {
  54. $this->_parameter->setType('Foo');
  55. $this->assertEquals('Foo', $this->_parameter->getType());
  56. }
  57. public function testNameGetterAndSetterPersistValue()
  58. {
  59. $this->_parameter->setName('Foo');
  60. $this->assertEquals('Foo', $this->_parameter->getName());
  61. }
  62. public function testDefaultValueGetterAndSetterPersistValue()
  63. {
  64. $this->_parameter->setDefaultValue('Foo');
  65. $this->assertEquals('Foo', $this->_parameter->getDefaultValue());
  66. }
  67. public function testPositionGetterAndSetterPersistValue()
  68. {
  69. $this->_parameter->setPosition(2);
  70. $this->assertEquals(2, $this->_parameter->getPosition());
  71. }
  72. public function testGenerateIsCorrect()
  73. {
  74. $this->_parameter->setType('Foo');
  75. $this->_parameter->setName('bar');
  76. $this->_parameter->setDefaultValue(15);
  77. $this->assertEquals('Foo $bar = 15', $this->_parameter->generate());
  78. $this->_parameter->setDefaultValue('foo');
  79. $this->assertEquals('Foo $bar = \'foo\'', $this->_parameter->generate());
  80. }
  81. }