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

TaskdefTaskTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testGlobal() 0 7 1
A testNoClassname() 0 3 1
A testNoName() 0 3 1
A testEmpty() 0 3 1
A testClassNotFound() 0 11 2
A testLocal() 0 7 1
A setUp() 0 3 1
A tesFile() 0 10 1
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\Exception\BuildException;
23
use Phing\Exception\ConfigurationException;
24
use Phing\Support\BuildFileTest;
25
use Phing\Support\TaskdefTestSimpleTask;
26
27
/**
28
 * @package phing.tasks.system
29
 */
30
class TaskdefTaskTest extends BuildFileTest
31
{
32
    public function setUp(): void
33
    {
34
        $this->configureProject(PHING_TEST_BASE . "/etc/tasks/taskdef.xml");
35
    }
36
37
    public function testEmpty()
38
    {
39
        $this->expectBuildException("empty", "required argument not specified");
40
    }
41
42
    public function testNoName()
43
    {
44
        $this->expectBuildException("noName", "required argument not specified");
45
    }
46
47
    public function testNoClassname()
48
    {
49
        $this->expectBuildException("noClassname", "required argument not specified");
50
    }
51
52
    public function testClassNotFound()
53
    {
54
        $this->expectException(BuildException::class);
55
56
        try {
57
            $this->executeTarget("classNotFound");
58
            $this->fail(
59
                "Should throw ConfigurationException because: " .
60
                "classname specified doesn't exist"
61
            );
62
        } catch (ConfigurationException $e) {
63
            //ignored
64
        }
65
    }
66
67
    public function testGlobal()
68
    {
69
        $this->expectLog("testGlobal", "simpletask: testGlobal echo");
70
        $refs = $this->project->getReferences();
71
        $ref = $refs["global"];
72
        $this->assertNotNull("ref is not null");
73
        $this->assertInstanceOf(TaskdefTestSimpleTask::class, $ref);
74
    }
75
76
    public function testLocal()
77
    {
78
        $this->expectLog("testLocal", "Task local will be handled by class " . TaskdefTestSimpleTask::class);
79
        $refs = $this->project->getReferences();
80
        $ref = $refs["local"];
81
        $this->assertNotNull("ref is not null");
82
        $this->assertInstanceOf(TaskdefTestSimpleTask::class, $ref);
83
    }
84
85
    public function tesFile()
86
    {
87
        $this->expectLog("testFile", "simpletask: testTdfile echo");
88
        $refs = $this->project->getReferences();
89
        $ref = $refs["tdfile"];
90
        $this->assertNotNull("ref is not null");
91
        $this->assertInstanceOf(TaskdefTestSimpleTask::class, $ref);
92
        $ref = $refs["tdfile2"];
93
        $this->assertNotNull("ref is not null");
94
        $this->assertInstanceOf(TaskdefTestSimpleTask::class, $ref);
95
    }
96
}
97