Example #1
0
 public function testSettersAndGettersDoWhatTheyShould()
 {
     $field = new Field('type', 'element', 'label', 'description');
     $field->setOptions(['options' => 'options']);
     $field->setValidationRules('rules');
     $field->setValue('foo');
     $expectations = ['getOptions' => ['options' => 'options'], 'getValidationRules' => 'rules', 'getValue' => 'foo'];
     foreach ($expectations as $method => $value) {
         static::assertEquals($field->{$method}(), $value);
     }
 }
Example #2
0
 /**
  * Test setOptions exception
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid option
  */
 public function testSetOptionsException()
 {
     $object = new Field('PAGE');
     $object->setOptions(array('foo' => 'bar'));
 }
 /**
  * Unit Test case-9 to test Check Boxes
  */
 public function testAdminCheckbox()
 {
     $test = new Field(6);
     $test->setType("checkbox");
     $test->setIsRequired(true);
     $test->setTextBefore("CHECK BOX!");
     $test->setOptions("option1|-etm-|option2|-etm-|option3");
     $html = $test->getAdminHtml();
     /**
      * test to see the textbeforechanges
      */
     preg_match_all('/CHECK BOX!/', $html, $matches);
     $this->assertEquals(2, count($matches[0]));
     /**
      * test to see we see the id 6
      */
     preg_match_all('/etm_element_(\\d+)/', $html, $matches);
     $this->assertEquals(6, $matches[1][0]);
     /**
      * test to see we see  input types of type select
      */
     preg_match_all('/<input type=\'checkbox\'/', $html, $matches);
     $this->assertEquals(3, count($matches[0]));
 }