ApcSpec.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace spec\Gaufrette\Adapter;
  3. //hack - mock php built-in functions
  4. require_once 'functions.php';
  5. use PhpSpec\ObjectBehavior;
  6. class ApcSpec extends ObjectBehavior
  7. {
  8. function let()
  9. {
  10. global $extensionLoaded;
  11. $extensionLoaded = true;
  12. $this->beConstructedWith('prefix-apc-test/');
  13. }
  14. function letgo()
  15. {
  16. global $extensionLoaded;
  17. $extensionLoaded = null;
  18. }
  19. function it_is_adapter()
  20. {
  21. $this->shouldHaveType('Gaufrette\Adapter');
  22. }
  23. function it_reads_file()
  24. {
  25. $this->read('filename')->shouldReturn('prefix-apc-test/filename content');
  26. $this->read('filename2')->shouldReturn('prefix-apc-test/filename2 content');
  27. }
  28. function it_writes_file()
  29. {
  30. $this->write('filename', 'some content')->shouldReturn(12);
  31. $this->write('invalid', 'some content')->shouldReturn(false);
  32. }
  33. function it_deletes_file()
  34. {
  35. $this->delete('filename')->shouldReturn(true);
  36. $this->delete('invalid')->shouldReturn(false);
  37. }
  38. function it_rename_file()
  39. {
  40. $this->rename('filename', 'aaa/filename2')->shouldReturn(true);
  41. $this->rename('filename', 'invalid')->shouldReturn(false);
  42. $this->rename('invalid', 'somename')->shouldReturn(false);
  43. }
  44. function it_checks_if_file_exists()
  45. {
  46. $this->exists('filename')->shouldReturn(true);
  47. $this->exists('invalid')->shouldReturn(false);
  48. }
  49. function it_does_not_handles_directory()
  50. {
  51. $this->isDirectory('filename')->shouldReturn(false);
  52. $this->isDirectory('invalid')->shouldReturn(false);
  53. }
  54. }