Resource icon

Unit testing XenForo addons - tutorial

Framework Documentation

Refer to for documentation


Q: I'm getting an error: XF\Db\Exception: Too many connections when I run my tests

A: Your tests are making lots of queries in a short space of time. There are two approaches for dealing with this: 1) change your tests to make fewer queries, or 2) increase the maximum number of connections available to MySQL.

Given that you are presumably running your unit tests on a development server, then option 2 is perfectly reasonable - assuming you have sufficient memory available. Go ahead and increase the max_connections MySQL server variable on your dev server, which should fix the problem. If you start to run into performance problems or out of memory errors, then you should perform further optimisation on your dev server using tools such as MySQLTuner.