Skip to content

Commit dde9a89

Browse files
committed
added test case for Git2\TreeBuilder::write
1 parent 5d28737 commit dde9a89

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Check for Git2\TreeBuilder::construct
3+
--SKIPIF--
4+
<?php if (!extension_loaded("git2")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$path = __DIR__ . '/mock/007-02';
8+
if (file_exists($path)) {
9+
`rm -rf {$path}`;
10+
}
11+
12+
$repo = Git2\Repository::init($path,true);
13+
14+
$bld = new Git2\TreeBuilder();
15+
$bld->insert(new Git2\TreeEntry(array(
16+
"name" => "README.txt",
17+
"oid" => "63542fbea05732b78711479a31557bd1b0aa2116",
18+
"attributes" => 33188,
19+
)));
20+
$oid = $bld->write($repo);
21+
echo $oid . PHP_EOL;
22+
if (is_file($path . "/objects/75/b9737032278849da7e57829164a1265911afda")) {
23+
echo "PASS" . PHP_EOL;
24+
} else {
25+
echo "FAIL" . PHP_EOL;
26+
}
27+
echo `GIT_DIR={$path} git ls-tree 75b9737032278849da7e57829164a1265911afda`;
28+
`rm -rf {$path}`;
29+
--EXPECT--
30+
75b9737032278849da7e57829164a1265911afda
31+
PASS
32+
100644 blob 63542fbea05732b78711479a31557bd1b0aa2116 README.txt

0 commit comments

Comments
 (0)