1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-30 04:19:30 +01:00
PHP-Parser/test/PhpParser/CodeTestAbstract.php

27 lines
960 B
PHP
Raw Normal View History

<?php declare(strict_types=1);
namespace PhpParser;
abstract class CodeTestAbstract extends \PHPUnit\Framework\TestCase
{
protected function getTests($directory, $fileExtension, $chunksPerTest = 2) {
2017-01-19 22:23:19 +01:00
$parser = new CodeTestParser;
2017-08-13 14:35:03 +02:00
$allTests = [];
2017-01-19 22:23:19 +01:00
foreach (filesInDir($directory, $fileExtension) as $fileName => $fileContents) {
list($name, $tests) = $parser->parseTest($fileContents, $chunksPerTest);
2011-11-27 21:43:27 +01:00
// first part is the name
2017-01-19 22:23:19 +01:00
$name .= ' (' . $fileName . ')';
$shortName = ltrim(str_replace($directory, '', $fileName), '/\\');
2011-11-27 21:43:27 +01:00
// multiple sections possible with always two forming a pair
2017-01-19 22:23:19 +01:00
foreach ($tests as $i => list($mode, $parts)) {
$dataSetName = $shortName . (count($parts) > 1 ? '#' . $i : '');
$allTests[$dataSetName] = array_merge([$name], $parts, [$mode]);
2011-11-27 21:43:27 +01:00
}
}
2017-01-19 22:23:19 +01:00
return $allTests;
}
}