/typo3/sysext/dbal/tests/BaseTestCase.php
PHP | 88 lines | 40 code | 2 blank | 46 comment | 0 complexity | e5ab8c34eb7b79b1e2606a01bf94ef68 MD5 | raw file
Possible License(s): Apache-2.0
- <?php
- /***************************************************************
- * Copyright notice
- *
- * (c) 2009-2010 Robert Lemke <robert@typo3.org>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
- /**
- * The mother of all test cases.
- *
- * Subclass this base class if you want to take advantage of the framework
- * capabilities.
- *
- * $Id: BaseTestCase.php 27006 2009-11-25 22:08:07Z xperseguers $
- *
- * @author Robert Lemke <robert@typo3.org>
- *
- * This method is backported from FLOW3's BaseTestCase class.
- * @link https://svn.typo3.org/FLOW3/Packages/Testing/trunk/Classes/BaseTestCase.php
- *
- * @package TYPO3
- * @subpackage dbal
- */
- abstract class BaseTestCase extends tx_phpunit_testcase {
- /**
- * Creates a proxy class of the specified class which allows
- * for calling even protected methods and access of protected properties.
- *
- * @param protected $className Full qualified name of the original class
- * @return string Full qualified name of the built class
- * @api
- */
- protected function buildAccessibleProxy($className) {
- $accessibleClassName = uniqid('AccessibleTestProxy');
- $class = new ReflectionClass($className);
- $abstractModifier = $class->isAbstract() ? 'abstract ' : '';
- eval('
- ' . $abstractModifier . 'class ' . $accessibleClassName . ' extends ' . $className . ' {
- public function _call($methodName) {
- return call_user_func_array(array($this, $methodName), array_slice(func_get_args(), 1));
- }
- public function _callRef($methodName, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL) {
- switch (func_num_args()) {
- case 0 : return $this->$methodName();
- case 1 : return $this->$methodName($arg1);
- case 2 : return $this->$methodName($arg1, $arg2);
- case 3 : return $this->$methodName($arg1, $arg2, $arg3);
- case 4 : return $this->$methodName($arg1, $arg2, $arg3, $arg4);
- case 5 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5);
- case 6 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
- case 7 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
- case 8 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);
- case 9 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9);
- }
- }
- public function _set($propertyName, $value) {
- $this->$propertyName = $value;
- }
- public function _setRef($propertyName, &$value) {
- $this->$propertyName = $value;
- }
- public function _get($propertyName) {
- return $this->$propertyName;
- }
- }
- ');
- return $accessibleClassName;
- }
- }
- ?>