|
|
@@ -100,7 +100,50 @@ class MultiCheckboxTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testRenderSelected() {
|
|
|
- $this->markTestIncomplete();
|
|
|
+ $input = new MultiCheckbox($this->templates);
|
|
|
+ $data = [
|
|
|
+ 'name' => 'Tags[id]',
|
|
|
+ 'options' => [
|
|
|
+ 1 => 'CakePHP',
|
|
|
+ '1x' => 'Development',
|
|
|
+ ],
|
|
|
+ 'val' => [1]
|
|
|
+ ];
|
|
|
+ $result = $input->render($data);
|
|
|
+ $expected = [
|
|
|
+ ['div' => ['class' => 'checkbox']],
|
|
|
+ ['input' => [
|
|
|
+ 'type' => 'checkbox',
|
|
|
+ 'name' => 'Tags[id][]',
|
|
|
+ 'value' => 1,
|
|
|
+ 'id' => 'tags-id-1',
|
|
|
+ 'checked' => 'checked'
|
|
|
+ ]],
|
|
|
+ ['label' => ['for' => 'tags-id-1']],
|
|
|
+ 'CakePHP',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ ['div' => ['class' => 'checkbox']],
|
|
|
+ ['input' => [
|
|
|
+ 'type' => 'checkbox',
|
|
|
+ 'name' => 'Tags[id][]',
|
|
|
+ 'value' => '1x',
|
|
|
+ 'id' => 'tags-id-1x',
|
|
|
+ ]],
|
|
|
+ ['label' => ['for' => 'tags-id-1x']],
|
|
|
+ 'Development',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ ];
|
|
|
+ $this->assertTags($result, $expected);
|
|
|
+
|
|
|
+ $data['val'] = 1;
|
|
|
+ $result = $input->render($data);
|
|
|
+ $this->assertTags($result, $expected);
|
|
|
+
|
|
|
+ $data['val'] = '1';
|
|
|
+ $result = $input->render($data);
|
|
|
+ $this->assertTags($result, $expected);
|
|
|
}
|
|
|
|
|
|
/**
|