<commit_before><?php

class ElementTest extends PHPUnit_Framework_TestCase
{
    public function testDefaultTests()
    {
        $input = new Formulaic\Text;
        $this->assertTrue($input->valid());

        // Required:
        $input->isRequired();
        $input->setValue('foo');
        $this->assertTrue($input->valid());
        $input->setValue(null);
        $this->assertNotTrue($input->valid());
    }

    public function testButton()
    {
        $this->expectOutputString('<button type="button">B</button>');
        $button = new Formulaic\Button('B');
        echo $button;
    }

    public function testButtonReset()
    {
        $this->expectOutputString('<button type="reset">B</button>');
        $button = new Formulaic\Button\Reset('B');
        echo $button;
    }

    public function testButtonSubmit()
    {
        $this->expectOutputString('<button type="submit">B</button>');
        $button = new Formulaic\Button\Submit('B');
        echo $button;
    }

    public function testCheckbox()
    {
        $this->expectOutputString('<input type="checkbox" value="1">');
        $input = new Formulaic\Checkbox;
        echo $input;
    }

    public function testDate()
    {
        $this->expectOutputString('<input type="date">');
        $input = new Formulaic\Date;
        echo $input;
        $input->setMin('2010-01-01')->setMax('2012-01-01');
        $input->setValue('2009-01-01');
        $this->assertNotTrue($input->valid());
        $input->setValue('2013-01-01');
        $this->assertNotTrue($input->valid());
        $input->setValue('2011-01-01');
        $this->assertTrue($input->valid());
        $input->setValue('something illegal');
        $this->assertNotTrue($input->valid());
    }

    public function testDatetime()
    {
        $this->expectOutputString('<input type="datetime">');
        $input = new Formulaic\Datetime;
        echo $input;
        $input->setMin('2009-01-01 12:00:00')->setMax('2009-01-02 12:00:00');
        $input->setValue('2009-01-01');<commit_msg>add test for checkbox group<commit_after><?php

class ElementTest extends PHPUnit_Framework_TestCase
{
    public function testDefaultTests()
    {
        $input = new Formulaic\Text;
        $this->assertTrue($input->valid());

        // Required:
        $input->isRequired();
        $input->setValue('foo');
        $this->assertTrue($input->valid());
        $input->setValue(null);
        $this->assertNotTrue($input->valid());
    }

    public function testButton()
    {
        $this->expectOutputString('<button type="button">B</button>');
        $button = new Formulaic\Button('B');
        echo $button;
    }

    public function testButtonReset()
    {
        $this->expectOutputString('<button type="reset">B</button>');
        $button = new Formulaic\Button\Reset('B');
        echo $button;
    }

    public function testButtonSubmit()
    {
        $this->expectOutputString('<button type="submit">B</button>');
        $button = new Formulaic\Button\Submit('B');
        echo $button;
    }

    public function testCheckbox()
    {
        $this->expectOutputString('<input type="checkbox" value="1">');
        $input = new Formulaic\Checkbox;
        echo $input;
    }

    public function testCheckboxGroup()
    {
        $this->expectOutputString(<<<EOT
<div>
<label><input type="checkbox" value="1"> Option 1</label>
<label><input type="checkbox" value="2"> Option 2</label>
</div>
EOT
        );
        $group = new Formulaic\Checkbox\Group(
            'test',
            [
                1 => 'Option 1',
                2 => 'Option 2',
            ]
        );
        echo $group;
    }

    public function testDate()
    {
        $this->expectOutputString('<input type="date">');
        $input = new Formulaic\Date;
        echo $input;
        $input->setMin('2010-01-01')->setMax('2012-01-01');
        $input->setValue('2009-01-01');
        $this->assertNotTrue($input->valid());
        $input->setValue('2013-01-01');
        $this->assertNotTrue($input->valid());
        $input->setValue('2011-01-01');
        $this->assertTrue($input->valid());
        $input->setValue('something illegal');
        $this->assertNotTrue($input->valid());
    }

    public function testDatetime()
    {
        $this->expectOutputString('<input type="datetime">');
        $input = new Formulaic\Datetime;
        echo $input;
        $input->setMin('2009-01-01 12:00:00')->setMax('2009-01-02 12:00:00');
        $input->setValue('2009-01-01');
{'fraction_non_alphanumeric': 0.17627567925778662, 'fraction_numerical': 0.03578528827037773, 'mean_word_length': 2.510077519379845, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 96, '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': '3672096', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1316, 'n_words': 218}