/** * Tests maxLength attribute setup by JFormFieldText::setup method * * @covers JFormField::setup * @covers JFormField::__get * * @return void */ public function testSetup() { $field = new JFormFieldNumber(); $element = simplexml_load_string('<field name="myName" type="text" max="60" min="1" step="2" />'); $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.'); $this->assertThat($field->max, $this->equalTo(60), 'Line:' . __LINE__ . ' The property should be computed from the XML.'); $this->assertThat($field->min, $this->equalTo(1), 'Line:' . __LINE__ . ' The property should be computed from the XML.'); $this->assertThat($field->step, $this->equalTo(2), 'Line:' . __LINE__ . ' The property should be computed from the XML.'); }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->width = isset($this->element['width']) ? (string) $this->element['width'] : ''; $this->color = isset($this->element['color']) ? (string) $this->element['color'] : ''; $active = (string) $this->element['active']; $this->active = $active == 'true' || $active == 'on' || $active == '1'; $animated = (string) $this->element['animated']; $this->animated = !($animated == 'false' || $animated == 'off' || $animated == '0'); } return $return; }