Passed
Push — master ( cbf6d3...d62b89 )
by Michiel
08:56
created

ParameterTest::testCreateParamGetParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Phing\Type;
4
5
use Phing\Util\RegisterSlot;
6
7
/**
8
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
13
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
16
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
 *
20
 * This software consists of voluntary contributions made by many individuals
21
 * and is licensed under the LGPL. For more information please see
22
 * <http://phing.info>.
23
 */
24
class ParameterTest extends \PHPUnit\Framework\TestCase
25
{
26
    private $parameter;
27
28
    protected function setUp(): void
29
    {
30
        $this->parameter = new Parameter();
31
    }
32
33
    public function testSetName()
34
    {
35
        $this->parameter->setName(1);
36
        $this->assertEquals("1", $this->parameter->getName());
37
        $this->parameter->setName("foo");
38
        $this->assertEquals("foo", $this->parameter->getName());
39
    }
40
41
    public function testSetType()
42
    {
43
        $this->parameter->setType(1);
44
        $this->assertEquals("1", $this->parameter->getType());
45
        $this->parameter->setType("foo");
46
        $this->assertEquals("foo", $this->parameter->getType());
47
    }
48
49
    public function testSetValue()
50
    {
51
        $this->parameter->setValue(1);
52
        $this->assertEquals("1", $this->parameter->getValue());
53
        $this->parameter->setValue("foo");
54
        $this->assertEquals("foo", $this->parameter->getValue());
55
    }
56
57
    public function testGetParamsNoneSet()
58
    {
59
        $params = $this->parameter->getParams();
60
        $this->assertEquals([], $params);
61
    }
62
63
    public function testCreateParamGetParams()
64
    {
65
        $param = $this->parameter->createParam();
66
        $class = get_class($param);
67
        $this->assertEquals(Parameter::class, $class);
68
        $params = $this->parameter->getParams();
69
        $this->assertNotEquals([], $params);
70
    }
71
72
    public function testSetListeningValue()
73
    {
74
        $slot = new RegisterSlot("key");
75
        $slot->setValue("value1");
76
        $this->parameter->setListeningValue($slot);
77
        $this->assertEquals("value1", $this->parameter->getValue());
78
    }
79
}
80