public function testIlNYAPasDeTablesRestantesApresUnDropDB() { global $config, $db; dropDB(); $this->assertEquals(array(), preg_grep('/^' . str_replace('/', '\\/', $config['db']['prefix']) . '/', $db->fetchAll("show tables;", PDO::FETCH_COLUMN))); reinitDB(); }
public function testSilaclePrimaireNEstPasUnAutoInCrement_AlorsJeLAfficheDansLeModal() { global $config, $cookieTest; reinitDB(); initLogin(); $ch = curl_init($config['serverUrl'] . 'ajax/modal.php?table=setting&champs=cle'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieTest); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec($ch); $template = file_get_contents(dirname(__FILE__) . '/templates/modal_noautoincr.html'); $this->assertEquals($template, $result); curl_close($ch); }
public function testSitrouveAdminAvecUnMotDePasseVide_AlorsJAfficheLaPageDeMaintenance() { global $db, $config, $adminPassword, $adminLogin; $resInit = reinitDB(); $this->assertNotEquals(FALSE, $resInit); $db->query("UPDATE " . $config['db']['prefix'] . "users SET password='' where login = '******';"); $resCheck = $db->checkDB(); $this->assertEquals(FALSE, $resCheck); $page = new page(TRUE); $page->prepareHeader(FALSE); $resultPage = $page->showPage(); $template = file_get_contents(dirname(__FILE__) . '/templates/upgradeplz.html'); $this->assertEquals($template, $resultPage); $db->query("UPDATE " . $config['db']['prefix'] . "users SET password='******' where login = '******';"); $this->assertEquals(false, $resCheck); }
$port = 8000; $docRoot = "../public/"; $config['serverUrl'] = "http://{$host}:{$port}/"; $config['db']['prefix'] = 'tests_todelete_' . $config['db']['prefix']; $command = sprintf('ihm_prefix=' . $config['db']['prefix'] . 'XDEBUG_CONFIG="remote_enable=Off" php -S %s:%d -t %s >/dev/null 2>&1 & echo $!', $host, $port, $docRoot); $output = array(); exec($command, $output); $pid = (int) $output[0]; echo sprintf('%s - Web server started on %s:%d with PID %d', date('r'), $host, $port, $pid) . PHP_EOL; //Les tests ne doivent pas être interompus //$config['stopOnExec'] = FALSE; //Utilisé pour redirections ou autres //Ne doit pas être positionné avant car il planterait l'installation de base //de données $_SERVER['HTTP_HOST'] = 'localhost'; reinitDB(); initLogin(); startSession(); foreach (scandir('.') as $file) { if (preg_match('/^test.*.php$/', $file)) { include dirname(__FILE__) . '/' . $file; } } function reinitDB() { global $db, $config, $adminPassword, $adminLogin; //Nettoyage des précedents tests en cas d'interuption dropDB(); initDB(); upgradeDB(FALSE); $ret = $db->query($sql = "INSERT " . $config['db']['prefix'] . "users VALUES (NULL, '{$adminLogin}','{$adminPassword}','',1);");