Skip to content

Commit 4a03238

Browse files
committed
Added Widget unit tests.
1 parent 4e4b7b3 commit 4a03238

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/unit/Widgets/WidgetTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace PHPForm\Unit\Widgets;
3+
4+
use PHPUnit\Framework\TestCase;
5+
6+
use PHPForm\Widgets\Widget;
7+
8+
class WidgetTest extends TestCase
9+
{
10+
public function setUp()
11+
{
12+
$this->widget = $this->getMockForAbstractClass(Widget::class);
13+
}
14+
15+
public function testGetOptions()
16+
{
17+
$options = $this->widget->getOptions("name", "value");
18+
$this->assertEquals(array(), $options);
19+
}
20+
21+
public function testValueFromData()
22+
{
23+
$result = $this->widget->valueFromData(array("name" => "value"), array(), "name");
24+
$this->assertEquals("value", $result);
25+
}
26+
27+
public function testValueFromDataInexistent()
28+
{
29+
$result = $this->widget->valueFromData(array(), array(), "name");
30+
$this->assertNull($result);
31+
}
32+
33+
public function testBuildAutoId()
34+
{
35+
$this->assertEquals("id_name", $this->widget->buildAutoId("name"));
36+
$this->assertEquals("id_name_1", $this->widget->buildAutoId("name", 1));
37+
}
38+
}

0 commit comments

Comments
 (0)