/**
  * Test the getInput method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInput()
 {
     $form = new JFormInspector('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
	 *
	 * @since   11.1
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load('<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->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.'
		);

		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.
	}
	/**
	 * 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.
	}
	/**
	 * Test the getInput method.
	 *
	 * @return  void
	 *
	 * @since   12.1
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load('<form><field name="sql" type="sql" key_field="id" query="SELECT * FROM `jos_categories`"><option value="*">None</option></field></form>'),
			$this->isTrue(),
			'Line:' . __LINE__ . ' XML string should load successfully.'
		);

		$field = new JFormFieldSQL($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();
		}
	}
	/**
	 * Test the getInput method.
	 *
	 * @return  void
	 *
	 * @since   11.1
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('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.'
		);

		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();
		}
	}
Esempio n. 6
0
 /**
  * Test the getOptions method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetOptions()
 {
     $form = new JFormInspector('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.');
 }
	/**
	 * 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.
	}
	/**
	 * Test the getOptions method.
	 *
	 * @return  void
	 *
	 * @since   11.3
	 */
	public function testGetOptions()
	{
		$form = new JFormInspector('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.'
		);
	}
	/**
	 * Test the getInput method.
	 *
	 * @since   11.1
	 * @todo    Should check all the attributes have come in properly.
	 *
	 * @return  void
	 */
	public function testGetInput()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load('<form><field name="componentlayout" type="componentlayout" /></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->markTestIncomplete('Problems encountered in next assertion');

		$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 JFormInspector('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 getInput method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetInput()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load('<form><field name="cachehandler" type="cachehandler" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldCacheHandler($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.');
 }
Esempio n. 12
0
 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JFormInspector('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.');
 }
Esempio n. 13
0
 /**
  * Tests the getInput method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testGetInput()
 {
     $form = new JFormInspector('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.');
 }
Esempio n. 14
0
 /**
  * Test the getLabel method.
  */
 public function testGetLabel()
 {
     $form = new JFormInspector('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.');
     $this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class=""><label id="spacer-lbl" class="hasTip" title="spacer::spacer">spacer</label></span><span class="after"></span></span>', '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.');
     $this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class="text"><label id="spacer-lbl" class="">spacer</label></span><span class="after"></span></span>', '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.');
     $this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class="text"><label id="spacer-lbl" class="">MyLabel</label></span><span class="after"></span></span>', '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.');
     $this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class=""><hr class="" /></span><span class="after"></span></span>', 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
 }
Esempio n. 15
0
	/**
	 * Test the JForm::load method for XPath data.
	 *
	 * This method can load an XML data object, or parse an XML string.
	 *
	 * @return void
	 */
	public function testLoad_XPath()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load(JFormDataHelper::$loadXPathDocument, true, '/extension/fields'),
			$this->isTrue(),
			'Line:' . __LINE__ . ' XML string should load successfully.'
		);

		$this->assertThat(
			$form->getXml()->getName(),
			$this->equalTo('form'),
			'Line:' . __LINE__ . ' The internal XML should still be named "form".'
		);

		// @todo remove: $this->_showXml($form);die;
		$this->assertThat(
			count($form->getXml()->fields->fields),
			$this->equalTo(2),
			'Line:' . __LINE__ . ' The test data has 2 fields.'
		);
	}
Esempio n. 16
0
 /**
  * Tests the JFormField::getTitle method
  *
  * @return void
  */
 public function testGetTitle()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInspector($form);
     // Standard usage.
     $xml = $form->getXml();
     $data = $xml->xpath('fields/field[@name="title"]');
     $title = array_pop($data);
     $this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->getTitle(), $this->equalTo('Title'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     // Hidden field
     $data = $xml->xpath('fields/field[@name="id"]');
     $id = array_pop($data);
     $this->assertThat($field->setup($id, 'id'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->getTitle(), $this->equalTo(''), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }
Esempio n. 17
0
 /**
  * Test for JForm::validateField method for missing rule exception.
  *
  * @return  void
  *
  * @since   12.1
  *
  * @expectedException  UnexpectedValueException
  */
 public function testValidateField_missingRule()
 {
     $form = new JFormInspector('form1');
     $form->load(JFormDataHelper::$validateFieldDocument);
     $xml = $form->getXml();
     $data = $xml->xpath('fields/field[@name="missingrule"]');
     $field = array_pop($data);
     $form->validateField($field, null, 'value');
 }