Subversion Repositories eFlore/Applications.cel

Rev

Rev 1768 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1768 Rev 1769
Line 28... Line 28...
28
$all_tests = glob('phptests/*.test.php');
28
$all_tests = glob('phptests/*.test.php');
29
$tests = array_intersect($argv, $all_tests);
29
$tests = array_intersect($argv, $all_tests);
30
if(!$tests) $tests = $all_tests;
30
if(!$tests) $tests = $all_tests;
Line 31... Line 31...
31
 
31
 
32
foreach($tests as $test) {
32
foreach($tests as $test) {
33
	setupTestEnv();
33
	setupTestEnv(); @array_walk(glob('run/*'), function(&$i) { unlink($i);});
34
	// cache car l'upload de fichier PHP-curl ne peut être
34
	// cache car l'upload de fichier PHP-curl ne peut être
35
	// simulé avec le contenu d'une variable (cf CURLOPT_POSTFIELDS et @fichier)
35
	// simulé avec le contenu d'une variable (cf CURLOPT_POSTFIELDS et @fichier)
36
	$runfile = 'run/' . basename($test);
36
	$runfile = 'run/' . basename($test);
37
	if(!is_file($runfile)) {
37
	if(!is_file($runfile)) {
-
 
38
		$test_array = require($test);
38
		$csv = genCSV(require($test));
39
		$csv = genCSV($test_array);
39
		file_put_contents($runfile, $csv);
40
		file_put_contents($runfile, $csv);
Line -... Line 41...
-
 
41
	}
-
 
42
 
40
	}
43
	echo "\tcurl -F \"upload=@$runfile\" -F utilisateur=" . USER . " \"" . DOMAIN . "/jrest/ImportXLS\"\n";
Line 41... Line 44...
41
 
44
	echo "$test: ";
42
	$var_expected = include(str_replace('.test.', '.result.', $test));
45
	$var_expected = include(str_replace('.test.', '.result.', $test));
43
 
46
 
44
	$retour = import($runfile);
47
	$retour = import($runfile);
Line 45... Line -...
45
	$count_warn = 0;
-
 
46
	preg_match('/^ligne /', $retour, $count_warn);
48
	$count_warn = 0;
47
	$count_warn = count($count_warn);
49
	preg_match('/^ligne /', $retour, $count_warn);
Line 48... Line 50...
48
 
50
	$count_warn = count($count_warn);
49
	echo $count_warn . "\n";
51
 
-
 
52
	$result = getCSV_line(export(), 1);
50
	$result = getCSV_line(export(), 1);
53
	unset($result['date_creation'], $result['date_modification'], $result['id_observation']);
-
 
54
 
51
	unset($result['date_creation'], $result['date_modification'], $result['id_observation']);
55
	//var_dump(champsLongToShort2($test_array));die;
52
 
56
	if($var_expected) {
-
 
57
		$d1 = array_diff($var_expected, $result);
-
 
58
		$d2 = array_diff($result, $var_expected);
53
	echo "$test\n";
59
		if(!$d1 && !$d2) echo "OK\n";
54
	if($var_expected) {
-
 
55
		if(! array_diff($var_expected, $result) && ! array_diff($result, $var_expected)) echo "OK\n";
60
		else {
-
 
61
			echo "FAIL\n";
-
 
62
			if($d1) print_r($d1);
56
		else {
63
			if($d2) print_r($d2);
57
			echo "FAIL\n";
64
			//var_dump($var_expected, $result);
-
 
65
		}
-
 
66
		echo $retour;
-
 
67
		if($count_warn) { echo "warnings: $count_warn\n"; }
58
			//var_dump($var_expected, $result);
68
	}
59
			var_dump(array_diff($var_expected, $result), array_diff($result, $var_expected));
69
	else {
-
 
70
		echo $retour;
60
		}
71
		if($count_warn) { echo "warnings: $count_warn\n"; }
Line 61... Line 72...
61
	}
72