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