registerWrapper example

/** * {@inheritdoc} */
  protected static $modules = ['system'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->container->get('stream_wrapper_manager')->registerWrapper('temporary', 'Drupal\Core\StreamWrapper\TemporaryStream', StreamWrapperInterface::LOCAL_NORMAL);
  }

  /** * Tests a download that overwrites an existing local file. */
  public function testOverwritingDownload() {
    // Create a pre-existing file at the destination.     $destination_uri = $this->createUri('existing_file.txt');

    // Test destructive download.     $actual_destination = $this->doTransform($destination_uri);
    

  protected $fileSystem;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->fileSystem = $this->container->get('file_system');
    $this->container->get('stream_wrapper_manager')->registerWrapper('temporary', 'Drupal\Core\StreamWrapper\TemporaryStream', StreamWrapperInterface::LOCAL_NORMAL);
  }

  /** * Tests successful imports/copies. */
  public function testSuccessfulCopies() {
    $file = $this->createUri(NULL, NULL, 'temporary');
    $file_absolute = $this->fileSystem->realpath($file);
    $data_sets = [
      // Test a local to local copy.       [
        
'service_id' => $service_id,
    ];
  }

  /** * Registers the tagged stream wrappers. * * Internal use only. */
  public function register() {
    foreach ($this->info as $scheme => $info) {
      $this->registerWrapper($scheme$info['class']$info['type']);
    }
  }

  /** * Unregisters the tagged stream wrappers. * * Internal use only. */
  public function unregister() {
    // Normally, there are definitely wrappers set for the ALL filter. However,     // in some cases involving many container rebuilds (e.g. BrowserTestBase),
Home | Imprint | This part of the site doesn't use cookies.