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\Io\File; |
23
|
|
|
use Phing\Support\BuildFileTest; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @author Bryan Davis <[email protected]> |
27
|
|
|
* @package phing.tasks.system |
28
|
|
|
*/ |
29
|
|
|
class ImportTaskTest extends BuildFileTest |
30
|
|
|
{ |
31
|
|
|
public function setUp(): void |
32
|
|
|
{ |
33
|
|
|
$this->configureProject(PHING_TEST_BASE . "/etc/tasks/importing.xml"); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testOverloadedTarget() |
37
|
|
|
{ |
38
|
|
|
$f1 = new File(PHING_TEST_BASE . "/etc/tasks/importing.xml"); |
39
|
|
|
|
40
|
|
|
$this->executeTarget("main"); |
41
|
|
|
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " main target."); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testImportedTarget() |
45
|
|
|
{ |
46
|
|
|
$f1 = new File(PHING_TEST_BASE . "/etc/tasks/imports/imported.xml"); |
47
|
|
|
$f2 = new File(PHING_TEST_BASE . "/etc/tasks/imports"); |
48
|
|
|
|
49
|
|
|
$this->executeTarget("imported"); |
50
|
|
|
$this->assertInLogs("phing.file.imported=" . $f1->getAbsolutePath()); |
51
|
|
|
$this->assertInLogs("imported.basedir=" . $f2->getAbsolutePath()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testImported2Target() |
55
|
|
|
{ |
56
|
|
|
$f1 = new File(PHING_TEST_BASE . "/etc/tasks/imports/importedImport.xml"); |
57
|
|
|
|
58
|
|
|
$this->executeTarget("imported2"); |
59
|
|
|
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " imported2 target."); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testImportedMultiTarget() |
63
|
|
|
{ |
64
|
|
|
$this->configureProject(PHING_TEST_BASE . "/etc/tasks/importing-multi.xml"); |
65
|
|
|
|
66
|
|
|
$this->assertInLogs("parsing buildfile imported-multi-1.xml"); |
67
|
|
|
$this->assertInLogs("parsing buildfile imported-multi-2.xml"); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function testCascadeTarget() |
71
|
|
|
{ |
72
|
|
|
$f1 = new File(PHING_TEST_BASE . "/etc/tasks/imports/imported.xml"); |
73
|
|
|
$f2 = new File(PHING_TEST_BASE . "/etc/tasks/importing.xml"); |
74
|
|
|
|
75
|
|
|
$this->executeTarget("cascade"); |
76
|
|
|
$this->assertInLogs("This comes from the imported.properties file"); |
77
|
|
|
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " main target."); |
78
|
|
|
$this->assertInLogs("This is " . $f2->getAbsolutePath() . " cascade target."); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function testFlipFlopTarget() |
82
|
|
|
{ |
83
|
|
|
// calls target in main that depends on target in import that depends on |
84
|
|
|
// target orverridden in main |
85
|
|
|
$this->executeTarget("flipflop"); |
86
|
|
|
$f1 = new File(PHING_TEST_BASE . "/etc/tasks/importing.xml"); |
87
|
|
|
$f2 = new File(PHING_TEST_BASE . "/etc/tasks/imports/imported.xml"); |
88
|
|
|
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " flop target."); |
89
|
|
|
$this->assertInLogs("This is " . $f2->getAbsolutePath() . " flip target."); |
90
|
|
|
$this->assertInLogs("This is " . $f1->getAbsolutePath() . " flipflop target."); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function testOnlyTopLevel() |
94
|
|
|
{ |
95
|
|
|
$this->expectBuildExceptionContaining( |
96
|
|
|
__FUNCTION__, |
97
|
|
|
'Import can only be used as a top-level task', |
98
|
|
|
'import only allowed as a top-level task' |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|