Example #1
0
 public function requestAction(Request $request)
 {
     $jsonc = JSONConverter::create();
     $payload = $jsonc->parse((string) $request->getContent());
     $http = $this->get('http.client');
     // Log the full request and response messages using echo() calls.
     $log = '';
     $logger = function ($msg) use(&$log) {
         $log .= str_replace(array("\n", "\r"), array("--br--", ''), $msg);
     };
     $subscriber = new LogSubscriber($logger, Formatter::DEBUG);
     $http->getEmitter()->attach($subscriber);
     $request = $http->createRequest($payload->method, $payload->url);
     $response = $http->send($request);
     $response = new JsonResponse($jsonc->parse((string) $response->getBody()), 200, array('X-Debug' => $log));
     return $response;
 }
Example #2
0
        throw $parsingException;
    }
    $toRun = array();
    foreach ($report as $event) {
        if ($event->event === 'test' && ($event->status === 'fail' || $event->status === 'error')) {
            $testFQN = $event->suite;
            $file = Code::mapClassToFile($testFQN, $root->sub('tests/'));
            $file->getDirectory()->resolvePath();
            $toRun[(string) $file] = (string) $file;
        }
    }
    $toRun = array_filter($toRun);
    $output->writeln(count($toRun) . ' tests have failed');
    $root->getFile('to-run.json')->writeContents($jsonc->stringify($toRun));
});
$createCommand('tests:to-run', array(), function ($input, $output, $command) {
    $jsonc = JSONConverter::create();
    $root = Dir::factoryTS(__DIR__)->sub('../');
    $toRun = (array) $jsonc->parseFile($root->getFile('to-run.json'));
    $leftToRun = array();
    foreach ($toRun as $filename) {
        $leftToRun[] = $filename;
        $output->writeln('phpunit ' . $filename);
    }
    $ret = 200;
    do {
        passthru('phpunit ' . array_pop($leftToRun), $ret);
    } while ($ret === 0 && count($leftToRun) > 0);
    $root->getFile('to-run.json')->writeContents($jsonc->stringify($leftToRun));
    $output->writeln('<comment>reduced to: ' . count($leftToRun) . ' tests.</comment>');
});