Testing the PHP Application

Testing the PHP Application

It’s time to look at the Comedy Clüb application again. In this mini project, you test it. A good test suite is the only way to ensure the application works as expected.

Please keep in mind that you shouldn’t test your application after implementation in real life. The tests are created after implementing the whole application only for the purposes of this course. When creating real world applications, you’ll need to write tests together with code.

Remember how the controller was updated all the time during the second mini project? You had to run every new code unit and dump its results just to see how it worked. Usually, you don’t have to do that. If you write tests together with new code, you’ll see that it works even when it’s not connected to the rest of the application yet.

The goal is to cover every piece of logic you have. You’ll write some unit tests for units of pure logic in your application, like getters in entities and in-memory repositories.

This project will also cover ComedianViewRenderer to see how to test services with dependencies.

You’ll write integration tests for services communicating with external systems, like your Doctrine repositories. To test them, you’ll create a test database and fill it with test data from fixtures.

Finally, you’ll write functional tests to test whole pages, including controller code and templates.

You won’t have to write tests for the admin panel because you didn’t write logic there. You can use the library developed and tested by other people. Reusing existing libraries doesn’t just save development time, it also saves time during testing. As a result, there will be no changes to the application. Instead, you’ll have a test suite that makes sure that the application works now and future updates won’t break it.