You are here

class FlysystemBridgeTest in Flysystem 3.0.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/FlysystemBridgeTest.php \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest
  2. 3.x tests/src/Unit/FlysystemBridgeTest.php \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest
  3. 2.0.x tests/src/Unit/FlysystemBridgeTest.php \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest

@coversDefaultClass \Drupal\flysystem\FlysystemBridge @group flysystem

Hierarchy

Expanded class hierarchy of FlysystemBridgeTest

File

tests/src/Unit/FlysystemBridgeTest.php, line 18

Namespace

Drupal\Tests\flysystem\Unit
View source
class FlysystemBridgeTest extends UnitTestCase {

  /**
   * @var \Drupal\flysystem\FlysystemBridge
   */
  protected $bridge;

  /**
   * @var \League\Flysystem\FilesystemInterface
   */
  protected $filesystem;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this->bridge = new FlysystemBridge();
    $this->bridge
      ->setStringTranslation($this
      ->getStringTranslationStub());
    $this->bridge
      ->setUri('testscheme://file.txt');
    $factory = $this
      ->prophesize(FlysystemFactory::class);
    $factory
      ->getPlugin('testscheme')
      ->willReturn(new Missing());
    $this->filesystem = new Filesystem(new MissingAdapter());
    $factory
      ->getFilesystem('testscheme')
      ->willReturn($this->filesystem);
    $factory
      ->getSettings('testscheme')
      ->willReturn([
      'name' => '',
      'description' => '',
    ]);
    $container = new ContainerBuilder();
    $container
      ->set('flysystem_factory', $factory
      ->reveal());
    \Drupal::setContainer($container);
  }

  /**
   * @covers ::getType
   */
  public function testGetTypeReturnsWriteVisible() {
    $this
      ->assertSame(StreamWrapperInterface::WRITE_VISIBLE, FlysystemBridge::getType());
  }

  /**
   * @covers ::getName
   */
  public function testGetNameFormattingCorrect() {
    $this
      ->assertSame('Flysystem: testscheme', (string) $this->bridge
      ->getName());
  }

  /**
   * @covers ::getDescription
   */
  public function testGetDescriptionFormattingCorrect() {
    $this
      ->assertSame('Flysystem: testscheme', (string) $this->bridge
      ->getDescription());
  }

  /**
   * @covers ::getUri
   * @covers ::setUri
   */
  public function testGetUriMatchesSetUri() {
    $this->bridge
      ->setUri('beep://boop');
    $this
      ->assertSame('beep://boop', $this->bridge
      ->getUri());
  }

  /**
   * @covers ::getExternalUrl
   * @covers ::getFactory
   */
  public function testGetExternalUrlDelegatesToPlugin() {
    $this
      ->assertSame('', $this->bridge
      ->getExternalUrl('testscheme://testfile.txt'));
  }

  /**
   * @covers ::realpath
   */
  public function testRealpathIsFalse() {
    $this
      ->assertFalse($this->bridge
      ->realpath());
  }

  /**
   * @covers ::dirname
   */
  public function testDirname() {
    $this
      ->assertSame('testscheme://', $this->bridge
      ->dirname());
    $this
      ->assertSame('testscheme://dir://dir', $this->bridge
      ->dirname('testscheme:///dir://dir/file.txt'));
  }

  /**
   * @covers ::getFilesystem
   * @covers ::getFilesystemForScheme
   */
  public function testGetFilesystemOverridden() {
    $method = new \ReflectionMethod($this->bridge, 'getFilesystem');
    $method
      ->setAccessible(TRUE);
    $this
      ->assertSame($this->filesystem, $method
      ->invoke($this->bridge));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlysystemBridgeTest::$bridge protected property
FlysystemBridgeTest::$filesystem protected property
FlysystemBridgeTest::setUp public function Overrides UnitTestCase::setUp
FlysystemBridgeTest::testDirname public function @covers ::dirname
FlysystemBridgeTest::testGetDescriptionFormattingCorrect public function @covers ::getDescription
FlysystemBridgeTest::testGetExternalUrlDelegatesToPlugin public function @covers ::getExternalUrl @covers ::getFactory
FlysystemBridgeTest::testGetFilesystemOverridden public function @covers ::getFilesystem @covers ::getFilesystemForScheme
FlysystemBridgeTest::testGetNameFormattingCorrect public function @covers ::getName
FlysystemBridgeTest::testGetTypeReturnsWriteVisible public function @covers ::getType
FlysystemBridgeTest::testGetUriMatchesSetUri public function @covers ::getUri @covers ::setUri
FlysystemBridgeTest::testRealpathIsFalse public function @covers ::realpath
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function