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