I am new to PHPUnit & unit-testing in general, I have got this problem, thankfully I can sense, the answer is out there, maybe with everyone has ever done their first tests.
Here it goes:
I have been trying to find tutorials for unit-testing with PHPUnit. And, so far all, I found were similar tutorials, in which they all used assertEquals() function to test if a method from class output was as expected or not.
like in this tutorial
http://www.sitepoint.com/tutorial-introduction-to-unit-testing-in-php-with-phpunit/
and
phpmaster.com/getting-started-with-phpunit/
It just shows a simple example for comparing expected and actual strings from a method.
OK! I get that, but so far all it does is compare strings. Simply, I'm looking for more.
So, to better illustrate my problem, lets imagine I have a class called class userLogin
I have simplified it, just so you can get the idea and its purpose.
class userLogin{
function checkAlreadyLoggedIn($session){
//if user is logged in say something
}
function checkVaidEmail($email){
//if email is invalid throw error
}
function checkPassword($pass){
//if pass is empty, then do something
}
function checkFromDb($email, $pass){
//if user is found, set session else show message
}
}
Now, my question is, in what possible ways can I test this class or its methods. What sounds logic enough here to test. Or, what could unexpectedly go wrong in this class, that I would need to test something from it? And if so, using what functions?