Close and re-open tickets from tests: Fogbugz PHPUnit TicketListener

When working with unit testing in PHP, you might already be using my favorite PHP unit testing tool PHPUnit. If you are, perhaps you’ve heard of the TicketListener interface. No? Then read on.

Raphael Stolt closes GitHub issues from his PHPUnit tests. Which is cool. He inspired me.

I wrote some code. You can now do the same from FogBugz. (FogBugz is a commercial project management system that includes bug tracking.)

To install this, you can now just head over to the PHPUnit PEAR channel:

pear install phpunit/PHPUnit_TicketListener_Fogbugz

Steps to do it

Have a nice failing test that can re-open your ticket.

< ?
class ExampleClassTest extends PHPUnit_Framework_TestCase
     * @ticket 2
     * @test
    function example() {


Please note the annotation documentation block above the test method: it denotes that the method is a test, and that the issue with ID 2 should be re-opened if this test should ever fail.

Then, set up a continuous integration-specific PHPUnit configuration file (oh, why? Well, this extra checking against the bugs system takes time, and we don’t want to burden our test suite with that):

    <listener class="PHPUnit_Extensions_TicketListener_Fogbugz" 

Run the PHPUnit test (or, more realistically, your whole test suite) with the specific configuration, like so:

phpunit -ddisplay_errors=1 --configuration fogbugzlistener.xml ExampleClassTest

One Reply to “Close and re-open tickets from tests: Fogbugz PHPUnit TicketListener”

Leave a Reply

Your email address will not be published. Required fields are marked *