GridFSTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Gaufrette\Functional\Adapter;
  3. use Gaufrette\Adapter\GridFS;
  4. class GridFSTest extends FunctionalTestCase
  5. {
  6. /**
  7. * @test
  8. */
  9. public function shouldListKeys()
  10. {
  11. $this->filesystem->write('foo/foobar/bar.txt', 'data');
  12. $this->filesystem->write('foo/bar/buzz.txt', 'data');
  13. $this->filesystem->write('foobarbuz.txt', 'data');
  14. $this->filesystem->write('foo', 'data');
  15. $allKeys = $this->filesystem->listKeys(' ');
  16. //empty pattern results in ->keys call
  17. $this->assertEquals(
  18. $this->filesystem->keys(),
  19. $allKeys['keys']
  20. );
  21. //these values are canonicalized to avoid wrong order or keys issue
  22. $keys = $this->filesystem->listKeys('foo');
  23. $this->assertEquals(
  24. $this->filesystem->keys(),
  25. $keys['keys'],
  26. '', 0, 10, true);
  27. $keys = $this->filesystem->listKeys('foo/foob');
  28. $this->assertEquals(
  29. array('foo/foobar/bar.txt'),
  30. $keys['keys'],
  31. '', 0, 10, true);
  32. $keys = $this->filesystem->listKeys('foo/');
  33. $this->assertEquals(
  34. array('foo/foobar/bar.txt', 'foo/bar/buzz.txt'),
  35. $keys['keys'],
  36. '', 0, 10, true);
  37. $keys = $this->filesystem->listKeys('foo');
  38. $this->assertEquals(
  39. array('foo/foobar/bar.txt', 'foo/bar/buzz.txt', 'foobarbuz.txt', 'foo'),
  40. $keys['keys'],
  41. '', 0, 10, true);
  42. $keys = $this->filesystem->listKeys('fooz');
  43. $this->assertEquals(
  44. array(),
  45. $keys['keys'],
  46. '', 0, 10, true);
  47. }
  48. }