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

MoveTaskTest::testMoveFileSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
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\Support\BuildFileTest;
23
24
/**
25
 * Tests the Move Task
26
 *
27
 * @author  Michiel Rook <[email protected]>
28
 * @package phing.tasks.system
29
 */
30
class MoveTaskTest extends BuildFileTest
31
{
32
    public function setUp(): void
33
    {
34
        $this->configureProject(
35
            PHING_TEST_BASE
36
            . "/etc/tasks/system/MoveTaskTest.xml"
37
        );
38
        $this->executeTarget("setup");
39
    }
40
41
    public function tearDown(): void
42
    {
43
        $this->executeTarget("clean");
44
    }
45
46
    public function testMoveSingleFile()
47
    {
48
        $this->executeTarget(__FUNCTION__);
49
        $this->assertFileExists(PHING_TEST_BASE . '/etc/tasks/system/tmp/fileB');
50
    }
51
52
    public function testMoveFileSet()
53
    {
54
        $this->executeTarget(__FUNCTION__);
55
        $this->assertFileDoesNotExist(PHING_TEST_BASE . '/etc/tasks/system/tmp/base/fileA');
56
        $this->assertFileExists(PHING_TEST_BASE . '/etc/tasks/system/tmp/new/fileA');
57
    }
58
59
    public function testRenameDirectory()
60
    {
61
        $this->executeTarget(__FUNCTION__);
62
        $this->assertFileDoesNotExist(PHING_TEST_BASE . '/etc/tasks/system/tmp/base/fileA');
63
        $this->assertFileExists(PHING_TEST_BASE . '/etc/tasks/system/tmp/new/fileA');
64
    }
65
66
    /**
67
     * Regression test for ticket {@link http://www.phing.info/trac/ticket/582}
68
     * - Add haltonerror attribute to copy/move tasks
69
     */
70
    public function testIgnoreErrors()
71
    {
72
        $this->executeTarget(__FUNCTION__);
73
        $this->assertInLogs("Could not find file ");
74
    }
75
76
    /**
77
     * Regression test for ticket {@link http://www.phing.info/trac/ticket/307}
78
     * - Replaceregexp filter works in Copy task but not Move task
79
     */
80
    public function testReplaceRegexp()
81
    {
82
        $this->executeTarget(__FUNCTION__);
83
84
        $contents = file_get_contents(PHING_TEST_BASE . "/etc/tasks/system/tmp/anotherfile.bak");
85
86
        $this->assertEquals("BAR", $contents);
87
    }
88
89
    public function testGranularity()
90
    {
91
        $this->expectLogContaining(__FUNCTION__, 'Test omitted, Test is up to date');
92
    }
93
}
94