How to use __toString method of field class

Best Atoum code snippet using field.__toString

LiveValidationTest.php

Source:LiveValidationTest.php Github

copy

Full Screen

...52 public function testCanUseMultipleRulesArray()53 {54 $this->former->withRules(array('foo' => 'required'), array('bar' => 'email'));55 // First field56 $input = $this->former->text('foo')->__toString();57 $this->assertLabel($input, 'foo', true);58 $this->assertHTML($this->matchControlGroup(), $input);59 $this->assertHTML($this->matchField(array('required' => 'true')), $input);60 // Second field61 $email = $this->former->text('bar')->__toString();62 $this->assertLabel($email, 'bar');63 $this->assertHTML($this->matchControlGroup(), $email);64 $this->assertHTML($this->matchField(array(), 'email', 'bar'), $email);65 }66 public function testCanUseMultipleRulesArrayAsArray()67 {68 $this->former->withRules(array('foo' => array('required')), array('bar' => array('email')));69 // First field70 $input = $this->former->text('foo')->__toString();71 $this->assertLabel($input, 'foo', true);72 $this->assertHTML($this->matchControlGroup(), $input);73 $this->assertHTML($this->matchField(array('required' => 'true')), $input);74 // Second field75 $email = $this->former->text('bar')->__toString();76 $this->assertLabel($email, 'bar');77 $this->assertHTML($this->matchControlGroup(), $email);78 $this->assertHTML($this->matchField(array(), 'email', 'bar'), $email);79 }80 public function testCanSetFieldAsRequired()81 {82 $this->former->withRules(array('foo' => 'required'));83 $input = $this->former->text('foo')->__toString();84 $this->assertHTML($this->matchField(array('required' => 'true')), $input);85 $this->assertLabel($input, 'foo', true);86 $this->assertHTML($this->matchControlGroup(), $input);87 }88 public function testCanSetNestedBracketFieldAsRequired()89 {90 $this->former->withRules(array('foo[bar]' => 'required'));91 $input = $this->former->text('foo[bar]')->name('foo')->__toString();92 $this->assertHTML($this->matchField(array('required' => 'true')), $input);93 $this->assertLabel($input, 'foo', true);94 $this->assertHTML($this->matchControlGroup(), $input);95 }96 public function testCanSetNestedDotFieldAsRequired()97 {98 $this->former->withRules(array('foo.bar' => 'required'));99 $input = $this->former->text('foo[bar]')->name('foo')->__toString();100 $this->assertHTML($this->matchField(array('required' => 'true')), $input);101 $this->assertLabel($input, 'foo', true);102 $this->assertHTML($this->matchControlGroup(), $input);103 }104 public function testCanSetFieldAsRequiredAsArray()105 {106 $this->former->withRules(array('foo' => array('required')));107 $input = $this->former->text('foo')->__toString();108 $this->assertHTML($this->matchField(array('required' => 'true')), $input);109 $this->assertLabel($input, 'foo', true);110 $this->assertHTML($this->matchControlGroup(), $input);111 }112 public function testCanSetNestedBracketFieldAsRequiredAsArray()113 {114 $this->former->withRules(array('foo[bar]' => array('required')));115 $input = $this->former->text('foo[bar]')->name('foo')->__toString();116 $this->assertHTML($this->matchField(array('required' => 'true')), $input);117 $this->assertLabel($input, 'foo', true);118 $this->assertHTML($this->matchControlGroup(), $input);119 }120 public function testCanSetNestedDotFieldAsRequiredAsArray()121 {122 $this->former->withRules(array('foo.bar' => array('required')));123 $input = $this->former->text('foo[bar]')->name('foo')->__toString();124 $this->assertHTML($this->matchField(array('required' => 'true')), $input);125 $this->assertLabel($input, 'foo', true);126 $this->assertHTML($this->matchControlGroup(), $input);127 }128 public function testCanAddRequiredTextToPlainFields()129 {130 $this->former->close();131 $this->former->withRules(array('foo' => 'required'));132 $input = $this->former->text('foo')->__toString();133 $label = $this->matchLabel('Foo', 'foo', true);134 unset($label['attributes']['class']);135 $this->assertHTML($this->matchField(array('required' => 'true')), $input);136 $this->assertHTML($label, $input);137 }138 public function testCanAddRequiredTextToPlainFieldsAsArray()139 {140 $this->former->close();141 $this->former->withRules(array('foo' => array('required')));142 $input = $this->former->text('foo')->__toString();143 $label = $this->matchLabel('Foo', 'foo', true);144 unset($label['attributes']['class']);145 $this->assertHTML($this->matchField(array('required' => 'true')), $input);146 $this->assertHTML($label, $input);147 }148 public function testCanSetMaxToText()149 {150 $this->former->withRules(array('foo' => 'max:42'));151 $input = $this->former->text('foo')->__toString();152 $matcher = $this->matchField(array('maxlength' => '42'));153 $this->assertHTML($matcher, $input);154 $this->assertControlGroup($input);155 }156 public function testCanSetMaxToTextAsArray()157 {158 $this->former->withRules(array('foo' => array('max:42')));159 $input = $this->former->text('foo')->__toString();160 $matcher = $this->matchField(array('maxlength' => '42'));161 $this->assertHTML($matcher, $input);162 $this->assertControlGroup($input);163 }164 public function testCanSetMaxToNumber()165 {166 $this->former->withRules(array('foo' => 'max:42'));167 $input = $this->former->number('foo')->__toString();168 $matcher = $this->matchField(array('max' => '42'), 'number');169 $this->assertHTML($matcher, $input);170 $this->assertControlGroup($input);171 }172 public function testCanSetMaxToNumberAsArray()173 {174 $this->former->withRules(array('foo' => array('max:42')));175 $input = $this->former->number('foo')->__toString();176 $matcher = $this->matchField(array('max' => '42'), 'number');177 $this->assertHTML($matcher, $input);178 $this->assertControlGroup($input);179 }180 public function testCanSetMinToText()181 {182 $this->former->withRules(array('foo' => 'min:42'));183 $input = $this->former->text('foo')->__toString();184 $matcher = $this->matchField(array('pattern' => '.{42,}'));185 $this->assertHTML($matcher, $input);186 $this->assertControlGroup($input);187 }188 public function testCanSetMinToTextAsArray()189 {190 $this->former->withRules(array('foo' => array('min:42')));191 $input = $this->former->text('foo')->__toString();192 $matcher = $this->matchField(array('pattern' => '.{42,}'));193 $this->assertHTML($matcher, $input);194 $this->assertControlGroup($input);195 }196 public function testCanSetMinToNumber()197 {198 $this->former->withRules(array('foo' => 'min:42'));199 $input = $this->former->number('foo')->__toString();200 $matcher = $this->matchField(array('min' => '42'), 'number');201 $this->assertHTML($matcher, $input);202 $this->assertControlGroup($input);203 }204 public function testCanSetMinToNumberAsArray()205 {206 $this->former->withRules(array('foo' => array('min:42')));207 $input = $this->former->number('foo')->__toString();208 $matcher = $this->matchField(array('min' => '42'), 'number');209 $this->assertHTML($matcher, $input);210 $this->assertControlGroup($input);211 }212 /**213 * @dataProvider providePatterns214 */215 public function testCanApplyPatternsToFields($type, $pattern)216 {217 $this->former->withRules(array('foo' => $type));218 $input = $this->former->text('foo')->__toString();219 $matcher = $this->matchField(array('pattern' => $pattern));220 $this->assertControlGroup($input);221 $this->assertHTML($matcher, $input);222 }223 /**224 * @dataProvider providePatterns225 */226 public function testCanApplyPatternsToFieldsAsArray($type, $pattern)227 {228 $type = explode('|', $type);229 $this->former->withRules(array('foo' => $type));230 $input = $this->former->text('foo')->__toString();231 $matcher = $this->matchField(array('pattern' => $pattern));232 $this->assertControlGroup($input);233 $this->assertHTML($matcher, $input);234 }235 public function testCanSetNumberFieldAsNumeric()236 {237 $this->former->withRules(array('foo' => 'numeric'));238 $input = $this->former->number('foo')->__toString();239 $matcher = $this->matchField(array('step' => 'any'), 'number');240 $this->assertControlGroup($input);241 $this->assertHTML($matcher, $input);242 }243 public function testCanSetNumberFieldAsNumericAsArray()244 {245 $this->former->withRules(array('foo' => array('numeric')));246 $input = $this->former->number('foo')->__toString();247 $matcher = $this->matchField(array('step' => 'any'), 'number');248 $this->assertControlGroup($input);249 $this->assertHTML($matcher, $input);250 }251 public function testCanSetDateAsBeforeSomething()252 {253 $this->former->withRules(array('foo' => 'before:2012-03-03'));254 $input = $this->former->date('foo')->__toString();255 $matcher = $this->matchField(array('max' => '2012-03-03'), 'date');256 $this->assertControlGroup($input);257 $this->assertHTML($matcher, $input);258 }259 public function testCanSetDatetimeAsBeforeSomething()260 {261 $this->former->withRules(array('foo' => 'before:2012-03-03 10:00:00'));262 $input = $this->former->datetime('foo')->__toString();263 $matcher = $this->matchField(array('max' => '2012-03-03T10:00:00'), 'datetime');264 $this->assertControlGroup($input);265 $this->assertHTML($matcher, $input);266 }267 public function testCanSetDateAsBeforeSomethingAsArray()268 {269 $this->former->withRules(array('foo' => array('before:2012-03-03')));270 $input = $this->former->date('foo')->__toString();271 $matcher = $this->matchField(array('max' => '2012-03-03'), 'date');272 $this->assertControlGroup($input);273 $this->assertHTML($matcher, $input);274 }275 public function testCanSetDateAsAfterSomething()276 {277 $this->former->withRules(array('foo' => 'after:2012-03-03'));278 $input = $this->former->date('foo')->__toString();279 $matcher = $this->matchField(array('min' => '2012-03-03'), 'date');280 $this->assertControlGroup($input);281 $this->assertHTML($matcher, $input);282 }283 public function testCanSetDateAsAfterSomethingAsArray()284 {285 $this->former->withRules(array('foo' => array('after:2012-03-03')));286 $input = $this->former->date('foo')->__toString();287 $matcher = $this->matchField(array('min' => '2012-03-03'), 'date');288 $this->assertControlGroup($input);289 $this->assertHTML($matcher, $input);290 }291 public function testCanRestrictMimeTypes()292 {293 $this->former->withRules(array('foo' => 'mimes:jpg,gif'));294 $input = $this->former->file('foo')->__toString();295 $matcher = $this->matchField(array('accept' => 'image/jpeg,image/gif'), 'file');296 $this->assertControlGroup($input);297 $this->assertHTML($matcher, $input);298 }299 public function testCanRestrictMimeTypesAsArray()300 {301 $this->former->withRules(array('foo' => array('mimes:jpg,gif')));302 $input = $this->former->file('foo')->__toString();303 $matcher = $this->matchField(array('accept' => 'image/jpeg,image/gif'), 'file');304 $this->assertControlGroup($input);305 $this->assertHTML($matcher, $input);306 }307 public function testCantUseAcceptOnNonFilesFields()308 {309 $this->former->withRules(array('foo' => array('mimes:jpg,gif')));310 $input = $this->former->text('foo')->render();311 $matcher = $this->matchField();312 $this->assertHTML($matcher, $input);313 }314 public function testCanForceFieldToImage()315 {316 $this->former->withRules(array('foo' => 'image'));317 $input = $this->former->file('foo')->__toString();318 $matcher = $this->matchField(array('accept' => 'image/jpeg,image/png,image/gif,image/bmp'), 'file');319 $this->assertControlGroup($input);320 $this->assertHTML($matcher, $input);321 }322 public function testCanForceFieldToImageAsArray()323 {324 $this->former->withRules(array('foo' => array('image')));325 $input = $this->former->file('foo')->__toString();326 $matcher = $this->matchField(array('accept' => 'image/jpeg,image/png,image/gif,image/bmp'), 'file');327 $this->assertControlGroup($input);328 $this->assertHTML($matcher, $input);329 }330 /**331 * @dataProvider provideTypes332 */333 public function testCanSwitchTypesAccordingToRules($type)334 {335 $this->former->withRules(array('foo' => $type));336 $input = $this->former->text('foo')->__toString();337 $matcher = $this->matchField(array(), $type);338 $this->assertControlGroup($input);339 $this->assertHTML($matcher, $input);340 }341 /**342 * @dataProvider provideTypes343 */344 public function testCanSwitchTypesAccordingToRulesAsArray($type)345 {346 $type = explode('|', $type);347 $this->former->withRules(array('foo' => $type));348 $input = $this->former->text('foo')->__toString();349 $matcher = $this->matchField(array(), $type[0]);350 $this->assertControlGroup($input);351 $this->assertHTML($matcher, $input);352 }353 public function testCanSetBoundariesToText()354 {355 $this->former->withRules(array('foo' => 'between:1,10'));356 $input = $this->former->text('foo')->__toString();357 $matcher = $this->matchField(array('pattern' => '.{1,10}', 'maxlength' => '10'));358 $this->assertControlGroup($input);359 $this->assertHTML($matcher, $input);360 }361 public function testCanSetBoundariesToTextAsArray()362 {363 $this->former->withRules(array('foo' => array('between:1,10')));364 $input = $this->former->text('foo')->__toString();365 $matcher = $this->matchField(array('pattern' => '.{1,10}', 'maxlength' => '10'));366 $this->assertControlGroup($input);367 $this->assertHTML($matcher, $input);368 }369 public function testCanSetBoundariestoNumber()370 {371 $this->former->withRules(array('foo' => 'between:1,10'));372 $input = $this->former->number('foo')->__toString();373 $matcher = $this->matchField(array('min' => '1', 'max' => '10'), 'number');374 $this->assertControlGroup($input);375 $this->assertHTML($matcher, $input);376 }377 public function testCanSetBoundariestoNumberAsArray()378 {379 $this->former->withRules(array('foo' => array('between:1,10')));380 $input = $this->former->number('foo')->__toString();381 $matcher = $this->matchField(array('min' => '1', 'max' => '10'), 'number');382 $this->assertControlGroup($input);383 $this->assertHTML($matcher, $input);384 }385 public function testCanDisableLiveValidation()386 {387 // Change config388 $this->mockConfig(array('live_validation' => false));389 $this->former->withRules(array('foo' => 'required'));390 $input = $this->former->text('foo')->__toString();391 $matcher = $this->matchField();392 $this->assertHTML($matcher, $input);393 $this->assertControlGroup($input);394 }395 public function testCanDisableLiveValidationAsArray()396 {397 // Change config398 $this->mockConfig(array('live_validation' => false));399 $this->former->withRules(array('foo' => array('required')));400 $input = $this->former->text('foo')->__toString();401 $matcher = $this->matchField();402 $this->assertHTML($matcher, $input);403 $this->assertControlGroup($input);404 }405 public function testCanApplyRulesByChaining()406 {407 $input = $this->former->number('foo')->rule('max', 10)->__toString();408 $matcher = $this->matchField(array('max' => 10), 'number');409 $this->assertControlGroup($input);410 $this->assertHTML($matcher, $input);411 }412 public function testCanApplyMultipleRulesWithString()413 {414 $input = $this->former->number('foo')->rules('max:10|required')->__toString();415 $matcher = $this->matchField(array('max' => 10, 'required' => true), 'number');416 $this->assertControlGroup($input);417 $this->assertHTML($matcher, $input);418 }419 public function testCanCreateMaxFileSizeForFiles()420 {421 $input = $this->former->file('foo')->rule('max', 10)->__toString();422 $this->assertHTML($this->matchField(array('value' => 10240), 'hidden', 'MAX_FILE_SIZE'), $input);423 }424}...

Full Screen

Full Screen

InputTest.php

Source:InputTest.php Github

copy

Full Screen

...5class InputTest extends FormerTests6{7 public function testCanCreateText()8 {9 $input = $this->former->text('foo')->__toString();10 $this->assertControlGroup($input);11 $this->assertHTML($this->matchField(), $input);12 }13 public function testCanCreateTextWithoutLabel()14 {15 $this->mockConfig(array('automatic_label' => false));16 $input = $this->former->text('foo')->__toString();17 $matchField = array_except($this->matchField(), 'id');18 $this->assertHTML($this->matchControlGroup(), $input);19 $this->assertHTML($matchField, $input);20 }21 public function testCanCreateSingleTextWithoutLabelOnStart()22 {23 $input = $this->former->text('foo', '')->__toString();24 $matchField = array_except($this->matchField(), 'id');25 $this->assertHTML($this->matchControlGroup(), $input);26 $this->assertHTML($matchField, $input);27 }28 public function testCanCreateSingleTextWithoutLabel()29 {30 $input = $this->former->text('foo')->label(null)->__toString();31 $matchField = array_except($this->matchField(), 'id');32 $this->assertHTML($this->matchControlGroup(), $input);33 $this->assertHTML($matchField, $input);34 }35 public function testCanCreateSearchField()36 {37 $input = $this->former->search('foo')->__toString();38 $matchField = $this->matchField();39 array_set($matchField, 'attributes.class', 'search-query');40 $this->assertControlGroup($input);41 $this->assertHTML($matchField, $input);42 }43 public function testCanCreateTextFieldWithoutBootstrap()44 {45 $this->former->framework('Nude');46 $input = $this->former->text('foo')->data('foo')->class('bar')->__toString();47 $label = $this->matchLabel('Foo');48 array_forget($label, 'attributes.class');49 $this->assertHTML($label, $input);50 $this->assertHTML($this->matchField(), $input);51 }52 public function testCanCreateTextFieldWithoutFormInstance()53 {54 $this->former->close();55 $input = $this->former->text('foo')->data('foo')->class('bar')->__toString();56 $label = array('tag' => 'label', 'content' => 'Foo', array('for' => 'foo'));57 $this->assertHTML($label, $input);58 $this->assertHTML($this->matchField(), $input);59 $this->former->horizontal_open();60 }61 public function testCanCreateTextLabel()62 {63 $static = $this->former->text('foo')->label('bar', $this->testAttributes)->__toString();64 $label = $this->matchLabel('Bar', 'foo');65 $label['attributes']['class'] = 'foo control-label';66 $label['attributes']['data-foo'] = 'bar';67 $this->assertHTML($label, $static);68 $this->assertHTML($this->matchField(), $static);69 $this->assertHTML($this->matchControlGroup(), $static);70 $this->resetLabels();71 $input = $this->former->text('foo', 'bar')->__toString();72 $this->assertHTML($this->matchLabel('Bar', 'foo'), $input);73 $this->assertHTML($this->matchField(), $input);74 $this->assertHTML($this->matchControlGroup(), $input);75 }76 public function testCanCreateTextLabelWithoutBootstrap()77 {78 $this->former->framework('Nude');79 $static = $this->former->text('foo')->label('bar', $this->testAttributes)->__toString();80 $label = $this->matchLabel('Bar');81 $label['attributes']['class'] = 'foo';82 $label['attributes']['data-foo'] = 'bar';83 $this->assertHTML($label, $static);84 $this->assertHTML($this->matchField(), $static);85 $input = $this->former->text('foo', 'bar')->__toString();86 $label = $this->matchLabel('Bar');87 unset($label['attributes']['class']);88 $this->assertHTML($label, $static);89 $this->assertHTML($this->matchField(), $static);90 }91 public function testCanCreateWithErrors()92 {93 $this->former->withErrors($this->validator);94 $required = $this->former->text('required')->__toString();95 $matcher =96 '<div class="control-group error">'.97 '<label for="required" class="control-label">Required</label>'.98 '<div class="controls">'.99 '<input id="required" type="text" name="required">'.100 '<span class="help-inline">The required field is required.</span>'.101 '</div>'.102 '</div>';103 $this->assertEquals($matcher, $required);104 }105 public function testAnonymousFieldHasNoErrors()106 {107 $this->former->withErrors($this->validator);108 $required = $this->former->text()->__toString();109 $matcher =110 '<div class="control-group">'.111 '<div class="controls">'.112 '<input type="text">'.113 '</div>'.114 '</div>';115 $this->assertEquals($matcher, $required);116 }117 public function testCanDisableErrors()118 {119 $this->mockConfig(array('error_messages' => false));120 $this->former->withErrors($this->validator);121 $required = $this->former->text('required')->__toString();122 $matcher =123 '<div class="control-group error">'.124 '<label for="required" class="control-label">Required</label>'.125 '<div class="controls">'.126 '<input id="required" type="text" name="required">'.127 '</div>'.128 '</div>';129 $this->assertEquals($matcher, $required);130 }131 public function testCanCreatePopulate()132 {133 $this->former->populate(array('foo' => 'bar'));134 $populate = $this->former->text('foo')->__toString();135 $matcher = $this->controlGroup('<input id="foo" type="text" name="foo" value="bar">');136 $this->assertEquals($matcher, $populate);137 }138 public function testCanCreatePopulateWithSpecificValue()139 {140 $this->former->populate(array('foo' => 'bar'));141 $this->former->populateField('foo', 'foo');142 $populate = $this->former->text('foo')->__toString();143 $matcher = $this->controlGroup('<input id="foo" type="text" name="foo" value="foo">');144 $this->assertEquals($matcher, $populate);145 }146 public function testCanCreateNestedRelationships()147 {148 $foo = (object) array('bar' => (object) array('kal' => (object) array('ter' => 'men')));149 $this->former->populate($foo);150 $text = $this->former->text('bar.kal.ter')->__toString();151 $matcher = $this->controlGroup(152 '<input id="bar.kal.ter" type="text" name="bar.kal.ter" value="men">',153 '<label for="bar.kal.ter" class="control-label">Bar.kal.ter</label>');154 $this->assertEquals($matcher, $text);155 }156 public function testCanCreateNestedRelationshipsRenamedField()157 {158 $foo = (object) array('bar' => (object) array('kal' => (object) array('ter' => 'men')));159 $this->former->populate($foo);160 $text = $this->former->text('bar.kal.ter')->name('ter')->__toString();161 $matcher = $this->controlGroup(162 '<input id="ter" type="text" name="ter" value="men">',163 '<label for="ter" class="control-label">Ter</label>');164 $this->assertEquals($matcher, $text);165 }166 public function testCanCreateMultipleNestedRelationships()167 {168 for ($i = 0; $i < 2; $i++) {169 $bar[] = (object) array('kal' => 'val'.$i);170 }171 $foo = (object) array('bar' => $bar);172 $this->former->populate($foo);173 $text = $this->former->text('bar.kal')->__toString();174 $matcher = $this->controlGroup(175 '<input id="bar.kal" type="text" name="bar.kal" value="val0, val1">',176 '<label for="bar.kal" class="control-label">Bar.kal</label>');177 $this->assertEquals($matcher, $text);178 }179 public function testCanCreateNoPopulatingPasswords()180 {181 $this->former->populate(array('foo' => 'bar'));182 $populate = $this->former->password('foo')->__toString();183 $matcher = $this->controlGroup('<input id="foo" type="password" name="foo">');184 $this->assertEquals($matcher, $populate);185 }186 public function testCanCreateDatalist()187 {188 $datalist = $this->former->text('foo')->useDatalist(array('foo' => 'bar', 'kel' => 'tar'))->__toString();189 $matcher =190 '<div class="control-group">'.191 '<label for="foo" class="control-label">Foo</label>'.192 '<div class="controls">'.193 '<input list="datalist_foo" id="foo" type="text" name="foo">'.194 '<datalist id="datalist_foo">'.195 '<option value="bar">foo</option>'.196 '<option value="tar">kel</option>'.197 '</datalist>'.198 '</div>'.199 '</div>';200 $this->assertEquals($matcher, $datalist);201 }202 public function testCanCreateDatalistCustomList()203 {204 $datalist = $this->former->text('foo')->list('bar')->useDatalist(array(205 'foo' => 'bar',206 'kel' => 'tar',207 ))->__toString();208 $matcher =209 '<div class="control-group">'.210 '<label for="foo" class="control-label">Foo</label>'.211 '<div class="controls">'.212 '<input list="bar" id="foo" type="text" name="foo">'.213 '<datalist id="bar">'.214 '<option value="bar">foo</option>'.215 '<option value="tar">kel</option>'.216 '</datalist>'.217 '</div>'.218 '</div>';219 $this->assertEquals($matcher, $datalist);220 }221 public function testCanCreateNumberRange()222 {223 $range = $this->former->number('foo')->range(1, 5)->__toString();224 $this->assertContains('min="1" max="5"', $range);225 }226 public function testLabelCastsToString()227 {228 $object = new DummyEloquent(array('name' => 'Bar'));229 $static = $this->former->checkbox('foo')->label($object)->__toString();230 $label = $this->matchLabel('Bar', 'foo');231 $this->assertHTML($label, $static);232 }233 public function testUnderscoresInLabelsAreConverted()234 {235 $static = $this->former->text('foo')->label('customer_name')->__toString();236 $label = $this->matchLabel('Customer name', 'foo');237 $this->assertHTML($label, $static);238 }239}...

Full Screen

Full Screen

FieldTest.php

Source:FieldTest.php Github

copy

Full Screen

...21 public function testCanCreateFieldsOutsideForms()22 {23 $this->former->close();24 $field = $this->former->text('foo')->raw();25 $this->assertEquals('<input id="foo" type="text" name="foo">', $field->__toString());26 }27 public function testCanChangeTheFieldIdAndKeepLabelInSync()28 {29 $field = $this->former->text('foo');30 $field->id('bar');31 $matcher = '<div class="control-group"><label for="bar" class="control-label">Foo</label><div class="controls"><input id="bar" type="text" name="foo"></div></div>';32 $this->assertEquals($matcher, $field->__toString());33 }34 public function testCanChangeTypeMidCourse()35 {36 $field = $this->former->text('foo')->setType('email');37 $this->assertEquals('email', $field->getType());38 }39 public function testCanRenameField()40 {41 $input = $this->former->text('foo')->name('bar')->__toString();42 $matcher = $this->controlGroup(43 '<input id="bar" type="text" name="bar">',44 '<label for="bar" class="control-label">Bar</label>');45 $this->assertEquals($matcher, $input);46 }47 public function testCanSetValueOnFields()48 {49 $matcher = $this->controlGroup('<input id="foo" type="text" name="foo" value="bar">');50 $static = $this->former->text('foo')->value('bar')->__toString();51 $this->assertHTML($this->matchField(), $static);52 $this->assertHTML($this->matchControlGroup(), $static);53 $this->resetLabels();54 $input = $this->former->text('foo', null, 'bar')->__toString();55 $this->assertHTML($this->matchField(), $input);56 $this->assertHTML($this->matchControlGroup(), $input);57 }58 public function testCanForceValueOnFields()59 {60 $this->former->populate(array('foo' => 'unbar'));61 $static = $this->former->text('foo')->forceValue('bar')->__toString();62 $matcher = $this->controlGroup('<input id="foo" type="text" name="foo" value="bar">');63 $this->assertEquals($matcher, $static);64 }65 public function testCanCreateViaMagicAttribute()66 {67 $static = $this->former->text('foo')->class('foo')->data_bar('bar')->__toString();68 $this->assertHTML($this->matchField(), $static);69 $this->assertHTML($this->matchControlGroup(), $static);70 $this->resetLabels();71 $input = $this->former->text('foo', null, null, array('class' => 'foo', 'data-bar' => 'bar'))->__toString();72 $this->assertHTML($this->matchField(), $input);73 $this->assertHTML($this->matchControlGroup(), $input);74 }75 public function testCanCreateViaMagicAttributeUnvalue()76 {77 $static = $this->former->text('foo')->require()->__toString();78 $matcher = $this->controlGroup('<input require="true" type="text" name="foo" id="foo">');79 $this->assertHTML($this->matchField(), $static);80 $this->assertHTML($this->matchControlGroup(), $static);81 }82 public function testCanSetAttributes()83 {84 $attributes = array('class' => 'foo', 'data-foo' => 'bar');85 $static = $this->former->text('foo')->require()->setAttributes($attributes)->__toString();86 $field = $this->matchField();87 $field['attributes']['require'] = 'true';88 $field['attributes']['class'] = 'foo';89 $field['attributes']['data-foo'] = 'bar';90 $this->assertHTML($field, $static);91 $this->assertHTML($this->matchControlGroup(), $static);92 }93 public function testCanReplaceAttributes()94 {95 $attributes = array('class' => 'foo', 'data-foo' => 'bar');96 $static = $this->former->text('foo')->require()->replaceAttributes($attributes)->__toString();97 $matcher = $this->controlGroup('<input class="foo" data-foo="bar" type="text" name="foo" id="foo">');98 $field = $this->matchField();99 $field['attributes']['class'] = 'foo';100 $field['attributes']['data-foo'] = 'bar';101 $this->assertHTML($field, $static);102 $this->assertHTML($this->matchControlGroup(), $static);103 }104 public function testCanGetAttribute()105 {106 $former = $this->former->span1_text('name')->foo('bar');107 $this->assertEquals('span1', $former->class);108 $this->assertEquals('bar', $former->foo);109 }110 public function testCanAddClass()111 {112 $matcher = $this->controlGroup('<input class="foo bar" type="text" name="foo" id="foo">');113 $static = $this->former->text('foo')->class('foo')->addClass('bar')->__toString();114 $this->assertHTML($this->matchControlGroup(), $static);115 $this->assertHTML($this->matchField(), $static);116 $this->resetLabels();117 $input = $this->former->text('foo', null, null, array('class' => 'foo'))->addClass('bar')->__toString();118 $this->assertHTML($this->matchControlGroup(), $input);119 $this->assertHTML($this->matchField(), $input);120 }121 /**122 * @dataProvider provideSizes123 */124 public function testCanUseMagicMethods($size)125 {126 $method = $size.'_text';127 $class = Str::startsWith($size, 'span') ? $size.' ' : 'input-'.$size.' ';128 $static = $this->former->$method('foo')->addClass('bar')->__toString();129 if ($class == 'input-foo ') {130 $class = null;131 }132 $field = $this->matchField();133 $field['attributes']['class'] = $class.'bar';134 $this->assertHTML($this->matchControlGroup(), $static);135 $this->assertHTML($field, $static);136 }137 public function testAutomaticLabelsForSingleSelectField()138 {139 $field = $this->former->select('foo');140 $matcher = '<div class="control-group"><label for="foo" class="control-label">Foo</label><div class="controls"><select id="foo" name="foo"></select></div></div>';141 $this->assertEquals($matcher, $field->__toString());142 }143 public function testAutomaticLabelsForMultiSelectField()144 {145 $field = $this->former->select('foo[]');146 $matcher = '<div class="control-group"><label for="foo[]" class="control-label">Foo</label><div class="controls"><select id="foo[]" name="foo[]"></select></div></div>';147 $this->assertEquals($matcher, $field->__toString());148 }149 public function testCantHaveDuplicateIdsForFields()150 {151 $field = $this->former->text('name')->render();152 $fieldTwo = $this->former->text('name')->render();153 $fieldThree = $this->former->text('name')->render();154 $this->assertEquals('<input id="name" type="text" name="name">', $field);155 $this->assertEquals('<input id="name-2" type="text" name="name">', $fieldTwo);156 $this->assertEquals('<input id="name-3" type="text" name="name">', $fieldThree);157 }158 public function testCanChangeBindingOfField()159 {160 $this->former->populate(array('bar' => 'unbar'));161 $static = $this->former->text('foo')->bind('bar')->__toString();162 $matcher = $this->controlGroup('<input id="foo" type="text" name="foo" value="unbar">');163 $this->assertEquals($matcher, $static);164 }165}...

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1$obj = new field();2echo $obj;3$obj = new field();4echo $obj;5$obj = new field();6echo $obj;7$obj = new field();8echo $obj;9$obj = new field();10echo $obj;11$obj = new field();12echo $obj;13$obj = new field();14echo $obj;15$obj = new field();16echo $obj;17$obj = new field();18echo $obj;19$obj = new field();20echo $obj;21$obj = new field();22echo $obj;23$obj = new field();24echo $obj;25$obj = new field();26echo $obj;27$obj = new field();28echo $obj;29$obj = new field();30echo $obj;31$obj = new field();32echo $obj;33$obj = new field();34echo $obj;35$obj = new field();36echo $obj;37$obj = new field();38echo $obj;

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1$myField = new Field();2echo $myField;3$myField = new Field();4echo $myField;5$myField = new Field();6echo $myField;7$myField = new Field();8echo $myField;9$myField = new Field();10echo $myField;11$myField = new Field();12echo $myField;13$myField = new Field();14echo $myField;15$myField = new Field();16echo $myField;17$myField = new Field();18echo $myField;

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1$myField = new Field();2echo $myField;3$myField = new Field();4echo $myField;5Field::__toString() called6Field::__toString() called7Field::__toString() called8Field::__toString() called9Field::__toString() called10Field::__toString() called11Field::__toString() called12Field::__toString() called13Field::__toString() called14Field::__toString() called15Field::__toString() called16Field::__toString() called17Field::__toString() called18Field::__toString() called19Field::__toString() called20Field::__toString() called21Field::__toString() called22Field::__toString() called23Field::__toString() called24Field::__toString() called25Field::__toString() called26Field::__toString() called27Field::__toString() called28Field::__toString() called29Field::__toString() called

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1require_once 'field.php';2$myField = new field('myField');3echo $myField;4require_once 'field.php';5$myField = new field('myField');6echo $myField;7require_once 'field.php';8$myField = new field('myField');9echo $myField;10require_once 'field.php';11$myField = new field('myField');12echo $myField;13require_once 'field.php';14$myField = new field('myField');15echo $myField;16require_once 'field.php';17$myField = new field('myField');18echo $myField;19require_once 'field.php';20$myField = new field('myField');21echo $myField;22require_once 'field.php';23$myField = new field('myField');24echo $myField;25require_once 'field.php';26$myField = new field('myField');27echo $myField;28require_once 'field.php';29$myField = new field('myField');30echo $myField;

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1require_once 'field.php';2require_once 'form.php';3$form = new Form();4$field = new Field();5$field->setName('name');6$field->setType('text');7$field->setValue('Anil');8$field->setId('name');9$field->setClass('name');10$field->setLabel('Name');11$form->addField($field);12$field = new Field();13$field->setName('email');14$field->setType('text');15$field->setValue('

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1include_once("field.php");2$obj=new field();3$obj->setName("name");4$obj->setCaption("caption");5$obj->setType("text");6$obj->setValue("value");7echo $obj;

Full Screen

Full Screen

__toString

Using AI Code Generation

copy

Full Screen

1$test = new Field();2echo $test;3 class Field { 4 public $field = 1 ; 5 public function __toString ( ) { 6 return $this -> field ; 7 } 8 } 9 $test = new Field ( ) ; 10 echo $test ;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger __toString code on LambdaTest Cloud Grid

Execute automation tests with __toString on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful