NextcloudTestServerHelper.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. *
  4. * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Interface for classes that manage a Nextcloud server during acceptance tests.
  24. *
  25. * A NextcloudTestServerHelper takes care of setting up a Nextcloud server to be
  26. * used in acceptance tests through its "setUp" method. It does not matter
  27. * wheter the server is a fresh new server just started or an already running
  28. * server; in any case, the state of the server must comply with the initial
  29. * state expected by the tests (like having performed the Nextcloud installation
  30. * or having an admin user with certain password).
  31. *
  32. * As the IP address and thus its the base URL of the server is not known
  33. * beforehand, the NextcloudTestServerHelper must provide it through its
  34. * "getBaseUrl" method. Note that this must be the base URL from the point of
  35. * view of the Selenium server, which may be a different value than the base URL
  36. * from the point of view of the acceptance tests themselves.
  37. *
  38. * Once the Nextcloud test server is no longer needed the "cleanUp" method will
  39. * be called; depending on how the Nextcloud test server was set up it may not
  40. * need to do anything.
  41. *
  42. * All the methods throw an exception if they fail to execute; as, due to the
  43. * current use of this interface, it is just a warning for the test runner and
  44. * nothing to be explicitly catched a plain base Exception is used.
  45. */
  46. interface NextcloudTestServerHelper {
  47. /**
  48. * Sets up the Nextcloud test server.
  49. *
  50. * @throws \Exception if the Nextcloud test server can not be set up.
  51. */
  52. public function setUp();
  53. /**
  54. * Cleans up the Nextcloud test server.
  55. *
  56. * @throws \Exception if the Nextcloud test server can not be cleaned up.
  57. */
  58. public function cleanUp();
  59. /**
  60. * Returns the base URL of the Nextcloud test server (from the point of view
  61. * of the Selenium server).
  62. *
  63. * @return string the base URL of the Nextcloud test server.
  64. * @throws \Exception if the base URL can not be determined.
  65. */
  66. public function getBaseUrl();
  67. }