Answer the question
In order to leave comments, you need to log in
Why does an error occur when phpUnit tests fail?
I'm writing a small console application for testing. I don't use composer. As a training, I decided to work with tests. If the tests run, everything is ok. However, if the tests fail:
1) tests\CrawlerTest::testFunctionBuildUrl
PHP Warning: require(Composer/Autoload/ClassLoader.php): failed to open stream: No such file or directory in /home/nepster/www/test.ru/bot/vendor/autoload.php on line 18
PHP Fatal error: require(): Failed opening required 'Composer/Autoload/ClassLoader.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/nepster/www/test.ru/bot/vendor/autoload.php on line 18
/**
* PSR-0
* @param $className
*/
function autoload($className) {
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
spl_autoload_register('autoload');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question