cvs: pear /PECL_Gen Extension.php /PECL_Gen/Element Test.php
| From: | Hartmut Holzgraefe | Date: | Sat, 27 Sep 2003 16:48:34 +0000 |
| Subject: | cvs: pear /PECL_Gen Extension.php /PECL_Gen/Element Test.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13135@lists.php.net to get a copy of this message | ||
hholzgra Sat Sep 27 12:48:34 2003 EDT
Modified files:
/pear/PECL_Gen Extension.php
/pear/PECL_Gen/Element Test.php
Log:
custom testfile support added
Index: pear/PECL_Gen/Extension.php
diff -u pear/PECL_Gen/Extension.php:1.13 pear/PECL_Gen/Extension.php:1.14
--- pear/PECL_Gen/Extension.php:1.13 Thu Sep 25 17:05:04 2003
+++ pear/PECL_Gen/Extension.php Sat Sep 27 12:48:34 2003
@@ -28,7 +28,7 @@
* A class that generates PECL extension soure and documenation files
*
* @access public
- * @version $Id: Extension.php,v 1.13 2003/09/25 21:05:04 hholzgra Exp $
+ * @version $Id: Extension.php,v 1.14 2003/09/27 16:48:34 hholzgra Exp $
*/
class PECL_Gen_Extension
@@ -163,6 +163,13 @@
*/
var $makefragment = array();
+ /**
+ * Custom test cases
+ *
+ * @var array
+ */
+ var $testcases = array();
+
// }}}
@@ -1666,11 +1673,21 @@
// }}}
+ function add_test($test) {
+ $this->testcases[] = $test;
+ }
+
function write_test_files() {
@mkdir("$this->name/tests");
+ // function related tests
foreach ($this->functions as $function) {
$function->write_test($this);
+ }
+
+ // custom test cases
+ foreach ($this->testcases as $test) {
+ $test->write_test($this);
}
}
Index: pear/PECL_Gen/Element/Test.php
diff -u pear/PECL_Gen/Element/Test.php:1.1 pear/PECL_Gen/Element/Test.php:1.2
--- pear/PECL_Gen/Element/Test.php:1.1 Thu Sep 25 16:44:15 2003
+++ pear/PECL_Gen/Element/Test.php Sat Sep 27 12:48:34 2003
@@ -22,7 +22,7 @@
* @access public
* @param string testfile basename
*/
- function __constructor($name)
+ function __construct($name)
{
if (! $this->is_name($name)) $this = $this->raise("'$name' is not a
valid test case basename");
@@ -227,7 +227,7 @@
* @access public
* @param object the complete extension context
*/
- function write_testfile($extension)
+ function write_test($extension)
{
ob_start();
@@ -242,25 +242,27 @@
}
if (!empty($this->get)) {
- echo "--POST--\n{$this->get}\n";
+ echo "--GET--\n{$this->get}\n";
}
- echo "--FILE--\n{$this->code}\n";
- echo "--EXPECT--\n{$this->output}\n";
+ echo "--FILE--\n{$this->code}";
+ echo "--EXPECT--\n{$this->output}";
$fp = fopen("{$extension->name}/tests/{$this->name}.phpt", "w");
- fputs(ob_get_contents());
+ fputs($fp, ob_get_contents());
ob_end_clean();
- $fclose($fp);
+ fclose($fp);
}
function c_code($ext)
{
+ // no real code is generated by the test cases
return "";
}
function docbook_xml($ext)
{
+ // no user documentation is needed for the test cases
return "";
}
}