Passed
Push — master ( 345c9b...faecaf )
by Michiel
20:58
created

FileListTest::testSetRefidWithFileListSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
c 1
b 0
f 1
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
use PHPUnit\Framework\TestCase;
21
22
class FileListTest extends TestCase
23
{
24
    /**
25
     * @var Project
26
     */
27
    private $project;
28
29
    public function setUp(): void
30
    {
31
        $this->project = new Project();
32
        $this->project->setBasedir(PHING_TEST_BASE);
33
    }
34
35
    public function testGetFilesWithEmptyDir()
36
    {
37
        $this->expectException(BuildException::class);
38
        $this->expectExceptionMessage('No directory specified for filelist.');
39
40
        $f = new FileList();
41
        $f->getFiles($this->project);
42
    }
43
44
    public function testGetFilesWithNoFilenames()
45
    {
46
        $this->expectException(BuildException::class);
47
        $this->expectExceptionMessage('No files specified for filelist.');
48
49
        $f = new FileList();
50
        $f->setDir(new PhingFile("."));
51
        $f->getFiles($this->project);
52
    }
53
    public function testSetRefidWithDirSet()
54
    {
55
        $this->expectException(BuildException::class);
56
        $this->expectExceptionMessage("You must not specify more than one attribute when using refid");
57
58
        $f = new FileList();
59
        $f->setDir(new PhingFile("."));
60
        $project = new Project();
61
        $project->setBasedir(__DIR__);
62
        $f->setRefid(new Reference($this->project, "dummy"));
63
    }
64
65
    public function testSetRefidWithFileListSet()
66
    {
67
        $this->expectException(BuildException::class);
68
        $this->expectExceptionMessage("You must not specify more than one attribute when using refid");
69
70
        $f = new FileList();
71
        $f->setFiles('foo.php');
0 ignored issues
show
Bug introduced by
'foo.php' of type string is incompatible with the type array expected by parameter $filenames of FileList::setFiles(). ( Ignorable by Annotation )

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

71
        $f->setFiles(/** @scrutinizer ignore-type */ 'foo.php');
Loading history...
72
        $project = new Project();
73
        $project->setBasedir(__DIR__);
74
        $f->setRefid(new Reference($this->project, "dummy"));
75
    }
76
    public function testSetListfile()
77
    {
78
        $f = new FileList();
79
        $f->setListFile("foo.php");
80
        $project = new Project();
81
        $project->setBasedir(__DIR__);
82
        $l = $f->getListFile($project);
83
        $this->assertEquals($l->getPath(), "foo.php");
84
    }
85
}
86