@@ -2635,6 +2635,32 @@ function testDefaultValue() {
2635
2635
$ this ->assertTags ($ result , array ('input ' => array ('type ' => 'text ' , 'name ' => 'data[Model][field] ' , 'value ' => 'default value ' , 'id ' => 'ModelField ' )));
2636
2636
}
2637
2637
2638
+ /**
2639
+ * testCheckboxDefaultValue method
2640
+ *
2641
+ * Test default value setting on checkbox() method
2642
+ *
2643
+ * @access public
2644
+ * @return void
2645
+ */
2646
+ function testCheckboxDefaultValue () {
2647
+ $ this ->Form ->request ->data ['Model ' ]['field ' ] = false ;
2648
+ $ result = $ this ->Form ->checkbox ('Model.field ' , array ('default ' => true , 'hiddenField ' => false ));
2649
+ $ this ->assertTags ($ result , array ('input ' => array ('type ' => 'checkbox ' , 'name ' => 'data[Model][field] ' , 'value ' => '1 ' , 'id ' => 'ModelField ' )));
2650
+
2651
+ unset($ this ->Form ->request ->data ['Model ' ]['field ' ]);
2652
+ $ result = $ this ->Form ->checkbox ('Model.field ' , array ('default ' => true , 'hiddenField ' => false ));
2653
+ $ this ->assertTags ($ result , array ('input ' => array ('type ' => 'checkbox ' , 'name ' => 'data[Model][field] ' , 'value ' => '1 ' , 'id ' => 'ModelField ' , 'checked ' => 'checked ' )));
2654
+
2655
+ $ this ->Form ->request ->data ['Model ' ]['field ' ] = true ;
2656
+ $ result = $ this ->Form ->checkbox ('Model.field ' , array ('default ' => false , 'hiddenField ' => false ));
2657
+ $ this ->assertTags ($ result , array ('input ' => array ('type ' => 'checkbox ' , 'name ' => 'data[Model][field] ' , 'value ' => '1 ' , 'id ' => 'ModelField ' , 'checked ' => 'checked ' )));
2658
+
2659
+ unset($ this ->Form ->request ->data ['Model ' ]['field ' ]);
2660
+ $ result = $ this ->Form ->checkbox ('Model.field ' , array ('default ' => false , 'hiddenField ' => false ));
2661
+ $ this ->assertTags ($ result , array ('input ' => array ('type ' => 'checkbox ' , 'name ' => 'data[Model][field] ' , 'value ' => '1 ' , 'id ' => 'ModelField ' )));
2662
+ }
2663
+
2638
2664
/**
2639
2665
* testError method
2640
2666
*
0 commit comments