|
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
|
|
|
* Tests the Copy Task |
|
22
|
|
|
* |
|
23
|
|
|
* @author Michiel Rook <[email protected]> |
|
24
|
|
|
* @package phing.tasks.system |
|
25
|
|
|
*/ |
|
26
|
|
|
class CopyTaskTest extends BuildFileTest |
|
27
|
|
|
{ |
|
28
|
|
|
public function setUp(): void |
|
29
|
|
|
{ |
|
30
|
|
|
$this->configureProject( |
|
31
|
|
|
PHING_TEST_BASE |
|
32
|
|
|
. "/etc/tasks/system/CopyTaskTest.xml" |
|
33
|
|
|
); |
|
34
|
|
|
$this->executeTarget("setup"); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function tearDown(): void |
|
38
|
|
|
{ |
|
39
|
|
|
$this->executeTarget("clean"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @requires OS ^(?:(?!Win).)*$ |
|
44
|
|
|
*/ |
|
45
|
|
|
public function testCopyDanglingSymlink() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->executeTarget("testCopyDanglingSymlink"); |
|
48
|
|
|
$this->assertInLogs("Copying 1 file to"); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Test for {@link http://www.phing.info/trac/ticket/981} |
|
53
|
|
|
* FileUtil::copyFile(): preserveLastModified causes |
|
54
|
|
|
* empty symlink target file |
|
55
|
|
|
* |
|
56
|
|
|
* @requires OS ^(?:(?!Win).)*$ |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testCopySymlinkPreserveLastModifiedShouldCopyTarget() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->executeTarget(__FUNCTION__); |
|
61
|
|
|
$this->assertInLogs("Copying 2 files to"); |
|
62
|
|
|
$this->assertGreaterThan(0, $this->project->getProperty('test.filesize')); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Regression test for ticket {@link http://www.phing.info/trac/ticket/229} |
|
67
|
|
|
* - CopyTask should accept filelist subelement |
|
68
|
|
|
*/ |
|
69
|
|
|
public function testCopyFileList() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->executeTarget(__FUNCTION__); |
|
72
|
|
|
$this->assertInLogs("Copying 2 files to"); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* - CopyTask should accept dirset subelement |
|
77
|
|
|
*/ |
|
78
|
|
|
public function testCopyDirSet() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->executeTarget(__FUNCTION__); |
|
81
|
|
|
$this->assertInLogs("Copying 2 files to"); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Regression test for ticket {@link https://github.com/phingofficial/phing/issues/562} |
|
86
|
|
|
* - Error overwriting symlinks on copy or move |
|
87
|
|
|
* |
|
88
|
|
|
* @requires OS ^(?:(?!Win).)*$ |
|
89
|
|
|
*/ |
|
90
|
|
|
public function testOverwriteExistingSymlink() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->executeTarget(__FUNCTION__); |
|
93
|
|
|
$this->assertInLogs("Copying 1 file to"); |
|
94
|
|
|
$this->assertEquals("tmp/target-a", readlink(PHING_TEST_BASE . "/etc/tasks/system/tmp/link-b")); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function testGranularity() |
|
98
|
|
|
{ |
|
99
|
|
|
$this->expectLogContaining(__FUNCTION__, 'Test omitted, Test is up to date'); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|