PHPUnit doesn't recognize file_exists()
Posted
by Ondrej Slinták
on Stack Overflow
See other posts from Stack Overflow
or by Ondrej Slinták
Published on 2010-04-06T12:24:30Z
Indexed on
2010/04/06
12:33 UTC
Read the original article
Hit count: 225
I've set up a project with unit test files in NetBeans. I set bootstrap to C:\www\foo\_tests\TestAutoload.php
and put simple autoload method to this file:
function __autoload( $class_name ) {
// series of ifs
if ( ... ) {
$file_name = ...
}
if ( file_exists ( $file_name ) ) {
require_once( $file_name );
} else {
echo "autoload error";
}
}
All of my tests fail on autoload this way. They always output just "autoload error". If I don't check if file_exists
and just use require_once( $file )
no matter what's in $file
, it works perfectly.
Anyone encountered anything like this before? It's not something I couldn't resolve by simply not checking whether file exists or not, but I'm interested why it does this and if I can cheat it somehow.
© Stack Overflow or respective owner