Completed
Push — master ( 3a35d5...02819f )
by Gabriel
08:58
created

RadioGroupTest::generateTestRenderer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Nip\Form\Tests\Renderer\Elements;
4
5
use Nip\Form\Tests\AbstractTest;
6
7
/**
8
 * Class RadioGroupTest
9
 * @package Nip\Form\Tests\Renderer\Elements
10
 */
11
class RadioGroupTest extends AbstractTest
12
{
13
    public function testRenderEmptyElement()
14
    {
15
        $renderer = $this->generateTestRenderer();
16
        $html = $renderer->render();
17
18
        self::assertSame('', $html);
19
    }
20
21 View Code Duplication
    public function testRenderSimpleElement()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $renderer = $this->generateTestRenderer();
24
        $renderer->getElement()->addOption('123', 'Age');
25
        $renderer->getElement()->addOption('789', 'Height');
26
        $html = $renderer->render();
27
28
        self::assertSame(
29
            '<div class="form-check">'
30
            .'<label class="form-check-label">'
31
            .'<input  type="radio" name="" value="123" checked="checked" class="form-check-input " title="Age" />'
32
            .'Age'
33
            .'</label>'
34
            .'</div><br />'
35
            .'<div class="form-check">'
36
            .'<label class="form-check-label">'
37
            .'<input  type="radio" name="" value="789" class="form-check-input " title="Height" />'
38
            .'Height'
39
            .'</label>'
40
            .'</div>',
41
            $html
42
        );
43
    }
44
45 View Code Duplication
    public function testRenderAutoSelectFirstFalse()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        $renderer = $this->generateTestRenderer();
48
        $renderer->getElement()->autoSelectFirst(false);
49
        $renderer->getElement()->addOption('123', 'Age');
50
        $renderer->getElement()->addOption('789', 'Height');
51
        $html = $renderer->render();
52
53
        self::assertSame(
54
            '<div class="form-check">'
55
            .'<label class="form-check-label">'
56
            .'<input  type="radio" name="" value="123" class="form-check-input " title="Age" />'
57
            .'Age'
58
            .'</label>'
59
            .'</div><br />'
60
            .'<div class="form-check">'
61
            .'<label class="form-check-label">'
62
            .'<input  type="radio" name="" value="789" class="form-check-input " title="Height" />'
63
            .'Height'
64
            .'</label>'
65
            .'</div>',
66
            $html
67
        );
68
    }
69
70
    /**
71
     * @return \Nip_Form_Renderer_Elements_RadioGroup
72
     */
73
    protected function generateTestRenderer()
74
    {
75
        $input = new \Nip_Form_Element_RadioGroup(new \Nip\Form\Form());
76
        $render = new \Nip_Form_Renderer_Elements_RadioGroup();
77
        $render->setElement($input);
78
        return $render;
79
    }
80
}
81