function getActiveTaps() { $sql = "SELECT * FROM taps WHERE active = 1"; $qry = mysql_query($sql); $taps = array(); while ($i = mysql_fetch_array($qry)) { $tap = new Tap(); $tap->setFromArray($i); $taps[$tap->get_tapNumber()] = $tap; } return $taps; }
function test() { Tap::is_instance_of('db successfully initializes', 'Db', 'getDao', 'mysqli', NULL); // $all_tables = array('Classes', 'Professors', 'Student_classes', 'Students'); // Tap::is('read existing tables', 'Db', 'getAllTables', $all_tables, NULL); // $no_tables = array('status' => false); $table_name = 'taptest_table_' . Util::randString(10, 'lowercase'); $creation_statement = 'CREATE TABLE `' . $table_name . '` ( `id` int(10) NOT NULL auto_increment, `test_str` varchar(128) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2;'; Tap::is('create new table', 'Db', 'createTable', '1', $creation_statement); $all_tables[] = $table_name; Tap::is('read existing tables', 'Db', 'getAllTables', $all_tables, NULL); array_pop($all_tables); //create row array(''); //Tap::is('add a new row', 'Db', 'add', '', ); //read row //update row //read row //delete row //read row Tap::is('drop the random table created', 'Db', 'dropTable', $all_tables, $table_name); Tap::is('read existing tables', 'Db', 'getAllTables', NULL, ''); }
$tap = new Tap(); $tap->setFromArray($_POST); $tapManager->Save($tap); } redirect('tap_list.php'); } $beerList = $beerManager->GetAllActive(); $kegList = $kegManager->GetAllAvailable(); $tapNumber = $_GET['tapNumber']; if (isset($_GET['id'])) { $tap = $tapManager->GetById($_GET['id']); if (!array_key_exists($tap->get_kegId(), $kegList)) { $kegList[$tap->get_kegId()] = $kegManager->GetById($tap->get_kegId()); } } else { $tap = new Tap(); $tap->set_tapNumber($tapNumber); $tap->set_active(true); } // Code to set config values $config = array(); $sql = "SELECT * FROM config"; $qry = mysql_query($sql); while ($c = mysql_fetch_array($qry)) { $config[$c['configName']] = $c['configValue']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
$rows = $stockpile->history(array('limit' => 1)); Tap::is($rows[0]['event'], 'halloween', 'add an item with meta information. the information shows up in the log'); $stockpile->subtract($item_id, 1, array('event' => 'xmas')); $txn->commit(); $rows = $stockpile->history(array('limit' => 1)); Tap::is($rows[0]['event'], 'xmas', 'subtract an item with meta information. the information shows up in the log'); $user_id = uniqueUserID(); $item_id = uniqueNumber(1, 1000000); $txn = txn(); $stockpile = stockpile($app, $user_id, $txn); $stockpile->add($item_id, 1, array('event' => $teststring = 'äó')); $txn->commit(); $rows = $stockpile->history(array('item_id' => $item_id, 'limit' => 1)); Tap::is($rows[0]['event'], $teststring, 'utf8 characters come through'); $user_id = uniqueUserID(); $item_id = uniqueNumber(1, 1000000); $txn = txn(); $stockpile = stockpile($app, $user_id, $txn); for ($i = 0; $i < 20; $i++) { $stockpile->add($item_id, $i + 1); advanceCurrentTime(3600 * 12); } $txn->commit(); $diff = abs(count($history = $stockpile->history()) - 14); Tap::cmp_ok($diff, '<', 2, 'after logging two entries a day over 10 days, we get back only 7 days worth of data'); $start = $history[0]['touch']; $last_row = array_pop($history); $end = $last_row['touch']; $diff = abs(floor(($start - $end) / (3600 * 24))); Tap::cmp_ok($diff, '>', 5, 'the timestamps in the data span 6 or 7 days');
function web_require($msg, $url, $params, $expected_output) { $outcome = Tap::web_ok($url, $params, $expected_output); if ($outcome === FALSE) { throw new Exception('Required check failed.'); } }