/**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="mysqli" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldDatabaseConnection($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; in this case, a "Mysqli" option.');
     $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="non-existing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldDatabaseConnection($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; in this case, a "None" option.');
     // TODO: Should check all the attributes have come in properly.
 }
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="combo" type="combo" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldCombo($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
 }
 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="moduletag" type="moduletag" label="Module Tag" description="Module Tag listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldModuletag($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertContains('<option value="nav">nav</option>', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with various opening tags, verify nav tag is in list.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="color" type="color" disabled="true" onchange="window.reload()" class="inputbox" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldColor($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.');
 }
 /**
  * Test the getOptions method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetOptions()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="radio" type="radio"><option value="0">No</option><item value="1">Yes</item></field></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldRadio($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->logicalNot($this->StringContains('Yes')), 'Line:' . __LINE__ . ' The field should not contain a Yes option.');
 }
 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="helpsite" type="helpsite" label="Help Site" description="Help Site listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldHelpsite($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertContains('<option value="http://help.joomla.org/proxy/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with a link to the help site.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  * @todo    Should check all the attributes have come in properly.
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="componentlayout" type="componentlayout" extension="com_content" client_id="0" view="blog" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldComponentlayout($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.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="accesslevel" type="accesslevel" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldAccessLevel($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.');
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="filelist" type="filelist" directory="modules/mod_finder/tmpl" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldFileList($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.
 }
Beispiel #10
0
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="rules" type="rules" section="component" component="com_content" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldRules($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.
 }
 /**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $expected = '<form><field name="usergroup" type="usergroup" class="inputbox" disabled="true" onclick="window.reload()">' . '<option value="*">None</option><item value="fake">Fake</item></field></form>';
     $this->assertThat($form->load($expected), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldUsergroup($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.
 }
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInput()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="file" type="file" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldFile($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     // $this->markTestIncomplete('Problems encountered in next assertion');
     $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.
 }
 /**
  * Test the getOptions method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetOptions()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="integer" type="integer" first="1" last="-5" step="1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInteger($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat($field->input, $this->logicalNot($this->StringContains('<option')), 'Line:' . __LINE__ . ' The field should not contain any options.');
     $this->assertThat($form->load('<form><field name="integer" type="integer" first="-7" last="-5" step="1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInteger($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat($field->input, $this->StringContains('<option value="-7">-7</option>'), 'Line:' . __LINE__ . ' The field should contain -7 through -5 as options.');
     $this->assertThat($form->load('<form><field name="integer" type="integer" first="-7" last="-5" step="-1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInteger($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat($field->input, $this->logicalNot($this->StringContains('<option')), 'Line:' . __LINE__ . ' The field should not contain any options.');
     $this->assertThat($form->load('<form><field name="integer" type="integer" first="-5" last="-7" step="-1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInteger($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $this->assertThat($field->input, $this->StringContains('<option value="-7">-7</option>'), 'Line:' . __LINE__ . ' The field should contain -5 through -7 as options.');
 }
 /**
  * Test the getLabel method.
  *
  * @return void
  */
 public function testGetLabel()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="spacer" type="spacer" description="spacer" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldSpacer($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $equals = '<span class="spacer"><span class="before"></span><span>' . '<label id="spacer-lbl" class="hasTooltip" title="<strong>spacer</strong>">spacer</label></span>' . '<span class="after"></span></span>';
     $this->assertEquals($equals, $field->label, 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
     $this->assertThat($form->load('<form><field name="spacer" type="spacer" class="text" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldSpacer($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $equals = '<span class="spacer"><span class="before"></span><span class="text">' . '<label id="spacer-lbl" class="">spacer</label></span><span class="after"></span></span>';
     $this->assertEquals($equals, $field->label, 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
     $this->assertThat($form->load('<form><field name="spacer" type="spacer" class="text" label="MyLabel" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldSpacer($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $equals = '<span class="spacer"><span class="before"></span><span class="text">' . '<label id="spacer-lbl" class="">MyLabel</label></span><span class="after"></span></span>';
     $this->assertEquals($field->label, $equals, 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
     $this->assertThat($form->load('<form><field name="spacer" type="spacer" hr="true" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldSpacer($form);
     $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
     $expected = '<span class="spacer"><span class="before"></span><span><hr /></span>' . '<span class="after"></span></span>';
     $this->assertEquals($expected, $field->label, 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
 }
Beispiel #15
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param   JForm   $form   The form object
  * @param   array   $data   The data to be merged into the form object
  * @param   string  $group  The plugin group to be executed
  *
  * @return  void
  *
  * @since    3.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Association content items
     $app = JFactory::getApplication();
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_CONTENT_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_article');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     // Insert Mediatype from plugins
     $dispatcher = JDispatcher::getInstance();
     TZ_Portfolio_PlusPluginHelper::importPlugin('mediatype');
     if ($mediaType = $dispatcher->trigger('onAddMediaType')) {
         if (count($mediaType)) {
             $xml = $form->getXml();
             $field_type = $xml->xpath('//field[@name="type"]');
             $field_type = $field_type[0];
             foreach ($mediaType as $type) {
                 if (is_object($type)) {
                     $field_type->addChild('option', $type->text)->addAttribute('value', $type->value);
                 } elseif (is_array($type)) {
                     $field_type->addChild('option', $type['text'])->addAttribute('value', $type['value']);
                 }
             }
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
Beispiel #16
0
 public function testLoad_ReplaceDescendent(JForm $form)
 {
     // Check the replacement data loads ok.
     $this->assertThat($form->load(JFormDataHelper::$loadReplacementDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     // Check that replaced options are present
     $this->assertThat(count($form->getXml()->xpath('/form/fields/fields[@name="params"]/field[@name="show_title"]/option')), $this->equalTo(3), 'Line:' . __LINE__ . ' The show_title in the params group is supposed to have 3 descendant nodes.');
 }
 /**
  * Test the getInput method.
  *
  * @return void
  */
 public function testGetInputWithStringValue()
 {
     $form = new JForm('form1');
     $this->assertThat($form->load('<form><field name="calendar" type="calendar" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     // The calendar form field depends on having the time zone available. Easiest way is to
     // mock it in the config
     $testConfig = $this->getMockConfig();
     $testConfig->expects($this->any())->method('get')->will($this->returnValue('Europe/London'));
     JFactory::$config = $testConfig;
     $field = new JFormFieldCalendar($form);
     $this->assertThat($field->setup($form->getXml()->field, 'June 2015'), $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.
 }