lithium\tests\cases\template\helper\FormTest::testCheckboxGeneration PHP Method

testCheckboxGeneration() public method

    public function testCheckboxGeneration()
    {
        $result = $this->form->checkbox('foo');
        $this->assertTags($result, array(array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'foo')), array('input' => array('type' => 'checkbox', 'value' => '1', 'name' => 'foo', 'id' => 'Foo'))));
        $result = $this->form->checkbox('foo', array('checked' => false));
        $this->assertTags($result, array(array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'foo')), array('input' => array('type' => 'checkbox', 'value' => '1', 'name' => 'foo', 'id' => 'Foo'))));
        $result = $this->form->checkbox('foo', array('checked' => true));
        $this->assertTags($result, array(array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'foo')), array('input' => array('type' => 'checkbox', 'value' => '1', 'name' => 'foo', 'checked' => 'checked', 'id' => 'Foo'))));
        $record = new Record(array('model' => $this->_model, 'data' => array('foo' => true)));
        $this->form->create($record);
        $result = $this->form->checkbox('foo');
        $this->assertTags($result, array(array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'foo')), array('input' => array('type' => 'checkbox', 'value' => '1', 'name' => 'foo', 'id' => 'MockFormPostFoo', 'checked' => 'checked'))));
        $record = new Record(array('model' => $this->_model, 'data' => array('foo' => false)));
        $this->form->create($record);
        $result = $this->form->checkbox('foo');
        $this->assertTags($result, array(array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'foo')), array('input' => array('type' => 'checkbox', 'value' => '1', 'name' => 'foo', 'id' => 'MockFormPostFoo'))));
        $document = new Document(array('model' => $this->_model, 'data' => array('subdocument' => array('foo' => true))));
        $this->form->create($document);
        $result = $this->form->checkbox('subdocument.foo');
        $this->assertTags($result, array(array('input' => array('type' => 'hidden', 'value' => '', 'name' => 'subdocument[foo]')), array('input' => array('type' => 'checkbox', 'value' => '1', 'name' => 'subdocument[foo]', 'checked' => 'checked', 'id' => 'MockFormPostSubdocumentFoo'))));
    }
FormTest