[Cs-content-commits] SF.net SVN: cs-content:[490] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
|
From: <cra...@us...> - 2011-01-25 02:01:16
|
Revision: 490
http://cs-content.svn.sourceforge.net/cs-content/?rev=490&view=rev
Author: crazedsanity
Date: 2011-01-25 02:01:09 +0000 (Tue, 25 Jan 2011)
Log Message:
-----------
Parts of URL can be one character long; tests to make sure it always works.
/tests/testOfCSGlobalFunctions.php:
* test_clean_url() [NEW]:
-- test the new clean_url() method
/cs_globalFunctions.class.php:
* clean_url():
-- modified so the bits of the URL can be one character long or more
(not two or more)
Modified Paths:
--------------
trunk/1.0/cs_globalFunctions.class.php
trunk/1.0/tests/testOfCSGlobalFunctions.php
Modified: trunk/1.0/cs_globalFunctions.class.php
===================================================================
--- trunk/1.0/cs_globalFunctions.class.php 2011-01-25 00:01:07 UTC (rev 489)
+++ trunk/1.0/cs_globalFunctions.class.php 2011-01-25 02:01:09 UTC (rev 490)
@@ -920,7 +920,7 @@
$tUrl = null;
foreach($tArr as $tUrlPart) {
$temp = explode(".", $tUrlPart);
- if(strlen($temp[0]) > 1) {
+ if(strlen($temp[0])) {
$tUrlPart = $temp[0];
}
$tUrl = $this->create_list($tUrl, $tUrlPart, '/');
@@ -929,7 +929,7 @@
}
}
else {
- throw new exception(__METHOD__ .": invalid url (". $url .")");
+ $url = null;
}
return($url);
Modified: trunk/1.0/tests/testOfCSGlobalFunctions.php
===================================================================
--- trunk/1.0/tests/testOfCSGlobalFunctions.php 2011-01-25 00:01:07 UTC (rev 489)
+++ trunk/1.0/tests/testOfCSGlobalFunctions.php 2011-01-25 02:01:09 UTC (rev 490)
@@ -399,6 +399,34 @@
+ //-------------------------------------------------------------------------
+ function test_clean_url() {
+ $testUrls = array(
+ "testNulls" => NULL,
+ "testEmpty" => array("", NULL),
+ "root" => "",
+ "simple" => array("/index.php/test.html","index/test"),
+ "complex" => array("/x.xyz/y.123/_x/-y/*z", "x/y/_x/-y/*z"),
+ "noLeadingSlash"=> array("page/stuff.html", "page/stuff"),
+ );
+ $gf = new cs_globalFunctions;
+ foreach($testUrls as $testName=>$cleanThis) {
+ if(is_array($cleanThis)) {
+ $expectThis = $cleanThis[1];
+ $cleanThis = $cleanThis[0];
+ }
+ else {
+ $expectThis = $cleanThis;
+ }
+ $actualOutput = $gf->clean_url($cleanThis);
+ $this->assertEqual($expectThis, $actualOutput, "failed test '". $testName ."', expected=(". $expectThis ."), actualOutput=(". $actualOutput .")");
+ }
+ }//end test_clean_url()
+ //-------------------------------------------------------------------------
+
+
+
+
}//end TestOfCSGlobalFunctions
//=============================================================================
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|