You are here

phpunit-autoload.php in Convert Media Tags to Markup 8

Same filename and directory in other branches
  1. 2.x phpunit-autoload.php

File

phpunit-autoload.php
View source
<?php

/**
 * @file
 * PHPUnit class autoloader.
 *
 * PHPUnit knows nothing about Drupal, so provide PHPUnit with the bare
 * minimum it needs to know in order to find classes by namespace.
 *
 * Used by the PHPUnit test runner and referenced in ./phpunit.xml.
 */
spl_autoload_register(function ($class) {
  $custom_code = [
    'convert_media_tags_to_markup' => '.',
  ];
  require_once 'phpunit-bootstrap.php';
  foreach ($custom_code as $namespace => $dir) {
    if (substr($class, 0, strlen('Drupal\\' . $namespace . '\\')) == 'Drupal\\' . $namespace . '\\') {
      $class2 = preg_replace('/^Drupal\\\\' . $namespace . '\\\\/', '', $class);
      $path = $dir . '/src/' . str_replace('\\', '/', $class2) . '.php';
      require_once $path;
    }
  }
});