1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (c) Xerox, 2009. All Rights Reserved. |
4
|
|
|
* |
5
|
|
|
* Originally written by Nicolas Terray, 2009. Xerox Codendi Team. |
6
|
|
|
* |
7
|
|
|
* This file is a part of Codendi. |
8
|
|
|
* |
9
|
|
|
* Codendi is free software; you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU General Public License as published by |
11
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
12
|
|
|
* (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* Codendi is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with Codendi; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22
|
|
|
*/ |
23
|
|
|
/** |
24
|
|
|
* Description of GitUnitTestCaseclass |
25
|
|
|
* |
26
|
|
|
* @author gstorchi |
27
|
|
|
*/ |
28
|
|
|
class GitUnitTestCase extends UnitTestCase { |
29
|
|
|
//put your code here |
30
|
|
|
protected $rootPath; |
31
|
|
|
|
32
|
|
|
public function setUp() { |
33
|
|
|
$this->rootPath = '/tmp/'.basename(__FILE__); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function tearDown() { |
37
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function createRepo($path) { |
41
|
|
|
chdir($this->rootPath); |
42
|
|
|
mkdir($path, 0777, true); |
43
|
|
|
chdir($path); |
44
|
|
|
$rcode = 0; |
45
|
|
|
system('git --bare init', $rcode); |
46
|
|
|
if ( $rcode != 0 ) { |
|
|
|
|
47
|
|
|
return false; |
48
|
|
|
} |
49
|
|
|
return true; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
protected function createTestBareRepo($name) { |
54
|
|
|
chdir($this->rootPath); |
55
|
|
|
$rcode = 0; |
56
|
|
|
system('mkdir repo'.$name.' clone'.$name.';cd repo'.$name.';git --bare init', $rcode); |
57
|
|
|
if ( $rcode != 0 ) { |
|
|
|
|
58
|
|
|
return false; |
59
|
|
|
} |
60
|
|
|
chdir('clone'.$name); |
61
|
|
|
return true; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
protected function createTestRepo($name) { |
65
|
|
|
chdir($this->rootPath); |
66
|
|
|
mkdir('repo'.$name); |
67
|
|
|
system('git clone '.$this->remoteUrlToClone); |
68
|
|
|
chdir('repo'.$name); |
69
|
|
|
return $this->rootPath.DIRECTORY_SEPARATOR.'repo'.$name; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
protected function createBranch($branchName) { |
73
|
|
|
system('git checkout -b '.$branchName.' origin/master' ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
protected function removeTestDir() { |
77
|
|
|
$this->rootPath = '/tmp/'.basename(__FILE__); |
78
|
|
|
if ( file_exists($this->rootPath) ) { |
79
|
|
|
$rcode = 0; |
80
|
|
|
$msg = system('rm -fr '.$this->rootPath, $rcode); |
81
|
|
|
if ( $rcode != 0 ) { |
|
|
|
|
82
|
|
|
$this->fail($msg); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
?> |
89
|
|
|
|