Exemplo n.º 1
0
 public function testSegments()
 {
     $p = new Path('this/is/the/path/to/my/file.ext');
     $this->assertEquals(new ArrayObject(['this', 'is', 'the', 'path', 'to', 'my', 'file.ext']), $p->segments());
     $this->assertEquals(7, $p->segmentCount());
     $this->assertNull($p->segment(-1));
     $this->assertEquals('is', $p->segment(1));
     $this->assertEquals('file.ext', $p->lastSegment());
     $this->assertEquals('this/is/the', $p->upToSegment(3)->toString());
     $this->assertEquals('the/path/to/my/file.ext', $p->removeFirstSegments(2)->toString());
     $this->assertEquals('this/is/the/path/to', $p->removeLastSegments(2)->toString());
     $this->assertEquals('file.ext', $p->lastSegment());
     $this->assertEquals('', $p->upToSegment(0)->toString());
 }