Recently I have been reading online about eXtreme programming and agile practices. I wish to adapt them. However most of my code is all in PHP which is the normal CRUD type web applications. Moreover I user web framework like CodeIgniter, which also abstracts a lot of the core features.
To sum up, how can I implement the test driven development into applications which are heavily dependent on databases and user input, particularly in the test automation part?
I would now ask this question targeting my current project
I am working on an college forum web application. It has the basic social network features and also includes XMPP server on its stack. The following components constitute my application stack:
- Apache web server with mod_php enabled.
- PHP as a back-end language.(CodeIgniter framework)
- MySql database.
- Openfire server for XMPP.
- HTML, CSS, jQuery and Strophe(for XMPP) on front end, and
- A Python middleware for XMPP.
Currently I am working without any testing or build cycle. I use SVN as the version control system. And I wish to include TDD and CI into the development process. I already have some code in the project. What strategies and best practices should I adopt for implementing TDD and CI in this kind of project?
PS: We are a team of three people working on a self project as such we dont have any other person who influences the design(apart from the end users).
This is what I did to start implementing
I refactored the login function which was taking the username and password passed from the front end and then applies sanity checks, checks for valid username, then for valid password, If yes it sets the session cookie and redirects the user to a page based on his role.
I broke the above function into three one to take username and password and check if they are correct, another to set the cookies and the last one that takes the values from front end and applies sanity checks, calls the other two functions and then redirects.
I could write test for only the first function. Is that enough?