Exemplo n.º 1
0
$p = new GitPath("test/");
$t->ok($p->isSingle(), 'one directory is a single reference');
$p = new GitPath("test/file");
$t->ok(!$p->isSingle(), 'a file in a directory is not single');
$p = new GitPath("/test");
$t->ok($p->isSingle(), 'one file is a single reference');
$t->comment('isRoot testing');
$p = new GitPath("/");
$t->ok($p->isRoot(), 'root is a root');
$p = new GitPath("");
$t->ok($p->isRoot(), 'empty is a root');
$p = new GitPath("test");
$t->ok(!$p->isRoot(), 'a file is not a root');
$t->comment('Testing differences for Tree and Blob paths');
$p = new GitPath("abc/def/ghi");
$t->ok($p->refBlob(), 'no trailing slash references a blob object');
$p = new GitPath("abc/def/ghi/");
$t->ok($p->refTree(), 'a trailing slash references a tree object');
$t->comment('Testing array access');
$p = new GitPath("abc/def/ghi");
$t->is($p[0], 'abc', 'allows array access');
$t->is($p[-1], 'ghi', 'allows negative index array access');
$t->is(count($p), 3, 'count returns number of elements');
$t->comment('Testing iterator');
$p = new GitPath("abc/def");
foreach ($p as $index => $part) {
    switch ($index) {
        case 0:
            $t->is($part, 'abc', 'first iteration');
            break;
        case 1:
Exemplo n.º 2
0
 public function hasAncestor(GitPath $path)
 {
     if ($path->refBlob() || count($path) >= $this->count()) {
         return false;
     }
     return count(array_intersect_assoc($this->parts, $path->getParts())) == count($path);
 }