project:unittests
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
project:unittests [2025/07/29 03:41] – mnewnham | project:unittests [2025/08/05 16:54] (current) – [Prerequistes] mnewnham | ||
---|---|---|---|
Line 2: | Line 2: | ||
<WRAP warning> | <WRAP warning> | ||
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:// | ||
===== 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 the tests can be run against | + | If the ADOdb section is defined, and the item directory is set, the tests can be run against |
< | < | ||
Line 21: | Line 26: | ||
</ | </ | ||
+ | ==== Blob Section ==== | ||
+ | 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. | ||
+ | < | ||
+ | [blob] | ||
+ | testBlob=c:/ | ||
+ | </ | ||
+ | |||
+ | ==== XMLschema 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 | ||
+ | < | ||
+ | [xmlschema] | ||
+ | skipXmlTests=0 | ||
+ | </ | ||
==== 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 // |
< | < | ||
Line 46: | Line 64: | ||
|active|If 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| | |active|If 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| | ||
- | ==== Caching | + | ==== Meta Section ==== |
- | Unless explicitly enabled, | + | Unless explicitly enabled, |
+ | < | ||
+ | [meta] | ||
+ | skipDbCreation=0 | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Caching Section ==== | ||
+ | Unless explicitly enabled, cache functions such as // | ||
+ | === Filesystem === | ||
< | < | ||
[caching] | [caching] | ||
cacheMethod=1 | cacheMethod=1 | ||
cacheDir=c:/ | cacheDir=c:/ | ||
+ | </ | ||
+ | |||
+ | === Memcache Based === | ||
+ | < | ||
+ | [cache] | ||
+ | cacheMethod=2 | ||
+ | cacheHost=192.168.1.50 | ||
</ | </ | ||
Line 68: | Line 102: | ||
===== Test Execution ===== | ===== Test Execution ===== | ||
- | ==== PHPUnit 9 or lower ==== | + | ==== PHPUnit |
< | < | ||
phpunit unittest --bootstrap unittest/ | phpunit unittest --bootstrap unittest/ | ||
Line 80: | Line 114: | ||
</ | </ | ||
- | 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. |
+ | ===== 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:// | ||
+ | * 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. // | ||
+ | * Do not add driver-based code branches inside the generic test code | ||
project/unittests.1753753287.txt.gz · Last modified: by mnewnham