protected function writeTestAssertionsFailed(\DOMDocument $document_, \DOMElement $testCase_, Test_Result $resultTest_, $elementName_)
 {
     $element = $document_->createElement($elementName_);
     $testCase_->appendChild($element);
     $element->setAttribute(self::XML_ATTRIBUTE_NAME_TYPE, 'Assertion_Error');
     $element->setAttribute(self::XML_ATTRIBUTE_NAME_MESSAGE, 'Assertion Failed');
     $output = [];
     foreach ($resultTest_->collect(Test_Result::TYPE_ASSERTION, Test_Result::STATE_FAILED) as $result) {
         $output[] = $result->output;
     }
     $element->appendChild($document_->createCDATASection(implode(Io::LINE_SEPARATOR_DEFAULT, $output)));
 }
 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}");
             }
         }
     }
 }