ParameterTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_Reflection
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 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 Zend_Reflection_Parameter
  24. */
  25. require_once 'Zend/Reflection/Parameter.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Reflection
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Reflection
  33. * @group Zend_Reflection_Parameter
  34. */
  35. class Zend_Reflection_ParameterTest extends PHPUnit_Framework_TestCase
  36. {
  37. static protected $_sampleClassFileRequired = false;
  38. public function setup()
  39. {
  40. if (self::$_sampleClassFileRequired === false) {
  41. $fileToRequire = dirname(__FILE__) . '/_files/TestSampleClass.php';
  42. require_once $fileToRequire;
  43. self::$_sampleClassFileRequired = true;
  44. }
  45. }
  46. public function testDeclaringClassReturn()
  47. {
  48. $parameter = new Zend_Reflection_Parameter(array('Zend_Reflection_TestSampleClass2', 'getProp2'), 0);
  49. $this->assertEquals(get_class($parameter->getDeclaringClass()), 'Zend_Reflection_Class');
  50. }
  51. public function testClassReturn_NoClassGiven_ReturnsNull()
  52. {
  53. $parameter = new Zend_Reflection_Parameter(array('Zend_Reflection_TestSampleClass2', 'getProp2'), 'param1');
  54. $this->assertNull($parameter->getClass());
  55. }
  56. public function testClassReturn()
  57. {
  58. $parameter = new Zend_Reflection_Parameter(array('Zend_Reflection_TestSampleClass2', 'getProp2'), 'param2');
  59. $this->assertEquals(get_class($parameter->getClass()), 'Zend_Reflection_Class');
  60. }
  61. /**
  62. * @dataProvider paramTypeTestProvider
  63. */
  64. public function testTypeReturn($param, $type)
  65. {
  66. $parameter = new Zend_Reflection_Parameter(array('Zend_Reflection_TestSampleClass5', 'doSomething'), $param);
  67. $this->assertEquals($parameter->getType(), $type);
  68. }
  69. public function paramTypeTestProvider()
  70. {
  71. return array(
  72. array('one','int'),
  73. array('two','int'),
  74. array('three','string'),
  75. );
  76. }
  77. }