mock.tpl.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /*
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. ?><?php ob_start(); ?>
  15. class <?php echo $className; ?>
  16. <?php if ($extends) echo 'extends ', $extends; ?>
  17. implements
  18. <?php foreach ($interfaces as $interface) echo $interface, ', '; ?>
  19. Yay_MockObject
  20. {
  21. private $_yayInvocationHandler;
  22. public function __construct(Yay_InvocationHandler $invocationHandler)
  23. {
  24. $this->_yayInvocationHandler = $invocationHandler;
  25. }
  26. <?php foreach ($methods as $method): ?>
  27. <?php echo $method['access']; ?> <?php echo $method['modifiers']; ?> function <?php
  28. if ($method['returnReference']) echo '&'; ?><?php
  29. echo $method['name']; ?>(<?php
  30. foreach ($method['parameters'] as $i => $param): ?>
  31. <?php if ($i > 0) echo ','; ?>
  32. <?php if ($param['hint']) echo $param['hint']; ?>
  33. <?php if ($param['byReference']) echo '&'; ?>$arg_<?php echo $i; ?>
  34. <?php if ($param['optional']) echo '= null'; ?>
  35. <?php endforeach; ?>)
  36. {
  37. $value = null;
  38. if (isset($this->_yayInvocationHandler))
  39. {
  40. $args = array();
  41. for ($i = 0; $i < func_num_args(); ++$i)
  42. {
  43. $argName = 'arg_' . $i;
  44. $args[] =& ${$argName};
  45. }
  46. $invocation = new Yay_SimpleInvocation($this, __FUNCTION__, $args);
  47. $value =& $this->_yayInvocationHandler->handleInvocation($invocation);
  48. }
  49. return $value;
  50. }
  51. <?php endforeach; ?>
  52. public function __clone()
  53. {
  54. $this->_yayInvocationHandler = null;
  55. }
  56. }
  57. <?php return ob_get_clean(); ?>