annotate vendor/nikic/php-parser/test/PhpParser/CodeTestAbstract.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
rev   line source
Chris@13 1 <?php declare(strict_types=1);
Chris@0 2
Chris@0 3 namespace PhpParser;
Chris@0 4
Chris@13 5 use PHPUnit\Framework\TestCase;
Chris@13 6
Chris@13 7 require_once __DIR__ . '/CodeTestParser.php';
Chris@13 8
Chris@13 9 abstract class CodeTestAbstract extends TestCase
Chris@0 10 {
Chris@13 11 protected function getTests($directory, $fileExtension, $chunksPerTest = 2) {
Chris@13 12 $parser = new CodeTestParser;
Chris@13 13 $allTests = [];
Chris@13 14 foreach (filesInDir($directory, $fileExtension) as $fileName => $fileContents) {
Chris@13 15 list($name, $tests) = $parser->parseTest($fileContents, $chunksPerTest);
Chris@0 16
Chris@0 17 // first part is the name
Chris@13 18 $name .= ' (' . $fileName . ')';
Chris@0 19 $shortName = ltrim(str_replace($directory, '', $fileName), '/\\');
Chris@0 20
Chris@0 21 // multiple sections possible with always two forming a pair
Chris@13 22 foreach ($tests as $i => list($mode, $parts)) {
Chris@13 23 $dataSetName = $shortName . (count($parts) > 1 ? '#' . $i : '');
Chris@13 24 $allTests[$dataSetName] = array_merge([$name], $parts, [$mode]);
Chris@0 25 }
Chris@0 26 }
Chris@0 27
Chris@13 28 return $allTests;
Chris@0 29 }
Chris@0 30 }