[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/tests/http/ -> general.php (source)

   1  <?php
   2  
   3  /**
   4   * HTTP misc utilities and helpers
   5   *
   6   * @group http
   7   * @since 0.1
   8   */
   9  class HTTP_Misc_Tests extends PHPUnit\Framework\TestCase {
  10  
  11      protected function tearDown(): void {
  12          yourls_remove_filter( 'http_get_proxy', 'yourls_return_true' );
  13          yourls_remove_filter( 'http_get_proxy', 'yourls_return_false' );
  14      }
  15  
  16      /**
  17       * Check that SSL capability check returns a boolean
  18       *
  19       * @since 0.1
  20       */
  21      public function test_can_SSL() {
  22          $this->assertTrue( is_bool( yourls_can_http_over_ssl() ) );
  23      }
  24  
  25      /**
  26       * Check request default options
  27       *
  28       * @since 0.1
  29       */
  30      public function test_request_default_options() {
  31          yourls_add_filter( 'http_get_proxy', 'yourls_return_false' );
  32          $options = yourls_http_default_options();
  33          $this->assertArrayHasKey( 'timeout', $options );
  34          $this->assertArrayHasKey( 'useragent', $options );
  35          $this->assertArrayHasKey( 'follow_redirects', $options );
  36          $this->assertArrayHasKey( 'redirects', $options );
  37          $this->assertArrayNotHasKey( 'proxy', $options );
  38      }
  39  
  40      /**
  41       * Check request default options with a proxy
  42       *
  43       * @since 0.1
  44       */
  45      public function test_request_default_options_proxy() {
  46          yourls_add_filter( 'http_get_proxy', 'yourls_return_true' );
  47          $options = yourls_http_default_options();
  48          $this->assertArrayHasKey( 'timeout', $options );
  49          $this->assertArrayHasKey( 'useragent', $options );
  50          $this->assertArrayHasKey( 'follow_redirects', $options );
  51          $this->assertArrayHasKey( 'redirects', $options );
  52          $this->assertArrayHasKey( 'proxy', $options );
  53      }
  54  
  55      /**
  56       * Check we have a user agent string
  57       *
  58       * @since 0.1
  59       */
  60      public function test_user_agent() {
  61          $this->assertTrue( is_string( yourls_http_user_agent() ) );
  62      }
  63  
  64  }


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