|
From: Steven B. <ste...@gm...> - 2010-02-12 14:20:04
|
On Fri, Feb 12, 2010 at 6:01 AM, Wermelinger Reguel <
reg...@vo...> wrote:
> Hi
>
> Im trying to run a UnitTestCase inside Eclipse with the SimpleTest-Plugin.
>
> I can execute my test when I open the context-menu of a php-file with
> testcode, there i select "run as" -> "php script".
> The test execution works and i see the result in an unformatted view "debug
> output".
>
> But i like to execute the Test with the Simpletest-Runconfig, to see the
> better formatted test-output in the "Result View".
> This works also as long as i don't use any include or require statements
> inside the Testcase. But most of my testcases are depending on some
> libraries that i use. Now i can't include them or I run into errors. The PHP
> Output displays, that the files are not found in the given path, even if the
> files exist.
>
> The strange thing is, that the includes work if i point to files which are
> in the same folder as the testfile. It also works if use full path to
> include the file. But no chance with realtive paths....
>
> ---------------------------------------------------------------------------
> An excample: this could be my Testcase:
> // Library Autoloader:
> require_once('../lib/AutoLoader.php'); // doesn't work -> relative path!
> AutoLoader::Register();
>
> Hello,
This fix is simple, you need to give the require/include paths to the
library relative to file which has the require_once inside of it.
The method I use is (something like):
require_once(dirname(__FILE__).'/../../somedir/someotherdir/lib/AutoLoader.php');
The dirname(__FILE__) gives the directory of the file the php processor is
currently processing.
Hope this helps.
Regards,
Steven Balthzor
|