Home » Database » MDB2 » Bug #10207
Unit tests fail under PHP4
Details
| Submitted | 2007-02-27 15:04 UTC |
|---|---|
| From | andrew dot hill at openads dot org |
| Assigned | quipo |
| Status | Closed |
| Package | MDB2 |
| PHP Version | 4.3.11 |
| OS | Centos 4.3, Apache 1.3 |
| Roadmaps | (Not assigned) |
Comments
[2007-02-27 15:04 UTC] andrew dot hill at openads dot org
Description:
------------
Unfortunately, some of the tests in MDB2_Reverse_TestCase are expected to fail with the pgsql driver when PHP < 5.2.0, as the the required built in function pg_field_table() used to obtain the table name for columns was not introduced until PHP 5.2.0.
Test script:
---------------
Patch:
--- MDB2/tests/MDB2_reverse_testcase.php (revision 4696)
+++ MDB2/tests/MDB2_reverse_testcase.php (working copy)
@@ -226,7 +226,22 @@
} else {
$this->assertEquals(count($this->fields), count($table_info), 'The number of fields retrieved is different from the expected one');
foreach ($table_info as $field_info) {
- $this->assertEquals($this->table, $field_info['table'], "the table name is not correct");
+ // Hack! Alas, the tableInfo() method above relys on the built in PHP function
+ // pg_field_table() when the MDB2_Driver_pgsql is in use, but the built in did
+ // not make it into PHP until 5.2.0. As a result, only want to test the table
+ // info is set when NOT using the pgsql driver, or, the driver is in use, when
+ // the PHP version is appropriate
+ $checkTableInfo = true;
+ if (is_a($this->db, "MDB2_Driver_pgsql")) {
+ if (version_compare(PHP_VERSION, "5.2.0", "<")) {
+ $checkTableInfo = false;
+ }
+ }
+ if ($checkTableInfo) {
+ $this->assertEquals($this->table, $field_info['table'], "the table name is not correct");
+ } else {
+ $this->assertEquals('', $field_info['table'], "the table name is not correct");
+ }
if (!array_key_exists(strtolower($field_info['name']), $this->fields)) {
$this->assertTrue(false, 'Field names do not match ('.$field_info['name'].' is unknown)');
}