|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Robert Lemke <robert@typo3.org> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * The mother of all test cases. 00027 * 00028 * Subclass this base class if you want to take advantage of the framework 00029 * capabilities. 00030 * 00031 * $Id: BaseTestCase.php 40716 2010-12-01 10:49:27Z xperseguers $ 00032 * 00033 * @author Robert Lemke <robert@typo3.org> 00034 * 00035 * This method is backported from FLOW3's BaseTestCase class. 00036 * @link https://svn.typo3.org/FLOW3/Packages/Testing/trunk/Classes/BaseTestCase.php 00037 * 00038 * @package TYPO3 00039 * @subpackage dbal 00040 */ 00041 abstract class BaseTestCase extends tx_phpunit_testcase { 00042 00043 /** 00044 * Creates a proxy class of the specified class which allows 00045 * for calling even protected methods and access of protected properties. 00046 * 00047 * @param protected $className Full qualified name of the original class 00048 * @return string Full qualified name of the built class 00049 * @api 00050 */ 00051 protected function buildAccessibleProxy($className) { 00052 $accessibleClassName = uniqid('AccessibleTestProxy'); 00053 $class = new ReflectionClass($className); 00054 $abstractModifier = $class->isAbstract() ? 'abstract ' : ''; 00055 eval(' 00056 ' . $abstractModifier . 'class ' . $accessibleClassName . ' extends ' . $className . ' { 00057 public function _call($methodName) { 00058 return call_user_func_array(array($this, $methodName), array_slice(func_get_args(), 1)); 00059 } 00060 public function _callRef($methodName, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL) { 00061 switch (func_num_args()) { 00062 case 0 : return $this->$methodName(); 00063 case 1 : return $this->$methodName($arg1); 00064 case 2 : return $this->$methodName($arg1, $arg2); 00065 case 3 : return $this->$methodName($arg1, $arg2, $arg3); 00066 case 4 : return $this->$methodName($arg1, $arg2, $arg3, $arg4); 00067 case 5 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5); 00068 case 6 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6); 00069 case 7 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); 00070 case 8 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8); 00071 case 9 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9); 00072 } 00073 } 00074 public function _set($propertyName, $value) { 00075 $this->$propertyName = $value; 00076 } 00077 public function _setRef($propertyName, &$value) { 00078 $this->$propertyName = $value; 00079 } 00080 public function _get($propertyName) { 00081 return $this->$propertyName; 00082 } 00083 } 00084 '); 00085 return $accessibleClassName; 00086 } 00087 } 00088 00089 ?>
1.8.0