You are here

function RemoteStreamWrapperTestCase::testBitMasks in Remote Stream Wrapper 7

Same name and namespace in other branches
  1. 8 remote_stream_wrapper.test \RemoteStreamWrapperTestCase::testBitMasks()

Test STREAM_WRAPPERS_REMOTE bitmask and file_get_remote_stream_wrappers().

File

./remote_stream_wrapper.test, line 35

Class

RemoteStreamWrapperTestCase
Tests for the remote_stream_wrapper module.

Code

function testBitMasks() {
  $cases = array(
    array(
      'filter' => STREAM_WRAPPERS_ALL,
      'result' => TRUE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_LOCAL,
      'result' => TRUE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_READ,
      'result' => TRUE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_WRITE,
      'result' => FALSE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_VISIBLE,
      'result' => TRUE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_HIDDEN,
      'result' => FALSE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_LOCAL_HIDDEN,
      'result' => FALSE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_WRITE_VISIBLE,
      'result' => FALSE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_READ_VISIBLE,
      'result' => TRUE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_NORMAL,
      'result' => FALSE,
    ),
    array(
      'filter' => STREAM_WRAPPERS_LOCAL_NORMAL,
      'result' => FALSE,
    ),
  );
  foreach ($cases as $case) {
    $wrappers = file_get_stream_wrappers($case['filter']);
    $this
      ->assertEqual(isset($wrappers['http']), $case['result']);
  }
  $wrappers = file_get_remote_stream_wrappers();
  $this
    ->assertEqual(count($wrappers), 3, 'Correct number of remote stream wrappers returned.');
}