<commit_before><?php

class FormTest extends \tests\cases\Field
{
    /**
     * @dataProvider getInputProvider
     */
    public function testGetInput($options, $expected)
    {
        $field = $this->getField();
        $field->config($options);
        $this->assertEquals($expected, $field->getBeginTag());
        $this->assertEquals('</form>', $field->getEndTag());
    }

    public function getInputProvider()
    {
        return [
            'simple field' => [
                [
                    'attributes' => [
                        'action' => '/test/',
                    ],
                ],
                '<form action="/test/">',
            ],
            'xss in attribute' => [
                [
                    'attributes' => [
                        'action' => '" onclick="" param="',
                    ],
                ],
                '<form action="&quot; onclick=&quot;&quot; param=&quot;">',
            ],
        ];
    }

    public function testGetInputFromTemplate()
    {
        $field = $this->getField();
        $field->setTemplate(__DIR__.'/../../files/template.php');
        $this->assertEquals("test_template\n", $field->getInput());
    }

    public function testLoadData()
    {
        $field = $this->getField();
        $field->setName('form');
        $field->loadData(['form' => [
            'child' => 'test',
            'child3' => 'test3',
        ]]);
        $this->assertEquals(['child' => 'test', 'child2' => null], $field->getValue());
    }

    public function testGetElement()
    {
        $field = $this->getField();
        $this->assertInstanceOf('\serviform\IElement', $field->getElement('child'));
        $this->assertEquals($field, $field->getElement('child')->getParent());
        $this->assertInstanceOf('\serviform\IElement', $field->getElement('child2'));
        $this->assertEquals($field, $field->getElement('child2')->getParent());
        $this->assertEquals(null, $field->getElement('child3'));
    }

    public function testGetElements()
    {<commit_msg>add tests for default template for form class<commit_after><?php

class FormTest extends \tests\cases\Field
{
    /**
     * @dataProvider getInputProvider
     */
    public function testGetInput($options, $expected)
    {
        $field = $this->getField();
        $field->config($options);
        $this->assertEquals($expected, $field->getBeginTag());
        $this->assertEquals('</form>', $field->getEndTag());
    }

    public function getInputProvider()
    {
        return [
            'simple field' => [
                [
                    'attributes' => [
                        'action' => '/test/',
                    ],
                ],
                '<form action="/test/">',
            ],
            'xss in attribute' => [
                [
                    'attributes' => [
                        'action' => '" onclick="" param="',
                    ],
                ],
                '<form action="&quot; onclick=&quot;&quot; param=&quot;">',
            ],
        ];
    }

    public function testGetInputFromTemplate()
    {
        $field = $this->getField();
        $field->setTemplate(__DIR__.'/../../files/template.php');
        $this->assertEquals("test_template\n", $field->getInput());
    }

    public function testGetInputFordefaultTemplate()
    {
        $field = $this->getField();
        $this->assertStringStartsWith('<form class=" form-horizontal">', $field->getInput());
    }

    public function testLoadData()
    {
        $field = $this->getField();
        $field->setName('form');
        $field->loadData(['form' => [
            'child' => 'test',
            'child3' => 'test3',
        ]]);
        $this->assertEquals(['child' => 'test', 'child2' => null], $field->getValue());
    }

    public function testGetElement()
    {
        $field = $this->getField();
        $this->assertInstanceOf('\serviform\IElement', $field->getElement('child'));
        $this->assertEquals($field, $field->getElement('child')->getParent());
        $this->assertInstanceOf('\serviform\IElement', $field->getElement('child2'));
        $this->assertEquals($field, $field->getElement('child2')->getParent());
        $this->assertEquals(null, $field->getElement('child3'));
    }

    public function testGetElements()
    {
{'fraction_non_alphanumeric': 0.18173474070674622, 'fraction_numerical': 0.0027535566773749425, 'mean_word_length': 1.9001996007984032, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '506500', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1144, 'n_words': 180}