FilesystemMapSpec.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace spec\Gaufrette;
  3. use Gaufrette\Filesystem;
  4. use PhpSpec\ObjectBehavior;
  5. class FilesystemMapSpec extends ObjectBehavior
  6. {
  7. function it_is_initializable()
  8. {
  9. $this->shouldHaveType('Gaufrette\FilesystemMap');
  10. }
  11. /**
  12. * @param Gaufrette\Filesystem $filesystem
  13. */
  14. function it_checks_if_has_mapped_filesystem(Filesystem $filesystem)
  15. {
  16. $this->set('some', $filesystem);
  17. $this->has('some')->shouldReturn(true);
  18. $this->has('other')->shouldReturn(false);
  19. }
  20. /**
  21. * @param Gaufrette\Filesystem $filesystem
  22. */
  23. function it_sets_mapped_filesystem(Filesystem $filesystem)
  24. {
  25. $this->set('some', $filesystem);
  26. $this->get('some')->shouldReturn($filesystem);
  27. }
  28. function it_fails_when_get_filesystem_which_was_not_mapped()
  29. {
  30. $this
  31. ->shouldThrow(new \InvalidArgumentException('There is no filesystem defined for the "some" domain.'))
  32. ->duringGet('some')
  33. ;
  34. }
  35. /**
  36. * @param Gaufrette\Filesystem $filesystem
  37. */
  38. function it_removes_mapped_filesystem(Filesystem $filesystem)
  39. {
  40. $this->set('some', $filesystem);
  41. $this->remove('some');
  42. $this->has('some')->shouldReturn(false);
  43. }
  44. function it_fails_when_try_to_remove_filesystem_which_was_not_mapped()
  45. {
  46. $this
  47. ->shouldThrow(new \InvalidArgumentException('Cannot remove the "some" filesystem as it is not defined.'))
  48. ->duringRemove('some')
  49. ;
  50. }
  51. /**
  52. * @param Gaufrette\Filesystem $filesystem
  53. */
  54. function it_removes_all_filesystems(Filesystem $filesystem)
  55. {
  56. $this->set('some', $filesystem);
  57. $this->set('other', $filesystem);
  58. $this->clear();
  59. $this->has('some')->shouldReturn(false);
  60. $this->has('other')->shouldReturn(false);
  61. $this->all()->shouldReturn(array());
  62. }
  63. }