Test Failed
Push — master ( 440ce5...0cdbc1 )
by Siad
07:01
created

DefaultExcludesTest::testCopyExplicitNoExcludes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
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
/**
21
 * Tests the DefaultExcludes Task
22
 *
23
 * @author  Siad Ardroumli
24
 * @package phing.tasks.system
25
 */
26
class DefaultExcludesTest extends BuildFileTest
27
{
28
    private $output;
0 ignored issues
show
introduced by
The private property $output is not used, and could be removed.
Loading history...
29
30
    public function setUp(): void
31
    {
32
        $this->configureProject(
33
            PHING_TEST_BASE
0 ignored issues
show
Bug introduced by
The constant PHING_TEST_BASE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
            . "/etc/tasks/system/defaultexcludes-test.xml"
35
        );
36
        $this->executeTarget("setup");
37
    }
38
39
    public function tearDown(): void
40
    {
41
        $this->executeTarget("clean");
42
        $this->executeTarget("cleanup-excludes");
43
    }
44
45
    public function test1()
46
    {
47
        $expected = [
48
            "**/*~",
49
            "**/#*#",
50
            "**/.#*",
51
            "**/%*%",
52
            "**/CVS",
53
            "**/CVS/**",
54
            "**/.cvsignore",
55
            "**/SCCS",
56
            "**/SCCS/**",
57
            "**/vssver.scc",
58
            "**/.svn",
59
            "**/.svn/**",
60
            "**/._*",
61
            "**/.DS_Store",
62
            "**/.darcs",
63
            "**/.darcs/**",
64
            "**/.git",
65
            "**/.git/**",
66
            "**/.gitattributes",
67
            "**/.gitignore",
68
            "**/.gitmodules",
69
            "**/.hg",
70
            "**/.hg/**",
71
            "**/.hgignore",
72
            "**/.hgsub",
73
            "**/.hgsubstate",
74
            "**/.hgtags",
75
            "**/.bzr",
76
            "**/.bzr/**",
77
            "**/.bzrignore",
78
        ];
79
        $this->executeTarget(__FUNCTION__);
80
        $this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

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

80
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
81
    }
82
83
    public function test2()
84
    {
85
        $expected = [
86
            "**/*~",
87
            "**/#*#",
88
            "**/.#*",
89
            "**/%*%",
90
            "**/CVS",
91
            "**/CVS/**",
92
            "**/.cvsignore",
93
            "**/SCCS",
94
            "**/SCCS/**",
95
            "**/vssver.scc",
96
            "**/.svn",
97
            "**/.svn/**",
98
            "**/._*",
99
            "**/.DS_Store",
100
            "**/.darcs",
101
            "**/.darcs/**",
102
            "**/.git",
103
            "**/.git/**",
104
            "**/.gitattributes",
105
            "**/.gitignore",
106
            "**/.gitmodules",
107
            "**/.hg",
108
            "**/.hg/**",
109
            "**/.hgignore",
110
            "**/.hgsub",
111
            "**/.hgsubstate",
112
            "**/.hgtags",
113
            "**/.bzr",
114
            "**/.bzr/**",
115
            "**/.bzrignore",
116
            "foo"
117
        ];
118
        $this->executeTarget(__FUNCTION__);
119
        $this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

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

119
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
120
    }
121
122
    public function test3()
123
    {
124
        $expected = [
125
            "**/*~",
126
            "**/#*#",
127
            "**/.#*",
128
            "**/%*%",
129
            // CVS missing
130
            "**/CVS/**",
131
            "**/.cvsignore",
132
            "**/SCCS",
133
            "**/SCCS/**",
134
            "**/vssver.scc",
135
            "**/.svn",
136
            "**/.svn/**",
137
            "**/._*",
138
            "**/.DS_Store",
139
            "**/.darcs",
140
            "**/.darcs/**",
141
            "**/.git",
142
            "**/.git/**",
143
            "**/.gitattributes",
144
            "**/.gitignore",
145
            "**/.gitmodules",
146
            "**/.hg",
147
            "**/.hg/**",
148
            "**/.hgignore",
149
            "**/.hgsub",
150
            "**/.hgsubstate",
151
            "**/.hgtags",
152
            "**/.bzr",
153
            "**/.bzr/**",
154
            "**/.bzrignore",
155
        ];
156
        $this->executeTarget(__FUNCTION__);
157
        $this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

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

157
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset($expected, DirectoryScanner::getDefaultExcludes());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
158
    }
159
160
    public function testCopyNoExplicitExcludes()
161
    {
162
        $this->executeTarget(__FUNCTION__);
163
        $output = $this->getProject()->getProperty('output');
164
        $this->assertFileExists(__DIR__ . '/../../../../etc/tasks/system/defaultexcludes-test.xml');
165
        $this->assertFileNotExists($output . '/.svn/entries');
166
    }
167
168
    public function testCopyExplicitExcludes()
169
    {
170
        $this->executeTarget(__FUNCTION__);
171
        $output = $this->getProject()->getProperty('output');
172
        $this->assertFileExists(__DIR__ . '/../../../../etc/tasks/system/defaultexcludes-test.xml');
173
        $this->assertFileNotExists($output . '/.svn/entries');
174
    }
175
176
    public function testCopyExplicitNoExcludes()
177
    {
178
        $this->executeTarget(__FUNCTION__);
179
        $output = $this->getProject()->getProperty('output');
180
        $this->assertFileExists(__DIR__ . '/../../../../etc/tasks/system/defaultexcludes-test.xml');
181
        $this->assertFileExists($output . '/.svn/entries');
182
    }
183
}
184