ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


project:unittests

This is an old revision of the document!


Unit Testing

This feature is in initial development. Feature may change substantially at any time

Unit testing can be done using PHPUnit testing. Testing can be done against any database that is available that you have admin rights on. The test creates tables, populates them with small amounts of data and drops them.

Setup

Configuration information for the tests is held in a configuration file adodb-unittest.ini. The file can be located anywhere in the PHP include path.

ADOdb Section

If the ADOdb section is defined, and the item directory is set, the the tests can be run against an ADOdb installation set locally. This is useful if ADOdb is embedded into a different application

[ADOdb]
directory=/opt/some/local/ADOdb/installation

Driver Section

The driver configuration is based on the driver name.

[mysqli]
dsn=
host=mysql-server.com
user=root
password=somepassword
database=adodb-tester
debug=0
parameters=
active=1
SettingDescription
dsnEither use a connection DSN or specify the parameters usual
hostThe hostname associated with the database
userThe connection username
passwordThe connection password
debugSets the debug mode
parametersTo set parameters normally set by setConnectionParameter(), create a string in format key=value; Note that the parameters cannot be defined as constants, you must use the numeric or string equivalents
activeIf a run-time parameter of the driver is not passed of the PHPunit version > 9, then the test is run against the first driver where the active flag is set to true

Test Execution

PHPUnit 9 or lower

phpunit unittest --bootstrap unittest/dbconnector.php <driver>

Where the <driver> name represents the ADOdb driver to use. For use of PDO drivers use the format pdo-<driver>. The driver name must follow the bootstrap file name

PHPUnit 10 or higher

phpunit unittest --bootstrap unittest/dbconnector.php

The driver to test must have the active flag defined in the driver section

Testing Cache Functions

Unless explicitly enabled, cache functions such as CacheExecute() are skipped. Tests only currently support Filesystem based caching. To activate this, add the following section to adodb-unittest.ini:

[caching]
cacheMethod=1
cacheDir=c:/dev/cache

To disable cache tests while leaving the section in place, set cacheMethod=0

Miscellaneous

To test some date functions, the local timezone must be equal to the server timezone. To change the timezone temporarily for the test, set the following gloval parameter in adodb-unittest.ini. This should exactly match the format in php.ini.

[globals]
date.timezone = 'America/Denver'

Any parameter saved into the [globals] section will be set using ini_set()

project/unittests.1753752921.txt.gz · Last modified: by mnewnham