Skip to content

Commit

Permalink
Merge pull request #263 from nanasess/generate-classmap
Browse files Browse the repository at this point in the history
tests 以下の classmap を生成するよう修正
  • Loading branch information
kazumiiiiiiiiiii authored May 14, 2019
2 parents f6941a7 + 72ae82d commit 2966241
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/require.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<?php
$loader = require __DIR__.'/../data/vendor/autoload.php';

if (!class_exists('PHPUnit_Framework_TestCase')) {
class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
}
require_once __DIR__."/../html/require.php";
require_once __DIR__."/class/Common_TestCase.php";

$classMap = function ($dir) {
$map = [];
$iterator = new RegexIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir)
),
'/^(?!.+_ex\.php).+\.php$/i',
RecursiveRegexIterator::MATCH
);
foreach ($iterator as $fileinfo) {
/** @var SplFileInfo $fileinfo */
$map[(string)str_replace('.'.$fileinfo->getExtension(), '', $fileinfo->getFilename())] = $fileinfo->getPathname();
}
return $map;
};
$loader->addClassMap($classMap(__DIR__.'/../ctests'));
$loader->addClassMap($classMap(__DIR__.'/class'));
return $loader;

0 comments on commit 2966241

Please sign in to comment.