Example #1
0
 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);
 }
Example #2
0
 public function testSiJeCliqueSurDeconnexion_AlorsJeSuisSurLaPageDeLogin()
 {
     global $config, $cookieTest;
     $ch = curl_init($config['serverUrl'] . '/ajax/logout.php');
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieTest);
     curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieTest);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $retour = curl_exec($ch);
     curl_close($ch);
     //Un retour normal d'un logout est true
     $this->assertEquals('true', $retour);
     $ch = curl_init($config['serverUrl']);
     curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieTest);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $retour = curl_exec($ch);
     curl_close($ch);
     $template = file_get_contents(dirname(__FILE__) . '/templates/login.html');
     initLogin();
     $this->assertEquals($template, $retour);
 }
Example #3
0
 public function testSimaSessionRenseigneUnMenu_AlorsJaiUnMenu()
 {
     global $config;
     initLogin();
     $page = new page(TRUE);
     $_SESSION[$config['sessionName']]['menu'] = array('test' => 'toto');
     $result = $page->prepareHeader(TRUE);
     $template = file_get_contents(dirname(__FILE__) . '/templates/header_sans_dropdown.html');
     $this->assertEquals($template, $result);
     $_SESSION[$config['sessionName']]['menu'] = array('test' => array('tata' => 'tutu'), '2' => array(21 => 22));
     $result = $page->prepareHeader(TRUE);
     $template = file_get_contents(dirname(__FILE__) . '/templates/header_avec_dropdown.html');
     $this->assertEquals($template, $result);
 }
Example #4
0
$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);");
    return $ret;