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\Tasks\System; |
21
|
|
|
|
22
|
|
|
use Phing\Io\DirectoryScanner; |
23
|
|
|
use Phing\Support\BuildFileTest; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Tests the DefaultExcludes Task |
27
|
|
|
* |
28
|
|
|
* @author Siad Ardroumli |
29
|
|
|
* @package phing.tasks.system |
30
|
|
|
*/ |
31
|
|
|
class DefaultExcludesTest extends BuildFileTest |
32
|
|
|
{ |
33
|
|
|
private $output; |
|
|
|
|
34
|
|
|
|
35
|
|
|
public function setUp(): void |
36
|
|
|
{ |
37
|
|
|
$this->configureProject( |
38
|
|
|
PHING_TEST_BASE |
39
|
|
|
. "/etc/tasks/system/defaultexcludes-test.xml" |
40
|
|
|
); |
41
|
|
|
$this->executeTarget("setup"); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function tearDown(): void |
45
|
|
|
{ |
46
|
|
|
$this->executeTarget("clean"); |
47
|
|
|
$this->executeTarget("cleanup-excludes"); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @requires PHPUnit < 8 |
52
|
|
|
*/ |
53
|
|
|
public function test1() |
54
|
|
|
{ |
55
|
|
|
$expected = [ |
56
|
|
|
"**/*~", |
57
|
|
|
"**/#*#", |
58
|
|
|
"**/.#*", |
59
|
|
|
"**/%*%", |
60
|
|
|
"**/CVS", |
61
|
|
|
"**/CVS/**", |
62
|
|
|
"**/.cvsignore", |
63
|
|
|
"**/SCCS", |
64
|
|
|
"**/SCCS/**", |
65
|
|
|
"**/vssver.scc", |
66
|
|
|
"**/.svn", |
67
|
|
|
"**/.svn/**", |
68
|
|
|
"**/._*", |
69
|
|
|
"**/.DS_Store", |
70
|
|
|
"**/.darcs", |
71
|
|
|
"**/.darcs/**", |
72
|
|
|
"**/.git", |
73
|
|
|
"**/.git/**", |
74
|
|
|
"**/.gitattributes", |
75
|
|
|
"**/.gitignore", |
76
|
|
|
"**/.gitmodules", |
77
|
|
|
"**/.hg", |
78
|
|
|
"**/.hg/**", |
79
|
|
|
"**/.hgignore", |
80
|
|
|
"**/.hgsub", |
81
|
|
|
"**/.hgsubstate", |
82
|
|
|
"**/.hgtags", |
83
|
|
|
"**/.bzr", |
84
|
|
|
"**/.bzr/**", |
85
|
|
|
"**/.bzrignore", |
86
|
|
|
]; |
87
|
|
|
$this->executeTarget(__FUNCTION__); |
88
|
|
|
$this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes()); |
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @requires PHPUnit < 8 |
93
|
|
|
*/ |
94
|
|
|
public function test2() |
95
|
|
|
{ |
96
|
|
|
$expected = [ |
97
|
|
|
"**/*~", |
98
|
|
|
"**/#*#", |
99
|
|
|
"**/.#*", |
100
|
|
|
"**/%*%", |
101
|
|
|
"**/CVS", |
102
|
|
|
"**/CVS/**", |
103
|
|
|
"**/.cvsignore", |
104
|
|
|
"**/SCCS", |
105
|
|
|
"**/SCCS/**", |
106
|
|
|
"**/vssver.scc", |
107
|
|
|
"**/.svn", |
108
|
|
|
"**/.svn/**", |
109
|
|
|
"**/._*", |
110
|
|
|
"**/.DS_Store", |
111
|
|
|
"**/.darcs", |
112
|
|
|
"**/.darcs/**", |
113
|
|
|
"**/.git", |
114
|
|
|
"**/.git/**", |
115
|
|
|
"**/.gitattributes", |
116
|
|
|
"**/.gitignore", |
117
|
|
|
"**/.gitmodules", |
118
|
|
|
"**/.hg", |
119
|
|
|
"**/.hg/**", |
120
|
|
|
"**/.hgignore", |
121
|
|
|
"**/.hgsub", |
122
|
|
|
"**/.hgsubstate", |
123
|
|
|
"**/.hgtags", |
124
|
|
|
"**/.bzr", |
125
|
|
|
"**/.bzr/**", |
126
|
|
|
"**/.bzrignore", |
127
|
|
|
"foo" |
128
|
|
|
]; |
129
|
|
|
$this->executeTarget(__FUNCTION__); |
130
|
|
|
$this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes()); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @requires PHPUnit < 8 |
135
|
|
|
*/ |
136
|
|
|
public function test3() |
137
|
|
|
{ |
138
|
|
|
$expected = [ |
139
|
|
|
"**/*~", |
140
|
|
|
"**/#*#", |
141
|
|
|
"**/.#*", |
142
|
|
|
"**/%*%", |
143
|
|
|
// CVS missing |
144
|
|
|
"**/CVS/**", |
145
|
|
|
"**/.cvsignore", |
146
|
|
|
"**/SCCS", |
147
|
|
|
"**/SCCS/**", |
148
|
|
|
"**/vssver.scc", |
149
|
|
|
"**/.svn", |
150
|
|
|
"**/.svn/**", |
151
|
|
|
"**/._*", |
152
|
|
|
"**/.DS_Store", |
153
|
|
|
"**/.darcs", |
154
|
|
|
"**/.darcs/**", |
155
|
|
|
"**/.git", |
156
|
|
|
"**/.git/**", |
157
|
|
|
"**/.gitattributes", |
158
|
|
|
"**/.gitignore", |
159
|
|
|
"**/.gitmodules", |
160
|
|
|
"**/.hg", |
161
|
|
|
"**/.hg/**", |
162
|
|
|
"**/.hgignore", |
163
|
|
|
"**/.hgsub", |
164
|
|
|
"**/.hgsubstate", |
165
|
|
|
"**/.hgtags", |
166
|
|
|
"**/.bzr", |
167
|
|
|
"**/.bzr/**", |
168
|
|
|
"**/.bzrignore", |
169
|
|
|
]; |
170
|
|
|
$this->executeTarget(__FUNCTION__); |
171
|
|
|
$this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes()); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
public function testCopyNoExplicitExcludes() |
175
|
|
|
{ |
176
|
|
|
$this->executeTarget(__FUNCTION__); |
177
|
|
|
$output = $this->getProject()->getProperty('output'); |
178
|
|
|
$this->assertFileExists(__DIR__ . '/../../../etc/tasks/system/defaultexcludes-test.xml'); |
179
|
|
|
$this->assertFileDoesNotExist($output . '/.svn/entries'); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function testCopyExplicitExcludes() |
183
|
|
|
{ |
184
|
|
|
$this->executeTarget(__FUNCTION__); |
185
|
|
|
$output = $this->getProject()->getProperty('output'); |
186
|
|
|
$this->assertFileExists(__DIR__ . '/../../../etc/tasks/system/defaultexcludes-test.xml'); |
187
|
|
|
$this->assertFileDoesNotExist($output . '/.svn/entries'); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function testCopyExplicitNoExcludes() |
191
|
|
|
{ |
192
|
|
|
$this->executeTarget(__FUNCTION__); |
193
|
|
|
$output = $this->getProject()->getProperty('output'); |
194
|
|
|
$this->assertFileExists(__DIR__ . '/../../../etc/tasks/system/defaultexcludes-test.xml'); |
195
|
|
|
$this->assertFileExists($output . '/.svn/entries'); |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|