|
| 1 | +<?php |
| 2 | + |
| 3 | +# This is designed to sanity check the role request email functionality. |
| 4 | +# It is not a unit test, it is designed to be run against the sample data. |
| 5 | + |
| 6 | +require_once __DIR__.'/lib/Gocdb_Services/NotificationService.php'; |
| 7 | + |
| 8 | +$requesting_user_id = 5; // This corresponds to Richard Winters. |
| 9 | +$requesting_user = \Factory::getUserService()->getUser($requesting_user_id); |
| 10 | + |
| 11 | +echo "=====================================================================\n"; |
| 12 | +# Test 1, requesting a role over a site with existing role approvers |
| 13 | + |
| 14 | +$site_id = 5; // This corresponds to UNIBE-LHEP |
| 15 | +# Get Site object from above ID. |
| 16 | +$site = \Factory::getSiteService()->getSite($site_id); |
| 17 | + |
| 18 | +# Have Richard appear to request the "Site Operations Manager" role over |
| 19 | +# UNIBE-LHEP. This request should go to Donna, who also has the |
| 20 | +# "Site Operations Manager" role. |
| 21 | +$role_requested = new \Role( |
| 22 | + new \RoleType("Site Operations Manager"), |
| 23 | + $requesting_user, $site, RoleStatus::PENDING); |
| 24 | + |
| 25 | +$notificationService = \Factory::getNotificationService(); |
| 26 | +$notificationService->roleRequest($role_requested, $requesting_user, $site); |
| 27 | + |
| 28 | +echo "=====================================================================\n"; |
| 29 | +# Test 2, requesting a role over a site with no existing role approvers. |
| 30 | +$site_id = 6; // This corresponds to T3_CH_PSI |
| 31 | +# Get Site object from above ID. |
| 32 | +$site = \Factory::getSiteService()->getSite($site_id); |
| 33 | + |
| 34 | +# Have Richard appear to request the "Site Operations Manager" role over |
| 35 | +# T3_CH_PSI. As this Site has no one with a role over it the request should |
| 36 | +# email Neville (NGI Operations Manager of NGI_CH) but not Donna (who cannot |
| 37 | +# approve the role as "Regional Staff (ROD)") |
| 38 | +$role_requested = new \Role( |
| 39 | + new \RoleType("Site Operations Manager"), |
| 40 | + $requesting_user, $site, RoleStatus::PENDING); |
| 41 | + |
| 42 | +$notificationService = \Factory::getNotificationService(); |
| 43 | +$notificationService->roleRequest($role_requested, $requesting_user, $site); |
| 44 | + |
| 45 | +echo "=====================================================================\n"; |
| 46 | +# Test 3, requesting a role over a NGI with existing role approvers. |
| 47 | +$ngi_id = 2; // This corresponds to NGI_CH |
| 48 | +# Get Site object from above ID. |
| 49 | +$ngi = \Factory::getNgiService()->getNgi($ngi_id); |
| 50 | + |
| 51 | +# Have Richard appear to request the "NGI Operations Manager" role over |
| 52 | +# NGI_CH. This request should go to Neville, who also has the |
| 53 | +# "NGI Operations Manager" role but not Donna (who cannot approve the role as |
| 54 | +# "Regional Staff (ROD)") |
| 55 | +$role_requested = new \Role( |
| 56 | + new \RoleType("NGI Operations Manager"), |
| 57 | + $requesting_user, $ngi, RoleStatus::PENDING); |
| 58 | + |
| 59 | +$notificationService = \Factory::getNotificationService(); |
| 60 | +$notificationService->roleRequest($role_requested, $requesting_user, $ngi); |
| 61 | + |
| 62 | +echo "=====================================================================\n"; |
| 63 | +# Test 4, requesting a role over a site with no existing role approvers. |
| 64 | +$ngi_id = 3; // This corresponds to NGI_FIFE |
| 65 | +# Get Site object from above ID. |
| 66 | +$ngi = \Factory::getNgiService()->getNgi($ngi_id); |
| 67 | + |
| 68 | +# Have Richard appear to request the "NGI Operations Manager" role over |
| 69 | +# NGI_CH. This request should go to Griffin and Amy, who have Project roles. |
| 70 | +$role_requested = new \Role( |
| 71 | + new \RoleType("NGI Operations Manager"), |
| 72 | + $requesting_user, $ngi, RoleStatus::PENDING); |
| 73 | + |
| 74 | +$notificationService = \Factory::getNotificationService(); |
| 75 | +$notificationService->roleRequest($role_requested, $requesting_user, $ngi); |
| 76 | + |
| 77 | +?> |
0 commit comments