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

PropertyTaskTest::test4()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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\Exception\BuildException;
23
use Phing\Support\BuildFileTest;
24
25
/**
26
 * @author Hans Lellelid (Phing)
27
 * @author Conor MacNeill (Ant)
28
 * @package phing.tasks.system
29
 */
30
class PropertyTaskTest extends BuildFileTest
31
{
32
    public function setUp(): void
33
    {
34
        $this->configureProject(PHING_TEST_BASE . "/etc/tasks/property.xml");
35
    }
36
37
    public function test1()
38
    {
39
        // should get no output at all
40
        $this->expectOutputAndError("test1", "", "");
41
    }
42
43
    public function test2()
44
    {
45
        $this->expectLog("test2", "testprop1=aa, testprop3=xxyy, testprop4=aazz");
46
    }
47
48
    public function test4()
49
    {
50
        $this->expectLog("test4", "http.url is http://localhost:999");
51
    }
52
53
    public function testPrefixSuccess()
54
    {
55
        $this->executeTarget("prefix.success");
56
        $this->assertEquals("80", $this->project->getProperty("server1.http.port"));
57
    }
58
59
    public function testPrefixFailure()
60
    {
61
        $this->expectException(BuildException::class);
62
        $this->expectExceptionMessageMatches('/Prefix is only valid/');
63
64
        $this->executeTarget("prefix.fail");
65
    }
66
67
    public function testFilterChain()
68
    {
69
        $this->executeTarget(__FUNCTION__);
70
        $this->assertEquals("World", $this->project->getProperty("filterchain.test"));
71
    }
72
73
    public function circularDefinitionTargets()
74
    {
75
        return [
76
            ['test3'],
77
            ['testCircularDefinition1'],
78
            ['testCircularDefinition2'],
79
        ];
80
    }
81
82
    /**
83
     * @dataProvider circularDefinitionTargets
84
     */
85
    public function testCircularDefinitionDetection($target)
86
    {
87
        $this->expectException(BuildException::class);
88
        $this->expectExceptionMessageMatches('/was circularly defined/');
89
90
        $this->executeTarget($target);
91
    }
92
93
    public function testToString()
94
    {
95
        $this->expectLog(__FUNCTION__, 'sourcefiles = filehash.bin');
96
    }
97
98
    /**
99
     * Inspired by @link http://www.phing.info/trac/ticket/1118
100
     * This test should not throw exceptions
101
     */
102
    public function testUsingPropertyTwiceInPropertyValueShouldNotThrowException()
103
    {
104
        $this->expectNotToPerformAssertions();
105
        $this->executeTarget(__FUNCTION__);
106
    }
107
108
    public function testRequired()
109
    {
110
        $this->expectBuildException(__FUNCTION__, 'Unable to find property file.');
111
    }
112
}
113