xref: /dokuwiki/_test/tests/inc/common_getGoogleQuery.test.php (revision c7dab4e8843c91451755e1c9569773e6b7614702)
160ea9a07SPhy<?php
260ea9a07SPhy
3*c7dab4e8SAndreas Gohruse \dokuwiki\Input\Input;
4*c7dab4e8SAndreas Gohr
560ea9a07SPhyclass common_getGoogleQuery_test extends DokuWikiTest {
660ea9a07SPhy
760ea9a07SPhy    /**
860ea9a07SPhy     * https://github.com/splitbrain/dokuwiki/issues/2848
960ea9a07SPhy     */
1060ea9a07SPhy    function test_google_form(){
1160ea9a07SPhy        global $INPUT;
1260ea9a07SPhy        $_SERVER['HTTP_REFERER'] = 'https://www.google.com/url?q=https://www.dokuwiki.org/&sa=D&ust=a&usg=b';
1360ea9a07SPhy        $INPUT = new Input();
1460ea9a07SPhy        $this->assertEquals('', getGoogleQuery());
1560ea9a07SPhy    }
1660ea9a07SPhy
1760ea9a07SPhy    function test_google_url(){
1860ea9a07SPhy        global $INPUT;
1960ea9a07SPhy        $_SERVER['HTTP_REFERER'] = 'https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.dokuwiki.org/&ved=a';
2060ea9a07SPhy        $INPUT = new Input();
2160ea9a07SPhy        $this->assertEquals('', getGoogleQuery());
2260ea9a07SPhy    }
2360ea9a07SPhy
2460ea9a07SPhy    function test_uncommon_url(){
2560ea9a07SPhy        global $INPUT;
2660ea9a07SPhy        $_SERVER['HTTP_REFERER'] = 'http://search.example.com/search?q=DokuWiki';
2760ea9a07SPhy        $INPUT = new Input();
2860ea9a07SPhy        $this->assertEquals('', getGoogleQuery());
2960ea9a07SPhy    }
3060ea9a07SPhy
3160ea9a07SPhy    function test_old_google(){
3260ea9a07SPhy        global $INPUT;
3360ea9a07SPhy        $_SERVER['HTTP_REFERER'] = 'https://www.google.com/search?newwindow=1&q=what%27s+my+referer';
3460ea9a07SPhy        $INPUT = new Input();
3560ea9a07SPhy        $this->assertEquals(array('what', 's', 'my', 'referer'), getGoogleQuery());
3660ea9a07SPhy    }
3760ea9a07SPhy
3860ea9a07SPhy}
3960ea9a07SPhy
4060ea9a07SPhy//Setup VIM: ex: et ts=4 :
41