[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/tests/format/ -> referrers.php (source)

   1  <?php
   2  
   3  /**
   4   * Formatting functions for URLs
   5   *
   6   * @group formatting
   7   * @group referrer
   8   * @since 0.1
   9   */
  10  class Format_Referrer extends PHPUnit\Framework\TestCase {
  11  
  12      protected $backup;
  13  
  14      protected function setUp(): void {
  15          $this->backup = $_SERVER;
  16      }
  17  
  18      protected function tearDown(): void {
  19          $_REQUEST = $this->backup;
  20      }
  21  
  22      function test_no_referrer() {
  23          unset($_SERVER['HTTP_REFERER']);
  24          $this->assertEquals(yourls_get_referrer(), 'direct');
  25      }
  26  
  27      function test_referrer() {
  28          $ref = 'http://'.rand_str();
  29          $_SERVER['HTTP_REFERER'] = $ref;
  30          $this->assertEquals(yourls_get_referrer(), $ref);
  31      }
  32  
  33      function test_long_referrer() {
  34          $ref = 'http://'.str_repeat(rand_str(), 10);
  35          $_SERVER['HTTP_REFERER'] = $ref;
  36          $this->assertNotEquals(yourls_get_referrer(), $ref);
  37      }
  38  
  39  }


Generated: Wed Sep 28 05:10:02 2022 Cross-referenced by PHPXref 0.7.1