FilesystemMapSpec.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. }