[Cs-content-commits] SF.net SVN: cs-content:[467] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-10-21 16:31:01
|
Revision: 467 http://cs-content.svn.sourceforge.net/cs-content/?rev=467&view=rev Author: crazedsanity Date: 2009-10-21 16:30:53 +0000 (Wed, 21 Oct 2009) Log Message: ----------- Minor updates for unit testing. Modified Paths: -------------- trunk/1.0/contentSystem.class.php trunk/1.0/tests/testOfCSContent.php Added Paths: ----------- trunk/1.0/tests/files/includes/ trunk/1.0/tests/files/includes/shared.inc Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-10-21 16:30:18 UTC (rev 466) +++ trunk/1.0/contentSystem.class.php 2009-10-21 16:30:53 UTC (rev 467) @@ -107,7 +107,8 @@ $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); //figure out the section & subsection stuff. - $this->fullSectionArr = split('/', $_SERVER['REQUEST_URI']); //TODO: will this cope with an APPURL being set? + $requestUri = preg_replace('/\/$/', '', $_SERVER['REQUEST_URI']); + $this->fullSectionArr = split('/', $requestUri); //TODO: will this cope with an APPURL being set? $this->section = $this->clean_url($_SERVER['REQUEST_URI']); $this->initialize_locals($siteRoot); @@ -772,6 +773,7 @@ foreach($badUrlVars as $badVarName) { unset($_GET[$badVarName], $_POST[$badVarName]); } + unset($badUrlVars, $badVarName); if(is_array($this->injectVars) && count($this->injectVars)) { $definedVars = get_defined_vars(); @@ -784,6 +786,7 @@ } } } + unset($definedVars, $myVarName, $myVarVal); if(isset($this->session) && is_object($this->session)) { $this->templateObj->session = $this->session; @@ -810,6 +813,7 @@ try { foreach($this->includesList as $myInternalIndex=>$myInternalScriptName) { $this->myLastInclude = $myInternalScriptName; + unset($myInternalScriptName, $myInternalIndex); include_once($this->myLastInclude); } @@ -817,6 +821,7 @@ if(is_array($this->afterIncludesList)) { foreach($this->afterIncludesList as $myInternalIndex=>$myInternalScriptName) { $this->myLastInclude = $myInternalScriptName; + unset($myInternalScriptName, $myInternalIndex); include_once($this->myLastInclude); } } Added: trunk/1.0/tests/files/includes/shared.inc =================================================================== --- trunk/1.0/tests/files/includes/shared.inc (rev 0) +++ trunk/1.0/tests/files/includes/shared.inc 2009-10-21 16:30:53 UTC (rev 467) @@ -0,0 +1,40 @@ +<?php +/* + * Created on Oct 21, 2009 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + +$page->gfObj->debugPrintOpt=1; +$page->allow_invalid_urls(true); +$page->printOnFinish=false; + +if(isset($testObj) && is_object($testObj) && get_class($testObj) == 'TestOfCSContent') { + + //start unit tests!!! + + $testObj->assertTrue(is_array($sectionArr)); + $testObj->assertTrue(is_array($fullSectionArr)); + if(!$testObj->assertEqual(count($sectionArr), count($fullSectionArr))) { + $testObj->assertEqual(false, true, $page->gfObj->debug_print($fullSectionArr)); + } + + foreach(get_defined_vars() as $n=>$v) { + $acceptableVars = array('testObj', 'page', 'sectionArr', 'fullSectionArr', 'finalURL', 'finalSection', 'this'); + $testObj->assertTrue(in_array($n, $acceptableVars), "local var '". $n ."' not allowed as a local var"); + unset($acceptableVars); + } + +} +else { + throw new exception(__FILE__ .": failed to locate unit test object (testObj) while running include script unit tests"); +} + + +?> Property changes on: trunk/1.0/tests/files/includes/shared.inc ___________________________________________________________________ Added: svn:keywords + Author Revision HeadURL Date Modified: trunk/1.0/tests/testOfCSContent.php =================================================================== --- trunk/1.0/tests/testOfCSContent.php 2009-10-21 16:30:18 UTC (rev 466) +++ trunk/1.0/tests/testOfCSContent.php 2009-10-21 16:30:53 UTC (rev 467) @@ -247,6 +247,17 @@ + //------------------------------------------------------------------------- + public function test_contentSystem () { + + $content = new contentSystem(dirname(__FILE__) .'/files'); + $content->inject_var('testObj', $this); + $content->finish(); + }//end test_contentSystem() + //------------------------------------------------------------------------- + + + }//end TestOfCSContent //============================================================================= ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |