@@ -31,10 +31,10 @@ public function setUp()
31
31
$ request = Request::create ('/foo ' , 'GET ' , [
32
32
"person " => [
33
33
"name " => "John " ,
34
- "surname " => "Doe "
34
+ "surname " => "Doe " ,
35
35
],
36
- "aggree " => 1 ,
37
- "checkbox_array " => [1 ,2 , 3 ]
36
+ "agree " => 1 ,
37
+ "checkbox_array " => [1 , 2 , 3 ],
38
38
]);
39
39
40
40
$ request = Request::createFromBase ($ request );
@@ -52,25 +52,33 @@ public function tearDown()
52
52
53
53
public function testRequestValue ()
54
54
{
55
- $ name = $ this ->formBuilder ->text ("person[name] " );
56
- $ surname = $ this ->formBuilder ->text ("person[surname] " );
55
+ $ this ->formBuilder ->considerRequest ();
56
+ $ name = $ this ->formBuilder ->text ("person[name] " , "Not John " );
57
+ $ surname = $ this ->formBuilder ->text ("person[surname] " , "Not Doe " );
57
58
$ this ->assertEquals ('<input name="person[name]" type="text" value="John"> ' , $ name );
58
59
$ this ->assertEquals ('<input name="person[surname]" type="text" value="Doe"> ' , $ surname );
59
60
60
- $ checked = $ this ->formBuilder ->checkbox ("aggree " , 1 );
61
+ $ checked = $ this ->formBuilder ->checkbox ("agree " , 1 );
61
62
$ unchecked = $ this ->formBuilder ->checkbox ("no_value " , 1 );
62
- $ this ->assertEquals ('<input checked="checked" name="aggree " type="checkbox" value="1"> ' , $ checked );
63
+ $ this ->assertEquals ('<input checked="checked" name="agree " type="checkbox" value="1"> ' , $ checked );
63
64
$ this ->assertEquals ('<input name="no_value" type="checkbox" value="1"> ' , $ unchecked );
64
65
65
66
$ checked_array = $ this ->formBuilder ->checkbox ("checkbox_array[] " , 1 );
66
67
$ unchecked_array = $ this ->formBuilder ->checkbox ("checkbox_array[] " , 4 );
67
68
$ this ->assertEquals ('<input checked="checked" name="checkbox_array[]" type="checkbox" value="1"> ' , $ checked_array );
68
69
$ this ->assertEquals ('<input name="checkbox_array[]" type="checkbox" value="4"> ' , $ unchecked_array );
69
70
70
- $ checked = $ this ->formBuilder ->radio ("aggree " , 1 );
71
+ $ checked = $ this ->formBuilder ->radio ("agree " , 1 );
71
72
$ unchecked = $ this ->formBuilder ->radio ("no_value " , 1 );
72
- $ this ->assertEquals ('<input checked="checked" name="aggree " type="radio" value="1"> ' , $ checked );
73
+ $ this ->assertEquals ('<input checked="checked" name="agree " type="radio" value="1"> ' , $ checked );
73
74
$ this ->assertEquals ('<input name="no_value" type="radio" value="1"> ' , $ unchecked );
75
+
76
+ // now we check that Request is ignored and value take precedence
77
+ $ this ->formBuilder ->considerRequest (false );
78
+ $ name = $ this ->formBuilder ->text ("person[name] " , "Not John " );
79
+ $ surname = $ this ->formBuilder ->text ("person[surname] " , "Not Doe " );
80
+ $ this ->assertEquals ('<input name="person[name]" type="text" value="Not John"> ' , $ name );
81
+ $ this ->assertEquals ('<input name="person[surname]" type="text" value="Not Doe"> ' , $ surname );
74
82
}
75
83
76
84
public function testOpeningForm ()
0 commit comments