~hexmode/+junk/main

« back to all changes in this revision

Viewing changes to install-files/apps/phpmyadmin2.10.1/test/core.lib.php

  • Committer: Mark A. Hershberger
  • Date: 2008-01-05 19:38:56 UTC
  • Revision ID: hershberger@spawn-xp-20080105193856-6rnzgwa4nehue3qj
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/* $Id: core.lib.php 9913 2007-02-03 17:30:07Z lem9 $ */
 
3
// vim: expandtab sw=4 ts=4 sts=4:
 
4
 
 
5
/**
 
6
 * Core testing library to wrap phpMyAdmin and add some useful functions.
 
7
 *
 
8
 * @author Michal Čihař <michal@cihar.com>
 
9
 * @package phpMyAdmin-test
 
10
 */
 
11
 
 
12
/**
 
13
 * Go to root directory.
 
14
 */
 
15
chdir('..');
 
16
 
 
17
 
 
18
/**
 
19
 * Report failed test.
 
20
 *
 
21
 * @param string function to test
 
22
 * @param string test description
 
23
 * @param string failure description
 
24
 */
 
25
function PMA_test_fail($function, $test, $message) {
 
26
        $function = htmlspecialchars($function);
 
27
        $test = htmlspecialchars($test);
 
28
        $message = htmlspecialchars($message);
 
29
        echo <<<EOT
 
30
<dt>$function ($test)</dt>
 
31
<dd><strong>Failed:</strong> $message</dd>
 
32
EOT;
 
33
}
 
34
 
 
35
/**
 
36
 * Report ok test.
 
37
 *
 
38
 * @param string function to test
 
39
 * @param string test description
 
40
 */
 
41
function PMA_test_okay($function, $test) {
 
42
        $function = htmlspecialchars($function);
 
43
        $test = htmlspecialchars($test);
 
44
        echo <<<EOT
 
45
<dt>$function ($test)</dt>
 
46
<dd><strong>OK</strong></dd>
 
47
EOT;
 
48
}
 
49
 
 
50
/**
 
51
 * Function for testing strings.
 
52
 *
 
53
 * @uses    PMA_test_okay()
 
54
 * @uses    PMA_test_fail()
 
55
 * @param string function to test
 
56
 * @param string test description
 
57
 * @param string actual result
 
58
 * @param string expected result
 
59
 */
 
60
function PMA_test_string($function, $test, $received, $expected) {
 
61
        if ($received != $expected) {
 
62
                PMA_test_fail($function, $test, "Strings >$received< and >$expected< do not match");
 
63
        } else {
 
64
                PMA_test_okay($function, $test);
 
65
        }
 
66
}
 
67
?>