PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/typo3/sysext/dbal/tests/BaseTestCase.php

https://github.com/foxsoft/typo3v4core
PHP | 88 lines | 40 code | 2 blank | 46 comment | 0 complexity | e5ab8c34eb7b79b1e2606a01bf94ef68 MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 2009-2010 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. * $Id: BaseTestCase.php 27006 2009-11-25 22:08:07Z xperseguers $
  31. *
  32. * @author Robert Lemke <robert@typo3.org>
  33. *
  34. * This method is backported from FLOW3's BaseTestCase class.
  35. * @link https://svn.typo3.org/FLOW3/Packages/Testing/trunk/Classes/BaseTestCase.php
  36. *
  37. * @package TYPO3
  38. * @subpackage dbal
  39. */
  40. abstract class BaseTestCase extends tx_phpunit_testcase {
  41. /**
  42. * Creates a proxy class of the specified class which allows
  43. * for calling even protected methods and access of protected properties.
  44. *
  45. * @param protected $className Full qualified name of the original class
  46. * @return string Full qualified name of the built class
  47. * @api
  48. */
  49. protected function buildAccessibleProxy($className) {
  50. $accessibleClassName = uniqid('AccessibleTestProxy');
  51. $class = new ReflectionClass($className);
  52. $abstractModifier = $class->isAbstract() ? 'abstract ' : '';
  53. eval('
  54. ' . $abstractModifier . 'class ' . $accessibleClassName . ' extends ' . $className . ' {
  55. public function _call($methodName) {
  56. return call_user_func_array(array($this, $methodName), array_slice(func_get_args(), 1));
  57. }
  58. public function _callRef($methodName, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL) {
  59. switch (func_num_args()) {
  60. case 0 : return $this->$methodName();
  61. case 1 : return $this->$methodName($arg1);
  62. case 2 : return $this->$methodName($arg1, $arg2);
  63. case 3 : return $this->$methodName($arg1, $arg2, $arg3);
  64. case 4 : return $this->$methodName($arg1, $arg2, $arg3, $arg4);
  65. case 5 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5);
  66. case 6 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  67. case 7 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
  68. case 8 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);
  69. case 9 : return $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9);
  70. }
  71. }
  72. public function _set($propertyName, $value) {
  73. $this->$propertyName = $value;
  74. }
  75. public function _setRef($propertyName, &$value) {
  76. $this->$propertyName = $value;
  77. }
  78. public function _get($propertyName) {
  79. return $this->$propertyName;
  80. }
  81. }
  82. ');
  83. return $accessibleClassName;
  84. }
  85. }
  86. ?>