From 5dd169b33dbf777dcdce411039eda86151146dce Mon Sep 17 00:00:00 2001 From: mlantz Date: Sun, 21 May 2017 23:24:43 -0400 Subject: [PATCH] Macro test --- tests/FormBuilderTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/FormBuilderTest.php b/tests/FormBuilderTest.php index 0d2dabb..aabe67e 100644 --- a/tests/FormBuilderTest.php +++ b/tests/FormBuilderTest.php @@ -121,6 +121,26 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase $this->assertEquals('', $form6); } + public function testMacroField() + { + $this->formBuilder->macro('data_field', function ($name, $value, $data) { + $dataAttributes = []; + foreach ($data as $key => $attribute) { + $dataAttributes[] = $key.'="'.$attribute.'"'; + } + return ''; + }); + + $form = $this->formBuilder->data_field('foo', null, [ + 'role' => 'set_name', + 'data-titlecase' => 'ucfirst', + 'data-inputmask-type' => 'Regex', + 'data-inputmask-regex' => '[A-Za-z0-9\\s-\\(\\)&]{2,70}', + ]); + + $this->assertEquals('', $form); + } + public function testPasswordsNotFilled() { $this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));