You are here

public function FlysystemUrlTraitTest::testGetExternalUrl in Flysystem 3.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/Plugin/FlysystemUrlTraitTest.php \Drupal\Tests\flysystem\Unit\Plugin\FlysystemUrlTraitTest::testGetExternalUrl()
  2. 2.0.x tests/src/Unit/Plugin/FlysystemUrlTraitTest.php \Drupal\Tests\flysystem\Unit\Plugin\FlysystemUrlTraitTest::testGetExternalUrl()
  3. 3.0.x tests/src/Unit/Plugin/FlysystemUrlTraitTest.php \Drupal\Tests\flysystem\Unit\Plugin\FlysystemUrlTraitTest::testGetExternalUrl()

@covers ::getExternalUrl @covers ::getScheme @covers ::getTarget

File

tests/src/Unit/Plugin/FlysystemUrlTraitTest.php, line 21

Class

FlysystemUrlTraitTest
@coversDefaultClass \Drupal\flysystem\Plugin\FlysystemUrlTrait @group flysystem

Namespace

Drupal\Tests\flysystem\Unit\Plugin

Code

public function testGetExternalUrl() {
  $trait = $this
    ->getMockForTrait(FlysystemUrlTrait::class);
  $url_generator = $this
    ->prophesize(UrlGenerator::class);
  $url_generator
    ->generateFromRoute('flysystem.serve', [
    'scheme' => 'testscheme',
    'filepath' => 'dir/file.txt',
  ], [
    'absolute' => TRUE,
  ], FALSE)
    ->willReturn('download');
  $container = new ContainerBuilder();
  $container
    ->set('url_generator', $url_generator
    ->reveal());
  \Drupal::setContainer($container);
  $this
    ->assertSame('download', $trait
    ->getExternalUrl('testscheme://dir\\file.txt'));
}