Passed
Push — master ( b90d2b...4d6caf )
by Siad
13:52
created

testIfReferencesSetThenCreatExcludesFileThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
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
class PatternSetTest extends \PHPUnit\Framework\TestCase
21
{
22
    private $patternset;
23
24
    protected function setUp(): void
25
    {
26
        $this->patternset = new PatternSet();
27
    }
28
29
    public function testBothEmpty()
30
    {
31
        $s = "" . $this->patternset;
32
        $this->assertEquals($s, "patternSet{ includes: empty  excludes: empty }");
33
        $this->assertEquals(false, $this->patternset->hasPatterns());
34
    }
35
36
    public function testIfReferenceSetThenCreateIncludeThrowsException()
37
    {
38
        $project = new Project();
39
        $reference = new Reference($project);
40
        $this->patternset->setRefId($reference);
41
42
        $this->expectException(BuildException::class);
43
        $this->expectExceptionMessage('You must not specify nested elements when using refid');
44
45
        $this->patternset->createInclude();
46
    }
47
48
    public function testIfReferenceSetThenCreateExcludeThrowsException()
49
    {
50
        $project = new Project();
51
        $reference = new Reference($project);
52
        $this->patternset->setRefId($reference);
53
54
        $this->expectException(BuildException::class);
55
        $this->expectExceptionMessage('You must not specify nested elements when using refid');
56
57
        $this->patternset->createExclude();
58
    }
59
60
    public function testIfReferencesSetThenCreatExcludesFileThrowsException()
61
    {
62
        $project = new Project();
63
        $reference = new Reference($project);
64
        $this->patternset->setRefId($reference);
65
66
        $this->expectException(BuildException::class);
67
        $this->expectExceptionMessage('You must not specify nested elements when using refid');
68
69
        $this->patternset->createExcludesFile();
70
    }
71
72
    public function testIfReferencesSetThenCreatIncludesFileThrowsException()
73
    {
74
        $project = new Project();
75
        $reference = new Reference($project);
76
        $this->patternset->setRefId($reference);
77
78
        $this->expectException(BuildException::class);
79
        $this->expectExceptionMessage('You must not specify nested elements when using refid');
80
81
        $this->patternset->createIncludesFile();
82
    }
83
}
84