/** * Test the getInput method. */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat( $form->load('<form><field name="password" type="password" /></form>'), $this->isTrue(), 'Line:'.__LINE__.' XML string should load successfully.' ); $field = new JFormFieldPassword($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. }
public function setup(SimpleXMLElement $element, $value, $group = null) { $this->element = $element; $element['label'] = $this->prepareText($element['label']); $element['description'] = $this->prepareText($element['description']); $element['translateDescription'] = false; return parent::setup($element, $value, $group); }
/** * Tests meter attribute setup by using the magic set method * * @covers JFormFieldPassword::__set * * @return void */ public function testSetMeter() { $field = new JFormFieldPassword(); $element = simplexml_load_string('<field name="myName" type="password" />'); $this->assertTrue($field->setup($element, ''), 'Line:' . __LINE__ . ' The setup method should return true if successful.'); $this->assertFalse($field->meter, 'Line:' . __LINE__ . ' The property is false by default.'); $field->meter = true; $this->assertTrue($field->meter, 'Line:' . __LINE__ . ' The magic set method should set the property correctly.'); }
/** * Tests meter attribute setup by JFormFieldText::setup method * * @covers JFormField::setup * @covers JFormField::__get * * @return void */ public function testSetupMeter() { $field = new JFormFieldPassword(); $element = simplexml_load_string('<field name="myName" type="password" strengthmeter="true" />'); $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.'); $this->assertThat($field->meter, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.'); }