|
|
@@ -648,4 +648,43 @@ class MultiCheckboxWidgetTest extends TestCase
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * testRenderExplicitId method
|
|
|
+ *
|
|
|
+ * Test that the id passed is actually used
|
|
|
+ * Issue: https://github.com/cakephp/cakephp/issues/13342
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testRenderExplicitId()
|
|
|
+ {
|
|
|
+ $label = new LabelWidget($this->templates);
|
|
|
+ $input = new MultiCheckboxWidget($this->templates, $label);
|
|
|
+ $data = [
|
|
|
+ 'name' => 'field',
|
|
|
+ 'options' => ['value1', 'value2'],
|
|
|
+ 'id' => 'alternative-id',
|
|
|
+ ];
|
|
|
+ $result = $input->render($data, $this->context);
|
|
|
+ $expected = [
|
|
|
+ [
|
|
|
+ 'div' => ['class' => 'checkbox'],
|
|
|
+ 'input' => ['type' => 'checkbox', 'name' => 'field[]', 'value' => '0', 'id' => 'alternative-id-0'],
|
|
|
+ 'label' => ['for' => 'alternative-id-0'],
|
|
|
+ ],
|
|
|
+ 'value1',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ [
|
|
|
+ 'div' => ['class' => 'checkbox'],
|
|
|
+ 'input' => ['type' => 'checkbox', 'name' => 'field[]', 'value' => '1', 'id' => 'alternative-id-1'],
|
|
|
+ 'label' => ['for' => 'alternative-id-1'],
|
|
|
+ ],
|
|
|
+ 'value2',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ }
|
|
|
}
|