Passed
Push — master ( 28a3ce...b9357e )
by Siad
05:23
created

ModifiedSelectorTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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
/**
21
 * Class ModifiedSelectorTest
22
 */
23
class ModifiedSelectorTest extends BuildFileTest
24
{
25
    public function setUp(): void
26
    {
27
        $this->configureProject(
28
            PHING_TEST_BASE . '/etc/types/selectors/ModifiedSelectorTest.xml'
29
        );
30
        $this->executeTarget('setup');
31
    }
32
33
    public function tearDown(): void
34
    {
35
        $this->executeTarget('clean');
36
    }
37
38
    public function testOneFile(): void
39
    {
40
        $this->executeTarget(__FUNCTION__);
41
        $project = $this->getProject();
42
        $output = $project->getProperty('phing.dir');
43
        $this->assertFileExists($output . '/cc.properties');
44
    }
45
46
    public function testWithParam(): void
47
    {
48
        $this->executeTarget(__FUNCTION__);
49
        $project = $this->getProject();
50
        $output = $project->getProperty('phing.dir');
51
        $this->assertFileExists($output . '/cc.properties');
52
    }
53
54
    /** Test correct use of cache names. */
55
    public function testValidateWrongCache()
56
    {
57
        $name = "this-is-not-a-valid-cache-name";
58
        $this->expectException(BuildException::class);
59
        $this->expectExceptionMessage('Cache must be set');
60
        $sel = new ModifiedSelector();
61
        $sel->setCache($name);
62
        $sel->validate();
63
    }
64
65
    /** Test correct use of algorithm names. */
66
    public function testValidateWrongAlgorithm()
67
    {
68
        $name = "this-is-not-a-valid-algorithm-name";
69
        $this->expectException(BuildException::class);
70
        $this->expectExceptionMessage('Algorithm must be set');
71
        $sel = new ModifiedSelector();
72
        $sel->setAlgorithm($name);
73
        $sel->validate();
74
    }
75
}
76