DoctrineDbalTest.php 1.6 KB

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