Project

General

Profile

Actions

Bug #73874

closed

Make PHPunit usable with typo3 v7.6 ex. Add TYPO3_CONF_VARS to BaseTestCase::backupGlobalsBlacklist

Added by Oliver Klee about 8 years ago. Updated over 7 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2016-03-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Currently, when running the Domain Model tests generated by the Extension Builder extension using the BE module of the phpunit extension (master) in TYPO3 7LTS, I get this error:

Error in test case getTitleReturnsInitialValueForString
File: phar://typo3conf/ext/phpunit/Resources/Private/Libraries/phpunit-library.phar/vendor/sebastian/global-state/src/Snapshot.php
Line: 313
Serialization of 'Closure' is not allowed

This problem occurs because the backup of globals is enabled in the unit test base class, and $GLOBALS['TYPO3_CONF_VARS'] contains some closures, e.g., in $GLOBALS['SC_OPTIONS']['GLOBAL']['cliKeys']['extbase']0.

So we should add 'TYPO3_CONF_VARS' to BaseTestCase::backupGlobalsBlacklist.

TYPO3 6.2 is not affected.

Actions #1

Updated by Christian Kuhn about 8 years ago

please do not fiddle with backupGlobals, adding stuff to it significantly slows the tests down.

the acceptance tests run into a similar issue, there is a helper in BaseTest to unset this part of global. let's use this for now.

Actions #2

Updated by Oliver Klee about 8 years ago

Christian Kuhn wrote:

please do not fiddle with backupGlobals, adding stuff to it significantly slows the tests down.

Actually, backupGlobals is enabled by default in the BaseTestCase. I need the tests to backup less, not more. Will this also slow down anything?

Which helper in the BaseTestCase are you referring to?

Actions #3

Updated by Christian Kuhn almost 8 years ago

  • Description updated (diff)
Actions #4

Updated by Christian Kuhn almost 8 years ago

  • Status changed from New to Rejected

Still, removing TYPO3_CONF_VARS from backupGlobals is not a good idea. A lot of tests rely on the fact that this array is backed up, no matter what a test changes in it. That is a good thing, we should not give up on having this global backed up.

The bootstrap of the unit tests only loads the DefaultConfiguration (it would be even better if that also wouldn't be done) and nothing from ext_tables or ext_localconf or LocalConfiguration to have a base state that is identical on all systems. The bootstrap of your extension must reach the same state, please fix that instead.

I'll close this issue as rejected now.

Actions #5

Updated by Paul A. Auwehla over 7 years ago

  • Subject changed from Add TYPO3_CONF_VARS to BaseTestCase::backupGlobalsBlacklist to Make PHPunit usable with typo3 v7.6 ex. Add TYPO3_CONF_VARS to BaseTestCase::backupGlobalsBlacklist

Install fresh new IntroPack use for ex.
typo3 7.6.11 with
php 5.6.12 or 7.0.2

Clear complete typo3temp-folder and all cahces in the backend.

Run any PHPunit-test, beuser, backend whatever you want.
In any case you will get a red "Failures!" bar.
Enable ERROR in the options.

You will see:
File: phar://typo3conf/ext/phpunit/Resources/Private/Libraries/phpunit-library.phar/vendor/sebastian/global-state/src/Snapshot.php
Line: 313
Serialization of 'Closure' is not allowed

Conclusion:
The concept of Test-Driven-Design for typo3 and
its extensions is not useable at all at least from within the backend.

So the Close of this issue is a Close
for the Test-Driven-Design of typo3??

Is the documentation to be rewritten:?
https://docs.typo3.org/typo3cms/ExtbaseFluidBook/2-BasicPrinciples/4-Test-Driven-Development.html

Actions #6

Updated by Wouter Wolters over 7 years ago

Please read https://wiki.typo3.org/Unit_Testing_TYPO3 for more information on how to do Unit Testing in TYPO3 from 6.2 and higher.

Actions

Also available in: Atom PDF