Bug #24838
closed[Unit Tests] t3lib_formprotection_BackendFormProtectionTest causes php fatal error
0%
Description
The t3lib_formprotection_BackendFormProtectionTest test sets $GLOBALS['BE_USER'] to a mocked BE user object.
Revision 10306 introduced t3lib_formprotection_BackendFormProtection::isAuthorizedBackendSession()
The methode isAuthorizedBackendSession() is called on construction of t3lib_formprotection_BackendFormProtection and an exception is thrown if it fails.
Within the test an instance of t3lib_formprotection_BackendFormProtection is created. This fails due to the above mentioned BE user mocking and the checks in isAuthorizedBackendSession() (see source).
Furthermore a php fatal error occurs since __destruct() is call within tearDown of the test. Which isn't possible since the object has never been created (due to exception in constructor).
This is just a quickfix. It would be better to stop messing arround with GLOBALS within tests and the actuall class implementation.
Something like: isAuthorizedBackendSession($beSession) and injection of the current beSession on construction would be much cleaner and easier to test imho. But that is another story.
(issue imported from #M17342)
Files
Updated by Ernesto Baschny almost 14 years ago
Could you check that please, Helmut? Thanks!
Updated by Helmut Hummel almost 14 years ago
The fix for this has been committed with the fix for #24962