Passed
Push — master ( 972120...1c77fc )
by Michiel
08:19
created

DefaultExcludesTest::test1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 33
nc 1
nop 0
dl 0
loc 36
rs 9.392
c 0
b 0
f 0
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;
0 ignored issues
show
introduced by
The private property $output is not used, and could be removed.
Loading history...
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());
0 ignored issues
show
Bug introduced by
The method assertArraySubset() does not exist on Phing\Tasks\System\DefaultExcludesTest. Did you maybe mean assertArrayHasKey()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

88
        $this->/** @scrutinizer ignore-call */ 
89
               assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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