[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> common_getGoogleQuery.test.php (source)

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