How can I test my PHP code - what test framework can I use?

My core competency is Java (Android). I have been in the industry long enough to understand the benefits of proper testing, and I would like to think that I have a somewhat mature idea on how to test production code and how to create a test architecture.

Recently, as a rule, I am more and more involved in PHP coding. The few PHP projects that I had at the moment were more or less straightforward home pages for various charity events and similar, where "manual test cases" were sufficient.

But now I am planning a large PHP project for a paid client (a complete, REST-based web application with a heavy database backend, that is, not the project “Welcome to my home page”). I understand that there is not a sufficient set of manual testing instructions listed in a text document. I need a proper automated test environment, like the JUnit framework for Java, but for PHP.

Are there any vital “industry standards” for PHP code (preferably open source)? I read briefly about the PHPUnit and SimpleTest frames. Are they recommended to you guys?

Project parameters are set: PHP is one of the requirements, so you do not need to put energy to convince me of the best web platforms, etc. (but I will gladly read any notes and tips you may have, though, for future projects :-)

+7
source share
2 answers

Your two main options: PHPUnit and SimpleTest. You can see their comparison here: SimpleTest vs. Phpunit

However, keep in mind that this discussion is from 2008, and everything has changed since then.

If you want to test actual web pages and save yourself any trouble clicking on links and submitting forms, see Selenium: http://seleniumhq.org/

In addition, if you are using an IDE such as NetBeans or Eclipse, or using a PHP framework such as CakePHP or Zend, you should see which testing platforms are supported by your selection tools.

+3
source

PHPUnit seems to be the standard for unit testing.

http://www.phpunit.de/manual/current/en/

https://github.com/sebastianbergmann/phpunit/

I use it for TDD and find it excellent, and it clicks all the fields for you if I understand your question correctly.

+3
source

All Articles