/** * Test the getInput method. * * @return void * * @since 11.4 */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat( $form->load('<form><field name="editors" type="plugins" folder="editors" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.' ); $field = new JFormFieldPlugins($form); $this->assertThat( $field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.' ); if (!is_null(self::$driver)) { $this->assertThat( strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.' ); } else { $this->markTestSkipped(); } // TODO: Should check all the attributes have come in properly. }
/** * Tests folder attribute setup by JFormFieldPlugins::setup method * * @covers JFormField::setup * @covers JFormField::__get * * @return void */ public function testSetupFolder() { $field = new JFormFieldPlugins(); $element = simplexml_load_string('<field name="editors" type="plugins" folder="editors" />'); $this->assertThat($field->setup($element, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.'); $this->assertThat($field->folder, $this->equalTo("editors"), 'Line:' . __LINE__ . ' The property should be computed from the XML.'); }
/** * Get defined payment gateway profiles. * * @return array */ protected function getOptions() { // Initialize variables $prefix = isset($this->element['prefix']) ? (string) $this->element['prefix'] : ''; $filter = isset($this->element['filter']) ? (string) $this->element['filter'] : ''; // Call parent method to get list of plugin $options = parent::getOptions(); $edition = defined('JSN_UNIFORM_EDITION') ? JSN_UNIFORM_EDITION : "free"; if (strtolower($edition) == "free") { return array($options[0]); } // Loop thru results to filter foreach ($options as $k => $v) { // Only filter if option is a plugin if (is_file(JPATH_ROOT . '/plugins/' . (string) $this->element['folder'] . "/{$v->value}/{$v->value}.php")) { if ($prefix and strpos($v->value, $prefix) !== 0) { unset($options[$k]); } if ($filter and !preg_match($filter, $v->value)) { unset($options[$k]); } } elseif ($k != '0') { unset($options[$k]); } } return $options; }
/** * Method to get certain otherwise inaccessible properties from the form field object. * * @param string $name The property name for which to the the value. * * @return mixed The property value or null. * * @since 2.0 */ public function __get($name) { switch ($name) { case 'static': if (empty($this->static)) { $this->static = $this->getStatic(); } return $this->static; break; case 'repeatable': if (empty($this->repeatable)) { $this->repeatable = $this->getRepeatable(); } return $this->static; break; default: return parent::__get($name); } }