Completed
Push — master ( ffa95e...df33b7 )
by Siad
13:09
created

VisualizerTaskTest::testCustomServer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
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
 * @requires extension xsl
22
 */
23
class VisualizerTaskTest extends BuildFileTest
24
{
25
    public function setUp(): void
26
    {
27
        $this->configureProject(PHING_TEST_BASE . '/etc/tasks/ext/visualizer/VisualizerTaskTest.xml');
28
    }
29
30
    public function tearDown(): void
31
    {
32
        $this->executeTarget('clean');
33
    }
34
35
    /**
36
     * Testing different diagram formats: png, puml, svg and eps
37
     */
38
    public function testFormat()
39
    {
40
        $this->executeTarget(__FUNCTION__);
41
        $this->assertFileExists(PHING_TEST_BASE . '/etc/tasks/ext/visualizer/VisualizerTaskTest.puml');
42
        $this->assertInLogs('VisualizerTaskTest.puml');
43
        $this->assertFileSizeAtLeast(PHING_TEST_BASE . '/etc/tasks/ext/visualizer/VisualizerTaskTest.puml', 1200);
44
    }
45
46
    /**
47
     * Test that an exception is raised when invalid format is used
48
     */
49
    public function testInvalidFormat()
50
    {
51
        $this->expectBuildException(__FUNCTION__, "'jpg' is not a valid format");
52
        $this->assertInLogs("'jpg' is not a valid format");
53
    }
54
55
    /**
56
     * Testing custom destination including filename
57
     */
58
    public function testDestinationFile()
59
    {
60
        $this->executeTarget(__FUNCTION__);
61
        $this->assertFileExists(PHING_TEST_BASE . '/tmp/my-diagram.puml');
62
        $this->assertInLogs('my-diagram.puml');
63
        $this->assertFileSizeAtLeast(PHING_TEST_BASE . '/tmp/my-diagram.puml', 1200);
64
    }
65
66
    /**
67
     * Testing custom destination without filename
68
     */
69
    public function testDestinationDirectory()
70
    {
71
        $this->executeTarget(__FUNCTION__);
72
        $this->assertFileExists(PHING_TEST_BASE . '/tmp/VisualizerTaskTest.puml');
73
        $this->assertInLogs('VisualizerTaskTest.puml');
74
        $this->assertFileSizeAtLeast(PHING_TEST_BASE . '/tmp/VisualizerTaskTest.puml', 1200);
75
    }
76
77
    /**
78
     * Testing that an exception is raised when an invalid directory is used as destination
79
     */
80
    public function testInvalidDestination()
81
    {
82
        $this->expectBuildException(__FUNCTION__, "Directory 'foo/bar/baz/' is invalid");
83
        $this->assertInLogs("Directory 'foo/bar/baz/' is invalid");
84
    }
85
86
    /**
87
     * Testing that exception is raised when an invalid URL is used
88
     */
89
    public function testInvalidServer()
90
    {
91
        $this->expectBuildException(__FUNCTION__, 'Invalid PlantUml server');
92
        $this->assertInLogs('Invalid PlantUml server');
93
    }
94
}
95