Пример #1
0
 public function testEquals()
 {
     $current = new Path(__FILE__);
     $cwd = new Path(getcwd());
     $relative = new Path('.' . $current->makeRelativeTo($cwd));
     $this->assertTrue($current->equals($relative));
     // with virtual path
     $current = new Path('vfs://root/dir/file.ext');
     $relative = new Path('vfs://root/file.ext');
     $this->assertFalse($current->equals($relative));
     $this->assertFalse($current->equals($cwd));
 }
Пример #2
0
 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()));
 }
Пример #3
0
 /**
  * Returns a count of the number of segments which match in this 
  * path and the given path, comparing in increasing segment number order.
  * 
  * @param Path $anotherPath
  * @return int
  */
 public function matchingFirstSegments(Path $anotherPath)
 {
     $segments = $anotherPath->segments();
     $count = 0;
     foreach ($this->segments as $i => $segment) {
         if ($segment != $segments[$i]) {
             break;
         }
         $count++;
     }
     return $count;
 }