-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_include_utils.php
79 lines (74 loc) · 3.67 KB
/
test_include_utils.php
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
# <one line to give a brief idea of what this does.>
#
# Copyright 2005-2006 (c) Tobias Toedter <t.toedter--gmx.net>
#
# This file is part of Savane.
#
# Savane is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Savane is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require_once '../../frontend/php/include/utils.php';
class include_utils extends PHPUnit_TestCase
{
function testStringIsASCII()
{
$this->assertTrue(utils_is_ascii("ABCaoidn 97a 18923 471 90asf y0l"));
$this->assertTrue(utils_is_ascii("This is a string with \n a newline"));
$this->assertFalse(utils_is_ascii("Tobias Tödter"));
}
function testMakeLinks()
{
# Construct a hash with input strings and expected output strings
$urls = array(
''
=> '',
'No conversion'
=> 'No conversion',
'Simple www.conversion.org'
=> 'Simple <a href="http://www.conversion.org">http://www.conversion.org</a>',
'Simple www.conversion.org/ with backslash'
=> 'Simple <a href="http://www.conversion.org/">http://www.conversion.org/</a> with backslash',
'Simple www.conversion.org/index.html'
=> 'Simple <a href="http://www.conversion.org/index.html">http://www.conversion.org/index.html</a>',
'www.dont-include-the-dot.com.'
=> '<a href="http://www.dont-include-the-dot.com">http://www.dont-include-the-dot.com</a>.',
"Include \n newlines \n www.as-well.com,\n please!"
=> "Include \n newlines \n <a href=\"http://www.as-well.com\">http://www.as-well.com</a>,\n please!",
'http://this.should.be/marked'
=> '<a href="http://this.should.be/marked">http://this.should.be/marked</a>',
'<a href="http://dont-touch-me.net/">Go away!</a>'
=> '<a href="http://dont-touch-me.net/">Go away!</a>',
'<a href="http://dont-touch-me.net/">Go away!</a>, but www.markup-me.com'
=> '<a href="http://dont-touch-me.net/">Go away!</a>, but <a href="http://www.markup-me.com">http://www.markup-me.com</a>',
'http://www.mail-archive.com/[email protected]/msg00068.html'
=> '<a href="http://www.mail-archive.com/bug-grep@gnu.org/msg00068.html">http://www.mail-archive.com/bug-grep@gnu.org/msg00068.html</a>',
'www.mail-archive.com/[email protected]/msg00068.html'
=> '<a href="http://www.mail-archive.com/bug-grep@gnu.org/msg00068.html">http://www.mail-archive.com/bug-grep@gnu.org/msg00068.html</a>',
=> '<a href="mailto:[email protected]">[email protected]</a>',
'Link to bug #1234, please'
=> 'Link to <a href="bugs/?func=detailitem&item_id=1234" class="italic">bug #1234</a>, please',
'Other <html> tags should not be touched'
=> 'Other <html> tags should not be touched',
'Even if in "<quotes>"'
=> 'Even if in "<quotes>"',
'Or in single \'<quotes> escaped\''
=> 'Or in single \'<quotes> escaped\'',
);
foreach ($urls as $testdata => $expected)
{
$this->assertEquals($expected, utils_make_links($testdata));
}
}
}
?>