Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1768 → Rev 1769

/trunk/jrest/tests/IO-fields-unittest.php
30,15 → 30,18
if(!$tests) $tests = $all_tests;
 
foreach($tests as $test) {
setupTestEnv();
setupTestEnv(); @array_walk(glob('run/*'), function(&$i) { unlink($i);});
// 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)) {
$csv = genCSV(require($test));
$test_array = require($test);
$csv = genCSV($test_array);
file_put_contents($runfile, $csv);
}
 
echo "\tcurl -F \"upload=@$runfile\" -F utilisateur=" . USER . " \"" . DOMAIN . "/jrest/ImportXLS\"\n";
echo "$test: ";
$var_expected = include(str_replace('.test.', '.result.', $test));
 
$retour = import($runfile);
46,22 → 49,30
preg_match('/^ligne /', $retour, $count_warn);
$count_warn = count($count_warn);
 
echo $count_warn . "\n";
$result = getCSV_line(export(), 1);
unset($result['date_creation'], $result['date_modification'], $result['id_observation']);
 
echo "$test\n";
//var_dump(champsLongToShort2($test_array));die;
if($var_expected) {
if(! array_diff($var_expected, $result) && ! array_diff($result, $var_expected)) echo "OK\n";
$d1 = array_diff($var_expected, $result);
$d2 = array_diff($result, $var_expected);
if(!$d1 && !$d2) echo "OK\n";
else {
echo "FAIL\n";
if($d1) print_r($d1);
if($d2) print_r($d2);
//var_dump($var_expected, $result);
var_dump(array_diff($var_expected, $result), array_diff($result, $var_expected));
}
echo $retour;
if($count_warn) { echo "warnings: $count_warn\n"; }
}
else {
echo '<?php return ' . var_export($result, true) . ';'
echo $retour;
if($count_warn) { echo "warnings: $count_warn\n"; }
 
echo '<?php return ' . var_export($result, true) . ';';
}
 
}
 
// sed -i -e '1{/<?php return/!s:^:<?php return :}' -e '${/^)$/s:$:;:}' phptests/*.result.php