cvs: pear /MDB/tests Console_TestListener.php HTML_TestListener.php MDB_api_testcase.php MDB_bugs_testcase.php MDB_manager_testcase.php
MDB_pear_wrapper_test.php MDB_test.php MDB_usage_testcase.php clitest.php testchoose.php

From: Date: Sat, 18 Jan 2003 21:35:19 +0000
Subject: cvs: pear /MDB/tests Console_TestListener.php HTML_TestListener.php MDB_api_testcase.php MDB_bugs_testcase.php MDB_manager_testcase.php
MDB_pear_wrapper_test.php MDB_test.php MDB_usage_testcase.php clitest.php testchoose.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8390@lists.php.net to get a copy of this message
lsmith Sat Jan 18 16:35:19 2003 EDT Modified files: /pear/MDB/tests testchoose.php MDB_usage_testcase.php MDB_test.php MDB_pear_wrapper_test.php MDB_manager_testcase.php MDB_bugs_testcase.php MDB_api_testcase.php HTML_TestListener.php Console_TestListener.php clitest.php Log: cs improvements

Index: pear/MDB/tests/testchoose.php diff -u pear/MDB/tests/testchoose.php:1.3 pear/MDB/tests/testchoose.php:1.4 --- pear/MDB/tests/testchoose.php:1.3 Mon Nov 25 19:07:32 2002 +++ pear/MDB/tests/testchoose.php Sat Jan 18 16:35:19 2003 @@ -10,13 +10,13 @@ } ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path')); -require_once 'PHPUnit.php'; -require_once 'test_setup.php'; -require_once 'testUtils.php'; +require_once('PHPUnit.php'); +require_once('test_setup.php'); +require_once('testUtils.php'); $output = ''; foreach ($testcases as $testcase) { - include_once $testcase . '.php'; + include_once($testcase.'.php'); $output .= "<div class=\"testlineup\">\n"; $output .= "<h1>TestCase : $testcase</h1>\n"; $testmethods[$testcase] = getTests($testcase); @@ -36,7 +36,7 @@ <form method="post" action="test.php"> <?php -echo $output; +echo($output); ?> <input type="submit"> </form> Index: pear/MDB/tests/MDB_usage_testcase.php diff -u pear/MDB/tests/MDB_usage_testcase.php:1.21 pear/MDB/tests/MDB_usage_testcase.php:1.22 --- pear/MDB/tests/MDB_usage_testcase.php:1.21 Wed Oct 30 10:18:26 2002 +++ pear/MDB/tests/MDB_usage_testcase.php Sat Jan 18 16:35:19 2003 @@ -41,7 +41,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: MDB_usage_testcase.php,v 1.21 2002/10/30 15:18:26 pgc Exp $ +// $Id: MDB_usage_testcase.php,v 1.22 2003/01/18 21:35:19 lsmith Exp $ class MDB_Usage_TestCase extends PHPUnit_TestCase { //contains the dsn of the database we are testing @@ -101,10 +101,10 @@ function methodExists($name) { if (array_key_exists(strtolower($name), array_flip(get_class_methods($this->db)))) { - return TRUE; + return(TRUE); } - $this->assertTrue(FALSE, 'method '. $name . ' not implemented in ' . get_class($this->db)); - return FALSE; + $this->assertTrue(FALSE, 'method '. $name.' not implemented in '.get_class($this->db)); + return(FALSE); } function clearTables() { @@ -118,15 +118,15 @@ function supported($feature) { if (!$this->db->support($feature)) { - $this->assertTrue(FALSE, 'This database does not support' . $feature); - return FALSE; + $this->assertTrue(FALSE, 'This database does not support'.$feature); + return(FALSE); } - return TRUE; + return(TRUE); } function insertTestValues($prepared_query, &$data) { for ($i = 0; $i < count($this->fields); $i++) { - $func = 'setParam' . $this->types[$i]; + $func = 'setParam'.$this->types[$i]; $this->db->$func($prepared_query, ($i + 1), $data[$this->fields[$i]]); } } @@ -136,7 +136,7 @@ if ($this->types[$i] == 'text') { $func = 'fetch'; } else { - $func = 'fetch' . $this->types[$i]; + $func = 'fetch'.$this->types[$i]; } if ($this->types[$i] == 'float') { $delta = 0.0000000001; @@ -145,7 +145,7 @@ } $value = $this->db->$func($result, $rownum, $i); $field = $this->fields[$i]; - $this->assertEquals($value, $data[$field], "the value retrieved for field \"$field\" ($value) doesn't match what was stored ($data[$field]) . $func", $delta); + $this->assertEquals($value, $data[$field], "the value retrieved for field \"$field\" ($value) doesn't match what was stored ($data[$field]).$func", $delta); } } @@ -159,15 +159,15 @@ function testStorage() { $row = 1234; $data = array(); - $data["user_name"] = "user_$row"; - $data["user_password"] = "somepassword"; - $data["subscribed"] = $row % 2; - $data["user_id"] = $row; - $data["quota"] = strval($row/100); - $data["weight"] = sqrt($row); - $data["access_date"] = MDB_date::mdbToday(); - $data["access_time"] = MDB_date::mdbTime(); - $data["approved"] = MDB_date::mdbNow(); + $data['user_name'] = "user_$row"; + $data['user_password'] = 'somepassword'; + $data['subscribed'] = $row % 2; + $data['user_id'] = $row; + $data['quota'] = strval($row/100); + $data['weight'] = sqrt($row); + $data['access_date'] = MDB_date::mdbToday(); + $data['access_time'] = MDB_date::mdbTime(); + $data['approved'] = MDB_date::mdbNow(); $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); @@ -178,13 +178,13 @@ $this->db->freePreparedQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } $result = $this->db->query('SELECT user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->verifyFetchedValues($result, 0, $data); @@ -204,22 +204,22 @@ $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); for ($row = 0; $row < $total_rows; $row++) { - $data[$row]["user_name"] = "user_$row"; - $data[$row]["user_password"] = "somepassword"; - $data[$row]["subscribed"] = $row % 2; - $data[$row]["user_id"] = $row; - $data[$row]["quota"] = sprintf("%.2f",strval(1+($row+1)/100)); - $data[$row]["weight"] = sqrt($row); - $data[$row]["access_date"] = MDB_date::mdbToday(); - $data[$row]["access_time"] = MDB_date::mdbTime(); - $data[$row]["approved"] = MDB_date::mdbNow(); + $data[$row]['user_name'] = "user_$row"; + $data[$row]['user_password'] = 'somepassword'; + $data[$row]['subscribed'] = $row % 2; + $data[$row]['user_id'] = $row; + $data[$row]['quota'] = sprintf("%.2f",strval(1+($row+1)/100)); + $data[$row]['weight'] = sqrt($row); + $data[$row]['access_date'] = MDB_date::mdbToday(); + $data[$row]['access_time'] = MDB_date::mdbTime(); + $data[$row]['approved'] = MDB_date::mdbNow(); $this->insertTestValues($prepared_query, $data[$row]); $result = $this->db->executeQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } } @@ -229,11 +229,11 @@ for ($i = 0; $i < $total_fields; $i++) { $field = $this->fields[$i]; for ($row = 0; $row < $total_rows; $row++) { - $value = $this->db->queryOne('SELECT ' . $field . ' FROM users WHERE user_id=' . $row, $this->types[$i]); + $value = $this->db->queryOne('SELECT '.$field.' FROM users WHERE user_id='.$row, $this->types[$i]); if (MDB::isError($value)) { - $this->assertTrue(FALSE, 'Error fetching row ' . $row . ' for field ' . $field . ' of type ' . $this->types[$i]); + $this->assertTrue(FALSE, 'Error fetching row '.$row.' for field '.$field.' of type '.$this->types[$i]); } else { - $this->assertEquals(strval(rtrim($value)), strval($data[$row][$field]), 'the query field ' . $field . ' of type ' . $this->types[$i] . ' for row ' . $row . ' was returned in ' . $value . ' unlike ' . $data[$row][$field] . ' as expected'); + $this->assertEquals(strval(rtrim($value)), strval($data[$row][$field]), 'the query field '.$field.' of type '.$this->types[$i].' for row '.$row.' was returned in '.$value.' unlike '.$data[$row][$field].' as expected'); } } } @@ -245,11 +245,11 @@ * Tests prepared queries, making sure they correctly deal with ?, !, and ' */ function testPreparedQueries() { - $question_value = $this->db->getTextValue("Does this work?"); + $question_value = $this->db->getTextValue('Does this work?'); $prepared_query = $this->db->prepareQuery("INSERT INTO users (user_name, user_password, user_id) VALUES (?, $question_value, 1)"); - $this->db->setParamText($prepared_query, 1, "Sure!"); + $this->db->setParamText($prepared_query, 1, 'Sure!'); $result = $this->db->executeQuery($prepared_query); @@ -265,7 +265,7 @@ $prepared_query = $this->db->prepareQuery("INSERT INTO users (user_name, user_password, user_id) VALUES (?, $question_value, 2)"); - $this->db->setParamText($prepared_query, 1, "For Sure!"); + $this->db->setParamText($prepared_query, 1, 'For Sure!'); $result = $this->db->executeQuery($prepared_query); @@ -289,15 +289,15 @@ function testMetadata() { $row = 1234; $data = array(); - $data["user_name"] = "user_$row"; - $data["user_password"] = "somepassword"; - $data["subscribed"] = $row % 2; - $data["user_id"] = $row; - $data["quota"] = strval($row/100); - $data["weight"] = sqrt($row); - $data["access_date"] = MDB_date::mdbToday(); - $data["access_time"] = MDB_date::mdbTime(); - $data["approved"] = MDB_date::mdbNow(); + $data['user_name'] = "user_$row"; + $data['user_password'] = 'somepassword'; + $data['subscribed'] = $row % 2; + $data['user_id'] = $row; + $data['quota'] = strval($row/100); + $data['weight'] = sqrt($row); + $data['access_date'] = MDB_date::mdbToday(); + $data['access_time'] = MDB_date::mdbTime(); + $data['approved'] = MDB_date::mdbNow(); $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); @@ -308,22 +308,22 @@ $this->db->freePreparedQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } $result = $this->db->query('SELECT user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $numcols = $this->db->numCols($result); - $this->assertEquals($numcols, count($this->fields), "The query result returned a number of $numcols columns unlike " . count($this->fields) ." as expected"); + $this->assertEquals($numcols, count($this->fields), "The query result returned a number of $numcols columns unlike ".count($this->fields) .' as expected'); $column_names = $this->db->getColumnNames($result); for ($column = 0; $column < $numcols; $column++) { - $this->assertEquals($column_names[$this->fields[$column]], $column, "The query result column \"" . $this->fields[$column] . "\" was returned in position " . $column_names[$this->fields[$column]] . " unlike $column as expected"); + $this->assertEquals($column_names[$this->fields[$column]], $column, "The query result column \"".$this->fields[$column]."\" was returned in position ".$column_names[$this->fields[$column]]." unlike $column as expected"); } } @@ -336,15 +336,15 @@ */ function testNulls() { $test_values = array( - "test", - "NULL", - "null", - "" + 'test', + 'NULL', + 'null', + '' ); for ($test_value = 0; $test_value <= count($test_values); $test_value++) { if ($test_value == count($test_values)) { - $value = "NULL"; + $value = 'NULL'; $is_null = TRUE; } else { $value = $this->db->getTextValue($test_values[$test_value]); @@ -356,28 +356,28 @@ $result = $this->db->query("INSERT INTO users (user_name,user_password,user_id) VALUES ($value,$value,0)"); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing insert query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing insert query'.$result->getMessage()); } - $result = $this->db->query("SELECT user_name,user_password FROM users"); + $result = $this->db->query('SELECT user_name,user_password FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing select query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing select query'.$result->getMessage()); } - $this->assertTrue(!$this->db->endOfResult($result), "The query result seems to have reached the end of result earlier than expected"); + $this->assertTrue(!$this->db->endOfResult($result), 'The query result seems to have reached the end of result earlier than expected'); if ($is_null) { - $error_message = "A query result column is not NULL unlike what was expected"; + $error_message = 'A query result column is not NULL unlike what was expected'; } else { - $error_message = "A query result column is NULL even though it was expected to be \"" . $test_values[$test_value] . "\""; + $error_message = "A query result column is NULL even though it was expected to be \"".$test_values[$test_value]."\""; } $this->assertTrue(($this->db->resultIsNull($result, 0, 0) == $is_null), $error_message); $this->assertTrue(($this->db->resultIsNull($result, 0, 1) == $is_null), $error_message); - $this->assertTrue($this->db->endOfResult($result), "the query result did not seem to have reached the end of result as expected after testing only if columns are NULLs"); + $this->assertTrue($this->db->endOfResult($result), 'the query result did not seem to have reached the end of result as expected after testing only if columns are NULLs'); } } @@ -387,7 +387,7 @@ * */ function testEscapeSequences() { - $test_strings=array( + $test_strings = array( "'", "\"", "\\", @@ -400,7 +400,7 @@ "\\\"\\\"" ); - for($string=0; $string < count($test_strings); $string++) { + for($string = 0; $string < count($test_strings); $string++) { $this->clearTables(); $value = $this->db->getTextValue($test_strings[$string]); @@ -408,20 +408,20 @@ $result = $this->db->query("INSERT INTO users (user_name,user_password,user_id) VALUES ($value,$value,0)"); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing insert query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing insert query'.$result->getMessage()); } - $result = $this->db->query("SELECT user_name,user_password FROM users"); + $result = $this->db->query('SELECT user_name,user_password FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing select query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing select query'.$result->getMessage()); } - $this->assertTrue(!$this->db->endOfResult($result), "The query result seems to have reached the end of result earlier than expected"); + $this->assertTrue(!$this->db->endOfResult($result), 'The query result seems to have reached the end of result earlier than expected'); $value = $this->db->fetch($result, 0, 'user_name'); - $this->assertEquals(rtrim($value), $test_strings[$string], "the value retrieved for field \"user_name\" (\"$value\") doesn't match what was stored (" . $test_strings[$string] . ")"); + $this->assertEquals(rtrim($value), $test_strings[$string], "the value retrieved for field \"user_name\" (\"$value\") doesn't match what was stored (".$test_strings[$string].')'); } } @@ -442,22 +442,22 @@ $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); for ($row = 0; $row < $total_rows; $row++) { - $data[$row]["user_name"] = "user_$row"; - $data[$row]["user_password"] = "somepassword"; - $data[$row]["subscribed"] = $row % 2; - $data[$row]["user_id"] = $row; - $data[$row]["quota"] = sprintf("%.2f",strval(1+($row+1)/100)); - $data[$row]["weight"] = sqrt($row); - $data[$row]["access_date"] = MDB_date::mdbToday(); - $data[$row]["access_time"] = MDB_date::mdbTime(); - $data[$row]["approved"] = MDB_date::mdbNow(); + $data[$row]['user_name'] = "user_$row"; + $data[$row]['user_password'] = 'somepassword'; + $data[$row]['subscribed'] = $row % 2; + $data[$row]['user_id'] = $row; + $data[$row]['quota'] = sprintf("%.2f",strval(1+($row+1)/100)); + $data[$row]['weight'] = sqrt($row); + $data[$row]['access_date'] = MDB_date::mdbToday(); + $data[$row]['access_time'] = MDB_date::mdbTime(); + $data[$row]['approved'] = MDB_date::mdbNow(); $this->insertTestValues($prepared_query, $data[$row]); $result = $this->db->executeQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } } @@ -470,7 +470,7 @@ $result = $this->db->query('SELECT user_name,user_password,subscribed,user_id,quota,weight,access_date,access_time,approved FROM users ORDER BY user_id'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing select query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing select query'.$result->getMessage()); } for ($row = 0; $row < $rows && ($row + $start_row < $total_rows); $row++) { @@ -489,7 +489,7 @@ $result = $this->db->query('SELECT user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved FROM users ORDER BY user_id'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing select query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing select query'.$result->getMessage()); } $result_rows = $this->db->numRows($result); @@ -533,7 +533,7 @@ $result = $this->db->dropSequence($sequence_name); if (MDB::isError($result)) { - $this->assertTrue(FALSE, "Error dropping sequence $sequence_name : " . $result->getMessage()); + $this->assertTrue(FALSE, "Error dropping sequence $sequence_name : ".$result->getMessage()); } } @@ -553,7 +553,7 @@ $result = $this->db->dropSequence($sequence_name); if (MDB::isError($result)) { - $this->assertTrue(FALSE, "Error dropping sequence $sequence_name : " . $result->getMessage()); + $this->assertTrue(FALSE, "Error dropping sequence $sequence_name : ".$result->getMessage()); } } @@ -570,53 +570,53 @@ $row = 1234; $data = array(); - $data["user_name"] = "user_$row"; - $data["user_password"] = "somepassword"; - $data["subscribed"] = $row % 2; - $data["user_id"] = $row; - $data["quota"] = strval($row/100); - $data["weight"] = sqrt($row); - $data["access_date"] = MDB_date::mdbToday(); - $data["access_time"] = MDB_date::mdbTime(); - $data["approved"] = MDB_date::mdbNow(); - - $fields=array( - "user_name" => array( - "Value" => "user_$row", - "Type" => "text" + $data['user_name'] = "user_$row"; + $data['user_password'] = 'somepassword'; + $data['subscribed'] = $row % 2; + $data['user_id'] = $row; + $data['quota'] = strval($row/100); + $data['weight'] = sqrt($row); + $data['access_date'] = MDB_date::mdbToday(); + $data['access_time'] = MDB_date::mdbTime(); + $data['approved'] = MDB_date::mdbNow(); + + $fields = array( + 'user_name' => array( + 'Value' => "user_$row", + 'Type' => 'text' ), - "user_password" => array( - "Value" => $data["user_password"], - "Type" => "text" + 'user_password' => array( + 'Value' => $data['user_password'], + 'Type' => 'text' ), - "subscribed" => array( - "Value" => $data["subscribed"], - "Type" => "boolean" + 'subscribed' => array( + 'Value' => $data['subscribed'], + 'Type' => 'boolean' ), - "user_id" => array( - "Value" => $data["user_id"], - "Type" => "integer", - "Key" => 1 + 'user_id' => array( + 'Value' => $data['user_id'], + 'Type' => 'integer', + 'Key' => 1 ), - "quota" => array( - "Value" => $data["quota"], - "Type" => "decimal" + 'quota' => array( + 'Value' => $data['quota'], + 'Type' => 'decimal' ), - "weight" => array( - "Value" => $data["weight"], - "Type" => "float" + 'weight' => array( + 'Value' => $data['weight'], + 'Type' => 'float' ), - "access_date" => array( - "Value" => $data["access_date"], - "Type" => "date" + 'access_date' => array( + 'Value' => $data['access_date'], + 'Type' => 'date' ), - "access_time" => array( - "Value" => $data["access_time"], - "Type" => "time" + 'access_time' => array( + 'Value' => $data['access_time'], + 'Type' => 'time' ), - "approved" => array( - "Value" => $data["approved"], - "Type" => "timestamp" + 'approved' => array( + 'Value' => $data['approved'], + 'Type' => 'timestamp' ) ); @@ -637,20 +637,20 @@ $result = $this->db->query('SELECT user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->verifyFetchedValues($result, 0, $data); $row = 4321; - $fields["user_name"]["Value"] = $data["user_name"] = "user_$row"; - $fields["user_password"]["Value"] = $data["user_password"] = "somepassword"; - $fields["subscribed"]["Value"] = $data["subscribed"] = $row % 2; - $fields["quota"]["Value"] = $data["quota"] = strval($row/100); - $fields["weight"]["Value"] = $data["weight"] = sqrt($row); - $fields["access_date"]["Value"] = $data["access_date"] = MDB_date::mdbToday(); - $fields["access_time"]["Value"] = $data["access_time"] = MDB_date::mdbTime(); - $fields["approved"]["Value"] = $data["approved"] = MDB_date::mdbNow(); + $fields['user_name']['Value'] = $data['user_name'] = "user_$row"; + $fields['user_password']['Value'] = $data['user_password'] = 'somepassword'; + $fields['subscribed']['Value'] = $data['subscribed'] = $row % 2; + $fields['quota']['Value'] = $data['quota'] = strval($row/100); + $fields['weight']['Value'] = $data['weight'] = sqrt($row); + $fields['access_date']['Value'] = $data['access_date'] = MDB_date::mdbToday(); + $fields['access_time']['Value'] = $data['access_time'] = MDB_date::mdbTime(); + $fields['approved']['Value'] = $data['approved'] = MDB_date::mdbNow(); $result = $this->db->replace('users', $fields); @@ -667,7 +667,7 @@ $result = $this->db->query('SELECT user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->verifyFetchedValues($result, 0, $data); @@ -691,15 +691,15 @@ $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); for ($row = 0; $row < $total_rows; $row++) { - $data[$row]["user_name"] = "user_$row"; - $data[$row]["user_password"] = "somepassword"; - $data[$row]["subscribed"] = $row % 2; - $data[$row]["user_id"] = $row; - $data[$row]["quota"] = sprintf("%.2f",strval(1+($row+1)/100)); - $data[$row]["weight"] = sqrt($row); - $data[$row]["access_date"] = MDB_date::mdbToday(); - $data[$row]["access_time"] = MDB_date::mdbTime(); - $data[$row]["approved"] = MDB_date::mdbNow(); + $data[$row]['user_name'] = "user_$row"; + $data[$row]['user_password'] = 'somepassword'; + $data[$row]['subscribed'] = $row % 2; + $data[$row]['user_id'] = $row; + $data[$row]['quota'] = sprintf("%.2f",strval(1+($row+1)/100)); + $data[$row]['weight'] = sqrt($row); + $data[$row]['access_date'] = MDB_date::mdbToday(); + $data[$row]['access_time'] = MDB_date::mdbTime(); + $data[$row]['approved'] = MDB_date::mdbNow(); $this->insertTestValues($prepared_query, $data[$row]); @@ -707,10 +707,10 @@ $affected_rows = $this->db->affectedRows(); - $this->assertEquals($affected_rows, 1, "Inserting the row $row return $affected_rows affected row count instead of 1 as expected"); + $this->assertEquals($affected_rows, 1, "Inserting the row $row return($affected_rows affected row count instead of 1 as expected)"); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } } @@ -725,12 +725,12 @@ $result = $this->db->executeQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } $affected_rows = $this->db->affectedRows(); - $this->assertEquals($affected_rows, $row, "Updating the $row rows return $affected_rows affected row count"); + $this->assertEquals($affected_rows, $row, "Updating the $row rows return($affected_rows affected row count)"); } @@ -744,12 +744,12 @@ $result = $this->db->executeQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } $affected_rows = $this->db->affectedRows(); - $this->assertEquals($affected_rows, ($total_rows - $row), "Deleting " . ($total_rows - $row) . " rows returned $affected_rows affected row count"); + $this->assertEquals($affected_rows, ($total_rows - $row), 'Deleting '.($total_rows - $row)." rows returned $affected_rows affected row count"); } @@ -768,15 +768,15 @@ $row = 0; $data = array(); - $data["user_name"] = "user_$row"; - $data["user_password"] = "somepassword"; - $data["subscribed"] = $row % 2; - $data["user_id"] = $row; - $data["quota"] = strval($row/100); - $data["weight"] = sqrt($row); - $data["access_date"] = MDB_date::mdbToday(); - $data["access_time"] = MDB_date::mdbTime(); - $data["approved"] = MDB_date::mdbNow(); + $data['user_name'] = "user_$row"; + $data['user_password'] = 'somepassword'; + $data['subscribed'] = $row % 2; + $data['user_id'] = $row; + $data['quota'] = strval($row/100); + $data['weight'] = sqrt($row); + $data['access_date'] = MDB_date::mdbToday(); + $data['access_time'] = MDB_date::mdbTime(); + $data['approved'] = MDB_date::mdbNow(); $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); @@ -786,7 +786,7 @@ $result = $this->db->query('SELECT * FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->assertTrue($this->db->endOfResult($result), 'Transaction rollback did not revert the row that was inserted'); @@ -798,7 +798,7 @@ $result = $this->db->query('SELECT * FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->assertTrue(!$this->db->endOfResult($result), 'Transaction commit did not make permanent the row that was inserted'); @@ -806,7 +806,7 @@ $result = $this->db->query('DELETE FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error deleting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error deleting from users'.$result->getMessage()); $this->db->rollback(); } @@ -817,7 +817,7 @@ $result = $this->db->query('SELECT * FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->assertTrue($this->db->endOfResult($result), 'Transaction end with implicit commit when re-enabling auto-commit did not make permanent the rows that were deleted'); @@ -833,32 +833,32 @@ return; } - $prepared_query = $this->db->prepareQuery("INSERT INTO files (document,picture) VALUES (?,?)"); + $prepared_query = $this->db->prepareQuery('INSERT INTO files (document,picture) VALUES (?,?)'); $character_lob = array( - "Database" => $this->db, - "Error" => "", - "Data" => "" + 'Database' => $this->db, + 'Error' => '', + 'Data' => '' ); - for ($code=32; $code <= 127; $code++) { - $character_lob["Data"] .= chr($code); + for ($code = 32; $code <= 127; $code++) { + $character_lob['Data'] .= chr($code); } $binary_lob = array( - "Database" => $this->db, - "Error" => "", - "Data" => "" + 'Database' => $this->db, + 'Error' => '', + 'Data' => '' ); - for ($code=0; $code <= 255; $code++) { - $binary_lob["Data"] .= chr($code); + for ($code = 0; $code <= 255; $code++) { + $binary_lob['Data'] .= chr($code); } $clob = $this->db->createLob($character_lob); - $this->assertTrue(!MDB::isError($clob), 'Error creating character LOB: ' . $character_lob['Error']); + $this->assertTrue(!MDB::isError($clob), 'Error creating character LOB: '.$character_lob['Error']); $blob = $this->db->createLob($binary_lob); - $this->assertTrue(!MDB::isError($blob), 'Error creating binary LOB: ' . $binary_lob['Error']); + $this->assertTrue(!MDB::isError($blob), 'Error creating binary LOB: '.$binary_lob['Error']); $this->db->setParamClob($prepared_query, 1, $clob, 'document'); $this->db->setParamBlob($prepared_query, 2, $blob, 'picture'); @@ -873,7 +873,7 @@ $result = $this->db->query('SELECT document, picture FROM files'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from files' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from files'.$result->getMessage()); } $this->assertTrue(!$this->db->endOfResult($result), 'The query result seem to have reached the end of result too soon.'); @@ -888,7 +888,7 @@ $this->db->destroyLob($clob); - $this->assertEquals($value, $character_lob['Data'], "Retrieved character LOB value (\"" . $value . "\") is different from what was stored (\"" . $character_lob["Data"] ."\")"); + $this->assertEquals($value, $character_lob['Data'], "Retrieved character LOB value (\"".$value."\") is different from what was stored (\"".$character_lob['Data']."\")"); } else { $this->assertTrue(FALSE, 'Error retrieving CLOB result'); } @@ -903,7 +903,7 @@ $this->db->destroyLob($blob); - $this->assertEquals($value, $binary_lob['Data'], "Retrieved binary LOB value (\"" . $value . "\") is different from what was stored (\"" . $binary_lob["Data"] ."\")"); + $this->assertEquals($value, $binary_lob['Data'], "Retrieved binary LOB value (\"".$value."\") is different from what was stored (\"".$binary_lob['Data']."\")"); } else { $this->assertTrue(FALSE, 'Error retrieving CLOB result'); } @@ -920,33 +920,33 @@ return; } - $prepared_query = $this->db->prepareQuery("INSERT INTO files (document,picture) VALUES (?,?)"); + $prepared_query = $this->db->prepareQuery('INSERT INTO files (document,picture) VALUES (?,?)'); - $character_data_file = "character_data"; - if (($file = fopen($character_data_file, "w"))) { - for ($character_data = "", $code = 32; $code <= 127; $code++) { + $character_data_file = 'character_data'; + if (($file = fopen($character_data_file, 'w'))) { + for ($character_data = '', $code = 32; $code <= 127; $code++) { $character_data .= chr($code); } $character_lob = array( - "Type" => "inputfile", - "Database" => $this->db, - "Error" => "", - "FileName" => $character_data_file + 'Type' => 'inputfile', + 'Database' => $this->db, + 'Error' => '', + 'FileName' => $character_data_file ); $this->assertTrue((fwrite($file, $character_data, strlen($character_data)) == strlen($character_data)), 'Error creating clob file to read from'); fclose($file); } - $binary_data_file="binary_data"; - if (($file = fopen($binary_data_file, "wb"))) { - for($binary_data = "", $code = 0; $code <= 255; $code++) { + $binary_data_file = 'binary_data'; + if (($file = fopen($binary_data_file, 'wb'))) { + for($binary_data = '', $code = 0; $code <= 255; $code++) { $binary_data .= chr($code); } $binary_lob = array( - "Type" => "inputfile", - "Database" => $this->db, - "Error" => "", - "FileName" => $binary_data_file + 'Type' => 'inputfile', + 'Database' => $this->db, + 'Error' => '', + 'FileName' => $binary_data_file ); $this->assertTrue((fwrite($file, $binary_data, strlen($binary_data)) == strlen($binary_data)), 'Error creating blob file to read from'); fclose($file); @@ -971,20 +971,20 @@ $result = $this->db->query('SELECT document, picture FROM files'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from files' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from files'.$result->getMessage()); } $this->assertTrue(!$this->db->endOfResult($result), 'The query result seem to have reached the end of result too soon.'); $character_lob = array( - "Type" => "outputfile", - "Database" => $this->db, - "Result" => $result, - "Row" => 0, - "Field" => "document", - "Binary" => 0, - "Error" => "", - "FileName" => $character_data_file + 'Type' => 'outputfile', + 'Database' => $this->db, + 'Result' => $result, + 'Row' => 0, + 'Field' => 'document', + 'Binary' => 0, + 'Error' => '', + 'FileName' => $character_data_file ); $clob = $this->db->createLOB($character_lob); @@ -993,24 +993,24 @@ $this->assertTrue(($this->db->readLOB($clob, $data, 0) >= 0), 'Error reading CLOB '); $this->db->destroyLOB($clob); - $this->assertTrue(($file = fopen($character_data_file, "r")), "Error opening character data file: $character_data_file"); + $this->assertTrue(($file = fopen($character_data_file, 'r')), "Error opening character data file: $character_data_file"); $this->assertEquals(getType($value = fread($file, filesize($character_data_file))), 'string', "Could not read from character LOB file: $character_data_file"); fclose($file); - $this->assertEquals($value, $character_data, "retrieved character LOB value (\"" . $value . "\") is different from what was stored (\"" . $character_data . "\")"); + $this->assertEquals($value, $character_data, "retrieved character LOB value (\"".$value."\") is different from what was stored (\"".$character_data."\")"); } else { $this->assertTrue(FALSE, 'Error creating character LOB in a file'); } $binary_lob = array( - "Type" => "outputfile", - "Database" => $this->db, - "Result" => $result, - "Row" => 0, - "Field" => "picture", - "Binary" => 1, - "Error" => "", - "FileName" => $binary_data_file + 'Type' => 'outputfile', + 'Database' => $this->db, + 'Result' => $result, + 'Row' => 0, + 'Field' => 'picture', + 'Binary' => 1, + 'Error' => '', + 'FileName' => $binary_data_file ); $blob = $this->db->createLOB($binary_lob); @@ -1019,11 +1019,11 @@ $this->assertTrue(($this->db->readLOB($blob, $data, 0) >= 0), 'Error reading BLOB '); $this->db->destroyLOB($blob); - $this->assertTrue(($file = fopen($binary_data_file, "rb")), "Error opening binary data file: $binary_data_file"); + $this->assertTrue(($file = fopen($binary_data_file, 'rb')), "Error opening binary data file: $binary_data_file"); $this->assertEquals(getType($value = fread($file, filesize($binary_data_file))), 'string', "Could not read from binary LOB file: $binary_data_file"); fclose($file); - $this->assertEquals($value, $binary_data, "retrieved binary LOB value (\"" . $value . "\") is different from what was stored (\"" . $binary_data . "\")"); + $this->assertEquals($value, $binary_data, "retrieved binary LOB value (\"".$value."\") is different from what was stored (\"".$binary_data."\")"); } else { $this->assertTrue(FALSE, 'Error creating binary LOB in a file'); } @@ -1040,10 +1040,10 @@ return; } - $prepared_query = $this->db->prepareQuery("INSERT INTO files (document,picture) VALUES (?,?)"); + $prepared_query = $this->db->prepareQuery('INSERT INTO files (document,picture) VALUES (?,?)'); - $this->db->setParamNull($prepared_query, 1, "clob"); - $this->db->setParamNull($prepared_query, 2, "blob"); + $this->db->setParamNull($prepared_query, 1, 'clob'); + $this->db->setParamNull($prepared_query, 2, 'blob'); $result = $this->db->executeQuery($prepared_query); $this->assertTrue(!MDB::isError($result), 'Error executing prepared query - inserting NULL lobs'); @@ -1052,7 +1052,7 @@ $result = $this->db->query('SELECT document, picture FROM files'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from files' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from files'.$result->getMessage()); } $this->assertTrue(!$this->db->endOfResult($result), 'The query result seem to have reached the end of result too soon.'); Index: pear/MDB/tests/MDB_test.php diff -u pear/MDB/tests/MDB_test.php:1.38 pear/MDB/tests/MDB_test.php:1.39 --- pear/MDB/tests/MDB_test.php:1.38 Mon Nov 25 19:07:32 2002 +++ pear/MDB/tests/MDB_test.php Sat Jan 18 16:35:19 2003 @@ -1,5 +1,5 @@ <?php -// $Id: MDB_test.php,v 1.38 2002/11/26 00:07:32 lsmith Exp $ +// $Id: MDB_test.php,v 1.39 2003/01/18 21:35:19 lsmith Exp $ // // MDB test script. // @@ -16,10 +16,10 @@ // MDB.php doesnt have to be included since manager.php does that // manager.php is only necessary for handling xml schema files - require_once 'MDB.php'; + require_once('MDB.php'); MDB::loadFile('Manager'); // only including this to output result data - require_once 'Var_Dump.php'; + require_once('Var_Dump.php'); // just for kicks you can mess up this part to see some pear error handling $user = 'metapear'; @@ -32,7 +32,7 @@ } else { $db_type = 'mysql'; } - echo $db_type.'<br>'; + echo($db_type.'<br>'); // Data Source Name: This is the universal connection string $dsn['username'] = $user; @@ -61,68 +61,68 @@ // lets create the database using 'metapear_test_db.schema' // if you have allready run this script you should have 'metapear_test_db.schema.before' // in that case MDB will just compare the two schemas and make any necessary modifications to the existing DB - echo Var_Dump::display($manager->updateDatabase($input_file, $input_file.'.before')).'<br>'; - echo 'updating database from xml schema file<br>'; + echo(Var_Dump::display($manager->updateDatabase($input_file, $input_file.'.before')).'<br>'); + echo('updating database from xml schema file<br>'); - echo 'switching to database: '.$db_name.'<br>'; + echo('switching to database: '.$db_name.'<br>'); $db->setDatabase($db_name); // happy query $query ='SELECT * FROM test'; - echo 'query for the following examples:'.$query.'<br>'; + echo('query for the following examples:'.$query.'<br>'); // run the query and get a result handler $result = $db->query($query); // lets just get row:0 column:0 and free the result $field = $db->fetchOne($result); - echo '<br>field:<br>'.$field.'<br>'; + echo('<br>field:<br>'.$field.'<br>'); // run the query and get a result handler $result = $db->query($query); // lets just get row:0 and free the result $array = $db->fetchRow($result); - echo '<br>row:<br>'; - echo Var_Dump::display($array).'<br>'; + echo('<br>row:<br>'); + echo(Var_Dump::display($array).'<br>'); // run the query and get a result handler $result = $db->query($query); // lets just get column:0 and free the result $array = $db->fetchCol($result); - echo '<br>column:<br>'; - echo Var_Dump::display($array).'<br>'; + echo('<br>column:<br>'); + echo(Var_Dump::display($array).'<br>'); // run the query and get a result handler $result = $db->query($query); // lets just get column:0 and free the result $array = $db->fetchCol($result, MDB_FETCHMODE_DEFAULT, 2); - echo '<br>get column #2 (counting from 0):<br>'; - echo Var_Dump::display($array).'<br>'; + echo('<br>get column #2 (counting from 0):<br>'); + echo(Var_Dump::display($array).'<br>'); // run the query and get a result handler $result = $db->query($query); - echo 'tableInfo:<br>'; - echo Var_Dump::display($db->tableInfo($result)).'<br>'; + echo('tableInfo:<br>'); + echo(Var_Dump::display($db->tableInfo($result)).'<br>'); // lets just get everything and free the result $result = $db->query($query); $types = array('integer', 'text', 'timestamp'); $db->setResultTypes($result, $types); $array = $db->fetchAll($result, MDB_FETCHMODE_FLIPPED); - echo '<br>all with result set flipped:<br>'; - echo Var_Dump::display($array).'<br>'; + echo('<br>all with result set flipped:<br>'); + echo(Var_Dump::display($array).'<br>'); // save some time with this function // lets just get all and free the result $array = $db->queryAll($query); - echo '<br>all with just one call:<br>'; - echo Var_Dump::display($array).'<br>'; + echo('<br>all with just one call:<br>'); + echo(Var_Dump::display($array).'<br>'); // run the query with the offset 1 and count 1 and get a result handler $result = $db->limitQuery($query, NULL, 1, 1); // lets just get everything but with an associative array and free the result $array = $db->fetchAll($result, MDB_FETCHMODE_ASSOC); - echo '<br>associative array with offset 1 and count 1:<br>'; - echo Var_Dump::display($array).'<br>'; + echo('<br>associative array with offset 1 and count 1:<br>'); + echo(Var_Dump::display($array).'<br>'); // lets create a sequence - echo '<br>create a new seq with start 3 name real_funky_id<br>'; + echo('<br>create a new seq with start 3 name real_funky_id<br>'); $err = $db->createSequence('real_funky_id', 3); if (MDB::isError($err)) { - echo '<br>could not create sequence again<br>'; + echo('<br>could not create sequence again<br>'); } - echo '<br>get the next id:<br>'; + echo('<br>get the next id:<br>'); $value = $db->nextId('real_funky_id'); - echo $value.'<br>'; + echo($value.'<br>'); // lets try an prepare execute combo $alldata = array( array(1, 'one', 'un'), @@ -132,7 +132,7 @@ ); $prepared_query = $db->prepareQuery('INSERT INTO numbers VALUES(?,?,?)'); foreach ($alldata as $row) { - echo 'running execute<br>'; + echo('running execute<br>'); $db->execute($prepared_query, NULL, $row); } // lets try an prepare execute combo @@ -143,41 +143,41 @@ array(8, 'eight', 'huit') ); $prepared_query = $db->prepareQuery('INSERT INTO numbers VALUES(?,?,?)'); - echo 'running executeMultiple<br>'; - echo Var_Dump::display($db->executeMultiple($prepared_query, NULL, $alldata)).'<br>'; + echo('running executeMultiple<br>'); + echo(Var_Dump::display($db->executeMultiple($prepared_query, NULL, $alldata)).'<br>'); $array = array(4); - echo '<br>see getOne in action:<br>'; - echo Var_Dump::display($db->getOne('SELECT trans_en FROM numbers WHERE number = ?','text',$array)).'<br>'; - echo '<br>see getRow in action:<br>'; + echo('<br>see getOne in action:<br>'); + echo(Var_Dump::display($db->getOne('SELECT trans_en FROM numbers WHERE number = ?','text',$array)).'<br>'); + echo('<br>see getRow in action:<br>'); $db->setFetchmode(MDB_FETCHMODE_ASSOC); - echo '<br>default fetchmode ist now MDB_FETCHMODE_ASSOC<br>'; - echo Var_Dump::display($db->getRow('SELECT * FROM numbers WHERE number = ?',array('integer','text','text'),$array)); - echo 'default fetchmode ist now MDB_FETCHMODE_ORDERED<br>'; + echo('<br>default fetchmode ist now MDB_FETCHMODE_ASSOC<br>'); + echo(Var_Dump::display($db->getRow('SELECT * FROM numbers WHERE number = ?',array('integer','text','text'),$array))); + echo('default fetchmode ist now MDB_FETCHMODE_ORDERED<br>'); $db->setFetchmode(MDB_FETCHMODE_ORDERED); - echo '<br>see getCol in action:<br>'; - echo Var_Dump::display($db->getCol('SELECT * FROM numbers','text', NULL, NULL, 1)).'<br>'; - echo '<br>see getAll in action:<br>'; - echo Var_Dump::display($db->getAll('SELECT * FROM test',array('integer','text','text'))).'<br>'; - echo '<br>see getAssoc in action:<br>'; - echo Var_Dump::display($db->getAssoc('SELECT * FROM test',array('integer','text','text'), NULL, NULL, MDB_FETCHMODE_ASSOC)).'<br>'; - echo 'tableInfo on a string:<br>'; - echo Var_Dump::display($db->tableInfo('numbers')).'<br>'; - echo '<br>just a simple update query:<br>'; - echo Var_Dump::display($db->query('UPDATE numbers set trans_en ='.$db->getIntegerValue(0))).'<br>'; - echo '<br>affected rows:<br>'; - echo $db->affectedRows().'<br>'; + echo('<br>see getCol in action:<br>'); + echo(Var_Dump::display($db->getCol('SELECT * FROM numbers','text', NULL, NULL, 1)).'<br>'); + echo('<br>see getAll in action:<br>'); + echo(Var_Dump::display($db->getAll('SELECT * FROM test',array('integer','text','text'))).'<br>'); + echo('<br>see getAssoc in action:<br>'); + echo(Var_Dump::display($db->getAssoc('SELECT * FROM test',array('integer','text','text'), NULL, NULL, MDB_FETCHMODE_ASSOC)).'<br>'); + echo('tableInfo on a string:<br>'); + echo(Var_Dump::display($db->tableInfo('numbers')).'<br>'); + echo('<br>just a simple update query:<br>'); + echo(Var_Dump::display($db->query('UPDATE numbers set trans_en ='.$db->getIntegerValue(0))).'<br>'); + echo('<br>affected rows:<br>'); + echo($db->affectedRows().'<br>'); // subselect test $sub_select = $db->subSelect('SELECT test_name from test WHERE test_name = '.$db->getTextValue('gummihuhn'), TRUE); - echo Var_Dump::display($sub_select).'<br>'; + echo(Var_Dump::display($sub_select).'<br>'); $query_with_subselect = 'SELECT * FROM test WHERE test_name IN ('.$sub_select.')'; // run the query and get a result handler - echo $query_with_subselect.'<br>'; + echo($query_with_subselect.'<br>'); $result = $db->query($query_with_subselect); $array = $db->fetchAll($result); - echo '<br>all with subselect:<br>'; - echo Var_Dump::display($array).'<br>'; - echo '<br>drop index (will fail if the index was never created):<br>'; - echo Var_Dump::display($db->dropIndex('test', 'test_id_index')).'<br>'; + echo('<br>all with subselect:<br>'); + echo(Var_Dump::display($array).'<br>'); + echo('<br>drop index (will fail if the index was never created):<br>'); + echo(Var_Dump::display($db->dropIndex('test', 'test_id_index')).'<br>'); $index_def = array( 'FIELDS' => array( 'test_id' => array( @@ -185,8 +185,8 @@ ) ) ); - echo '<br>create index:<br>'; - echo Var_Dump::display($db->createIndex('test', 'test_id_index', $index_def)).'<br>'; + echo('<br>create index:<br>'); + echo(Var_Dump::display($db->createIndex('test', 'test_id_index', $index_def)).'<br>'); if($db_type == 'mysql') { $manager->captureDebugOutput(TRUE); $manager->database->setOption('log_line_break', '<br>'); @@ -194,21 +194,21 @@ // we will not use the 'metapear_test_db.schema' for this // this feature is especially interesting for people that have an existing Db and want to move to MDB's xml schema management // you can also try MDB_MANAGER_DUMP_ALL and MDB_MANAGER_DUMP_CONTENT - echo Var_Dump::display($manager->dumpDatabase( + echo(Var_Dump::display($manager->dumpDatabase( array( 'Output_Mode' => 'file', 'Output' => $db_name.'2.schema' ), MDB_MANAGER_DUMP_STRUCTURE - )).'<br>'; + )).'<br>'); if($manager->options['debug']) { - echo $manager->debugOutput().'<br>'; + echo($manager->debugOutput().'<br>'); } // this is the database definition as an array - echo Var_Dump::display($manager->database_definition).'<br>'; + echo(Var_Dump::display($manager->database_definition).'<br>'); } - echo '<br>just a simple delete query:<br>'; - echo Var_Dump::display($db->query('DELETE FROM numbers')).'<br>'; + echo('<br>just a simple delete query:<br>'); + echo(Var_Dump::display($db->query('DELETE FROM numbers')).'<br>'); // You can disconnect from the database with: $db->disconnect() ?> Index: pear/MDB/tests/MDB_pear_wrapper_test.php diff -u pear/MDB/tests/MDB_pear_wrapper_test.php:1.20 pear/MDB/tests/MDB_pear_wrapper_test.php:1.21 --- pear/MDB/tests/MDB_pear_wrapper_test.php:1.20 Mon Nov 25 19:07:32 2002 +++ pear/MDB/tests/MDB_pear_wrapper_test.php Sat Jan 18 16:35:19 2003 @@ -1,5 +1,5 @@ <?php -// $Id: MDB_pear_wrapper_test.php,v 1.20 2002/11/26 00:07:32 lsmith Exp $ +// $Id: MDB_pear_wrapper_test.php,v 1.21 2003/01/18 21:35:19 lsmith Exp $ // // MDB test script for the PEAR DB Wrapper. // @@ -14,9 +14,9 @@ } ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path')); - require_once 'MDB.php'; + require_once('MDB.php'); MDB::loadFile('peardb_wrapper'); - require_once 'Var_Dump.php'; + require_once('Var_Dump.php'); // just for kicks you can mess up this part to see some pear error handling $user = 'metapear'; @@ -34,49 +34,49 @@ $db =& DB::connect($dsn); // With DB::isError you can differentiate between an error or // a valid connection. - //echo Var_Dump::display($db).'<br>'; + //echo(Var_Dump::display($db).'<br>'); if (DB::isError($db)) { die (__LINE__.$db->getMessage()); } // happy query $query ='SELECT * FROM test'; - echo 'query for the following examples:'.$query.'<br>'; - echo '<br>field:<br>'.$db->getOne($query).'<br>'; + echo('query for the following examples:'.$query.'<br>'); + echo('<br>field:<br>'.$db->getOne($query).'<br>'); // run the query and get a result handler $result = $db->simpleQuery($query); - echo '<br>tableInfo() '; + echo('<br>tableInfo() '); Var_Dump::display($db->tableInfo($result)); $result = $db->query($query); - echo '<br>numCols() '; + echo('<br>numCols() '); Var_Dump::display($result->numCols()); $result->fetchInto($arr); - echo '<br>fetchInto() '; + echo('<br>fetchInto() '); Var_Dump::display($arr); - echo '<br>free() '; + echo('<br>free() '); Var_Dump::display($result->free()); $result = $db->query($query); - echo '<br>numRows() '; + echo('<br>numRows() '); Var_Dump::display($result->numRows()); - echo '<br>fetchRow() '; + echo('<br>fetchRow() '); Var_Dump::display($result->fetchRow()); // lets create a sequence on demand - echo '<br>get the next id using on demand:<br>'; - echo '<br>nextId:'.$db->nextId('real_funky_id_2'); - echo '<br>dropSequence:'.$db->dropSequence('real_funky_id_2'); + echo('<br>get the next id using on demand:<br>'); + echo('<br>nextId:'.$db->nextId('real_funky_id_2')); + echo('<br>dropSequence:'.$db->dropSequence('real_funky_id_2')); // lets create a sequence - echo '<br>create a new seq with start 3 name real_funky_id<br>'; + echo('<br>create a new seq with start 3 name real_funky_id<br>'); $err = $db->createSequence('real_funky_id',3); if (DB::isError($err)) { - echo '<br>could not create sequence again<br>'; + echo('<br>could not create sequence again<br>'); } - echo '<br>get the next id:<br>'; - echo $db->nextId('real_funky_id').'<br>'; + echo('<br>get the next id:<br>'); + echo($db->nextId('real_funky_id').'<br>'); // lets try an prepare execute combo $alldata = array( array(1, 'one', 'un'), array(2, 'two', 'deux'), @@ -84,7 +84,7 @@ array(4, 'four', 'quatre')); $prepared_query = $db->prepare('INSERT INTO numbers VALUES(?,?,?)'); foreach ($alldata as $row) { - echo 'running execute<br>'; + echo('running execute<br>'); $db->execute($prepared_query, $row); } // lets try an prepare execute combo @@ -94,25 +94,25 @@ array(8, 'eight', 'huit')); $prepared_query = $db->prepare('INSERT INTO numbers VALUES(?,?,?)'); $db->executeMultiple($prepared_query, $alldata); - echo 'running executeMultiple<br>'; + echo('running executeMultiple<br>'); $array = array(4); - echo '<br>see getOne in action:<br>'.$db->getOne('SELECT trans_en FROM numbers WHERE number = ?',$array).'<br>'; + echo('<br>see getOne in action:<br>'.$db->getOne('SELECT trans_en FROM numbers WHERE number = ?',$array).'<br>'); // You can disconnect from the database with: - echo '<br>see getRow in action:<br>'; - echo Var_Dump::display($db->getRow('SELECT * FROM numbers WHERE number = ?',$array)).'<br>'; - echo '<br>see getCol in action:<br>'; - echo Var_Dump::display($db->getCol('SELECT * FROM numbers', 1)).'<br>'; - echo '<br>see getAll in action:<br>'; - echo Var_Dump::display($db->getAll('SELECT * FROM test')).'<br>'; - echo '<br>see getAssoc in action:<br>'; - echo Var_Dump::display($db->getAssoc('SELECT * FROM test', FALSE, '', DB_FETCHMODE_ASSOC)).'<br>'; - echo 'tableInfo on a string:<br>'; - echo Var_Dump::display($db->tableInfo('numbers')).'<br>'; - echo '<br>just a simple delete query:<br>'; - echo Var_Dump::display($db->query('UPDATE numbers set trans_en = 0')).'<br>'; - echo '<br>affected rows:<br>'; - echo $db->affectedRows().'<br>'; - echo '<br>just a simple delete query:<br>'; - echo Var_Dump::display($db->query('DELETE FROM numbers')).'<br>'; + echo('<br>see getRow in action:<br>'); + echo(Var_Dump::display($db->getRow('SELECT * FROM numbers WHERE number = ?',$array)).'<br>'); + echo('<br>see getCol in action:<br>'); + echo(Var_Dump::display($db->getCol('SELECT * FROM numbers', 1)).'<br>'); + echo('<br>see getAll in action:<br>'); + echo(Var_Dump::display($db->getAll('SELECT * FROM test')).'<br>'); + echo('<br>see getAssoc in action:<br>'); + echo(Var_Dump::display($db->getAssoc('SELECT * FROM test', FALSE, '', DB_FETCHMODE_ASSOC)).'<br>'); + echo('tableInfo on a string:<br>'); + echo(Var_Dump::display($db->tableInfo('numbers')).'<br>'); + echo('<br>just a simple delete query:<br>'); + echo(Var_Dump::display($db->query('UPDATE numbers set trans_en = 0')).'<br>'); + echo('<br>affected rows:<br>'); + echo($db->affectedRows().'<br>'); + echo('<br>just a simple delete query:<br>'); + echo(Var_Dump::display($db->query('DELETE FROM numbers')).'<br>'); $db->disconnect(); ?> Index: pear/MDB/tests/MDB_manager_testcase.php diff -u pear/MDB/tests/MDB_manager_testcase.php:1.6 pear/MDB/tests/MDB_manager_testcase.php:1.7 --- pear/MDB/tests/MDB_manager_testcase.php:1.6 Sun Oct 27 06:14:59 2002 +++ pear/MDB/tests/MDB_manager_testcase.php Sat Jan 18 16:35:19 2003 @@ -41,7 +41,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: MDB_manager_testcase.php,v 1.6 2002/10/27 11:14:59 lsmith Exp $ +// $Id: MDB_manager_testcase.php,v 1.7 2003/01/18 21:35:19 lsmith Exp $ class MDB_Manager_TestCase extends PHPUnit_TestCase { //contains the dsn of the database we are testing @@ -60,31 +60,37 @@ function setUp() { global $dsn, $options, $database; $this->dsn = $dsn; + unset($this->dsn['database']); $this->database = $database; $this->manager =& new MDB_Manager; - $this->manager->connect($dsn, $options); - - $this->fields = array('user_name', - 'user_password', - 'subscribed', - 'user_id', - 'quota', - 'weight', - 'access_date', - 'access_time', - 'approved' - ); + $this->manager->connect($this->dsn, $options); + if (MDB::isError($this->manager)) { + $this->assertTrue(FALSE, 'Could not connect to manager in setUp'); + exit; + } + $this->fields = array( + 'user_name', + 'user_password', + 'subscribed', + 'user_id', + 'quota', + 'weight', + 'access_date', + 'access_time', + 'approved' + ); - $this->types = array('text', - 'text', - 'boolean', - 'text', - 'decimal', - 'float', - 'date', - 'time', - 'timestamp' - ); + $this->types = array( + 'text', + 'text', + 'boolean', + 'text', + 'decimal', + 'float', + 'date', + 'time', + 'timestamp' + ); } function tearDown() { @@ -97,22 +103,22 @@ function methodExists(&$class, $name) { if (array_key_exists(strtolower($name), array_flip(get_class_methods($class)))) { - return TRUE; + return(TRUE); } - $this->assertTrue(FALSE, 'method '. $name . ' not implemented in ' . get_class($class)); - return FALSE; + $this->assertTrue(FALSE, 'method '. $name.' not implemented in '.get_class($class)); + return(FALSE); } // test the manager function testManager() { if ($this->methodExists($this->manager, 'updateDatabase')) { $input_file = 'driver_test.schema'; - $backup_file = $input_file . '.before'; - $result = $this->manager->updateDatabase($input_file, $backup_file, array('create'=>'1', 'name'=>$this->database)); + $backup_file = $input_file.'.before'; + $result = $this->manager->updateDatabase($input_file, $backup_file, array('create' =>'1', 'name' =>$this->database)); if(!MDB::isError($result)) { $input_file = 'lob_test.schema'; - $backup_file = $input_file . '.before'; - $result = $this->manager->updateDatabase($input_file, $backup_file, array('create'=>'1', 'name'=>$this->database)); + $backup_file = $input_file.'.before'; + $result = $this->manager->updateDatabase($input_file, $backup_file, array('create' =>'1', 'name' =>$this->database)); } $this->assertTrue(!MDB::isError($result), 'Error creating/updating database'); } Index: pear/MDB/tests/MDB_bugs_testcase.php diff -u pear/MDB/tests/MDB_bugs_testcase.php:1.2 pear/MDB/tests/MDB_bugs_testcase.php:1.3 --- pear/MDB/tests/MDB_bugs_testcase.php:1.2 Wed Oct 30 10:18:26 2002 +++ pear/MDB/tests/MDB_bugs_testcase.php Sat Jan 18 16:35:19 2003 @@ -111,7 +111,7 @@ function insertTestValues($prepared_query, &$data) { for ($i = 0; $i < count($this->fields); $i++) { - $func = 'setParam' . $this->types[$i]; + $func = 'setParam'.$this->types[$i]; $this->db->$func($prepared_query, ($i + 1), $data[$this->fields[$i]]); } } @@ -126,22 +126,22 @@ $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); for ($row = 0; $row < $total_rows; $row++) { - $data[$row]["user_name"] = "user_$row"; - $data[$row]["user_password"] = "somepassword"; - $data[$row]["subscribed"] = $row % 2; - $data[$row]["user_id"] = $row; - $data[$row]["quota"] = sprintf("%.2f",strval(1+($row+1)/100)); - $data[$row]["weight"] = sqrt($row); - $data[$row]["access_date"] = MDB_date::mdbToday(); - $data[$row]["access_time"] = MDB_date::mdbTime(); - $data[$row]["approved"] = MDB_date::mdbNow(); + $data[$row]['user_name'] = "user_$row"; + $data[$row]['user_password'] = 'somepassword'; + $data[$row]['subscribed'] = $row % 2; + $data[$row]['user_id'] = $row; + $data[$row]['quota'] = sprintf("%.2f",strval(1+($row+1)/100)); + $data[$row]['weight'] = sqrt($row); + $data[$row]['access_date'] = MDB_date::mdbToday(); + $data[$row]['access_time'] = MDB_date::mdbTime(); + $data[$row]['approved'] = MDB_date::mdbNow(); $this->insertTestValues($prepared_query, $data[$row]); $result = $this->db->executeQuery($prepared_query); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error executing prepared query' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error executing prepared query'.$result->getMessage()); } } @@ -150,7 +150,7 @@ $result = $this->db->query('SELECT * FROM users'); if (MDB::isError($result)) { - $this->assertTrue(FALSE, 'Error selecting from users' . $result->getMessage()); + $this->assertTrue(FALSE, 'Error selecting from users'.$result->getMessage()); } $this->db->setFetchMode(MDB_FETCHMODE_ASSOC); Index: pear/MDB/tests/MDB_api_testcase.php diff -u pear/MDB/tests/MDB_api_testcase.php:1.9 pear/MDB/tests/MDB_api_testcase.php:1.10 --- pear/MDB/tests/MDB_api_testcase.php:1.9 Tue Nov 12 13:08:34 2002 +++ pear/MDB/tests/MDB_api_testcase.php Sat Jan 18 16:35:19 2003 @@ -41,7 +41,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: MDB_api_testcase.php,v 1.9 2002/11/12 18:08:34 lsmith Exp $ +// $Id: MDB_api_testcase.php,v 1.10 2003/01/18 21:35:19 lsmith Exp $ class MDB_Api_TestCase extends PHPUnit_TestCase { //contains the dsn of the database we are testing @@ -63,7 +63,6 @@ $this->database = $database; $this->db =& MDB::connect($dsn, $options); if (MDB::isError($this->db)) { - print_r($this->db); $this->assertTrue(FALSE, 'Could not connect to database in setUp'); exit; } @@ -101,10 +100,10 @@ function methodExists($name) { if (array_key_exists(strtolower($name), array_flip(get_class_methods($this->db)))) { - return TRUE; + return(TRUE); } - $this->assertTrue(FALSE, 'method '. $name . ' not implemented in ' . get_class($this->db)); - return FALSE; + $this->assertTrue(FALSE, 'method '. $name.' not implemented in '.get_class($this->db)); + return(FALSE); } //test stuff in common.php @@ -151,18 +150,18 @@ if (!$this->methodExists('loadManager')) { return; } - $this->assertTrue(!MDB::isError($this->db->loadManager("Create database"))); + $this->assertTrue(!MDB::isError($this->db->loadManager('Create database'))); } // test of the driver // helper function so that we don't have to write out a query a million times function standardQuery() { - $query ="SELECT * FROM users"; + $query = 'SELECT * FROM users'; // run the query and get a result handler if (!MDB::isError($this->db)) { - return $this->db->query($query); + return($this->db->query($query)); } - return FALSE; + return(FALSE); } function testQuery() { Index: pear/MDB/tests/HTML_TestListener.php diff -u pear/MDB/tests/HTML_TestListener.php:1.2 pear/MDB/tests/HTML_TestListener.php:1.3 --- pear/MDB/tests/HTML_TestListener.php:1.2 Mon Nov 18 09:45:16 2002 +++ pear/MDB/tests/HTML_TestListener.php Sat Jan 18 16:35:19 2003 @@ -3,31 +3,31 @@ class HTML_TestListener extends PHPUnit_TestListener { function addError(&$test, &$t) { $this->_errors += 1; - echo "<div class=\"error\"> Error $this->_errors in " . $test->getName() . " : $t</div>"; + echo("<div class=\"error\"> Error $this->_errors in ".$test->getName()." : $t</div>"); } function addFailure(&$test, &$t) { $this->_fails += 1; if ($this->_fails == 1) { - echo '<div class="failure">'; + echo('<div class="failure">'); } - echo "Failure $this->_fails : $t<br>"; + echo("Failure $this->_fails : $t<br>"); } function endTest(&$test) { if ($this->_fails == 0 && $this->_errors == 0) { - echo ' Test passed'; + echo(' Test passed'); } else { - echo "There were $this->_fails failures for " . $test->getName() . "</br>"; - echo "There were $this->_errors errors for " . $test->getName() . "</div>"; + echo("There were $this->_fails failures for ".$test->getName().'</br>'); + echo("There were $this->_errors errors for ".$test->getName().'</div>'); } - echo "</div>"; + echo('</div>'); } function startTest(&$test) { $this->_fails = 0; $this->_errors = 0; - echo "\n<div class=\"test\">" . get_class($test) . " : Starting " . $test->getName() . " ..."; + echo("\n<div class=\"test\">".get_class($test).' : Starting '.$test->getName().' ...'); } } Index: pear/MDB/tests/Console_TestListener.php diff -u pear/MDB/tests/Console_TestListener.php:1.2 pear/MDB/tests/Console_TestListener.php:1.3 --- pear/MDB/tests/Console_TestListener.php:1.2 Mon Nov 18 09:45:16 2002 +++ pear/MDB/tests/Console_TestListener.php Sat Jan 18 16:35:19 2003 @@ -2,31 +2,31 @@ class Console_TestListener extends PHPUnit_TestListener { function addError(&$test, &$t) { $this->_errors += 1; - echo " Error $this->_errors in " . $test->getName() . " : $t\n"; + echo(" Error $this->_errors in ".$test->getName()." : $t\n"); } function addFailure(&$test, &$t) { $this->_fails += 1; if ($this->_fails == 1) { - echo '\n'; + echo('\n'); } - echo "Failure $this->_fails : $t\n"; + echo("Failure $this->_fails : $t\n"); } function endTest(&$test) { if ($this->_fails == 0 && $this->_errors == 0) { - echo ' Test passed'; + echo(' Test passed'); } else { - echo "There were $this->_fails failures for " . $test->getName() . "\n"; - echo "There were $this->_errors errors for " . $test->getName() . "\n"; + echo("There were $this->_fails failures for ".$test->getName()."\n"); + echo("There were $this->_errors errors for ".$test->getName()."\n"); } - echo "\n"; + echo("\n"); } function startTest(&$test) { $this->_fails = 0; $this->_errors = 0; - echo get_class($test) . " : Starting " . $test->getName() . " ..."; + echo(get_class($test).' : Starting '.$test->getName().' ...'); } } ?> Index: pear/MDB/tests/clitest.php diff -u pear/MDB/tests/clitest.php:1.4 pear/MDB/tests/clitest.php:1.5 --- pear/MDB/tests/clitest.php:1.4 Tue Dec 3 06:36:45 2002 +++ pear/MDB/tests/clitest.php Sat Jan 18 16:35:19 2003 @@ -67,16 +67,16 @@ } ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path')); -require_once 'PHPUnit.php'; -require_once 'test_setup.php'; -require_once 'testUtils.php'; -require_once 'MDB.php'; +require_once('PHPUnit.php'); +require_once('test_setup.php'); +require_once('testUtils.php'); +require_once('MDB.php'); MDB::loadFile('Manager'); MDB::loadFile('Date'); foreach ($testcases as $testcase) { - include_once $testcase . '.php'; + include_once($testcase.'.php'); } $database = 'driver_test'; @@ -120,7 +120,7 @@ } } -require_once 'Console_TestListener.php'; +require_once('Console_TestListener.php'); $result = new PHPUnit_TestResult; $result->addListener(new Console_TestListener);
« previous php.pear.cvs (#8390) next »