[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / textwheel / tests / tw_propre_modeles_block.php
1 <?php
2 /**
3 * Test unitaire des raccourcis Markdown dans SPIP
4 *
5 */
6
7 $test = 'tw_propre_modeles_block';
8 $remonte = "../";
9 while (!is_dir($remonte . "ecrire")) {
10 $remonte = "../$remonte";
11 }
12 require $remonte . 'tests/test.inc';
13 find_in_path("inc/texte.php", '', true);
14
15 $GLOBALS['spip_lang'] = 'en'; // corrections typo
16 $GLOBALS['class_spip_plus'] = '';
17 $GLOBALS['class_spip'] = '';
18
19 // ajouter le dossier squelettes de test au chemin
20 _chemin(_DIR_PLUGIN_TW . "tests/squelettes/");
21
22 $notes = charger_fonction("notes", "inc");
23 function propre_notes($texte) {
24 global $notes;
25 $texte = propre($texte);
26 if ($r = $notes(array())) {
27 $texte .= "<div class='notes'>$r</div>";
28 $notes('', 'depiler');
29 $notes('', 'empiler');
30 }
31
32 return $texte;
33 }
34
35 //
36 // hop ! on y va
37 //
38 $err = tester_fun('propre_notes', essais_tw_propre());
39
40 // si le tableau $err est pas vide ca va pas
41 if ($err) {
42 die ('<dl>' . join('', $err) . '</dl>');
43 }
44
45 echo "OK";
46
47
48 function essais_tw_propre() {
49
50 $tests = preg_files(_DIR_PLUGIN_TW . "tests/data/modeles_block/", '\.txt$');
51
52 $texte = $expected = "";
53 $essais = array();
54
55 foreach ($tests as $t) {
56 lire_fichier($t, $texte);
57 lire_fichier(substr($t, 0, -4) . ".html", $expected);
58 $essais[basename($t, ".txt")] = array(
59 $expected,
60 $texte
61 );
62 }
63
64 return $essais;
65 }
66
67
68 ?>