Completed
Push — master ( 0a8746...607cf5 )
by Siad
13:31
created

TruncateTaskTest::testExplicitUnit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
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
/**
22
 * Tests the Truncate Task
23
 *
24
 * @author  Siad Ardroumli <[email protected]>
25
 * @package phing.tasks.system
26
 */
27
class TruncateTaskTest extends BuildFileTest
28
{
29
    public function setUp(): void
30
    {
31
        $this->configureProject(
32
            PHING_TEST_BASE
33
            . "/etc/tasks/system/TruncateTaskTest.xml"
34
        );
35
        $this->executeTarget("setup");
36
    }
37
38
    public function tearDown(): void
39
    {
40
        $this->executeTarget("clean");
41
    }
42
43
    public function testBasic()
44
    {
45
        $this->executeTarget(__FUNCTION__);
46
        $this->assertSame($this->getProject()->getProperty('test.basic.length'), 0);
47
    }
48
49
    public function testExplicit()
50
    {
51
        $this->executeTarget(__FUNCTION__);
52
        $this->assertSame($this->getProject()->getProperty('test.explicit.length'), 1034);
53
    }
54
55
    public function testExplicitUnit()
56
    {
57
        $this->executeTarget(__FUNCTION__);
58
        $this->assertSame($this->getProject()->getProperty('test.explicit.unit.length'), 1024);
59
    }
60
61
    public function testExtend()
62
    {
63
        $this->executeTarget(__FUNCTION__);
64
        $this->assertSame($this->getProject()->getProperty('test.extend.length'), 5);
65
        $this->assertSame($this->getProject()->getProperty('test.extend.adjust.length'), 10);
66
    }
67
68
    public function testTruncate()
69
    {
70
        $this->executeTarget(__FUNCTION__);
71
        $this->assertSame($this->getProject()->getProperty('test.truncate.length'), 5);
72
        $this->assertSame($this->getProject()->getProperty('test.truncate.adjust.length'), 0);
73
    }
74
75
    public function testNoCreate()
76
    {
77
        $this->executeTarget(__FUNCTION__);
78
        $this->assertFileNotExists($this->getProject()->getProperty('tmp.dir') . '/foo');
79
    }
80
81
    public function testMkdirs()
82
    {
83
        $this->assertFileNotExists($this->getProject()->getProperty('tmp.dir') . '/baz');
84
        $this->executeTarget(__FUNCTION__);
85
        $this->assertSame($this->getProject()->getProperty('test.mkdirs.length'), 0);
86
    }
87
88
    public function testInvalidAttrs()
89
    {
90
        $this->expectException(BuildException::class);
91
92
        $this->executeTarget(__FUNCTION__);
93
    }
94
95
    public function testBadLength()
96
    {
97
        $this->expectException(BuildException::class);
98
99
        $this->executeTarget(__FUNCTION__);
100
    }
101
102
    public function testNoFiles()
103
    {
104
        $this->expectException(BuildException::class);
105
106
        $this->executeTarget(__FUNCTION__);
107
    }
108
}
109