| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 10 class GeneratedTestClass 11 { 12 protected $class_name; 13 14 function __construct() 15 { 16 $this->class_name = 'GenClass_' . mt_rand(1, 10000); 17 } 18 19 function getClass() 20 { 21 return $this->class_name; 22 } 23 24 function getFileName() 25 { 26 return $this->class_name . ".class.php"; 27 } 28 29 function getOutput() 30 { 31 return $this->class_name . "\n"; 32 } 33 34 function generate() 35 { 36 $code = ''; 37 $code .= "<?php\n"; 38 $code .= $this->generateClass(); 39 $code .= "\n?>"; 40 return $code; 41 } 42 43 function generateFailing() 44 { 45 $code = ''; 46 $code .= "<?php\n"; 47 $code .= $this->generateClassFailing(); 48 $code .= "\n?>"; 49 return $code; 50 } 51 52 function generateClass() 53 { 54 $code = "class {$this->class_name} extends UnitTestCase { 55 function testSay() {echo \"" . $this->getOutput() . "\";} 56 }"; 57 return $code; 58 } 59 60 function generateClassFailing() 61 { 62 $code = "class {$this->class_name} extends UnitTestCase { 63 function testSay() {\$this->assertTrue(false);echo \"" . $this->getOutput() . "\";} 64 }"; 65 return $code; 66 } 67 } 68 69 abstract class lmbTestRunnerBase extends UnitTestCase 70 { 71 function _rmdir($path) 72 { 73 if(!is_dir($path)) 74 return; 75 76 $dir = opendir($path); 77 while($entry = readdir($dir)) 78 { 79 if(is_file("$path/$entry")) 80 unlink("$path/$entry"); 81 elseif(is_dir("$path/$entry") && $entry != '.' && $entry != '..') 82 $this->_rmdir("$path/$entry"); 83 } 84 closedir($dir); 85 $res = rmdir($path); 86 clearstatcache(); 87 return $res; 88 } 89 90 function _createTestCase($file, $extra = '') 91 { 92 $dir = dirname($file); 93 if(!is_dir($dir)) 94 mkdir($dir, 0777, true); 95 96 $generated = new GeneratedTestClass(); 97 file_put_contents($file, "<?php\n" . $generated->generateClass() . $extra . "\n?>"); 98 return $generated; 99 } 100 101 function _createTestCaseFailing($file, $extra = '') 102 { 103 $dir = dirname($file); 104 if(!is_dir($dir)) 105 mkdir($dir, 0777, true); 106 107 $generated = new GeneratedTestClass(); 108 file_put_contents($file, "<?php\n" . $generated->generateClassFailing() . $extra . "\n?>"); 109 return $generated; 110 } 111 } 112 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |