function do_reset() { $db = new Database(); $db->reset(); $db->close(); echo 'reseted the database'; }
<?php self::testStart('Registering'); // Resetting the database. Database::reset(); self::unitTest('Register', 'Registering a user', array('email' => '*****@*****.**', 'password' => 'password', 'first_name' => 'Jordan', 'last_name' => 'Lord'), '{"id":"1","success":true}'); self::unitTest('Login', 'Logging in as the user just created', array('email' => '*****@*****.**', 'password' => 'password'), '{"success":true}'); self::unitTest('Status', 'Checking the status of the user to see if it has logged in as the correct user', array(), '{"logged_in":true,"user":{"id":"1","email":"*****@*****.**","first_name":"Jordan","last_name":"Lord"},"success":true}'); self::unitTest('Register', 'Register a new user', array('email' => '*****@*****.**', 'password' => 'pass123', 'first_name' => 'New', 'last_name' => 'User'), '{"id":"2","success":true}'); self::unitTest('UserGet', 'Check to see if the user has successfully been registered', array('id' => '1'), '{"first_name":"Jordan","last_name":"Lord","id":"1","rating":1300,"leagues_playing":[],"leagues_managing":[],"success":true}'); self::unitTest('Register', 'Register another user', array('email' => '*****@*****.**', 'password' => 'password', 'first_name' => 'Another', 'last_name' => 'User'), '{"id":"3","success":true}'); self::testEnd();
case $state->getExport(): export('groph.json'); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=groph.json'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize('groph.json')); readfile('groph.json'); exit; break; case $state->getImport(): $param = $state->getImport()->getParam('file')->getName(); move_uploaded_file($_FILES[$param]['tmp_name'], 'groph.json'); $database->reset(); import('groph.json'); break; case $state->getResourceAdd(): $add = $state->getResourceAdd(); $tags = Vector::create(); $title = trim((string) $add->getParam('title')); if (empty($title)) { throw new Exception('Missing title'); } $link = trim((string) $add->getParam('link')); if (empty($link)) { throw new Exception('Missing link'); } $tagsGroups = trim((string) $add->getParam('tags')); if (empty($tagsGroups)) {
/** * Method that is called first. * Calls all tests individually. * * @method init * @public */ public static function init() { self::requireAll(); Database::reset(); self::loadTest('RegisterLogin'); self::loadTest('Leagues'); //self::loadTest('Main.php'); // Resets the database Database::reset(); }