1
votes

I am using PHPUnit in a Symfony2 project, installed through composer.

I need to override the command line argument handler, which is located in the PHPUnit_TextUI_Command class from vendor/phpunit/phpunit/src/TextUI/Command.php

That looks easy:

  • extend this class in a child class
  • override the method handleArguments(array $argv)
  • use the child class instead of the original one in PHPUnit launcher

The problem lies in the last point. I cannot get PHPUnit to use another class than the original one when the CLI is launched, because it's hardcoded in the phpunit binary, which is installed by composer.

My two clues are:

  • get the autoloader to use my child class instead of the original one, but that looks impossible because of name conflicts
  • get composer to install another PHPUnit binary of my own

I'm stuck either way, any help would be very appreciated! Thank you.

1

1 Answers

1
votes

Take a look at the bin folder where you can find a symlink to a files named phpunit where, in the last line, do:

PHPUnit_TextUI_Command::main();

In the same way, you can make a script that do the same, as example, make a file named bin\myphpunit with the following content:

#!/usr/bin/env php
<?php


require './vendor/autoload.php';

MY_CUSTOMER_PHPUnit_TextUI_Command::main();

and launch as

bin/myphpunit

Hope this help