1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the LGPL. For more information please see |
17
|
|
|
* <http://phing.info>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Phing\Task\Optional\Git; |
21
|
|
|
|
22
|
|
|
use Phing\Support\BuildFileTest; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @author Victor Farazdagi <[email protected]> |
26
|
|
|
* @requires OS ^(?:(?!Win).)*$ |
27
|
|
|
*/ |
28
|
|
|
class GitInitTaskTest extends BuildFileTest |
29
|
|
|
{ |
30
|
|
|
public function setUp(): void |
31
|
|
|
{ |
32
|
|
|
// set temp directory used by test cases |
33
|
|
|
mkdir(PHING_TEST_BASE . '/tmp/git'); |
34
|
|
|
|
35
|
|
|
$this->configureProject( |
36
|
|
|
PHING_TEST_BASE |
37
|
|
|
. '/etc/tasks/ext/git/GitInitTaskTest.xml' |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function tearDown(): void |
42
|
|
|
{ |
43
|
|
|
$this->rmdir(PHING_TEST_BASE . '/tmp/git'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testWrongRepository() |
47
|
|
|
{ |
48
|
|
|
$this->expectBuildExceptionContaining( |
49
|
|
|
'wrongRepository', |
50
|
|
|
'Repository directory not readable', |
51
|
|
|
'You must specify readable directory as repository.' |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testGitInit() |
56
|
|
|
{ |
57
|
|
|
$repository = PHING_TEST_BASE . '/tmp/git'; |
58
|
|
|
$gitFilesDir = $repository . '/.git'; |
59
|
|
|
$this->executeTarget('gitInit'); |
60
|
|
|
|
61
|
|
|
$this->assertInLogs('git-init: initializing "' . $repository . '" repository'); |
62
|
|
|
$this->assertDirectoryExists($repository); |
63
|
|
|
$this->assertDirectoryExists($gitFilesDir); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testGitInitBare() |
67
|
|
|
{ |
68
|
|
|
$repository = PHING_TEST_BASE . '/tmp/git'; |
69
|
|
|
$gitFilesDir = $repository . '/.git'; |
|
|
|
|
70
|
|
|
$this->executeTarget('gitInitBare'); |
71
|
|
|
$this->assertInLogs('git-init: initializing (bare) "' . $repository . '" repository'); |
72
|
|
|
$this->assertDirectoryExists($repository); |
73
|
|
|
$this->assertDirectoryExists($repository . '/branches'); |
74
|
|
|
$this->assertDirectoryExists($repository . '/info'); |
75
|
|
|
$this->assertDirectoryExists($repository . '/hooks'); |
76
|
|
|
$this->assertDirectoryExists($repository . '/refs'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function testNoRepositorySpecified() |
80
|
|
|
{ |
81
|
|
|
$this->expectBuildExceptionContaining( |
82
|
|
|
'noRepository', |
83
|
|
|
'Repo dir is required', |
84
|
|
|
'"repository" is required parameter' |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|