/** * Form::capture tests */ public function test_capture() { // with key $form = UI\Form::capture('', 'phpunit'); $expected = '<form role="form" id="phpunit-form"></form>'; $this->assertEquals($expected, $form); // with key and attribute $form = UI\Form::capture('', 'phpunit', array('method' => 'post')); $expected = '<form role="form" id="phpunit-form" method="post"></form>'; $this->assertEquals($expected, $form); // with content $form = UI\Form::capture('foo', 'phpunit', array()); $expected = '<form role="form" id="phpunit-form">foo</form>'; $this->assertEquals($expected, $form); // with callback $form = UI\Form::capture(function () { echo "bar"; }, 'phpunit', array('class' => 'form')); $expected = '<form role="form" id="phpunit-form" class="form">bar</form>'; $this->assertEquals($expected, $form); // reverse parameters $form = UI\Form::capture('phpunit', array(), function () { echo "bar"; }); $expected = '<form role="form" id="phpunit-form">bar</form>'; $this->assertEquals($expected, $form); // instance function in callback $form = UI\Form::capture('phpunit', array(), function ($f) { echo $f->input('user'); }); $expected = '<form role="form" id="phpunit-form"><input id="phpunit-form-user-input" name="user" type="text" /></form>'; $this->assertEquals($expected, $form); // without key $form = UI\Form::capture(null, array(), function ($f) { echo $f->input('user'); }); $expected = '<form role="form"><input id="user-input" name="user" type="text" /></form>'; $this->assertEquals($expected, $form); }