Beef up url_helper testing

This commit is contained in:
Master Yoda 2018-07-01 00:04:24 -07:00
parent c9c1182c45
commit cb90a1fcde
No known key found for this signature in database
GPG Key ID: CED549230775AD5B
2 changed files with 14 additions and 30 deletions

View File

@ -102,21 +102,11 @@ if ( ! function_exists('base_url'))
$path = implode('/', $path);
}
// We should be using the set baseURL the user set
// otherwise get rid of the path because we have
// We should be using the configured baseURL that the user set;
// otherwise get rid of the path, because we have
// no way of knowing the intent...
$config = \CodeIgniter\Config\Services::request()->config;
if ( ! empty($config->baseURL))
{
$url = new \CodeIgniter\HTTP\URI($config->baseURL);
}
else
{
$url = \CodeIgniter\Config\Services::request($config, false)->uri;
$url->setPath('/');
}
$url = new \CodeIgniter\HTTP\URI($config->baseURL);
unset($config);
// Merge in the path set by the user, if any
@ -402,7 +392,7 @@ if ( ! function_exists('safe_mailto'))
$x = str_split('<a href="mailto:', 1);
for ($i = 0, $l = strlen($email); $i < $l; $i ++)
for ($i = 0, $l = strlen($email); $i < $l; $i ++ )
{
$x[] = '|' . ord($email[$i]);
}
@ -416,7 +406,7 @@ if ( ! function_exists('safe_mailto'))
foreach ($attributes as $key => $val)
{
$x[] = ' ' . $key . '="';
for ($i = 0, $l = strlen($val); $i < $l; $i ++)
for ($i = 0, $l = strlen($val); $i < $l; $i ++ )
{
$x[] = '|' . ord($val[$i]);
}
@ -425,7 +415,7 @@ if ( ! function_exists('safe_mailto'))
}
else
{
for ($i = 0, $l = strlen($attributes); $i < $l; $i ++)
for ($i = 0, $l = strlen($attributes); $i < $l; $i ++ )
{
$x[] = $attributes[$i];
}
@ -435,7 +425,7 @@ if ( ! function_exists('safe_mailto'))
$x[] = '>';
$temp = [];
for ($i = 0, $l = strlen($title); $i < $l; $i ++)
for ($i = 0, $l = strlen($title); $i < $l; $i ++ )
{
$ordinal = ord($title[$i]);
@ -473,7 +463,7 @@ if ( ! function_exists('safe_mailto'))
. "//<![CDATA["
. "var l=new Array();";
for ($i = 0, $c = count($x); $i < $c; $i ++)
for ($i = 0, $c = count($x); $i < $c; $i ++ )
{
$output .= "l[" . $i . "] = '" . $x[$i] . "';";
}
@ -605,10 +595,10 @@ if ( ! function_exists('url_title'))
$q_separator = preg_quote($separator, '#');
$trans = [
'&.+?;' => '',
'[^\w\d _-]' => '',
'\s+' => $separator,
'(' . $q_separator . ')+' => $separator
'&.+?;' => '',
'[^\w\d _-]' => '',
'\s+' => $separator,
'(' . $q_separator . ')+' => $separator
];
$str = strip_tags($str);

View File

@ -187,8 +187,6 @@ class URLHelperTest extends \CIUnitTestCase
$this->assertEquals('http://example.com/index.php/', site_url());
}
//--------------------------------------------------------------------
/**
* @see https://github.com/bcit-ci/CodeIgniter4/issues/240
*/
@ -209,8 +207,6 @@ class URLHelperTest extends \CIUnitTestCase
$this->assertEquals('http://example.com/index.php/profile', site_url('profile'));
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Test base_url
@ -289,8 +285,6 @@ class URLHelperTest extends \CIUnitTestCase
$this->assertEquals('http://example.com/', base_url());
}
//--------------------------------------------------------------------
/**
* @see https://github.com/bcit-ci/CodeIgniter4/issues/867
*/
@ -323,8 +317,6 @@ class URLHelperTest extends \CIUnitTestCase
$this->assertEquals('http://example.com/profile', base_url('profile'));
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Test current_url
@ -856,6 +848,8 @@ class URLHelperTest extends \CIUnitTestCase
{
$this->assertEquals('http://codeigniter.com', prep_url('codeigniter.com'));
$this->assertEquals('http://www.codeigniter.com', prep_url('www.codeigniter.com'));
$this->assertEquals('', prep_url());
$this->assertEquals('http://www.codeigniter.com', prep_url('http://www.codeigniter.com'));
}
//--------------------------------------------------------------------