Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhptTestCase.php

function PhptTestCase::parse

Throws

Exception

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

File

vendor/phpunit/phpunit/src/Runner/PhptTestCase.php, line 442

Class

PhptTestCase
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Runner

Code

private function parse() : array {
    $sections = [];
    $section = '';
    $unsupportedSections = [
        'CGI',
        'COOKIE',
        'DEFLATE_POST',
        'EXPECTHEADERS',
        'EXTENSIONS',
        'GET',
        'GZIP_POST',
        'HEADERS',
        'PHPDBG',
        'POST',
        'POST_RAW',
        'PUT',
        'REDIRECTTEST',
        'REQUEST',
    ];
    $lineNr = 0;
    foreach (file($this->filename) as $line) {
        $lineNr++;
        if (preg_match('/^--([_A-Z]+)--/', $line, $result)) {
            $section = $result[1];
            $sections[$section] = '';
            $sections[$section . '_offset'] = $lineNr;
            continue;
        }
        if (empty($section)) {
            throw new InvalidPhptFileException();
        }
        $sections[$section] .= $line;
    }
    if (isset($sections['FILEEOF'])) {
        $sections['FILE'] = rtrim($sections['FILEEOF'], "\r\n");
        unset($sections['FILEEOF']);
    }
    $this->parseExternal($sections);
    if (!$this->validate($sections)) {
        throw new InvalidPhptFileException();
    }
    foreach ($unsupportedSections as $section) {
        if (isset($sections[$section])) {
            throw new UnsupportedPhptSectionException($section);
        }
    }
    return $sections;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal