/** * Test the JFormRuleUrl::test method. * * @param string $xmlfield @todo * @param string $url @todo * @param string $expected @todo * * @dataProvider provider * * @return void */ public function testUrl($xmlfield, $url, $expected) { $rule = new JFormRuleUrl(); // The field allows you to optionally limit the accepted schemes to a specific list. // Url1 tests without a list, Url2 tests with a list. $xml = simplexml_load_string('<form><field name="url1" /><field name="url2" schemes="gopher" /></form>'); if ($xmlfield == '0') { if ($expected == 'false') { // Test fail conditions. $this->assertThat($rule->test($xml->field[0], $url), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should return' . $expected . '.'); } if ($expected == 'true') { // Test pass conditions. $this->assertThat($rule->test($xml->field[0], $url), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should return' . $expected . '.'); } } if ($xmlfield == '1') { if ($expected == 'false') { // Test fail conditions. $this->assertThat($rule->test($xml->field[1], $url), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should return' . $expected . '.'); } if ($expected == 'true') { // Test pass conditions. $this->assertThat($rule->test($xml->field[1], $url), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should return' . $expected . '.'); } } }
private function getInstallFrom() { if (is_null($this->_installfrom)) { $app = JFactory::getApplication(); $installfrom = base64_decode($app->input->get('installfrom', '', 'base64')); $field = new SimpleXMLElement('<field></field>'); $rule = new JFormRuleUrl(); if ($rule->test($field, $installfrom) && preg_match('/\\.xml\\s*$/', $installfrom)) { jimport('joomla.updater.update'); $update = new JUpdate(); $update->loadFromXML($installfrom); $package_url = trim($update->get('downloadurl', false)->_data); if ($package_url) { $installfrom = $package_url; } } $this->_installfrom = $installfrom; } return $this->_installfrom; }