Select Page

Using PHPUnit to test-develop Joomla extensions in PhpStorm

Using PHPUnit to test-develop Joomla extensions in PhpStorm

Since I did not find any clear how to on the internet how to run test cases for 3rd party extensions that use Joomla CMS, here is my version of it.


Having PHPUnit properly install, if you use XAMPP you may want to read this post.


How to use PHPUnit in Joomla

At the root of your Joomla installation directory, make a checkout of

You’ll need at least the following file

  • ${joomla_root}testsunitbootstrap.php
  • ${joomla_root}testsunitconfig.php
  • ${joomla_root}testsunitJoomlaDatabaseTestCase.php
  • ${joomla_root}testsunitJoomlaTestCase.php
  • ${joomla_root}testsunitphpunit.xml
  • ${joomla_root}testsunitreadme.txt

config.php is a custom or a copy of your configuration.php

For your convenience, I provide a zip file (, unpack in your Joomla root and you’re done.

Note when using PHPUnit 3.6 , Joomla should not need to include/require anything PHPUnit related since (at least) PHPUnit 3.6. This create errors otherwise.

In PHPStorm

Set Up PHPUnit

Go to Settings, using CTRL+ALT+S, under PHPUnit, select the option “Use Bootstrap file” and use as value ${joomla_root}testsunitbootstrap.php

Set Up PHPUnit Skeleton Generator

Go to Settings, using CTRL+ALT+S, under “Skeleton Generator”

  • Enter for “Path to phpunit-skelgen” the value is  ${xampp_root}php, for example C:xamppphp
  • Enter for “use bootstrap file” the value ${joomla_root}testsunitphpunit.xml

Your first Joomla test case

Create a test case from any of your Joomla classes, by hitting CTRL+SHIFT+T, this will let you select the method you want to test and generate a runnable albeit incomplete test classes.

It is only the beginning of testing your Joomla extensions, there is a lot now to learn

  • Mocking objects in Joomla, Stubbing of Joomla classes
  • Invoking protected method using TestReflection::invoke
  • How to create integration tests using the database
  • How to test the user interface using PHPSelenium
  • and more…

These links may interest you


About The Author

Cédric Walter

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.