[TASK][WIP] Move non class code back to source files
[Packages/TYPO3.CMS.git] / typo3 / sysext / dbal / tests / BaseTestCase.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Robert Lemke <robert@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24 /**
25 * The mother of all test cases.
26 *
27 * Subclass this base class if you want to take advantage of the framework
28 * capabilities.
29 *
30 * @author Robert Lemke <robert@typo3.org>
31 * @link https://svn.typo3.org/FLOW3/Packages/Testing/trunk/Classes/BaseTestCase.php
32 * @package TYPO3
33 * @subpackage dbal
34 */
35 abstract class BaseTestCase extends tx_phpunit_testcase {
36
37 /**
38 * Creates a proxy class of the specified class which allows
39 * for calling even protected methods and access of protected properties.
40 *
41 * @param protected $className Full qualified name of the original class
42 * @return string Full qualified name of the built class
43 * @api
44 */
45 protected function buildAccessibleProxy($className) {
46 $accessibleClassName = uniqid('AccessibleTestProxy');
47 $class = new ReflectionClass($className);
48 $abstractModifier = $class->isAbstract() ? 'abstract ' : '';
49 eval(((((('
50 ' . $abstractModifier) . 'class ') . $accessibleClassName) . ' extends ') . $className) . ' {
51 public function _call($methodName) {
52 return call_user_func_array(array($this, $methodName), array_slice(func_get_args(), 1));
53 }
54 public function _callRef($methodName, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL) {
55 switch (func_num_args()) {
56 case 0 : return $this->$methodName();
57 case 1 : return $this->$methodName($arg1);
58 case 2 : return $this->$methodName($arg1, $arg2);
59 case 3 : return $this->$methodName($arg1, $arg2, $arg3);
60 case 4 : return $this->$methodName($arg1, $arg2, $arg3, $arg4);
61 case 5 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5);
62 case 6 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
63 case 7 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
64 case 8 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);
65 case 9 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9);
66 }
67 }
68 public function _set($propertyName, $value) {
69 $this->$propertyName = $value;
70 }
71 public function _setRef($propertyName, &$value) {
72 $this->$propertyName = $value;
73 }
74 public function _get($propertyName) {
75 return $this->$propertyName;
76 }
77 }
78 ');
79 return $accessibleClassName;
80 }
81
82 }
83
84 ?>