[TASK] Re-work/simplify copyright header in PHP files - Part 4
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / UnitTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Base test case for unit tests.
19 *
20 * This class currently only inherits the base test case. However, it is recommended
21 * to extend this class for unit test cases instead of the base test case because if,
22 * at some point, specific behavior needs to be implemented for unit tests, your test cases
23 * will profit from it automatically.
24 *
25 */
26 abstract class UnitTestCase extends BaseTestCase {
27
28 /**
29 * TODO: make LoadedExtensionsArray serializable instead
30 *
31 * @var array
32 */
33 protected $backupGlobalsBlacklist = array('TYPO3_LOADED_EXT');
34
35 /**
36 * Unset all additional properties of test classes to help PHP
37 * garbage collection. This reduces memory footprint with lots
38 * of tests.
39 *
40 * If owerwriting tearDown() in test classes, please call
41 * parent::tearDown() at the end. Unsetting of own properties
42 * is not needed this way.
43 *
44 * @return void
45 */
46 protected function tearDown() {
47 $reflection = new \ReflectionObject($this);
48 foreach ($reflection->getProperties() as $property) {
49 $declaringClass = $property->getDeclaringClass()->getName();
50 if (
51 !$property->isStatic()
52 && $declaringClass !== 'TYPO3\CMS\Core\Tests\UnitTestCase'
53 && $declaringClass !== 'TYPO3\CMS\Core\Tests\BaseTestCase'
54 && strpos($property->getDeclaringClass()->getName(), 'PHPUnit_') !== 0
55 ) {
56 $propertyName = $property->getName();
57 unset($this->$propertyName);
58 }
59 }
60 unset($reflection);
61 }
62 }