How to PHPUnit-test a Controller under BjyAuthorize?
I have a Controller, that does nothing so far, but display a view page. Well, it also check if the user has identity set up, but that's not as important right now.
The thing that is happening behind the scenes is that I am using BjyAuthorize to allow/deny access to that Controller. It is not visible from the Controller code itself as to who may have access to it and who can't. BjyAuthorize takes care of that behind the scenes, leaving the Controller code unaware of the access model.
Question: How can I test this Controller? What does it mean to test this Controller? Do I test this Controller, and if so, for what?
Re: How to PHPUnit-test a Controller under BjyAuthorize?
* my concern is that Controller is not aware of its access model under BjyAuthorize. Is that they way it was intended to be? Is that a good practice to leave it be this way?
* Can I test this Controller with various roles under BjyAuthorize, to see which roles are allowed, and which roles are denied? How, where do I do this?
* Aside from the above, there is an article on testing Controllers. If I want to test my Controller, am I to use that article's way of testing (in addition to any testing above, if that happens to be different)? The article doesn't go into access models however, so it will be simple testing, not the kind I need.
This lets you mock the identity roles (which is passed to BjyAuthorize to check if you're allowed to be in there). This is obviously a test case I use in my admin controller, but I could change that to "guest" or "user" and do a test that they get a 404 or 302 response code.