Page 1 of 1

include -> set_include_path problem

Posted: Thu Dec 31, 2009 1:56 am
by tua1
Hello

I have a problem with include my classes. I know that I can solved this by using set_include_path, but I don't know how to use it properly.

Root category of my all php classes is

Code: Select all

D:/tools/xampp/htdocs/CMS/classes
Here is my error msg from testsrunner.php:

Code: Select all

Warning: include(../Util/Config/Config.php) [function.include]: failed to open stream: No such file or directory in D:\tools\xampp\htdocs\CMS\classes\Validation\class.XMLPropertiesGetter.php on line 3

Code: Select all

Warning: include() [function.include]: Failed opening '../Util/Config/Config.php' for inclusion (include_path='.;D:\tools\xampp\php\PEAR;D:/tools/xampp/htdocs/CMS/classes') in D:\tools\xampp\htdocs\CMS\classes\Validation\class.XMLPropertiesGetter.php on line 3
etc...

My catalogy structure is:


-Util
--Config (Config.php)
-Validation (class.XMLPropertiesGetter.php)
--Tests (class.tests.XMLPropertiesGetterTests.php, testsrunner.php)

include in class.XMLPropertiesGetter.php:

Code: Select all

include('../Util/Config/Config.php');
include in class.tests.XMLPropertiesGetterTests.php:

Code: Select all

 
include('../class.XMLPropertiesGetter.php');
testsrunner.php:

Code: Select all

<?php
include('PHPUnit.php');
set_include_path(get_include_path().PATH_SEPARATOR.'D:/tools/xampp/htdocs/CMS/classes');
        function __autoload($name) {
 
                include('class.tests.'.$name.'Test.php');
        }
 
        $objSuite = new PHPUnit_TestSuite("XMLPropertiesGetter");
        $strResutl = PHPUnit::run($objSuite);
       
        print $strResutl->toString();
 
?>
Could somebody help me to solve this problem?

Regards

Re: include -> set_include_path problem

Posted: Thu Dec 31, 2009 2:11 am
by Christopher
Since the file giving the error is in "D:\tools\xampp\htdocs\CMS\classes\Validation\." then it seems like you should include '../../Util/Config/Config.php'.

Re: include -> set_include_path problem

Posted: Thu Dec 31, 2009 2:27 am
by tua1
class.XMLPropertiesGetter.php is in the classes/Validation

Code: Select all

 
//inside class.XMLPropertiesGetter.php;
include('../Util/Config/Config.php');
 
new XMLPropertiesGetter() - works ok
 
 
The error is coming from testsrunner.php in class/Validation/Tests/

so I must include Config.php in testsrunner.php too??

I am includin by autoloading class.test.XMLPropertiesGetterTests.php which ofcourse include:

Code: Select all

include('../class.XMLPropertiesGetter.php');