1
1
<?php
2
2
3
3
use Illuminate \Http \Request ;
4
- use Kris \LaravelFormBuilder \FormHelper ;
4
+ use Kris \LaravelFormBuilder \Fields \ CheckableType ;
5
5
use Kris \LaravelFormBuilder \Fields \InputType ;
6
+ use Kris \LaravelFormBuilder \FormHelper ;
6
7
7
8
class FormFieldTest extends FormBuilderTestCase
8
9
{
@@ -117,7 +118,7 @@ public function it_appends_to_the_class_attribute_of_the_field()
117
118
$ text = new InputType ('field_name ' , 'text ' , $ this ->plainForm , $ options );
118
119
$ renderResult = $ text ->render ();
119
120
120
- $ this ->assertMatchesRegularExpression ('/appended / ' , $ text ->getOption ('attr.class ' ));
121
+ $ this ->assertMatchesRegularExpression ('/\bappended\b / ' , $ text ->getOption ('attr.class ' ));
121
122
122
123
$ defaultClasses = $ this ->config ['defaults ' ]['field_class ' ];
123
124
$ this ->assertEquals ('form-control appended ' , $ text ->getOption ('attr.class ' ));
@@ -126,6 +127,26 @@ public function it_appends_to_the_class_attribute_of_the_field()
126
127
$ this ->assertStringNotContainsString ('class_append ' , $ renderResult );
127
128
}
128
129
130
+ /** @test */
131
+ public function it_appends_to_the_class_attribute_of_a_custom_classes_checkbox_field ()
132
+ {
133
+ $ options = [
134
+ 'attr ' => [
135
+ 'class_append ' => 'appended ' ,
136
+ ],
137
+ ];
138
+
139
+ $ text = new CheckableType ('field_name ' , 'checkbox ' , $ this ->plainForm , $ options );
140
+ $ renderResult = $ text ->render ();
141
+
142
+ $ this ->assertMatchesRegularExpression ('/\bappended\b/ ' , $ text ->getOption ('attr.class ' ));
143
+
144
+ $ this ->assertEquals ('custom-checkbox-field-class appended ' , $ text ->getOption ('attr.class ' ));
145
+
146
+ $ defaultClasses = $ this ->config ['defaults ' ]['field_class ' ];
147
+ $ this ->assertStringNotContainsString ($ defaultClasses , $ text ->getOption ('attr.class ' ));
148
+ }
149
+
129
150
/** @test */
130
151
public function it_appends_to_the_class_attribute_of_the_label ()
131
152
{
@@ -138,7 +159,7 @@ public function it_appends_to_the_class_attribute_of_the_label()
138
159
$ text = new InputType ('field_name ' , 'text ' , $ this ->plainForm , $ options );
139
160
$ renderResult = $ text ->render ();
140
161
141
- $ this ->assertMatchesRegularExpression ('/appended / ' , $ text ->getOption ('label_attr.class ' ));
162
+ $ this ->assertMatchesRegularExpression ('/\bappended\b / ' , $ text ->getOption ('label_attr.class ' ));
142
163
143
164
$ defaultClasses = $ this ->config ['defaults ' ]['label_class ' ];
144
165
$ this ->assertEquals ('control-label appended ' , $ text ->getOption ('label_attr.class ' ));
@@ -159,7 +180,7 @@ public function it_appends_to_the_class_attribute_of_the_wrapper()
159
180
$ text = new InputType ('field_name ' , 'text ' , $ this ->plainForm , $ options );
160
181
$ renderResult = $ text ->render ();
161
182
162
- $ this ->assertMatchesRegularExpression ('/appended / ' , $ text ->getOption ('wrapper.class ' ));
183
+ $ this ->assertMatchesRegularExpression ('/\bappended\b / ' , $ text ->getOption ('wrapper.class ' ));
163
184
164
185
$ defaultClasses = $ this ->config ['defaults ' ]['wrapper_class ' ];
165
186
$ this ->assertEquals ('form-group appended ' , $ text ->getOption ('wrapper.class ' ));
0 commit comments