You are here

protected static function Redis_Tests_AbstractUnitTestCase::enableAutoload in Redis 7.2

Same name and namespace in other branches
  1. 7.3 lib/Redis/Tests/AbstractUnitTestCase.php \Redis_Tests_AbstractUnitTestCase::enableAutoload()

Enable the autoloader (system wide)

1 call to Redis_Tests_AbstractUnitTestCase::enableAutoload()
Redis_Tests_AbstractUnitTestCase::setUp in lib/Redis/Tests/AbstractUnitTestCase.php
Sets up unit test environment.

File

lib/Redis/Tests/AbstractUnitTestCase.php, line 15

Class

Redis_Tests_AbstractUnitTestCase

Code

protected static function enableAutoload() {
  if (self::$loaderEnabled) {
    return;
  }
  if (class_exists('Redis_Client')) {
    return;
  }
  spl_autoload_register(function ($className) {
    $parts = explode('_', $className);
    if ('Redis' === $parts[0]) {
      $filename = __DIR__ . '/../lib/' . implode('/', $parts) . '.php';
      return (bool) (include_once $filename);
    }
    return false;
  }, null, true);
  self::$loaderEnabled = true;
}