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; }
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>'); });
public function debug() { $converter = new JSONConverter(); $text = "== Psc\\Net\\HTTP\\Request =========================\n"; $text .= $this->method . ' : /' . $this->resource . $this->getQueryString() . "\n"; $text .= $this->getHeader() . "\n"; $text .= "== Request-Body =================================\n"; $text .= $converter->stringify($this->body, JSONConverter::PRETTY_PRINT) . "\n"; $text .= "=================================================\n"; /* $text .= "\n"; $text .= "== Response =====================================\n"; $text .= $this->getResponseHeader()."\n"; $text .= "== Body =========================================\n"; $text .= $this->response->getRaw()."\n"; $text .= "=================================================\n"; */ return $text; }