PHP testing - problem with php libraries loading

2005-11-19 Thread Filin A.
Hi all.

I'm trying to use Apache::Test module for testing my
php driven site
(Linux, Apache 2.0, PHP 4.3).

Everything works pretty good, but when I try to test a
php page which uses any
of mysql functions - the test fails and the error_log
contains these lines:

... 
PHP Warning:  Unknown(): Unable to load dynamic
library './mysql.so' - ./mysql.so: cannot open shared
object file: No such file or directory in Unknown on
line 0
PHP Warning:  Unknown(): Unable to load dynamic
library './xmlrpc.so' - ./xmlrpc.so: cannot open
shared object file: No such file or directory in
Unknown on line 0
...
[Client 127.0.0.1] PHP Fatal error:  Call to
undefined function:  mysql_connect() in
/home/filin/work-varavka/staff/htdocs/_inc/dbconnect.inc.php
on line 8
...

I think a line in the t/conf/php.ini:

extension_dir = ./

means that php seeks libraries in the current
directory, while those 
libraries are in the /usr/lib/php4/. Thereby I have 2
questions:
1) Why it is necessary to have a special php.ini for
testing?
2) How can I test (in a sane manner) php code with
functions from 
dynamic libraries?

I've tried to copy mysql.so in the current
directory, in all
meanings of current which I could imagine but
without any success.
I've successfully tried to modify the
Apache::TestConfigPHP 
so that it generates now
'extension_dir=/usr/lib/php4/',
but I don't think it is a good solving...


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: PHP testing - problem with php libraries loading

2005-11-19 Thread Geoffrey Young
cc'ing chris :)

 I think a line in the t/conf/php.ini:
 
   extension_dir = ./
 
 means that php seeks libraries in the current
 directory, while those 
 libraries are in the /usr/lib/php4/. 

hmm, could be.  chris would know better.

 Thereby I have 2
 questions:
 1) Why it is necessary to have a special php.ini for
 testing?

for the same reason that Apache-Test maintains all its own configuration
files, really - consistency, principle of least surprise, and so on.  think
of it like this...

say you have code that works one system and doesn't work on another.  the
problem turns out to be that your php.ini file contains a crucial
difference, but one you didn't think was crucial.  if your tests relied on
the installed php.ini file then you'd have the exact same problem on each
box when running the tests, on one box it would fail and on one box it would
pass.  this is Very Bad from a testing point of view - tests should create a
very specific environment in which to exercise your code, one where all the
variables are known.

using our own php.ini file (and own httpd.conf, etc) means that the
described circumstance would never happen - the tests would pass on both
systems letting you know immediately that your production environment is
_not_ the same as your testing environment.  and that is Good from a testing
point of view.

 2) How can I test (in a sane manner) php code with
 functions from 
 dynamic libraries?

I don't know the specifics, but to alter any php.ini setting you would
create t/conf/extra.conf.in and use a php variable to override the default
settings in php.ini

 
 I've tried to copy mysql.so in the current
 directory, in all
 meanings of current which I could imagine but
 without any success.
 I've successfully tried to modify the
 Apache::TestConfigPHP 
 so that it generates now
 'extension_dir=/usr/lib/php4/',
 but I don't think it is a good solving...

no, anything you need to override you can do locally from t/extra.conf.in,
such as

IfModule @PHP_MODULE
  php_extension_dir /usr/lib/php4/
/IfModule

or somesuch - I'm not really a php guy :)

chris has links to the sample tarball where you can see tricks like this in
action.  unfortunately we haven't had the free tuits to document it as well
as we would have liked.  but then again, nobody seemed to be using the php
side of things but us.  so, welcome - we hope you like it :)

--Geoff