wiki.pl: Port some fixes from upstream
[Orgmuse.git] / t / duckduckgo-search.t
blob02e0695f6054f1070f65ba3b1a44e1d506ee52a5
1 # Copyright (C) 2007–2013  Alex Schroeder <alex@gnu.org>
3 # This program is free software: you can redistribute it and/or modify it under
4 # the terms of the GNU General Public License as published by the Free Software
5 # Foundation, either version 3 of the License, or (at your option) any later
6 # version.
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License along with
13 # this program. If not, see <http://www.gnu.org/licenses/>.
15 require 't/test.pl';
16 package OddMuse;
17 use Test::More tests => 9;
18 clear_pages();
20 add_module('duckduckgo-search.pl');
22 DuckDuckGoSearchInit();
23 is($DuckDuckGoSearchDomain, undef, 'No $ScriptName');
25 $DuckDuckGoSearchDomain = undef;
26 $ScriptName = 'http://www.communitywiki.org/en';
27 DuckDuckGoSearchInit();
28 is($DuckDuckGoSearchDomain, 'communitywiki.org', $ScriptName);
30 $DuckDuckGoSearchDomain = undef;
31 $ScriptName = 'http://www.community.org:80/';
32 DuckDuckGoSearchInit();
33 is($DuckDuckGoSearchDomain, 'community.org', $ScriptName);
35 $DuckDuckGoSearchDomain = undef;
36 $ScriptName = 'http://www.communitywiki.org';
37 DuckDuckGoSearchInit();
38 is($DuckDuckGoSearchDomain, 'communitywiki.org', $ScriptName);
40 $DuckDuckGoSearchDomain = undef;
41 $ScriptName = 'http://emacswiki.org/cgi-bin/emacs';
42 DuckDuckGoSearchInit();
43 is($DuckDuckGoSearchDomain, 'emacswiki.org', $ScriptName);
45 $DuckDuckGoSearchDomain = undef;
46 $ScriptName = 'http://localhost/wiki.pl';
47 DuckDuckGoSearchInit();
48 isnt($DuckDuckGoSearchDomain, 'localhost', $ScriptName);
50 test_page(get_page('search=alex'),
51           '<title>Wiki: Search for: alex</title>');
52 AppendStringToFile($ConfigFile, "\$ScriptName = 'http://emacswiki.org/';\n");
53 test_page(get_page('search=alex'),
54           'Status: 302',
55           'Location: https://www.duckduckgo.com/\?q=alex\+site%3Aemacswiki\.org');