[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/tests/links/ -> yourls_links.php (source)

   1  <?php
   2  
   3  /**
   4   * Links
   5   *
   6   * @group links
   7   * @group idn
   8   */
   9  
  10  class YOURLS_Link_Tests extends PHPUnit\Framework\TestCase {
  11  
  12      protected function tearDown(): void {
  13          yourls_remove_all_filters( 'get_yourls_site' );
  14      }
  15  
  16      /**
  17       * Check yourls_get_yourls_site() returns a string
  18       */
  19      public function test_yourls_site() {
  20          $this->assertIsString(yourls_get_yourls_site());
  21  
  22          $scheme = yourls_get_protocol( yourls_get_yourls_site() );
  23          $this->assertContains( $scheme, array( 'http://', 'https://' ), "yourls_get_yourls_site() isn't http(s)://" );
  24      }
  25  
  26      /**
  27       * Check yourls_link() gives a link
  28       */
  29      public function test_yourls_link() {
  30          $this->assertEquals( yourls_link('bonjour'), YOURLS_SITE . '/bonjour' );
  31      }
  32  
  33      /**
  34       * Check yourls_statlink() gives a link
  35       */
  36      public function test_yourls_statlink() {
  37          $this->assertEquals( yourls_statlink('hello'), YOURLS_SITE . '/hello+' );
  38      }
  39  
  40      /**
  41       * Check yourls_link() gives an IDN utf8 link
  42       */
  43      public function test_yourls_link_IDN() {
  44          yourls_add_filter( 'get_yourls_site', function() {return 'http://xn--hh-bjab.com';} );
  45          $this->assertEquals( yourls_link('suicidal'), 'http://héhé.com/suicidal' );
  46          $this->assertEquals( yourls_statlink('angels'), 'http://héhé.com/angels+' );
  47      }
  48  
  49  }


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