Menu

[r90]: / trunk / testing / unit-tests.php  Maximize  Restore  History

Download this file

59 lines (48 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**@file
* Script for unit testing, allows for more fine grained error reporting
* when things go wrong.
* @author Edward Z. Yang <admin@htmlpurifier.org>
*/
error_reporting(E_ALL);
require('../class.csstidy.php');
// require PEAR class Text_Diff for nice fail messages
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer.php';
require_once 'unit-tests.inc';
chdir(dirname(__FILE__));
$passed_tests = 0;
$failed_tests = 0;
?>
<html>
<title>CSSTidy unit tests</title>
<style type="text/css">
.box {color:white; font-weight:bold; padding: 8px; margin-top: 1em;}
.diff {margin-bottom: 1em;}
.diff th {width:50%;}
.diff pre {margin:0; padding:0;}
.diff .changed, .diff .deleted, .diff .added {background: #FF5;}
del {background: red; color: white; font-weight: bold;}
ins {background: green; color: white; font-weight: bold;}
</style>
<body>
<h1>CSSTidy unit tests</h1>
<?php
// allow only one directory deep, I guess otherwise, we need a recursive glob
foreach (globr('unit-tests', '*.csst') as $filename) {
$test = new csstidy_test_csst();
$test->load($filename);
if (!$test->run()) $failed_tests++;
else $passed_tests++;
$test->render();
}
// output test results
if (!$failed_tests) {
echo '<div style="background:green;" class="box">';
} else {
echo '<div style="background:red;" class="box">';
}
echo $passed_tests .' tests passed, ' . $failed_tests .' tests failed</div>'
?>
</body>
</html>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.