cvs: pear /CodeGen_PECL/PECL/Element Test.php

From: Date: Sun, 31 Jul 2005 17:26:57 +0000
Subject: cvs: pear /CodeGen_PECL/PECL/Element Test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-33484@lists.php.net to get a copy of this message
hholzgra Sun Jul 31 13:26:57 2005 EDT Modified files: /pear/CodeGen_PECL/PECL/Element Test.php Log: support for --INI-- section added, setSkipIf()/addSkipIf() are now clever enough to distinguish between simple PHP expressions and full code snippets and act accordingly http://cvs.php.net/diff.php/pear/CodeGen_PECL/PECL/Element/Test.php?r1=1.2&r2=1.3&ty=u Index: pear/CodeGen_PECL/PECL/Element/Test.php diff -u pear/CodeGen_PECL/PECL/Element/Test.php:1.2 pear/CodeGen_PECL/PECL/Element/Test.php:1.3 --- pear/CodeGen_PECL/PECL/Element/Test.php:1.2 Tue Jul 26 05:10:02 2005 +++ pear/CodeGen_PECL/PECL/Element/Test.php Sun Jul 31 13:26:57 2005 @@ -15,7 +15,7 @@ * @author Hartmut Holzgraefe <hartmut@php.net> * @copyright 2005 Hartmut Holzgraefe * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Test.php,v 1.2 2005/07/26 09:10:02 hholzgra Exp $ + * @version CVS: $Id: Test.php,v 1.3 2005/07/31 17:26:57 hholzgra Exp $ * @link http://pear.php.net/package/CodeGen */ @@ -112,6 +112,47 @@ } /** + * php.ini settings for this test + * + * @type string + */ + protected $ini = ""; + + /** + * Getter for php.ini settings + * + * @access public + * @return string value of + */ + function getIni() + { + return $this->ini; + } + + /** + * Setter for php.ini settings + * + * @access public + * @param string new value for + */ + function setIni($code) + { + $this->ini = $code; + } + + + /** + * Adder for php.ini settings + * + * @access public + * @param string new value for + */ + function addIni($code) + { + $this->ini.= "\n$code"; + } + + /** * Test code to decide whether to skip a test * * @type string @@ -137,7 +178,32 @@ */ function setSkipIf($code) { - $this->skipif = $code; + $this->skipif = ""; + $this->addSkipIf($code); + } + + /** + * Setter for skipif testcode + * + * @access public + * @param string new value for + */ + function addSkipIf($code) + { + // check whether $code is just an expression or a complete code snippet + $isExpression = true; + foreach (token_get_all("<?php $code") as $token) { + if (($token === ';') || ($token === '}')) { + $isExpression = false; + break; + } + } + + if ($isExpression) { + $this->skipif.= "\nif($code) die('skip');\n"; + } else { + $this->skipif.= "\n$code"; + } } /** @@ -284,9 +350,13 @@ $file = new CodeGen_Tools_Outbuf("{$extName}/tests/{$this->name}.phpt"); echo "--TEST--\n{$this->title}\n"; + + if (!empty($this->ini)) { + echo "--INI--\n{$this->ini}\n"; + } if (!empty($this->skipif)) { - echo "--SKIPIF--\n<?php if({$this->skipif}) echo 'skip'; ?>\n"; + echo "--SKIPIF--\n<?php \n{$this->skipif}\n ?>\n"; } if (!empty($this->post)) {

« previous php.pear.cvs (#33484) next »