/**
  * @dataProvider displaytypes
  */
 public function testControlGroupFull($displaytype)
 {
     $class = $displaytype;
     if ($displaytype != '') {
         $class = ' ' . $displaytype;
     }
     // Had to match label and go up to the parent
     // than back down to get the other elements. Odd but can't
     // figure out how to find 3 different child elements
     $matcher = array('tag' => 'div', 'attributes' => array('class' => 'controls'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'text', 'name' => 'inputfoo', 'id' => 'inputfoo')), 'parent' => array('tag' => 'div', 'attributes' => array('class' => 'control-group' . $class), 'child' => array('tag' => 'label', 'attributes' => array('class' => 'control-label', 'for' => 'inputfoo'), 'content' => 'foo'), 'descendant' => array('tag' => 'div', 'attributes' => array('class' => 'controls'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'text', 'name' => 'inputfoo', 'id' => 'inputfoo')))));
     $html = Form::control_group(Form::label('inputfoo', 'foo'), Form::text('inputfoo'), $displaytype, Form::block_help('You foobared that!'));
     $this->assertTag($matcher, $html);
 }
Example #2
0
    public function testCreateFullControlGroupWithOffsets()
    {
        $matcher = array(
            'tag' => 'div',
            'attributes' => array('class' => 'col-sm-2'),
            'child' => array(
                'tag' => 'label',
                'attributes' => array('for' => 'inputfoo'),
                'content' => 'foo',
            ),
            'parent' => array(
                'tag' => 'div',
                'attributes' => array('class' => 'form-group'),
                'child' => array(
                    'tag' => 'div',
                    'attributes' => array('class' => 'col-sm-10'),
                    'child' => array(
                        'tag' => 'input',
                        'attributes' => array(
                            'type' => 'text',
                            'name' => 'inputfoo',
                            'id' => 'inputfoo',
                            'class' => 'form-control'
                        ),
                    ),
                    'descendant' => array(
                        'tag' => 'span',
                        'attributes' => array(
                            'class' => 'help-block'
                        ),
                        'content' => 'You foobared that!',
                    ),
                ),
            ),
        );

        $html = Form::control_group(
            Form::label('inputfoo', 'foo'),
            Form::text('inputfoo'),
            null,
            Form::block_help('You foobared that!'),
            2
        );

        $this->assertHTML($matcher, $html);
    }