Search code examples
phpmysqlsql-server-2005tddlegacy

Integrating Test Driven Development for web server legacy PHP / MSSQL / MySQL code


At work, I am working with this old legacy code modified Cake-PHP code that works with MSSQL and MySQL. It is used as a web server. We also have a automated task that runs to collect data.

Upgrading Cake-PHP will help, but we can't do that because one of the developers modified the internals of Cake-PHP. T-T

Recently I found SimpleTest, which is great. Very low dependency, easy to install, etc. However:

  1. What is the best way to integrate test for PHP / MSSQL / MySQL setup?
  2. We have a mock database of production, but even that change over time, so how can we Unit Test it. Specifically, how do we test each of queries code? We insert a lot and one time, and sometime it's impossible to write a delete sql for that.

Thanks in advance


Solution

  • A down-to-earth answer would be to mock your database again and do not change it if not absolutely needed. When you do so, you should run your test and verify they don't fail.

    Also as time goes by, try to isolate the layer that gets the raw data and your utility functions, so you can test the latter with known-and-manually-provided data.