troubleshooting Question

How do I run time-dependent database tests with PHPUnit?

Avatar of tjgquicken
tjgquicken asked on
1 Comment1 Solution426 ViewsLast Modified:
I have a PHP application and I want to test the functionality where it records each login attempt in the database, including the time of the login attempt. The SQL statement that I'm trying to test is "INSERT INTO logins VALUES {$email}, {$user_id}, NOW(), {$_SERVER['REMOTE_ADDR']}, {$login_successful}". The problem is, I can't figure out how to use PHPUnit to accomplish this. The issue is that PHPUnit seems to require that I write up my expected data set in an XML file and then compare that file to what's in the database --- but since the value of NOW() depends on when I'm running the test, I can't have a pre-written file to compare against. Has anybody else run into this issue, and what's the best way to work around it? Thanks.
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros