Testing modern Symfony apps

Introduction

The words "modern" and "PHP framework" would usually be considered oxymorons – and for good reasons. However, here is no point in denying that a large number of things on the internet relies on Symfony or some other PHP framework to run. These things will be gradually phased out or upgraded but for now they can't just remain untested because they're somewhat (out)dated...

API testing

The more rigorous part is RESTful API testing that relies on sending json to server and getting server back from the server. Let's create a boilerplate class that's going to help us send POST/GET/DELETE requests wrapped around as methods:


And now we're going to use that ancestor class to facilitate some real-life testing of user profile reads and updates.

To run the tests do the following

Frontend functional/flow testing

While valuable, the API testing will not cover certain aspects of the application flow. For example you changed some <script> dependency version loaded from a CDN. Your API works fine but for whatever reason your JS code will die (this happened to us with react-bootstrap which deprecated the ModalTrigger component at some point).

Here is a simple test in mocha.js and zombie.js that will attempt to log the user in and see if the content pages even load. No interaction, just "does it load?".

Then to run the test

Comments

Popular posts from this blog

React.js – edit and delete comments in CommentBox

Example slurm cluster on your laptop (multiple VMs via vagrant)

Wrapping openbabel in python - using cython