class FlysystemBridgeTest in Flysystem 8
Same name and namespace in other branches
- 3.x tests/src/Unit/FlysystemBridgeTest.php \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest
- 2.0.x tests/src/Unit/FlysystemBridgeTest.php \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest
- 3.0.x tests/src/Unit/FlysystemBridgeTest.php \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest
@coversDefaultClass \Drupal\flysystem\FlysystemBridge @group flysystem
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\flysystem\Unit\FlysystemBridgeTest
Expanded class hierarchy of FlysystemBridgeTest
File
- tests/
src/ Unit/ FlysystemBridgeTest.php, line 18
Namespace
Drupal\Tests\flysystem\UnitView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlysystemBridgeTest:: |
protected | property | ||
FlysystemBridgeTest:: |
protected | property | ||
FlysystemBridgeTest:: |
public | function |
Overrides UnitTestCase:: |
|
FlysystemBridgeTest:: |
public | function | @covers ::dirname | |
FlysystemBridgeTest:: |
public | function | @covers ::getDescription | |
FlysystemBridgeTest:: |
public | function | @covers ::getExternalUrl @covers ::getFactory | |
FlysystemBridgeTest:: |
public | function | @covers ::getFilesystem @covers ::getFilesystemForScheme | |
FlysystemBridgeTest:: |
public | function | @covers ::getName | |
FlysystemBridgeTest:: |
public | function | @covers ::getType | |
FlysystemBridgeTest:: |
public | function | @covers ::getUri @covers ::setUri | |
FlysystemBridgeTest:: |
public | function | @covers ::realpath | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |