FilesystemMapSpec.php 1.8 KB

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