Thread: [Cs-content-commits] SF.net SVN: cs-content:[441] trunk/1.0/tests/testOfCSContent.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-08-18 18:41:47
|
Revision: 441 http://cs-content.svn.sourceforge.net/cs-content/?rev=441&view=rev Author: crazedsanity Date: 2009-08-18 18:41:36 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Don't rely on a defined constant to determine location of files dir since it is static. Modified Paths: -------------- trunk/1.0/tests/testOfCSContent.php Modified: trunk/1.0/tests/testOfCSContent.php =================================================================== --- trunk/1.0/tests/testOfCSContent.php 2009-08-18 18:40:18 UTC (rev 440) +++ trunk/1.0/tests/testOfCSContent.php 2009-08-18 18:41:36 UTC (rev 441) @@ -102,7 +102,7 @@ //------------------------------------------------------------------------- function test_genericPage() { - $filesDir = constant('TEST_FILESDIR'); + $filesDir = dirname(__FILE__) .'/files'; $page = new cs_genericPage(false, $filesDir .'/templates/main.shared.tmpl', false); $fs = new cs_fileSystem($filesDir .'/templates'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-18 18:56:25
|
Revision: 442 http://cs-content.svn.sourceforge.net/cs-content/?rev=442&view=rev Author: crazedsanity Date: 2009-08-18 18:55:52 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Remove test that is covered in the testOfCSFileSystem tests... Modified Paths: -------------- trunk/1.0/tests/testOfCSContent.php Modified: trunk/1.0/tests/testOfCSContent.php =================================================================== --- trunk/1.0/tests/testOfCSContent.php 2009-08-18 18:41:36 UTC (rev 441) +++ trunk/1.0/tests/testOfCSContent.php 2009-08-18 18:55:52 UTC (rev 442) @@ -157,36 +157,6 @@ - //------------------------------------------------------------------------- - function test_cs_fileSystem() { - $fs = new cs_fileSystem(constant('TEST_FILESDIR')); - - $list = array( - 'slashTest' => array('/sampleConfig.xml', 'sampleConfig.xml'), - 'slashtest2' => array('/templates/content.shared.tmpl', 'templates/content.shared.tmpl'), - 'pathWithDots' => array('templates/.././sampleConfig.xml', '/templates/.././sampleConfig.xml'), - 'multiSlashes' => array('////sampleConfig.xml', '///sampleConfig.xml', '/templates///////content.shared.tmpl/../templates/content.shared.tmpl') - ); - - foreach($list as $testName=>$files) { - foreach($files as $filename) { - $gotException=false; - try { - $data = $fs->ls('/sampleConfig.xml'); - } - catch(exception $e) { - $gotException=true; - } - - $this->assertFalse($gotException, "Failed test '". $testName ."'"); - } - } - - }//end test_cs_fileSystem() - //------------------------------------------------------------------------- - - - }//end TestOfCSContent //============================================================================= ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-08-18 20:36:50
|
Revision: 445 http://cs-content.svn.sourceforge.net/cs-content/?rev=445&view=rev Author: crazedsanity Date: 2009-08-18 20:36:41 +0000 (Tue, 18 Aug 2009) Log Message: ----------- More unit testing. Modified Paths: -------------- trunk/1.0/tests/testOfCSContent.php Modified: trunk/1.0/tests/testOfCSContent.php =================================================================== --- trunk/1.0/tests/testOfCSContent.php 2009-08-18 20:35:56 UTC (rev 444) +++ trunk/1.0/tests/testOfCSContent.php 2009-08-18 20:36:41 UTC (rev 445) @@ -104,14 +104,15 @@ function test_genericPage() { $filesDir = dirname(__FILE__) .'/files'; - $page = new cs_genericPage(false, $filesDir .'/templates/main.shared.tmpl', false); + $mainTemplate = $filesDir .'/templates/main.shared.tmpl'; + $page = new cs_genericPage(false, $mainTemplate); $fs = new cs_fileSystem($filesDir .'/templates'); $lsData = $fs->ls(); foreach($lsData as $index=>$value) { $filenameBits = explode('.', $index); - $page->add_template_var($filenameBits[0], $page->file_to_string($index)); + $page->add_template_file($filenameBits[0], $index); } $page->add_template_var('blockRowTestVal', 3); @@ -152,6 +153,44 @@ $this->assertNotEqual($page2->templateVars['content'], $page2->strip_undef_template_vars($page2->templateVars['content'])); $page2->templateVars['content'] = $page2->strip_undef_template_vars($page2->templateVars['content']); $this->assertEqual($page->return_printed_page(1), $page2->return_printed_page(1)); + + + //test to see if the list of templateFiles is as expected... + { + $files = array_keys($lsData); + $expectedList = array(); + foreach($files as $name) { + $bits = explode('.', $name); + $expectedList[$bits[0]] = $name; + } + + $this->assertEqual($expectedList, $page->templateFiles); + } + + + //make sure stripping undefined vars works properly. + { + $page = new cs_genericPage(false, $mainTemplate); + $this->assertEqual($fs->read($mainTemplate), $page->return_printed_page(0)); + $this->assertNotEqual($fs->read($mainTemplate), $page->return_printed_page(1)); + + //rip out undefined template vars manually & check 'em. + $junk = array(); + $contents = $page->strip_undef_template_vars($fs->read($mainTemplate), $junk); + $this->assertEqual($page->strip_undef_template_vars($fs->read($mainTemplate)), $page->return_printed_page(1)); + $this->assertNotEqual($page->strip_undef_template_vars($fs->read($mainTemplate)), $page->return_printed_page(0)); + + + //make sure the unhandled var lists are the same. + $myUnhandledVars = array(); + $page->strip_undef_template_vars($fs->read($mainTemplate), $myUnhandledVars); + $page->return_printed_page(1);//the last run MUST strip undefined vars. + $this->assertEqual(array_keys($myUnhandledVars), array_keys($page->unhandledVars)); + if(!$this->assertEqual($myUnhandledVars, $page->unhandledVars)) { + $this->gfObj->debug_print($myUnhandledVars); + $this->gfObj->debug_print($page->unhandledVars); + } + } }//end test_genericPage //------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-09-14 15:21:27
|
Revision: 458 http://cs-content.svn.sourceforge.net/cs-content/?rev=458&view=rev Author: crazedsanity Date: 2009-09-14 15:21:16 +0000 (Mon, 14 Sep 2009) Log Message: ----------- Add a couple of tests to ensure $page->templateObj->varvals['out'] matches the printed data. Modified Paths: -------------- trunk/1.0/tests/testOfCSContent.php Modified: trunk/1.0/tests/testOfCSContent.php =================================================================== --- trunk/1.0/tests/testOfCSContent.php 2009-09-14 15:20:16 UTC (rev 457) +++ trunk/1.0/tests/testOfCSContent.php 2009-09-14 15:21:16 UTC (rev 458) @@ -120,6 +120,7 @@ $this->assertEqual($checkThis, file_get_contents($filesDir .'/gptest_all-together.txt')); + $this->assertEqual($checkThis, $page->templateObj->varvals['out']); //now let's rip all the template rows out & add them back in. $rowDefs = $page->get_block_row_defs('content'); @@ -137,8 +138,10 @@ $checkThis2 = $page->return_printed_page(); $this->assertEqual($checkThis, $checkThis2); + $this->assertEqual($checkThis2, $page->templateObj->varvals['out']); $checkThis = $page->return_printed_page(0); + $this->assertTrue(preg_match('/\{.\S+?\}/', $page->templateObj->varvals['out'])); $this->assertTrue(preg_match('/\{.\S+?\}/', $checkThis)); //clone the page object so we can change stuff & not affect the original. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |