BasicIntegrityTest.php in X Autoload 7.5
File
tests/src/BasicIntegrityTest.php
View source
<?php
namespace Drupal\xautoload\Tests;
class BasicIntegrityTest extends \PHPUnit_Framework_TestCase {
public function testIncludeAll() {
$lib = dirname(dirname(__DIR__)) . '/lib';
$skip = array(
$lib . '/Drupal',
);
$this
->includeAllRecursivePsr4($lib, 'Drupal\\xautoload', $skip);
}
private function includeAllRecursivePsr4($dir, $namespace, array $skip) {
foreach (scandir($dir) as $candidate) {
if ('.' === $candidate || '..' === $candidate) {
continue;
}
$path = $dir . '/' . $candidate;
if (in_array($path, $skip)) {
continue;
}
if (is_dir($path)) {
$this
->includeAllRecursivePsr4($dir . '/' . $candidate, $namespace . '\\' . $candidate, $skip);
}
elseif (is_file($path)) {
if ('.php' === substr($candidate, -4)) {
$class = $namespace . '\\' . substr($candidate, 0, -4);
if (class_exists($class)) {
continue;
}
if (interface_exists($class)) {
continue;
}
if (function_exists('trait_exists') && trait_exists($class)) {
continue;
}
throw new \Exception("Non-existing class, trait or interface '{$class}'.");
}
}
}
}
}
Classes
Name |
Description |
BasicIntegrityTest |
A test class to verify that all class files work well across PHP versions. |