|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class ParameterUnitTest extends \PHPUnit\Framework\TestCase |
|
4
|
|
|
{ |
|
5
|
|
|
private $parameter; |
|
6
|
|
|
|
|
7
|
|
|
protected function setUp(): void |
|
8
|
|
|
{ |
|
9
|
|
|
$this->parameter = new Parameter(); |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
|
|
public function testSetName() |
|
13
|
|
|
{ |
|
14
|
|
|
$this->parameter->setName(1); |
|
15
|
|
|
$this->assertEquals("1", $this->parameter->getName()); |
|
16
|
|
|
$this->parameter->setName("foo"); |
|
17
|
|
|
$this->assertEquals("foo", $this->parameter->getName()); |
|
18
|
|
|
} |
|
19
|
|
|
public function testSetType() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->parameter->setType(1); |
|
22
|
|
|
$this->assertEquals("1", $this->parameter->getType()); |
|
23
|
|
|
$this->parameter->setType("foo"); |
|
24
|
|
|
$this->assertEquals("foo", $this->parameter->getType()); |
|
25
|
|
|
} |
|
26
|
|
|
public function testSetValue() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->parameter->setValue(1); |
|
29
|
|
|
$this->assertEquals("1", $this->parameter->getValue()); |
|
30
|
|
|
$this->parameter->setValue("foo"); |
|
31
|
|
|
$this->assertEquals("foo", $this->parameter->getValue()); |
|
32
|
|
|
} |
|
33
|
|
|
public function testGetParamsNoneSet() |
|
34
|
|
|
{ |
|
35
|
|
|
$params = $this->parameter->getParams(); |
|
36
|
|
|
$this->assertEquals([], $params); |
|
37
|
|
|
} |
|
38
|
|
|
public function testCreateParamGetParams() |
|
39
|
|
|
{ |
|
40
|
|
|
$param = $this->parameter->createParam(); |
|
41
|
|
|
$class = get_class($param); |
|
42
|
|
|
$this->assertEquals("Parameter", $class); |
|
43
|
|
|
$params = $this->parameter->getParams(); |
|
44
|
|
|
$this->assertNotEquals([], $params); |
|
45
|
|
|
} |
|
46
|
|
|
public function testSetListeningValue() |
|
47
|
|
|
{ |
|
48
|
|
|
$slot = new RegisterSlot("key"); |
|
49
|
|
|
$slot->setValue("value1"); |
|
50
|
|
|
$this->parameter->setListeningValue($slot); |
|
51
|
|
|
$this->assertEquals("value1", $this->parameter->getValue()); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|