mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-04-02 21:36:14 +03:00
Allow running tests without surrounding framework
This commit is contained in:
parent
ef40b1c3c2
commit
1e1a35aed5
1 changed files with 18 additions and 2 deletions
|
@ -12,6 +12,22 @@ if ((!$loader = includeIfExists(__DIR__.'/../../../../../.composer/autoload.php'
|
|||
'php composer.phar install'.PHP_EOL);
|
||||
}
|
||||
|
||||
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
|
||||
spl_autoload_register(function($class) {
|
||||
if (0 === strpos($class, 'Nelmio\ApiDocBundle\\')) {
|
||||
$path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
|
||||
if (!stream_resolve_include_path($path)) {
|
||||
return false;
|
||||
}
|
||||
require_once $path;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return $loader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
AnnotationRegistry::registerLoader(function($class) {
|
||||
if (strpos($class, 'Nelmio\ApiDocBundle\Annotation\\') === 0) {
|
||||
$path = __DIR__.'/../'.str_replace('\\', '/', substr($class, strlen('Nelmio\ApiDocBundle\\'))) .'.php';
|
||||
require_once $path;
|
||||
}
|
||||
return class_exists($class, false);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue