xref: /dokuwiki/_test/tests/inc/common_getGoogleQuery.test.php (revision 8108306bd5dd53b541609196b90bdf7ba7386833)
1<?php
2
3class common_getGoogleQuery_test extends DokuWikiTest {
4
5    /**
6     * https://github.com/splitbrain/dokuwiki/issues/2848
7     */
8    function test_google_form(){
9        global $INPUT;
10        $_SERVER['HTTP_REFERER'] = 'https://www.google.com/url?q=https://www.dokuwiki.org/&sa=D&ust=a&usg=b';
11        $INPUT = new Input();
12        $this->assertEquals('', getGoogleQuery());
13    }
14
15    function test_google_url(){
16        global $INPUT;
17        $_SERVER['HTTP_REFERER'] = 'https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.dokuwiki.org/&ved=a';
18        $INPUT = new Input();
19        $this->assertEquals('', getGoogleQuery());
20    }
21
22    function test_uncommon_url(){
23        global $INPUT;
24        $_SERVER['HTTP_REFERER'] = 'http://search.example.com/search?q=DokuWiki';
25        $INPUT = new Input();
26        $this->assertEquals('', getGoogleQuery());
27    }
28
29    function test_old_google(){
30        global $INPUT;
31        $_SERVER['HTTP_REFERER'] = 'https://www.google.com/search?newwindow=1&q=what%27s+my+referer';
32        $INPUT = new Input();
33        $this->assertEquals(array('what', 's', 'my', 'referer'), getGoogleQuery());
34    }
35
36}
37
38//Setup VIM: ex: et ts=4 :
39