Skip to content
Browse files

tests/bootstrap.php now works with the composer autoloader

  • Loading branch information...
1 parent cd8d47b commit f39f96e111c5c2a0fc966429b3b4efba89c18543 @bzikarsky bzikarsky committed
Showing with 12 additions and 16 deletions.
  1. +4 −1 composer.json
  2. +8 −15 tests/bootstrap.php
View
5 composer.json
@@ -19,6 +19,9 @@
"php": ">=5.3.0"
},
"autoload": {
- "psr-0": {"Stash": "src/"}
+ "psr-0": {
+ "Stash": "src/",
+ "Stash\\Test": "tests/"
+ }
}
}
View
23 tests/bootstrap.php
@@ -14,18 +14,11 @@
// use this anywhere else in the project since that would defeat the point of testing.
error_reporting(-1);
-spl_autoload_register(function($class) {
- if (0 === strpos($class, 'Stash\\Test\\')) {
- $file = __DIR__ . '/../tests/' . str_replace('\\', '/', $class) . '.php';
- if (file_exists($file)) {
- require_once $file;
- return true;
- }
- } elseif (0 === strpos($class, 'Stash\\')) {
- $file = __DIR__ . '/../src/' . str_replace('\\', '/', $class) . '.php';
- if (file_exists($file)) {
- require_once $file;
- return true;
- }
- }
-});
+$filename = __DIR__ .'/../vendor/autoload.php';
+
+if (!file_exists($filename)) {
+ throw new Exception("You need to execute `composer install` before running the tests. (vendors are required for test execution)");
+}
+
+require_once $filename;
+

0 comments on commit f39f96e

Please sign in to comment.
Something went wrong with that request. Please try again.