Storage.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Illuminate\Support\Facades;
  3. use Illuminate\Filesystem\Filesystem;
  4. /**
  5. * @see \Illuminate\Filesystem\FilesystemManager
  6. */
  7. class Storage extends Facade
  8. {
  9. /**
  10. * Replace the given disk with a local testing disk.
  11. *
  12. * @param string|null $disk
  13. *
  14. * @return void
  15. */
  16. public static function fake($disk = null)
  17. {
  18. $disk = $disk ?: self::$app['config']->get('filesystems.default');
  19. (new Filesystem)->cleanDirectory(
  20. $root = storage_path('framework/testing/disks/'.$disk)
  21. );
  22. static::set($disk, self::createLocalDriver(['root' => $root]));
  23. }
  24. /**
  25. * Replace the given disk with a persistent local testing disk.
  26. *
  27. * @param string|null $disk
  28. * @return void
  29. */
  30. public static function persistentFake($disk = null)
  31. {
  32. $disk = $disk ?: self::$app['config']->get('filesystems.default');
  33. static::set($disk, self::createLocalDriver([
  34. 'root' => storage_path('framework/testing/disks/'.$disk),
  35. ]));
  36. }
  37. /**
  38. * Get the registered name of the component.
  39. *
  40. * @return string
  41. */
  42. protected static function getFacadeAccessor()
  43. {
  44. return 'filesystem';
  45. }
  46. }