public function testBasicNaming() { $p = new Path('this/is/the/path/to/my/file.ext'); $this->assertEquals('this/is/the/path/to/my', $p->getDirname()); $this->assertEquals('file.ext', $p->getFilename()); $this->assertEquals('ext', $p->getExtension()); $this->assertEquals('this/is/the/path/to/my/file.ext', $p->getPathname()); $p = new Path('another/path'); $this->assertEmpty($p->getExtension()); $p = $p->append('to'); $this->assertEquals('another/path/to', $p->getPathname()); $p = $p->append(new Path('my/stuff')); $this->assertEquals('another/path/to/my/stuff', $p->getPathname()); }
public function testLink() { $origin = new Path(tempnam(sys_get_temp_dir(), 'orig')); $target = new File(tempnam(sys_get_temp_dir(), 'target')); $target->delete(); $target = new Path($target->getPathname()); $file = new File($origin); $file->touch(); $file->linkTo($target); $link = $target->toFileDescriptor(); $this->assertNull($file->getLinkTarget()); $this->assertTrue($link->exists()); $this->assertTrue($link->isLink()); $this->assertTrue($origin->equals($link->getLinkTarget())); }
/** * Checks whether this path is the prefix of another path * * @param Path $anotherPath * @return boolean */ public function isPrefixOf(Path $anotherPath) { return $anotherPath->getPathname()->startsWith($this->pathname); }