コード例 #1
0
 public function testAddWarning()
 {
     $data = new DataTable();
     $warning = new Warning(new ReasonType(ReasonType::INVALID_QUERY), "invalid query");
     $data->addWarning($warning);
     $warnings = $data->getWarnings();
     $this->assertSame(1, $data->getNumberOfWarnings(), "data must contain zero warnings");
     $this->assertSame(1, count($warnings), "warnings array must contain 1 element");
     $this->assertSame($warning, $warnings[0], "Returned warning must match input warning");
 }
コード例 #2
0
 /**
  * Render the DataTable as a string
  *
  * This may result in different output depending on the
  * output type in the request.
  */
 public function __toString()
 {
     try {
         $renderer = $this->getRenderer();
         // If there were any warnings generating this DataTable, we must send them
         // in the response and set the response status to WARNING
         $responseStatus = $this->responseStatus;
         if ($responseStatus === null) {
             if ($this->data->getNumberOfWarnings() > 0) {
                 $responseStatus = new ResponseStatus(new StatusType(StatusType::WARNING));
             }
         }
         $output = $renderer->render($this, $responseStatus);
         return $output;
     } catch (\Exception $e) {
         throw new RenderFailureException($e);
     }
 }