Reputation: 2015
I have a problem with phpUnit.
Whenever I try to open a file using require (or any other similar function) which is not in the same directory or subdirectory as the test file itself, phpUnit throws this error:
Warning: include_once Failed opening "C:\....." for inclusion (include path = '.;C:\xampp\php\PEAR')
Can anybody tell me what I am doing wrong? Thank you
Upvotes: 1
Views: 206
Reputation: 23379
try using realpath and dirname to get a full path
# ../myfolder/file.php
$path = realpath(dirname(dirname(__FILE__)))."/myfolder/file.php"
# ./file.php
$path = realpath(dirname(__FILE__))."/file.php"
# ../file.php
$path = realpath(dirname(dirname(__FILE__)))."/file.php"
# ../../file.php
$path = realpath(dirname(dirname(dirname(__FILE__))))."/file.php"
Upvotes: 2