コード例 #1
0
 public function testSending()
 {
     $output = $this->setupOutput();
     $writer = new ResponseWriter($output);
     $response = new Response();
     $response->setRunId('response-writer-run-id');
     $writer->sendResponse($response);
     $this->assertEquals($response->getResponseCode(), \http_response_code());
     $this->assertEquals($response->__toString(), file_get_contents($output));
 }
コード例 #2
0
ファイル: Pipeline.php プロジェクト: fractile/testpoint
 /**
  * Executes the pipeline.
  *
  * @param   Request     $request
  * @return  Response
  */
 public function execute(Request $request)
 {
     $response = new Response();
     $runId = $request->getRunId();
     $run = $this->runRepository->retrieve($runId);
     if (null === $run) {
         $run = $this->runRepository->create();
         $runId = $run->getRunId();
     }
     $this->runRepository->persist($run);
     $response->setRunId($runId);
     return $response;
 }
コード例 #3
0
ファイル: Application.php プロジェクト: fractile/testpoint
 /**
  * Performs basic request validation.
  *
  * Will setup an error response if necessary.
  *
  * @return  bool
  */
 private function validateRequest()
 {
     $method = $_SERVER['REQUEST_METHOD'] ?? 'INVALID';
     if ('POST' !== $method) {
         $this->response = new Response();
         $this->response->setResponseCode(405);
         return false;
     }
     if (null === $this->request) {
         $this->response = new Response();
         $this->response->setResponseCode(400);
         return false;
     }
     return true;
 }