Joomla extensions have moved!

Galaxiis (formely www.waltercedric.com) creates industry leading premium Joomla Extensions and is the longest running Joomla extensions provider since 2005.

Powerful Joomla extensions. - Excellent documentation. - Amazing support.

Visit now www.galaxiis.com

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.

Prerequisites

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 https://github.com/joomla/joomla-cms/tree/master/tests/unit

You’ll need at least the following file

  • ${joomla_root}\tests\unit\bootstrap.php
  • ${joomla_root}\tests\unit\config.php
  • ${joomla_root}\tests\unit\JoomlaDatabaseTestCase.php
  • ${joomla_root}\tests\unit\JoomlaTestCase.php
  • ${joomla_root}\tests\unit\phpunit.xml
  • ${joomla_root}\tests\unit\readme.txt

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

For your convenience, I provide a zip file (joomla_phpunit_testing.zip), 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}\tests\unit\bootstrap.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:\xampp\php
  • Enter for “use bootstrap file” the value ${joomla_root}\tests\unit\phpunit.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

 

comments powered by Disqus

You might like also

No Thumbnail was found
The Joomla! Project and the Production Leadership Team are proud to announce the release of Joomla! 3.6 as the latest in the 3.x series. Joomla! 3.6 introduces more than 400 improvements, including many features which make administration of Joomla! Web sites easier and more feature-rich, as well as many UX (user experience) improvements. Joomla! 3 is the latest major release of the Joomla! CMS, with 3.6 the seventh standard-term support release in this series. Please note that going from 3.5 to 3.6 is …
1105 Days ago
GitHub project joomla-packager allow rapid application development of Joomla extensions
RAD Rapid application development (RAD) is a software development methodology that uses minimal planning in favor of rapid prototyping. Something that was really slowing me a lot and making any builds or changes in my extensions a real pain to maintain was the packaging of code spread in the joomla tree. I did create numerous custom Phing builds to automate and reduce these pains (Phing is heavily derived from Apache ANT) and 2 months ago Joomla-packager was born! My Joomla-packager …
2154 Days ago
Add2Home 1.7.5 for J2.5 / J3.0 / J3.1 Released
This small plugin for Joomla! add a message inviting iPhone/iPad users to add the web application to the home screen. Add2Home has been updated to version 1.7.5 correct 1 bugs for Joomla 2.5 /3.0 / 3.1. For existing users the update will display in the Extensions Manager under Updates. If you do not have this currently installed, you can click the link below and install as normal via the Extensions Manager. New ideas/features/bugs are always welcomed either through forums or …
2154 Days ago
Schema Validation for Joomla 3.1 Extensions
Full support for Joomla 3.1 has been added to the project “Schema Validation for Joomla Extensions” (GitHub), tested with all 113 manifests of Joomla 3.1.5! (components, modules, plugins and templates) Without them, Joomla accept any entry in manifest xml and never complains about Mistyping, like a valid xml but that the Joomla installer do not understand or only partially, Wrong constructs, xml tag child misplaced, Invalid data type, like a path not being a valid path, an …
2164 Days ago
CedThumbnails 2.6.4 for Joomla 2.5/3.x available
cedThumbnails has been updated to version 2.6.4 for Joomla 2.5/3.0/3.1. For existing users the update will display in the Extensions Manager under Updates. If you do not have this currently installed, you can click the link below and install as normal via the Extensions Manager. New ideas/features/bugs are always welcomed either through forums or by using feedback …
2175 Days ago
SocialSharingLive 3.1.5 for Joomla 2.5/3.x Released
SocialSharingLive has been updated to version 3.1.5 correct increase compatibility and contains five new important feature for both Joomla 2.5 and Joomla 3.x. For existing users the update will display in the Extensions Manager under Updates. If you do not have this currently installed, you can click the link below and install as normal via the Extensions Manager. SocialSharingLive add automatically to any article a set of social icons that let your reader increase your social ranking. It support: Twitter, …
2176 Days ago
How to migrate from cedtag to joomla 3.1.x Internal Tag extension
Why you may consider migrating away from cedTag? Joomla 3.1.x has a better build in internal tags solution that differ from cedTag: Joomla com_tags support multi languages, Joomla com_tags support tags hierarchy, Joomla is build in Joomla core which mean a clear roadmap and better support. It still miss some nice features of cedTag, but the may be added by me or somebody else in the future! In order to move away from cedTag and import all …
2176 Days ago
Attention cedtag extension and Joomla 3.1 warning
Remove cedtag before updating to Joomla 3.1! My extension cedtag is now colliding with the internal component name of Joomla Tag! both are named com_tags! You wont loose any data by removing cedtag, cedtag databases tables will remains allowing to do a migration later to the internal com_tags of Joomla! A migration path is documented and will be posted shortly. …
2176 Days ago
Add2Home 1.7.3 for Joomla 3.1/3.0/2.5 Released
This small plugin for Joomla! add a message inviting iPhone/iPad users to add the web application to the home screen. Add2Home has been updated to version 1.7.3 for Joomla 2.5/3.0/3.1. For existing users the update will display in the Extensions Manager under Updates. If you do not have this currently installed, you can click the link below and install as normal via the Extensions Manager. New ideas/features/bugs are always welcomed either through forums or by using feedback What’s new? …
2197 Days ago
cedphotofeed 2.6.3 for joomla J2.5 and J3.0 released
This extension for Joomla 2.5 and Joomla 3.0 allow you to inline a set of images from your favorite online gallery: Smugmug, Flickr, Picasa, Gallery2/Gallery3 and YouTube or any RSS feed in any article. To update your extension, either download the latest extension packages from the download section of cedphotofeed or update via the Joomla Extensions Update interface. You can visit also the blog of cedPhotofeed for joomla What’s New NEW Support for RokBox 2.0, use under Rendering “RokBox 2”, …
2234 Days ago