ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


project:unittests

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
project:unittests [2025/08/03 03:20] – [ADOdb Section] mnewnhamproject:unittests [2025/08/05 16:54] (current) – [Prerequistes] mnewnham
Line 2: Line 2:
 <WRAP warning>This feature is in initial development. Feature may change substantially at any time</WRAP> <WRAP warning>This feature is in initial development. Feature may change substantially at any time</WRAP>
 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. 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.
 +
 +===== Prerequistes =====  
 +  * PHP 8.0 or higher
 +  * [[https://phpunit.de|PHPUnit]] Version 9 or higher must be installed to conduct the suite of tests. 
  
 ===== Setup ===== ===== 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. +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. 
  
 +===== Settup Up The Configuration File ===== 
 ==== ADOdb Section ==== ==== ADOdb Section ====
 If the ADOdb section is defined, and the item directory is set, the tests can be run against any ADOdb installation set locally. This is useful if ADOdb is embedded into a different application If the ADOdb section is defined, and the item directory is set, the tests can be run against any ADOdb installation set locally. This is useful if ADOdb is embedded into a different application
Line 22: Line 27:
  
 ==== Blob Section ====  ==== Blob Section ==== 
-This section must be defined, either with the path name to a binary file, such as a jpeg file that can be used for read-write testing. If set to false, all blob tests are skipped.+This section must be defined with the path name of a binary file, such as a jpeg file that can be used for read-write testing. If set to false, all blob tests are skipped.
  
 <code> <code>
Line 30: Line 35:
  
 ==== XMLschema Section ====  ==== XMLschema Section ==== 
-This section must be explicitly enabled in the configuration file, otherwise all tests in the section are skipped. To activate the tests, set the following section+This section must be explicitly enabled in the configuration file, with the skipXmlTests value set to 0 , otherwise all tests in the section are skipped. Setting the value to 1 will also skip the tests
 <code> <code>
 [xmlschema] [xmlschema]
Line 36: Line 41:
 </code> </code>
 ==== Driver Section ==== ==== Driver Section ====
-The driver configuration is based on the driver name.+The driver configuration is based on the driver name. You can add as many drivers to the configuration file as you want. Only the driver specified on the command line or the first driver found in the configuration file flagged //**active**// is tested.
  
 <code> <code>
Line 60: Line 65:
  
 ==== Meta Section ==== ==== Meta Section ====
-Unless explicitly enabled, the test to create new database using the //**createDatabase**// method is skipped as it requires CREATE DATABASE privilege on the DBMS. To enable this test, set the following section:+Unless explicitly enabled, the test to create new database using the //**createDatabase**// method is skipped as it requires CREATE DATABASE privilege on the DBMS. To enable this test, set the following section:
  
-<code>[meta]+<code> 
 +[meta]
 skipDbCreation=0 skipDbCreation=0
 </code> </code>
Line 68: Line 74:
  
 ==== Caching Section ==== ==== Caching Section ====
-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: +Unless explicitly enabled, cache functions such as //**CacheExecute()**// are skipped. Tests are supported using Filesystem based or memcache based caching. To activate this, add the following section to adodb-unittest.ini: 
 +=== Filesystem === 
 <code> <code>
 [caching] [caching]
 cacheMethod=1 cacheMethod=1
 cacheDir=c:/dev/cache cacheDir=c:/dev/cache
 +</code>
 +
 +=== Memcache Based === 
 +<code>
 +[cache]
 +cacheMethod=2
 +cacheHost=192.168.1.50
 </code> </code>
  
Line 89: Line 102:
  
 ===== Test Execution =====  ===== Test Execution ===== 
-==== PHPUnit 9 or lower ====+==== PHPUnit Version 9 ====
 <code> <code>
 phpunit unittest --bootstrap unittest/dbconnector.php <driver> phpunit unittest --bootstrap unittest/dbconnector.php <driver>
Line 101: Line 114:
 </code> </code>
  
-The driver to test must have the **active** flag defined in the driver section+It is not possible to pass the driver name as a run-time argument in this version. The driver to test must have the **active** flag defined in the driver section.
  
 +===== Writing or Updating Tests ===== 
  
 +  * Tests should be compliant with PHPunit version 9 and higher
 +  * Tests should be compatible with all platforms supported by PHPunit
 +  * Tests should be written to [[https://www.php-fig.org/psr/psr-12/|PSR 12]] standards when possible
 +  * Wherever possible, write database agnostic tests. Only write driver specific tests when a feature is only supported by one or two DBMS
 +  * Only add driver specific tests to the test file specifically labeled for that driver, e.g. //**MysqliDriverTest.php**//
 +  * Do not add driver-based code branches inside the generic test code
    
  
  
project/unittests.1754184059.txt.gz · Last modified: by mnewnham