Skip to content

Commit f93886c

Browse files
committed
Create test bootstrap for autoloading
1 parent 3db125f commit f93886c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
convertWarningsToExceptions="true"
1212
stopOnFailure="false"
1313
syntaxCheck="false"
14-
bootstrap="vendor/autoload.php"
14+
bootstrap="tests/bootstrap.php"
1515
>
1616

1717
<php>

tests/bootstrap.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
4+
// Dependencies were installed with Composer and this is the main project
5+
$loader = require_once __DIR__ . '/../vendor/autoload.php';
6+
} elseif (file_exists(__DIR__ . '/../../../../autoload.php')) {
7+
// We're installed as a dependency in another project's `vendor` directory
8+
$loader = require_once __DIR__ . '/../../../../autoload.php';
9+
} else {
10+
throw new Exception('Can\'t find autoload.php. Did you install dependencies with Composer?');
11+
}
12+
13+
$loader->addPsr4('MongoDB\\Tests\\', __DIR__);

0 commit comments

Comments
 (0)