Пример #1
0
 public function testNormalize()
 {
     $this->assertTrue(CFilePath::normalize("/path/to//file.png")->equals("/path/to/file.png"));
     $this->assertTrue(CFilePath::normalize("/path//to///file.png")->equals("/path/to/file.png"));
     $this->assertTrue(CFilePath::normalize("/path/to/dir/")->equals("/path/to/dir"));
     $this->assertTrue(CFilePath::normalize("/path//to/dir//")->equals("/path/to/dir"));
     $this->assertTrue(CFilePath::normalize("//path///to////dir")->equals("/path/to/dir"));
     $this->assertTrue(CFilePath::normalize("/")->equals("/"));
     $this->assertTrue(CFilePath::normalize("//")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/path/./to/././dir")->equals("/path/to/dir"));
     $this->assertTrue(CFilePath::normalize("/path/./to/././dir/.")->equals("/path/to/dir"));
     $this->assertTrue(CFilePath::normalize("./path/./to/././dir/.")->equals("path/to/dir"));
     $this->assertTrue(CFilePath::normalize("/.")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/./")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/./.")->equals("/"));
     $this->assertTrue(CFilePath::normalize("././.")->equals("."));
     $this->assertTrue(CFilePath::normalize("./././")->equals("."));
     $this->assertTrue(CFilePath::normalize("path/to/dir/")->equals("path/to/dir"));
     $this->assertTrue(CFilePath::normalize("path/to/./dir/")->equals("path/to/dir"));
     $this->assertTrue(CFilePath::normalize("/dir")->equals("/dir"));
     $this->assertTrue(CFilePath::normalize("/dir/")->equals("/dir"));
     $this->assertTrue(CFilePath::normalize("/..")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/../..")->equals("/"));
     $this->assertTrue(CFilePath::normalize("dir")->equals("dir"));
     $this->assertTrue(CFilePath::normalize("dir/")->equals("dir"));
     $this->assertTrue(CFilePath::normalize("/path/to/../dir")->equals("/path/dir"));
     $this->assertTrue(CFilePath::normalize("/path/to/../..")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/path/to/../../")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/path/to/../../../..")->equals("/"));
     $this->assertTrue(CFilePath::normalize("/./path/./to/../dir")->equals("/path/dir"));
     $this->assertTrue(CFilePath::normalize("/./path/./to//../../dir")->equals("/dir"));
     $this->assertTrue(CFilePath::normalize("/path/././dir-a/../to/../dir-b")->equals("/path/dir-b"));
     $this->assertTrue(CFilePath::normalize("/path//./dir-a/.././to//../dir-b/")->equals("/path/dir-b"));
     $this->assertTrue(CFilePath::normalize("path/to/../dir")->equals("path/dir"));
     $this->assertTrue(CFilePath::normalize("path/to/../..")->equals("."));
     $this->assertTrue(CFilePath::normalize("path/to/../../")->equals("."));
     $this->assertTrue(CFilePath::normalize("path/./to/../dir")->equals("path/dir"));
     $this->assertTrue(CFilePath::normalize("./path/./to//../../dir")->equals("dir"));
     $this->assertTrue(CFilePath::normalize("./.././..")->equals("../.."));
     $this->assertTrue(CFilePath::normalize("path/././dir-a/../to/../dir-b")->equals("path/dir-b"));
     $this->assertTrue(CFilePath::normalize("path/././dir-a/../to/../dir-b/../..")->equals("."));
     $this->assertTrue(CFilePath::normalize("path/././dir-a/../to/../dir-b/../../")->equals("."));
     $this->assertTrue(CFilePath::normalize("path/././dir-a/../to/../dir-b/../../..")->equals(".."));
     $this->assertTrue(CFilePath::normalize("path/././dir-a/../to/../dir-b/../../../..")->equals("../.."));
 }