I’m trying to learn how to develop using TDD. I keep getting stuck at the most basic things.
For example, I want to develop a very simple webapp that has a single page with a file upload form, and then return a modified version of that file. I want to develop this using TDD.
How do I start out? I know it’s entirely up to me what level of granularity I want to write my tests at, but I want to simulate the process the user goes through.
I know about functional tests/Selenium, but I want to try to stick with PHPUnit as much as possible for simplicity (learn to walk before I learn how to run, so to say).
Let me give an example of what I’m getting stuck at:
In a unit test, I want to create an instance of a controller (I assume?), set a file in a supplied POST $_FILES variable, and then make sure my controller can handle this.
I don’t even know how to simulate a request with code, so it’s super tricky. I can write my own custom models/components as classes and play around with those, sure, but there comes a point when you want to test it out together with the main app flow.
Any tips on where to start?