You are here

public function PHP_CodeCoverage::append in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/php-code-coverage/src/CodeCoverage.php \PHP_CodeCoverage::append()

Appends code coverage data.

Parameters

array $data:

mixed $id:

bool $append:

mixed $linesToBeCovered:

array $linesToBeUsed:

Throws

PHP_CodeCoverage_Exception

2 calls to PHP_CodeCoverage::append()
PHP_CodeCoverage::addUncoveredFilesFromWhitelist in vendor/phpunit/php-code-coverage/src/CodeCoverage.php
Processes whitelisted files that are not covered.
PHP_CodeCoverage::stop in vendor/phpunit/php-code-coverage/src/CodeCoverage.php
Stop collection of code coverage information.

File

vendor/phpunit/php-code-coverage/src/CodeCoverage.php, line 268

Class

PHP_CodeCoverage
Provides collection functionality for PHP code coverage information.

Code

public function append(array $data, $id = null, $append = true, $linesToBeCovered = array(), array $linesToBeUsed = array()) {
  if ($id === null) {
    $id = $this->currentId;
  }
  if ($id === null) {
    throw new PHP_CodeCoverage_Exception();
  }
  $this
    ->applyListsFilter($data);
  $this
    ->applyIgnoredLinesFilter($data);
  $this
    ->initializeFilesThatAreSeenTheFirstTime($data);
  if (!$append) {
    return;
  }
  if ($id != 'UNCOVERED_FILES_FROM_WHITELIST') {
    $this
      ->applyCoversAnnotationFilter($data, $linesToBeCovered, $linesToBeUsed);
  }
  if (empty($data)) {
    return;
  }
  $size = 'unknown';
  $status = null;
  if ($id instanceof PHPUnit_Framework_TestCase) {
    $_size = $id
      ->getSize();
    if ($_size == PHPUnit_Util_Test::SMALL) {
      $size = 'small';
    }
    elseif ($_size == PHPUnit_Util_Test::MEDIUM) {
      $size = 'medium';
    }
    elseif ($_size == PHPUnit_Util_Test::LARGE) {
      $size = 'large';
    }
    $status = $id
      ->getStatus();
    $id = get_class($id) . '::' . $id
      ->getName();
  }
  elseif ($id instanceof PHPUnit_Extensions_PhptTestCase) {
    $size = 'large';
    $id = $id
      ->getName();
  }
  $this->tests[$id] = array(
    'size' => $size,
    'status' => $status,
  );
  foreach ($data as $file => $lines) {
    if (!$this->filter
      ->isFile($file)) {
      continue;
    }
    foreach ($lines as $k => $v) {
      if ($v == PHP_CodeCoverage_Driver::LINE_EXECUTED) {
        if (empty($this->data[$file][$k]) || !in_array($id, $this->data[$file][$k])) {
          $this->data[$file][$k][] = $id;
        }
      }
    }
  }
}