/** * Test the getInput method. */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat( $form->load('<form><field name="checkbox" type="checkbox" /></form>'), $this->isTrue(), 'Line:'.__LINE__.' XML string should load successfully.' ); $field = new JFormFieldCheckbox($form); $this->assertThat( $field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:'.__LINE__.' The setup method should return true.' ); $this->assertThat( strlen($field->input), $this->greaterThan(0), 'Line:'.__LINE__.' The getInput method should return something without error.' ); // TODO: Should check all the attributes have come in properly. }
/** * Tests checked attribute setup by JFormField::setup method * * @covers JFormFieldCheckbox::setup * @covers JFormField::__get * * @return void */ public function testSetupChecked() { $field = new JFormFieldCheckbox(); $element = simplexml_load_string('<field name="myName" type="checkbox" checked="true" />'); $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.'); $this->assertThat($field->checked, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.'); }