1
0

startsessionlistener.php 770 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. use OC\Session\Memory;
  9. use PHPUnit\Framework\Test;
  10. use PHPUnit\Framework\TestListener;
  11. use PHPUnit\Framework\TestListenerDefaultImplementation;
  12. /**
  13. * Starts a new session before each test execution
  14. */
  15. class StartSessionListener implements TestListener {
  16. use TestListenerDefaultImplementation;
  17. public function endTest(Test $test, float $time): void {
  18. // reopen the session - only allowed for memory session
  19. if (\OC::$server->getSession() instanceof Memory) {
  20. /** @var $session Memory */
  21. $session = \OC::$server->getSession();
  22. $session->reopen();
  23. }
  24. }
  25. }