protected function writeTestResult(\DOMDocument $document_, \DOMElement $testCase_, Test_Result $resultTest_, $name_)
 {
     $testCase_->setAttribute(self::XML_ATTRIBUTE_NAME_CLASS_NAME, $name_);
     $testCase_->setAttribute(self::XML_ATTRIBUTE_NAME_NAME, $resultTest_->name);
     $testCase_->setAttribute(self::XML_ATTRIBUTE_NAME_TIME, $resultTest_->processingTime);
     if ($resultTest_->hasState(Test_Result::STATE_SKIPPED)) {
         $testCase_->appendChild($document_->createElement(self::XML_ELEMENT_NAME_SKIPPED));
     } else {
         if ($resultTest_->hasState(Test_Result::STATE_FAILED)) {
             if (null !== $resultTest_->exception && $resultTest_->exception->isErrorException) {
                 $elementName = self::XML_ELEMENT_NAME_ERROR;
             } else {
                 $elementName = self::XML_ELEMENT_NAME_FAILURE;
             }
             if (null !== $resultTest_->exception) {
                 $this->writeTestException($document_, $testCase_, $resultTest_, $elementName);
             } else {
                 if ($resultTest_->count(Test_Result::TYPE_ASSERTION, Test_Result::STATE_FAILED)) {
                     $this->writeTestAssertionsFailed($document_, $testCase_, $resultTest_, $elementName);
                 }
             }
         }
     }
 }
 public function leaveTest(Test_Result $result_)
 {
     // FIXME (CSH) Align consumption details.
     if ($result_->profilerMemoryConsumption) {
         $consumption = $result_->profilerMemoryConsumption;
     } else {
         $consumption = str_repeat(' ', 10);
     }
     $consumption .= sprintf('%07.7s', sprintf('%-.4f', round($result_->processingTime, 5)));
     $this->m_cursor += $result_->count(Test_Result::TYPE_ASSERTION);
     $this->append(str_repeat(' ', $this->width - ($this->m_cursor + 22)));
     $this->append($consumption);
     if ($result_->hasState(Test_Result::STATE_SKIPPED)) {
         $this->append(' SKIP');
     } else {
         if ($result_->hasState(Test_Result::STATE_FAILED)) {
             $this->append(' FAIL');
         } else {
             $this->append('   OK');
         }
     }
     $this->appendLine();
     if (trim($result_->output)) {
         $output = wordwrap($result_->output, $this->width - 8, Io::LINE_SEPARATOR_DEFAULT, true);
         $lines = explode(Io::LINE_SEPARATOR_DEFAULT, $output);
         $this->appendLine();
         $this->appendLine('    + OUTPUT');
         foreach ($lines as $line) {
             if (trim($line)) {
                 $this->appendLine("      {$line}");
             }
         }
     }
     if ($result_->exception) {
         $this->appendLine();
         $this->appendLine('    + EXCEPTION');
         $title = str_split(sprintf('%1$s in %2$s:', $result_->exception->type, implode(':', array($result_->exception->file, $result_->exception->line))), $this->width - 9);
         $this->appendLine('      ' . array_shift($title));
         foreach ($title as $line) {
             $this->appendLine("        {$line}");
         }
         $message = str_split($result_->exception->message, $this->width - 9);
         $this->appendLine('      ' . array_shift($message));
         foreach ($message as $line) {
             $this->appendLine("        {$line}");
         }
         $trace = explode(Io::LINE_SEPARATOR_DEFAULT, $result_->exception->traceAsString);
         foreach ($trace as $chunk) {
             foreach (str_split($chunk, $this->width - 9) as $line) {
                 $this->appendLine("        {$line}");
             }
         }
     }
     if ($result_->count(Test_Result::TYPE_ASSERTION, Test_Result::STATE_FAILED)) {
         $this->appendLine();
         $this->appendLine('    + FAILED ASSERTIONS');
         foreach ($result_->collect(Test_Result::TYPE_ASSERTION, Test_Result::STATE_FAILED) as $assertion) {
             $assertionOutput = str_split($assertion->output, $this->width - 9);
             $this->appendLine('      ' . array_shift($assertionOutput));
             foreach ($assertionOutput as $line) {
                 $this->appendLine("        {$line}");
             }
         }
     }
     if (count($result_->profilerSplitTimeTable)) {
         $this->appendLine();
         $this->appendLine('    + TIMES');
         foreach ($result_->profilerSplitTimeTable as $entry) {
             $splitTimeTableEntryOutput = str_split(end($entry), $this->width - 9);
             $this->appendLine(sprintf('      %07.7s %s', sprintf('%-.4f', round(reset($entry), 5)), array_shift($splitTimeTableEntryOutput)));
             foreach ($splitTimeTableEntryOutput as $line) {
                 $this->appendLine("       {$line}");
             }
         }
     }
 }