You are here

function CoderTestFile::render in Coder 6

Same name and namespace in other branches
  1. 6.2 scripts/coder_format/tests/CoderTestFile.php \CoderTestFile::render()
  2. 7.2 scripts/coder_format/tests/CoderTestFile.php \CoderTestFile::render()
  3. 7 scripts/coder_format/tests/CoderTestFile.php \CoderTestFile::render()

Renders the test with an HTML diff table.

File

scripts/coder_format/tests/CoderTestFile.php, line 145

Class

CoderTestFile
Represents coder test file for full coder_format_string_all() tests.

Code

function render() {
  drupal_add_css(drupal_get_path('module', 'coder') . '/scripts/coder_format/tests/coder-diff.css', 'module', 'all', false);
  foreach ($this->input as $unit => $content) {

    // Do not output passed units.
    if ($this->expect[$unit] === $this->actual[$unit]) {
      continue;
    }
    $diff = new Text_Diff('auto', array(
      explode("\n", $this->expect[$unit]),
      explode("\n", $this->actual[$unit]),
    ));
    $renderer = new Text_Diff_Renderer_parallel($this->test . ' test in ' . htmlspecialchars(basename($this->filename)));
    $message .= $renderer
      ->render($diff);
  }
  return $message;
}