<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(34, new lime_output_color()); $t->comment('Testing output'); $a = array('abc', 'def', 'ghi'); $p = new GitPath($a); $t->is((string) $p, 'abc/def/ghi', '__tostring returns string'); $t->is((string) $p->getTreePart(), 'abc/def/', 'getTreePart() returns string'); $t->is((string) $p->getBlobPart(), 'ghi', 'getBlobPart() returns string'); $t->ok($p->getShifted() instanceof GitPath, 'getShifted() returns GitPath'); $t->is((string) $p->getShifted(), 'def/ghi', 'getShifted() returns all items after first part'); $t->comment('Constructor testing'); $s = 'abc/def/ghi'; $p = new GitPath("/" . $s); $t->is((string) $p, $s, 'constructor removes leading slashes'); $p = new GitPath("/////" . $s); $t->is((string) $p, $s, 'constructor removes leading slashes'); $p = new GitPath(""); $t->is((string) $p, "/", 'constructor makes empty string into root reference'); $p = new GitPath("/"); $t->is((string) $p, "/", 'constructor accepts / as root reference'); $s .= '/'; $p = new GitPath($s); $t->is((string) $p, $s, 'constructor accepts refTree paths'); $p = new GitPath($s . '/'); $t->is((string) $p, $s, 'constructor removes trailing slashes'); $p = new GitPath($s . '/////'); $t->is((string) $p, $s, 'constructor removes trailing slashes'); $p = new GitPath('abc//def//ghi//'); $t->is((string) $p, $s, 'constructor removes empty parts');