[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Localization helper functions
   5   *
   6   * @group l10n
   7   * @since 0.1
   8   */
   9  class Translation_General_Tests extends PHPUnit\Framework\TestCase {
  10  
  11      protected $locale_backup;
  12  
  13      protected function setUp(): void {
  14          global $yourls_locale;
  15          $this->locale_backup = $yourls_locale;
  16      }
  17  
  18      protected function tearDown(): void {
  19          global $yourls_locale;
  20          $yourls_locale = $this->locale_backup;
  21      }
  22  
  23      /**
  24       * Check yourls_is_rtl() returns bool
  25       *
  26       * @since 0.1
  27       */
  28      public function test_is_rtl() {
  29          $this->assertTrue( is_bool( yourls_is_rtl() ) );
  30      }
  31  
  32      /**
  33       * Check yourls_get_locale() gets config setting
  34       *
  35       * @since 0.1
  36       */
  37      public function test_get_locale_from_config() {
  38          $this->assertSame( 'fr_FR' , yourls_get_locale() );
  39      }
  40  
  41      /**
  42       * Test yourls_get_locale() with custom value
  43       *
  44       * @since 0.1
  45       */
  46      public function test_get_locale() {
  47          global $yourls_locale;
  48  
  49          $yourls_locale = rand_str();
  50          $this->assertSame( $yourls_locale , yourls_get_locale() );
  51  
  52          $yourls_locale = false;
  53          $this->assertSame( '' , yourls_get_locale() );
  54      }
  55  
  56      /**
  57       * Get available languages
  58       *
  59       * @since 0.1
  60       */
  61      public function test_get_languages() {
  62          $this->assertEquals( array( 'fr_FR', 'test-fr_FR' ), yourls_get_available_languages() );
  63          $this->assertEquals( array( 'fr_FR', 'test-fr_FR' ), yourls_get_available_languages( YOURLS_TESTDATA_DIR . '/pomo/' ) );
  64      }
  65  
  66  }


Generated: Thu Sep 19 05:10:04 2024 Cross-referenced by PHPXref 0.7.1