xp-framework/xp-framework — pull request #188 by ohinckel (2012-10-01 09:16:23+00:00)
Title: Support options for unittest listeners

Currently it's possible to specify multiple listeners when invoking the `unittest` command by using the `-l ` option, which is okay for the existing listeners.

But writing more complex listeners you may need to specify some options to configure the listener. This patch introduces a new option which can be used to pass options to the listener.

## The new argument
The `unittest` command accepts the `-l ` options which can be used to add a given listener to the test suite and configure them to use the given output. Additionally to this, it will be possible to specify more options for the listener by using the new `-o ` option, which can be specified multiple times and which add the options to the last added listener.

For example it will be possible to run the following command:
`unittest -l xp.unittest.MailListener - -o mailTo user@host.com -o subject Unittest-Report`

This will ...
* add the `xp.unittest.MailListener` (does not exist, is just and example)
* write a report to STDOUT (the first agrument after the listener class - which is default behaviour of -l option)
* set the `mailTo` option
* set the `subject` option

## How does it work

When specifying a listener option, a method is invoked which will get the option value. The method is build by using the option name `ucfirst()`'ed prefixed with "set".

In the example above, the `MailListener` would look like this:
```php
class MailListener extends Object implements TestListener {

public function setMailTo($target) {
$this->mailTo= $target;
}

public function setSubject($text) {
$this->subject= $text;
}
}
```