FlightPathTestCase.php

File

tests/FlightPathTestCase.php
View source
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. abstract class FlightPathTestCase extends TestCase
  4. {
  5. /**
  6. * This is run before each test; useful for resetting variables back to defaults
  7. * before the next test.
  8. */
  9. protected function setUp(): void
  10. {
  11. parent::setUp();
  12. global $user;
  13. $user = new stdClass();
  14. $user->id = 1;
  15. $user->cwid = 1;
  16. $user->name = 'admin';
  17. $user->school_id = 0;
  18. unset($_REQUEST);
  19. unset($_GET);
  20. unset($_POST);
  21. foreach ($GLOBALS as $key => $val) {
  22. if (strstr($key, "cache")) {
  23. unset($GLOBALS[$key]);
  24. }
  25. }
  26. unset($GLOBALS["fp_temp_degree_major_codes"]);
  27. unset($GLOBALS["fp_temp_degree_advising_weights"]);
  28. unset($GLOBALS["fp_load_user"]);
  29. unset($GLOBALS["fp_translate_numeric_grade"]);
  30. // Clear SESSION of unneeded vars...
  31. $keep_array = [
  32. 'fp_db_fingerprint',
  33. 'fp_db_host_ip',
  34. 'fp_user_object',
  35. 'fp_logged_in',
  36. 'fp_alert_count_by_type_last_check',
  37. 'fp_pie_chart_token',
  38. 'fp_pie_chart_token',
  39. ];
  40. foreach ($_SESSION as $k => $v) {
  41. if (!in_array($k, $keep_array)) {
  42. unset($_SESSION[$k]);
  43. }
  44. }
  45. // Reset various variables to default...
  46. variable_delete_for_school("course_repeat_policy", 0);
  47. }
  48. /**
  49. * When ending a particular test, call the garbage collector, just to make sure we
  50. * free up memory immediately.
  51. */
  52. protected function tearDown(): void
  53. {
  54. gc_collect_cycles();
  55. parent::tearDown();
  56. }
  57. } // class
  58. //

Classes

Namesort descending Description
FlightPathTestCase