PathSpec.php 940 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace spec\Gaufrette\Util;
  3. use PhpSpec\ObjectBehavior;
  4. class PathSpec extends ObjectBehavior
  5. {
  6. function it_checks_if_path_is_absolute()
  7. {
  8. $this->isAbsolute('/home/path')->shouldBe(true);
  9. $this->isAbsolute('home/path')->shouldBe(false);
  10. $this->isAbsolute('../home/path')->shouldBe(false);
  11. $this->isAbsolute('protocol://home/path')->shouldBe(true);
  12. }
  13. function it_normalizes_file_path()
  14. {
  15. $this->normalize('C:\\some\other.txt')->shouldReturn('c:/some/other.txt');
  16. $this->normalize('..\other.txt')->shouldReturn('../other.txt');
  17. $this->normalize('..\other.txt')->shouldReturn('../other.txt');
  18. $this->normalize('/home/other/../new')->shouldReturn('/home/new');
  19. $this->normalize('/home/other/./new')->shouldReturn('/home/other/new');
  20. $this->normalize('protocol://home/other.txt')->shouldReturn('protocol://home/other.txt');
  21. }
  22. }