IsEqual($oStartingTableCounts)) { $bTestSuccess = false; echo "\n\nStarting and ending table counts do not match\n"; $oStartingTableCounts->OutputSideBySide($oEndingTableCounts, "Starting", "Ending"); } else { echo "\n\nTable counts match from the start and end of the test suite.\n"; } if($bTestSuccess == true) { echo "\nAll tests were successful\n"; } else { echo "\nSome test(s) failed!\n"; } // keep track of the counts of various tables class table_counts { // the tables we should count, set in the constructor var $aTablesToCount; // the counts of the tables var $aTableCounts; function table_counts() { $this->aTablesToCount = array('appBundle', 'appCategory', 'appComments', 'appData', 'appFamily', 'appMaintainers', 'appMonitors', 'appNotes', 'appVersion', 'appVotes', 'buglinks', 'distributions', 'prefs_list', 'testResults', 'user_list', 'user_privs', 'vendor'); $this->update_counts(); } // update the count for each table function update_counts() { $this->aTableCounts = array(); foreach($this->aTablesToCount as $sTable) { $sQuery = "select count(*) as cnt from ?;"; $hResult = query_parameters($sQuery, $sTable); $oRow = query_fetch_object($hResult); $this->aTableCounts[] = $oRow->cnt; } } // returns 'true' if equal, 'false' if not function IsEqual($oTableCounts) { $iIndex = 0; for($iIndex = 0; $iIndex < count($this->aTableCounts); $iIndex++) { if($this->aTableCounts[$iIndex] != $oTableCounts->aTableCounts[$iIndex]) { return false; } } return true; } function OutputSideBySide($oTableCounts, $sFirstTableCountName, $sSecondTableCountName) { $iIndex = 0; // output the header printf("%20s%20s%20s\n", "Table name", $sFirstTableCountName, $sSecondTableCountName); for($iIndex = 0; $iIndex < count($this->aTableCounts); $iIndex++) { printf("%20s%20s%20s", $this->aTablesToCount[$iIndex], $this->aTableCounts[$iIndex], $oTableCounts->aTableCounts[$iIndex]); if($this->aTableCounts[$iIndex] != $oTableCounts->aTableCounts[$iIndex]) { echo " <-- Mismatch"; } echo "\n"; } } function output() { $iIndex = 0; for($iIndex = 0; $iIndex < count($this->aTableCounts); $iIndex++) { $sTableName = $this->aTablesToCount[$iIndex]; $iTableCount = $this->aTableCounts[$iIndex]; echo "$sTableName count of $iTableCount\n"; } } } ?>