Completed
Push — master ( c4c6a2...1fc5e4 )
by Siad
12:41
created

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