1

I installed PHPUnit 3.6.10 recently.

I don't understand what is wrong with the include_path in php.ini file

the php.ini files being used are as follows

Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini

another file being used by Apache2 is /etc/php5/apache2/php.ini

I have changed the include paths both in cli/php.ini and apache2/php.ini

the include path which I wrote in php.ini is

include_path = ".:/home/username/pear/share/pear:/usr/share/php

previously the include path was

include_path = .:/usr/share/php:/usr/share/pear

but the error form PHPUnit is this way

    PHP Warning:  require_once(PHPUnit/Framework.php): failed to open stream: No such file or directory in /home/username/public_html/PHP-Library/APITest.php on line 14
PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Framework.php' (include_path='.:/home/username/pear/share/pear') in /home/username/public_html/PHP-Library/APITest.php on line 14

This is written in the APITest.php file

require_once 'PHPUnit/Framework.php';

Could anybody explain what the problem is? Is there any other place where I need to make changes in php.ini?

Update

when I run below command

$ php -c /path/to/php.ini -r 'echo get_include_path()."\n";'
.:/usr/share/php:/usr/share/pear

update 2 When I remove require and extend PHPUnit_Framework_TestCase I get the following error in apache2 logs I found

[Sun Mar 11 14:54:58 2012] [error] [client 127.0.0.1] PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in /home/username/public_html/phplib/APITest.php on line 15
3
  • Oh, you're trying to run PHPUnit from within Apache? Can you post that code you're using to start the test runner? Look at /usr/bin/phpunit and phpunit.php to see what the standard script does. Commented Mar 11, 2012 at 11:07
  • The command line is now some how working fine. But when running from browser I get http 500 error. Commented Mar 11, 2012 at 16:28
  • Specifically, how are you running it from the browser? Commented Mar 11, 2012 at 22:00

2 Answers 2

1

PHPUnit 3.6 has its own autoloader that is responsible for making all of the classes available without using require. Simply extend the test case in your tests without worrying about PHPUnit.

class MyTest extends PHPUnit_Framework_TestCase { ... }

Update

When running your tests through the browser, you're bypassing the phpunit executable which sets up the autoloader. Add

require_once 'PHPUnit/Autoload.php';

to your index.php script (or whatever runs the tests).

Sign up to request clarification or add additional context in comments.

Comments

0

I had to add in the following to my php.ini: /usr/share/php/

The entire string looks like this in /etc/php5/apache2/php.ini:

".:/usr/bin/php:/var/www/cakephp2/lib/:/var/www/cakephp2/:/usr/bin/phpunit:/usr/bin/pear:/usr/share/php/"

To figure out where to link it I ran

locate Autoload.php

From the shell which pointed me to where PHPUnit was installed at /usr/share/php/PHPUnit and then looking at what it was trying to include I concluded I needed to add /usr/share/php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.