/**
  * Test...
  *
  * @covers  Joomla\Filesystem\Helper::isJoomlaStream
  *
  * @return void
  */
 public function testIsJoomlaStream()
 {
     $this->assertTrue(Helper::isJoomlaStream('String'));
     $this->assertFalse(Helper::isJoomlaStream('unknown'));
 }
 /**
  * Generic File Operations
  *
  * Open a stream with some lazy loading smarts
  *
  * @param   string    $filename              Filename
  * @param   string    $mode                  Mode string to use
  * @param   boolean   $use_include_path      Use the PHP include path
  * @param   resource  $context               Context to use when opening
  * @param   boolean   $use_prefix            Use a prefix to open the file
  * @param   boolean   $relative              Filename is a relative path (if false, strips JPATH_ROOT to make it relative)
  * @param   boolean   $detectprocessingmode  Detect the processing method for the file and use the appropriate function
  *                                           to handle output automatically
  *
  * @return  boolean
  *
  * @since   11.1
  */
 public function open($filename, $mode = 'r', $use_include_path = false, $context = null, $use_prefix = false, $relative = false, $detectprocessingmode = false)
 {
     $filename = $this->_getFilename($filename, $mode, $use_prefix, $relative);
     if (!$filename) {
         $this->setError(Text::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILENAME'));
         return false;
     }
     $this->filename = $filename;
     $this->openmode = $mode;
     $url = parse_url($filename);
     $retval = false;
     if (isset($url['scheme'])) {
         // If we're dealing with a Joomla! stream, load it
         if (Helper::isJoomlaStream($url['scheme'])) {
             require_once __DIR__ . '/streams/' . $url['scheme'] . '.php';
         }
         // We have a scheme! force the method to be f
         $this->processingmethod = 'f';
     } elseif ($detectprocessingmode) {
         $ext = strtolower(JFile::getExt($this->filename));
         switch ($ext) {
             case 'tgz':
             case 'gz':
             case 'gzip':
                 $this->processingmethod = 'gz';
                 break;
             case 'tbz2':
             case 'bz2':
             case 'bzip2':
                 $this->processingmethod = 'bz';
                 break;
             default:
                 $this->processingmethod = 'f';
                 break;
         }
     }
     // Capture PHP errors
     $php_errormsg = 'Error Unknown whilst opening a file';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     // Decide which context to use:
     switch ($this->processingmethod) {
         // Gzip doesn't support contexts or streams
         case 'gz':
             $this->fh = gzopen($filename, $mode, $use_include_path);
             break;
             // Bzip2 is much like gzip except it doesn't use the include path
         // Bzip2 is much like gzip except it doesn't use the include path
         case 'bz':
             $this->fh = bzopen($filename, $mode);
             break;
             // Fopen can handle streams
         // Fopen can handle streams
         case 'f':
         default:
             // One supplied at open; overrides everything
             if ($context) {
                 $this->fh = fopen($filename, $mode, $use_include_path, $context);
             } elseif ($this->context) {
                 $this->fh = fopen($filename, $mode, $use_include_path, $this->context);
             } else {
                 $this->fh = fopen($filename, $mode, $use_include_path);
             }
             break;
     }
     if (!$this->fh) {
         $this->setError($php_errormsg);
     } else {
         $retval = true;
     }
     // Restore error tracking to what it was before
     ini_set('track_errors', $track_errors);
     // Return the result
     return $retval;
 }