Mocking php internal functions in unit tests

At some point, it is necessary to replace calls to an internal php function by a stub or mock which can be controlled by the test, e.g. to return certain error codes. Doing this will overwrite the php function for all tests that follow, so use it with care and only when all other options cannot be used. The following example shows how it is done, by replacing the php function file_get_contents.

Read more: Mocking php internal functions in unit tests

Migration from Symfony 2.8 to 4.3

Why not migrate directly?

I developed the first version of the software for a long time and ended up with Symfony version 2.8, after it was actively supported. I tried to migrate to symfony 3.4 using several of the migration guides available, but I failed. I could not get the system up and running again, because there are a lot of dependencies in the versions of the components, mixed with deprecations at a lot of places. To fix this, I started with a completely different approach: Start with a fresh up to date empty Symfony 4.3, and then migrate each file one by one. With this approach, I can also update each file and get the most benefit from new features, e.g. use the service injection / auto wiring also in non-service classes.

Read more: Migration from Symfony 2.8 to 4.3

More Articles ...

  1. Using the form collection