PHP Unit Testing with Zend Auth and Zend ACL -
I have an application that is behind the login and uses zend_acl and zend_auth.
During pre-transmission, I have an ACL plugin that makes all the rules for ACL. I also have an eth plugin that checks whether you are logged in or not, and if so, according to ACL Access the requested resource.
As the entry is completely APL, only when you are logged in.
Unit testing seems to be impossible, or more likely that I'm seeing something clearly.
In my unit test setup method, I am following a successful login which gives a zend_auth example, the passing test indicates that this login was successful.
However, if I send it to another location through the test, or evaluate whether a user has access to a given resource, then it is always rejected as a plugin They are not logged in yet. I'm not sure why this is so, can anyone give advice?
For example this pass:
public function testLoggedIn () {$ This-> AssertTrue (Zend_Auth :: getInstance () - & gt; Hendency ()); }
This has been rejected by the plug-in:
public function testUserAccess () {$ this- & gt; Dispatch ('/ house'); $ This- & gt; AssertResponseCode (200); $ This- & gt; AssertQueryContentContains ('# nav_side'); $ This- & gt; Reset () - & gt; Reset response (); }
This, I think, is still being redirected back to the login page because plugins do not know that the user is logged in.
Any help appreciated.
The problem you describe is much more with the use of global variables and the OOP global variable (singleton pattern ).
There is an article by the author of PHPUnit, which describes that using dependency injection and which other possibilities you can get and it is very descriptive, so I suggest you to read it For example:
As an ugly choice (if you need quick results) you can create a stub of Zend_Auth (description in link) and Zend_Auth example to use PHP 5.3 reflection API Variable
hope That helps (as that question was another answer without 4h is)
Comments
Post a Comment