FormTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFormTags() 0 6 1
A testFormAttributesAndChildren() 0 24 1
1
<?php
2
/**
3
 * DronePHP (http://www.dronephp.com)
4
 *
5
 * @link      http://github.com/Pleets/DronePHP
6
 * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
7
 * @license   http://www.dronephp.com/license
8
 * @author    Darío Rivera <[email protected]>
9
 */
10
11
namespace DroneTest\Dom\Element;
12
13
use Drone\Dom\Attribute;
14
use Drone\Dom\Element\Form;
15
use Drone\Dom\Element\Input;
16
use PHPUnit\Framework\TestCase;
17
18
class FormTest extends TestCase
19
{
20
    /**
21
     * Tests form tag constructor
22
     *
23
     * @return null
24
     */
25
    public function testFormTags()
26
    {
27
        $form = new Form();
28
29
        $this->assertEquals('<form>', $form->getStartTag());
30
        $this->assertEquals('</form>', $form->getEndTag());
31
    }
32
33
    /**
34
     * Tests adding attributes and children
35
     *
36
     * @return null
37
     */
38
    public function testFormAttributesAndChildren()
39
    {
40
        $form = new Form();
41
42
        $this->assertEquals(0, count($form->getAttributes()));
43
        $this->assertEquals(0, count($form->getChildren()));
44
45
        # adding an attribute
46
        $form->setAttribute(new Attribute("action", "someurl"));
47
48
        $this->assertTrue($form->hasAttribute('action'));
49
50
        $attr = $form->getAttribute('action');
51
        $this->assertEquals("action", $attr->getName());
52
        $this->assertEquals("someurl", $attr->getValue());
53
54
        # adding an element
55
        $input = new Input();
56
        $input->setAttribute(new Attribute("type", "hidden"));
57
58
        $form->setChild("someinput", $input);
59
60
        $_input = $form->getChild('someinput');
61
        $this->assertInstanceOf('\Drone\Dom\Element\Input', $_input);
62
    }
63
}
64