InMemorySpec.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_is_a_mime_type_provider()
  18. {
  19. $this->shouldHaveType('Gaufrette\Adapter\MimeTypeProvider');
  20. }
  21. function it_gets_the_file_mime_type()
  22. {
  23. $this->mimeType('filename')->shouldReturn('text/plain');
  24. }
  25. function it_reads_file()
  26. {
  27. $this->read('filename')->shouldReturn('content');
  28. }
  29. function it_writes_file()
  30. {
  31. $this->write('filename', 'some content')->shouldReturn(12);
  32. }
  33. function it_renames_file()
  34. {
  35. $this->rename('filename', 'aaa/filename2')->shouldReturn(true);
  36. $this->exists('filename')->shouldReturn(false);
  37. $this->exists('aaa/filename2')->shouldReturn(true);
  38. }
  39. function it_checks_if_file_exists()
  40. {
  41. $this->exists('filename')->shouldReturn(true);
  42. $this->exists('filenameTest')->shouldReturn(false);
  43. }
  44. function it_fetches_keys()
  45. {
  46. $this->keys()->shouldReturn(array('filename', 'filename2'));
  47. }
  48. function it_fetches_mtime()
  49. {
  50. $this->mtime('filename')->shouldReturn(12345);
  51. }
  52. function it_deletes_file()
  53. {
  54. $this->delete('filename')->shouldReturn(true);
  55. $this->exists('filename')->shouldReturn(false);
  56. }
  57. function it_does_not_handle_dirs()
  58. {
  59. $this->isDirectory('filename')->shouldReturn(false);
  60. $this->isDirectory('filename2')->shouldReturn(false);
  61. }
  62. }