Ejemplo n.º 1
0
 /**
  * @covers ::setValue
  * @covers ::getValue
  * @group  Fieldset
  */
 public function testSetValue()
 {
     $checkbox1 = new Checkbox('', [], '1');
     $checkbox2 = new Checkbox('', [], '2');
     $this->object[] = $checkbox1;
     $this->object[] = $checkbox2;
     $this->object->setValue(1);
     $this->assertEquals(1, $this->object->getValue());
     $this->assertTrue($checkbox1->isChecked());
     $this->assertFalse($checkbox2->isChecked());
     $this->object->setValue([1, 2]);
     $this->assertTrue($checkbox1->isChecked());
     $this->assertTrue($checkbox2->isChecked());
     $this->object->setValue([]);
     $this->assertFalse($checkbox1->isChecked());
     $this->assertFalse($checkbox2->isChecked());
 }
Ejemplo n.º 2
0
 /**
  * @covers ::getName
  * @covers ::isAutoArray
  * @group  Fieldset
  */
 public function testChildNameSet()
 {
     $child = new Checkbox();
     $name = 'test[]';
     $this->object[] = $child;
     $this->object->setName($name);
     $this->assertEquals($name, $child->getName());
 }
Ejemplo n.º 3
0
 /**
  * @covers            ::setChecked
  * @expectedException \InvalidArgumentException
  * @group             Fieldset
  */
 public function testSetNonBool()
 {
     $this->object->setChecked('failure');
 }
Ejemplo n.º 4
0
 /**
  * Renders a basic checkbox
  *
  * @param $checkbox Checkbox
  *
  * @return string
  *
  * @since 2.0
  */
 public function renderCheckbox(Checkbox $checkbox)
 {
     $content = '<div class="checkbox"><label>';
     $content .= $checkbox->render($this);
     $content .= $checkbox->getLabel();
     $content .= '</label></div>';
     return $content;
 }