Configuring and Running PHP's OCI8 tests

The PHP source code includes tests for all the core functionality and extensions.  You should run the tests after building PHP.

The test suite can't test everything. You should test your applications with your new PHP too. This gives load and real-life testing not possible with PHP's script based test suite.

You should also strongly consider contributing tests to the PHP
community.  Adding tests that are relevant to your application
minimizes the risks of PHP developers breaking PHP features important
to you.

The tests in ext/oci8/tests verify the behavior of the OCI8 extension. To run them follow these steps.

1. Edit ext/oci8/tests/details.inc and set the Oracle SYSTEM user password for your database:

    $user     = "system";
    $password = "mypassword";
(In older versions of PHP these variables are located in connect.inc).

The OCI8 tests rely on being able to create tables, types, stored procedures etc.  If you change $user you may have to grant that database user extra privileges.

At the bottom of details.inc set the connection string for the database:

    $dbase = "//localhost/XE";

If PHP is running on the same machine as the database then also set:

    $oracle_on_localhost = TRUE;

This specifies whether to test functionality that has the Oracle database reading files created directly by PHP.  If the database and PHP are not using the same file system this is not possible and the variable should be set FALSE.

2. In your php.ini check that variables_order has "E", for example:

    variables_order = "EGPCS"

Without this flag, Oracle environment variables won't get propagated through the test system and tests will fail to connect.

3. Set any necessary Oracle environment variables in your shell. E.g. for PHP linked with Oracle XE enter:

    $ . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

Note the space after the full stop.

4. Finally you can run the tests:

    $ cd /home/cjones/myphpsource
    $ make test

If you want to run just the OCI8 tests use:

    $ make test TESTS=ext/oci8

The test scripts run sequentially and their status reported:

    =====================================================================
    CWD         : /home/cjones/php
    PHP         : /home/cjones/php/sapi/cli/php
    PHP_SAPI    : cli
    PHP_VERSION : 5.2.2
    ZEND_VERSION: 2.2.0
    PHP_OS      : Linux - Linux localhost.localdomain 2.6.9-42.0.10.0.1.EL
    INI actual  : /home/cjones/php/lib/php.ini
    More .INIs  :
    Extra dirs  :
    =====================================================================
    Running selected tests.
    PASS oci_bind_array_by_name() and invalid values 1 [ext/oci8/tests/array_bind_001.phpt]
    PASS oci_bind_array_by_name() and invalid values 2 [ext/oci8/tests/array_bind_002.phpt]
    PASS oci_bind_array_by_name() and invalid values 3 [ext/oci8/tests/array_bind_003.phpt]
    . . .
Successful tests begin with PASS.  Tests that are to be skipped in the current configuration are marked SKIP.  Failing tests are marked FAIL. A summary of the failing tests is given at the completion of the tests.

Occasionally a few tests are known to fail.  These might be for unfixed bugs, or where portability of the test can not be guaranteed. The output of failing tests is kept for your analysis.  For example if ext/oci8/tests/demotest.phpt fails these files will be in ext/oci8/tests:

    demotest.phpt : the test framework script
    demotest.php  : the actual PHP file executed
    demotest.out  : actual output when the test ran
    demotest.exp  : the expected output as coded in the .phpt file
    demotest.diff : difference between actual and expected output
    demotest.log  : the actual and expected output in a single file

Examine the failures and report any problems to php-qa@lists.php.net. New tests can be sent to that address too.

More information on PHP testing is on the PHP web site Writing Tests

Update: PHP 5.2.2 Release Candidate 1 has just been announced.  This has quite a few changes.  Test it!

Comments:

I'm impressed, never though for a second that php includes a testsuite. I will recommend this article to my web developers asap. I built a regression test suite for all my plsql packages in python taking advantage of its pyunit module (a lot like junit but funnier to deal with) but this tip you gave us definitely will help us to improve our QA cycle and include every piece of our software in the process. Thanks cj, I really appreciate it.

Posted by Mariano on April 10, 2007 at 08:08 AM PDT #

You may be interested in PHPUnit http://www.phpunit.de/ and SimpleTest http://www.simpletest.org/. Happy Testing!

Posted by Christopher Jones on April 10, 2007 at 08:59 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

Tourists looking out over an Opal mine
I'm a Product Manager in Server Technologies, working on scripting languages and developer-access.
Email: christopher.jones@oracle.com
Twitter: http://twitter.com/ghrd
Book: Free PHP Oracle book
Download: PHP Linux RPMs with the OCI8 extension
Links: OTN PHP Developer Center

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today