2,9 → 2,38 |
|
$options = getopt("hu:d:e:p:P:D",array("help", "user:", "domain:", "email:", "pass:", "phpsessid", "debug")); |
if(isset($options['h']) || isset($options['help'])) { |
die(basename(__FILE__) . ' [-u|--user = 22506] [-d|--domain = http://cel]'); |
printf(<<<EOF |
%s [fichiers de test] |
--help|-h: cette aide |
-debug|-d: informations sur les requêtes curl |
[-u|--user = 22506] |
[-d|--domain = "http://cel"] |
--pass|-p: pour l'authentifiation |
--email|-e: pour l'authentifiation |
--phpsessid|-P: pour l'authentifiation, alternative à -e/-p |
|
* --phpsessid permet de passer un identifiant de session PHP pour effectuer l'export. |
Exemple: |
$ sqlite3 ~/.mozilla/firefox/*.default/cookies.sqlite<<<"SELECT * FROM moz_cookies WHERE baseDomain = 'cel' AND name = 'PHPSESSID';" |
|
* [fichiers de test]: un ou plusieurs fichier(s) de test valide(s), commençant par "phptests/" et finissant en ".test.php" |
Exemple: phptests/a*.test.php ou bien phptests/latitude-virgule.test.php |
|
Exemple: |
$ php IO-fields-unittest.php -P s97knu4axzi6440n1ihja9ppk1 |
$ php IO-fields-unittest.php -e me@tela -p blah -u 23004 -d http://localhost phptests/determ-espece* |
|
EOF |
, /* relax emacs*/ |
basename(__FILE__)); |
die; |
} |
|
// stocke les test |
define('_TESTDIR', dirname(__FILE__) . '/' . 'phptests'); |
// stocke les CSV générés à partir des test (répertoire de cache) |
define('_RUNDIR', dirname(__FILE__) . '/' . 'run'); |
|
define('USER', isset($options['u']) ? $options['u'] : (isset($options['user']) ? $options['user'] : 22506)); |
define('DOMAIN', isset($options['d']) ? $options['d'] : (isset($options['domain']) ? $options['domain'] : 'http://cel')); |
define('EMAIL', isset($options['e']) ? $options['e'] : (isset($options['email']) ? $options['email'] : NULL)); |
21,22 → 50,30 |
cel_upload_image('image-test2.jpg'); |
} |
|
if(! is_dir('phptests')) die('no phptests/'); |
if(! is_dir('run')) mkdir('run'); |
if(! is_dir('run')) die('no run/'); |
if(! is_dir(_TESTDIR)) die('no phptests/ directory inside ' . __DIR__); |
if(! is_dir(_RUNDIR)) mkdir(_RUNDIR); |
if(! is_dir(_RUNDIR)) die('no run/ directory inside ' . __DIR__); |
|
|
$all_tests = glob('phptests/*.test.php'); |
$tests = array_intersect($argv, $all_tests); |
$all_tests = array_map('basename', glob(_TESTDIR . '/*.test.php')); |
$tests = array_intersect(array_map('basename', $argv), $all_tests); |
|
if(!$tests) $tests = $all_tests; |
|
//@array_walk(glob('run/*'), function(&$i) { unlink($i);}); |
|
foreach($tests as $test) { |
setupTestEnv(); @array_walk(glob('run/*'), function(&$i) { unlink($i);}); |
setupTestEnv(); |
$testfile = _TESTDIR . '/' . $test; |
|
// cache car l'upload de fichier PHP-curl ne peut être |
// simulé avec le contenu d'une variable (cf CURLOPT_POSTFIELDS et @fichier) |
$runfile = 'run/' . basename($test); |
if(!is_file($runfile)) { |
$test_array = require($test); |
$runfile = _RUNDIR . '/' . $test; |
|
$test_array = require($testfile); |
|
$cols = isset($test_array['dumpCols']) ? $test_array['dumpCols'] : 'standard'; |
|
if(!is_file($runfile) || filemtime($runfile) < filemtime($testfile)) { |
$csv = genCSV($test_array['data']); |
file_put_contents($runfile, $csv); |
} |
43,7 → 80,7 |
|
echo "\tcurl -F \"upload=@$runfile\" -F utilisateur=" . USER . " \"" . DOMAIN . "/jrest/ImportXLS\"\n"; |
echo "$test: "; |
$var_expected = include(str_replace('.test.', '.result.', $test)); |
$var_expected = include(_TESTDIR . '/' . str_replace('.test.', '.result.', $test)); |
|
$retour = import($runfile); |
$count_warn = 0; |
50,7 → 87,8 |
preg_match('/^ligne /', $retour, $count_warn); |
$count_warn = count($count_warn); |
|
$result = getCSV_line(export(isset($test_array['dumpCols']) ? $test_array['dumpCols'] : 'standard'), 1); |
$result = getCSV_line(export($cols), 1); |
if(!$result) die("\n!!! export vide, problème probable d'authentification ?\n"); |
|
//var_dump(champsLongToShort2($test_array['data']));die; |
if($var_expected) { |