Navigation Menu

Skip to content

Commit

Permalink
tests/bootstrap.php now works with the composer autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Zikarsky committed Oct 23, 2012
1 parent cd8d47b commit f39f96e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
5 changes: 4 additions & 1 deletion composer.json
Expand Up @@ -19,6 +19,9 @@
"php": ">=5.3.0" "php": ">=5.3.0"
}, },
"autoload": { "autoload": {
"psr-0": {"Stash": "src/"} "psr-0": {
"Stash": "src/",
"Stash\\Test": "tests/"
}
} }
} }
23 changes: 8 additions & 15 deletions tests/bootstrap.php
Expand Up @@ -14,18 +14,11 @@
// use this anywhere else in the project since that would defeat the point of testing. // use this anywhere else in the project since that would defeat the point of testing.
error_reporting(-1); error_reporting(-1);


spl_autoload_register(function($class) { $filename = __DIR__ .'/../vendor/autoload.php';
if (0 === strpos($class, 'Stash\\Test\\')) {
$file = __DIR__ . '/../tests/' . str_replace('\\', '/', $class) . '.php'; if (!file_exists($filename)) {
if (file_exists($file)) { throw new Exception("You need to execute `composer install` before running the tests. (vendors are required for test execution)");
require_once $file; }
return true;
} require_once $filename;
} elseif (0 === strpos($class, 'Stash\\')) {
$file = __DIR__ . '/../src/' . str_replace('\\', '/', $class) . '.php';
if (file_exists($file)) {
require_once $file;
return true;
}
}
});

0 comments on commit f39f96e

Please sign in to comment.