class FlysystemRoutesTest in Flysystem 2.0.x
Same name and namespace in other branches
- 8 tests/src/Unit/Routing/FlysystemRoutesTest.php \Drupal\Tests\flysystem\Unit\Routing\FlysystemRoutesTest
- 3.x tests/src/Unit/Routing/FlysystemRoutesTest.php \Drupal\Tests\flysystem\Unit\Routing\FlysystemRoutesTest
- 3.0.x tests/src/Unit/Routing/FlysystemRoutesTest.php \Drupal\Tests\flysystem\Unit\Routing\FlysystemRoutesTest
@coversDefaultClass \Drupal\flysystem\Routing\FlysystemRoutes @group flysystem
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- class \Drupal\Tests\flysystem\Unit\Routing\FlysystemRoutesTest
Expanded class hierarchy of FlysystemRoutesTest
File
- tests/
src/ Unit/ Routing/ FlysystemRoutesTest.php, line 18
Namespace
Drupal\Tests\flysystem\Unit\RoutingView source
class FlysystemRoutesTest extends UnitTestCase {
/**
* @var \Drupal\flysystem\FlysystemFactory
*/
protected $factory;
/**
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* @var \Drupal\flysystem\Routing\FlysystemRoutes
*/
protected $router;
/**
* {@inheritdoc}
*/
public function setUp() {
$container = new ContainerBuilder();
$stream_wrapper = $this
->prophesize(LocalStream::class);
$stream_wrapper
->getDirectoryPath()
->willReturn('sites/default/files');
$stream_wrapper_manager = $this
->prophesize(StreamWrapperManagerInterface::class);
$stream_wrapper_manager
->getViaScheme('public')
->willReturn($stream_wrapper
->reveal());
$this->moduleHandler = $this
->prophesize(ModuleHandlerInterface::class);
$factory = $this
->prophesize(FlysystemFactory::class);
$factory
->getSchemes()
->willReturn([
'test',
]);
$container
->set('flysystem_factory', $factory
->reveal());
$container
->set('stream_wrapper_manager', $stream_wrapper_manager
->reveal());
$container
->set('module_handler', $this->moduleHandler
->reveal());
$this->router = FlysystemRoutes::create($container);
}
/**
* @covers ::__construct
* @covers ::create
* @covers ::routes
*/
public function testInvalidSettingsAreSkipped() {
new Settings([
'flysystem' => [
'invalid' => [
'driver' => 'local',
],
'test' => [
'driver' => 'local',
],
],
]);
$this
->assertSame([], $this->router
->routes());
}
/**
* @covers ::routes
*/
public function testInvalidDriversAreSkipped() {
new Settings([
'flysystem' => [
'test' => [
'driver' => 'ftp',
],
],
]);
$this
->assertSame([], $this->router
->routes());
}
/**
* @covers ::routes
*/
public function testDriversNotPublicAreSkipped() {
new Settings([
'flysystem' => [
'test' => [
'driver' => 'local',
],
],
]);
$this
->assertSame([], $this->router
->routes());
}
/**
* @covers ::routes
*/
public function testLocalPathSameAsPublicIsSkipped() {
new Settings([
'flysystem' => [
'test' => [
'driver' => 'local',
'public' => TRUE,
'config' => [
'public' => TRUE,
'root' => 'sites/default/files',
],
],
],
]);
$this
->assertSame([], $this->router
->routes());
}
/**
* @covers ::routes
*/
public function testValidRoutesReturned() {
new Settings([
'flysystem' => [
'test' => [
'driver' => 'local',
'public' => TRUE,
'config' => [
'public' => TRUE,
'root' => 'sites/default/files/flysystem',
],
],
],
]);
$routes = $this->router
->routes();
$this
->assertSame(1, count($routes));
$this
->assertTrue(isset($routes['flysystem.test.serve']));
}
/**
* @covers ::routes
*/
public function testValidRoutesReturnedWithImageModule() {
new Settings([
'flysystem' => [
'test' => [
'driver' => 'local',
'public' => TRUE,
'config' => [
'public' => TRUE,
'root' => 'sites/default/files/flysystem',
],
],
],
]);
$this->moduleHandler
->moduleExists('image')
->willReturn(TRUE);
$routes = $this->router
->routes();
$this
->assertSame(3, count($routes));
$this
->assertTrue(isset($routes['flysystem.image_style']));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlysystemRoutesTest:: |
protected | property | ||
FlysystemRoutesTest:: |
protected | property | ||
FlysystemRoutesTest:: |
protected | property | ||
FlysystemRoutesTest:: |
public | function |
Overrides UnitTestCase:: |
|
FlysystemRoutesTest:: |
public | function | @covers ::routes | |
FlysystemRoutesTest:: |
public | function | @covers ::routes | |
FlysystemRoutesTest:: |
public | function | @covers ::__construct @covers ::create @covers ::routes | |
FlysystemRoutesTest:: |
public | function | @covers ::routes | |
FlysystemRoutesTest:: |
public | function | @covers ::routes | |
FlysystemRoutesTest:: |
public | function | @covers ::routes | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
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 | 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. | |
UnitTestCase:: |
public static | function |