FilesystemManagerTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Illuminate\Tests\Filesystem;
  3. use Illuminate\Contracts\Filesystem\Filesystem;
  4. use Illuminate\Filesystem\FilesystemManager;
  5. use Illuminate\Foundation\Application;
  6. use InvalidArgumentException;
  7. use PHPUnit\Framework\TestCase;
  8. class FilesystemManagerTest extends TestCase
  9. {
  10. public function testExceptionThrownOnUnsupportedDriver()
  11. {
  12. $this->expectException(InvalidArgumentException::class);
  13. $this->expectExceptionMessage('Disk [local] does not have a configured driver.');
  14. $filesystem = new FilesystemManager(tap(new Application, function ($app) {
  15. $app['config'] = ['filesystems.disks.local' => null];
  16. }));
  17. $filesystem->disk('local');
  18. }
  19. public function testCanBuildOnDemandDisk()
  20. {
  21. $filesystem = new FilesystemManager(new Application);
  22. $this->assertInstanceOf(Filesystem::class, $filesystem->build('my-custom-path'));
  23. $this->assertInstanceOf(Filesystem::class, $filesystem->build([
  24. 'driver' => 'local',
  25. 'root' => 'my-custom-path',
  26. 'url' => 'my-custom-url',
  27. 'visibility' => 'public',
  28. ]));
  29. rmdir(__DIR__.'/../../my-custom-path');
  30. }
  31. }