DummyUpdater.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. require_once 'application/Updater.php';
  3. /**
  4. * Class DummyUpdater.
  5. * Extends Updater to add update method designed for unit tests.
  6. */
  7. class DummyUpdater extends Updater
  8. {
  9. /**
  10. * Object constructor.
  11. *
  12. * @param array $doneUpdates Updates which are already done.
  13. * @param LinkDB $linkDB LinkDB instance.
  14. * @param ConfigManager $conf Configuration Manager instance.
  15. * @param boolean $isLoggedIn True if the user is logged in.
  16. */
  17. public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn)
  18. {
  19. parent::__construct($doneUpdates, $linkDB, $conf, $isLoggedIn);
  20. // Retrieve all update methods.
  21. // For unit test, only retrieve final methods,
  22. $class = new ReflectionClass($this);
  23. $this->methods = $class->getMethods(ReflectionMethod::IS_FINAL);
  24. }
  25. /**
  26. * Update method 1.
  27. *
  28. * @return bool true.
  29. */
  30. private final function updateMethodDummy1()
  31. {
  32. return true;
  33. }
  34. /**
  35. * Update method 2.
  36. *
  37. * @return bool true.
  38. */
  39. private final function updateMethodDummy2()
  40. {
  41. return true;
  42. }
  43. /**
  44. * Update method 3.
  45. *
  46. * @return bool true.
  47. */
  48. private final function updateMethodDummy3()
  49. {
  50. return true;
  51. }
  52. /**
  53. * Update method 4, raise an exception.
  54. *
  55. * @throws Exception error.
  56. */
  57. private final function updateMethodException()
  58. {
  59. throw new Exception('whatever');
  60. }
  61. }