[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/tests/utilities/ -> FileLoaderTest.php (source)

   1  <?php
   2  
   3  /**
   4   * Test sandboxed file loader
   5   *
   6   * @since 1.9.1
   7   */
   8  #[\PHPUnit\Framework\Attributes\Group('functions')]
   9  class FileLoaderTest extends PHPUnit\Framework\TestCase {
  10  
  11      /**
  12       * Load valid file = true
  13       */
  14      public function test_load_file_exists() {
  15          $file = YOURLS_TESTDATA_DIR . "/" . rand_str() . ".php";
  16          if( touch("$file") ) {
  17              $this->assertTrue( yourls_include_file_sandbox( $file ) );
  18              unlink("$file");
  19          } else {
  20              $this->markTestSkipped( "Cannot create test '$file");
  21          }
  22      }
  23  
  24      /**
  25       * Load missing file = string
  26       */
  27      public function test_load_file_not_exists() {
  28          $this->assertIsString( yourls_include_file_sandbox( YOURLS_TESTDATA_DIR . "/" . rand_str() . ".php" ) );
  29      }
  30  
  31      /**
  32       * For tests to load valid and broken PHP code: see in tests/plugins/files.php
  33       */
  34  
  35  }


Generated: Tue Apr 1 05:10:01 2025 Cross-referenced by PHPXref 0.7.1