views:

21

answers:

1

In my PHP Zend Framework application, I am using APC to cache certain repeat requests to the database. Within the application, I can clear the cache with this command:apc_clear_cache('user')

I am also running PHPUnit Selenium tests against this application. Before adding APC, I had no problems. I have a test that adds a test user to the database (in setup), logs them into the application (in the test), and removes the user record from the database (in teardown). This same routine happens in all the tests, since you need to be logged in to use certain features of the application. Now that APC is in place, APC is caching the first user that is created, but doesn't clear the cache when the user is re-created, which means the login only works on the first test.

I need to figure out a way to clear the cache from my Selenium test. The only way I could think of how to do this was to create a controller action that is wide open to the public to access, that way, from my test I could open /cache/clear and it would clear the cache. I tried this approach and it worked, but this approach doesn't seem very practical since anyone can access that URL.

What should be my solution to this situation?

A: 

Well, clear your cache in TearDown() and SetUp() then?

zerkms