You are here

private function PHPUnit_Extensions_PhptTestCase::parse in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Extensions/PhptTestCase.php \PHPUnit_Extensions_PhptTestCase::parse()

Return value

array

Throws

PHPUnit_Framework_Exception

1 call to PHPUnit_Extensions_PhptTestCase::parse()
PHPUnit_Extensions_PhptTestCase::run in vendor/phpunit/phpunit/src/Extensions/PhptTestCase.php
Runs a test and collects its result in a TestResult instance.

File

vendor/phpunit/phpunit/src/Extensions/PhptTestCase.php, line 182

Class

PHPUnit_Extensions_PhptTestCase
Runner for PHPT test cases.

Code

private function parse() {
  $sections = array();
  $section = '';
  foreach (file($this->filename) as $line) {
    if (preg_match('/^--([_A-Z]+)--/', $line, $result)) {
      $section = $result[1];
      $sections[$section] = '';
      continue;
    }
    elseif (empty($section)) {
      throw new PHPUnit_Framework_Exception('Invalid PHPT file');
    }
    $sections[$section] .= $line;
  }
  if (!isset($sections['FILE']) || !isset($sections['EXPECT']) && !isset($sections['EXPECTF'])) {
    throw new PHPUnit_Framework_Exception('Invalid PHPT file');
  }
  return $sections;
}