InMemorySpec.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace spec\Gaufrette\Adapter;
  3. use PhpSpec\ObjectBehavior;
  4. class InMemorySpec extends ObjectBehavior
  5. {
  6. function let()
  7. {
  8. $this->beConstructedWith(array(
  9. 'filename' => array('mtime' => 12345, 'content' => 'content'),
  10. 'filename2' => 'other content'
  11. ));
  12. }
  13. function it_is_adapter()
  14. {
  15. $this->shouldHaveType('Gaufrette\Adapter');
  16. }
  17. function it_reads_file()
  18. {
  19. $this->read('filename')->shouldReturn('content');
  20. }
  21. function it_writes_file()
  22. {
  23. $this->write('filename', 'some content')->shouldReturn(12);
  24. }
  25. function it_renames_file()
  26. {
  27. $this->rename('filename', 'aaa/filename2')->shouldReturn(true);
  28. $this->exists('filename')->shouldReturn(false);
  29. $this->exists('aaa/filename2')->shouldReturn(true);
  30. }
  31. function it_checks_if_file_exists()
  32. {
  33. $this->exists('filename')->shouldReturn(true);
  34. $this->exists('filenameTest')->shouldReturn(false);
  35. }
  36. function it_fetches_keys()
  37. {
  38. $this->keys()->shouldReturn(array('filename', 'filename2'));
  39. }
  40. function it_fetches_mtime()
  41. {
  42. $this->mtime('filename')->shouldReturn(12345);
  43. }
  44. function it_deletes_file()
  45. {
  46. $this->delete('filename')->shouldReturn(true);
  47. $this->exists('filename')->shouldReturn(false);
  48. }
  49. function it_does_not_handle_dirs()
  50. {
  51. $this->isDirectory('filename')->shouldReturn(false);
  52. $this->isDirectory('filename2')->shouldReturn(false);
  53. }
  54. }