Ich habe eine Browserkomponente, die als 'After-Hook' konzipiert ist (d.h. die sie wird um die eigentliche Methode herum ausgefuehrt):

PHP-Code:
    /**
     * Call a remote URL in execute after.
     */
class BrowseHook implements MethodHook {
    private 
$user_id;
    private 
$url;
    private 
$params;
    private 
$expectedResponse;
    private 
$match false;
    
/**
     */
    
public function __construct($user_id,$url,$params,$expected_response$match false) {
        
$this->user_id $user_id;
        
$this->url $url;
        
$this->params $params;
        
$this->expectedResponse trim($expected_response);
        
$this->match $match;
        if (
$this->expectedResponse != '') {
            
$this->expectedResponse explode('|'strtolower($this->expectedResponse));
        } else {
            
$this->expectedResponse false;
        }
    }

    
/**
     * 
     * @param object $object Das Object auf dem der Backgroundjob erledigt werden soll.
     * @param string $methodname Name der Methode die auf $object ausgefuehrt werden soll.
     * @param array $params Parameter die an die Methode uebergeben wurden.
     */
    
public function executeBefore($object$methodname$params) {
        return 
true;
    }

    
/**
     *
     * @param object $object Das Object auf dem der Backgroundjob erledigt wurde.
     * @param string $methodname Name der Methode, die auf $object ausgefuehrt wurde.
     * @param array $params Parameter, die an die methode uebergeben wurden.
     * @param $result Rueckgabewert der als Backgroundjob ausgefuehrten Methode.
     */
    
public function executeAfter($object$methodname$params$result) {
        
$remote_url_params = ($this->params && $this->params != '') ? $this->params : array();
        
$cookieJar tempnam(sys_get_temp_dir(), 'BrowseHook');
        
$browser = new Browser($cookieJar);
        
$result $browser->Get($this->url$remote_url_params);
        if (
$this->expectedResponse && count($this->expectedResponse) > 0) {
            
$result trim(strtolower($result));
            if (!
$this->match) {
                
$result in_array($result,$this->expectedResponse);
            } else {
                
$result array_reduce(
                    
array_map(function($re) use ($result) {logDebug("Matching ~{$re}~");return preg_match("~{$re}~"$result);}, $this->expectedResponse),
                    function (
$carry$it) {return ($carry || $it);}, false); 
            }
         } else {
            
$result substr_compare($browser->http_code"2"01);
        }
        return 
$result;
    }

Interessant ist hier nur executeAfter(), ich teste die Methode mit einem Echo-Service (von scooterlabs, hier auf deutsch von mir vorgestellt):

PHP-Code:
BrowseHook(Session::get('user_id'), 'http://scooterlabs.com/echo.json', array('test' => $testparam), "{\"test\":\"{$testparam}\"}"true); 
Das ist ok fuer einen oberflaechlichen und manuellen Funktionstest. Aber wie kann ich das ganze automatisch, etwa mit travis-ci.org, und systematischer testen? -- da schwimmen mir grad ein wenig die Faelle weg...