File tree Expand file tree Collapse file tree 3 files changed +11
-12
lines changed
Expand file tree Collapse file tree 3 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 55use App \Exceptions \BadRequestException ;
66use App \Exceptions \ForbiddenRequestException ;
77use App \Exceptions \NotFoundException ;
8- use App \Exceptions \NotImplementedException ;
9- use App \Helpers \RecodexApiHelper ;
108use App \Helpers \RecodexGroup ;
119use App \Model \Entity \SisScheduleEvent ;
1210use App \Model \Repository \SisScheduleEvents ;
1614/**
1715 * Group management (both for teachers and students).
1816 */
19- class GroupsPresenter extends BasePresenter
17+ class GroupsPresenter extends BasePresenterWithApi
2018{
2119 /**
2220 * @var SisScheduleEvents
2321 * @inject
2422 */
2523 public $ sisEvents ;
2624
27- /**
28- * @var RecodexApiHelper
29- * @inject
30- */
31- public $ recodexApi ;
32-
3325 /**
3426 * @var IEventPermissions
3527 * @inject
Original file line number Diff line number Diff line change @@ -25,15 +25,17 @@ class BasePresenterWithApi extends BasePresenter
2525
2626 public function startup ()
2727 {
28- parent ::startup ();
29-
3028 // Initialize ReCodEx auth token (main part is in User entity, suffix is in our auth token's payload).
3129 $ user = $ this ->getCurrentUser ();
3230 $ token = $ this ->getAccessToken ();
33- $ suffix = $ token ->getPayload ('suffix ' );
31+ $ suffix = $ token ->getPayloadOrDefault ('suffix ' , null );
3432
3533 if ($ user ->getRecodexToken () && $ suffix ) {
3634 $ this ->recodexApi ->setAuthToken ($ user ->getRecodexToken () . $ suffix );
3735 }
36+
37+ // the parent startup performs authorization checks, so it must be called after we set the token
38+ // (some presenters check permissions via ReCodEx API)
39+ parent ::startup ();
3840 }
3941}
Original file line number Diff line number Diff line change 33$ container = require_once __DIR__ . "/../bootstrap.php " ;
44
55use App \Helpers \RecodexApiHelper ;
6+ use App \Helpers \SisHelper ;
67use App \Presenters \GroupsPresenter ;
78use App \Exceptions \BadRequestException ;
89use App \Exceptions \ForbiddenRequestException ;
@@ -60,6 +61,10 @@ class TestGroupsPresenter extends Tester\TestCase
6061 $ this ->namingHelper ,
6162 $ this ->client
6263 ));
64+
65+ $ sisHelperName = current ($ this ->container ->findByType (SisHelper::class));
66+ $ this ->container ->removeService ($ sisHelperName );
67+ $ this ->container ->addService ($ sisHelperName , Mockery::mock (SisHelper::class));
6368 }
6469
6570 protected function setUp ()
You can’t perform that action at this time.
0 commit comments