|
Server IP : 10.111.20.6 / Your IP : 216.73.217.121 Web Server : Apache System : Linux webm006.cluster111.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : edizioni ( 7252) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/edizioni/stampaeweb/../wordpress/../extonymask/book/tests/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
use PHPUnit\Framework\TestSuite;
class TestHelper
{
public static $Debug = false;
/**
* @param string $relativePath
* @param string[] $ignoreCallback
* @return TestSuite
*/
public static function GetSuite($relativePath, $ignoreCallback = [])
{
$testDirectory = ROOT_DIR . $relativePath;
$tests = TestHelper::GetTests($testDirectory, $ignoreCallback);
$suite = new TestSuite();
/** @var UnitTest $test */
foreach ($tests as $test) {
if (self::$Debug) {
echo "Adding " . get_class($test) . "\n";
}
$test->AddToSuite($suite, $testDirectory);
}
return $suite;
}
public static function GetTests($directory, $ignoreCallback)
{
$tests = [];
if ($dh = opendir($directory)) {
while (($file = readdir($dh)) !== false) {
if (!self::Ignored($file, $ignoreCallback) && self::endsWith($file, "Tests.php")) {
$tests[] = new UnitTest($file);
if (self::$Debug) {
echo "Adding $file\n";
}
} else {
if (self::$Debug) {
echo "Ignored $file\n";
}
}
}
closedir($dh);
}
return $tests;
}
private static function Ignored($fileName, $ignoreCallback)
{
if (empty($ignoreCallback)) {
return false;
}
return call_user_func($ignoreCallback, $fileName);
}
private static function endsWith($haystack, $needle)
{
$length = strlen($needle);
$start = $length * -1; //negative
return (substr($haystack, $start, $length) === $needle);
}
}