ParameterTest.php 2.8 KB

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