Issue Bug Closed

#24838[Unit Tests] t3lib_formprotection_BackendFormProtectionTest causes php fatal error

Nikolas Hagelstein 01/26/11, 17:15 updated 02/26/11, 01:11

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)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.