joomla/joomla-cms — pull request #4279 by wilsonge (2014-09-14 16:04:16+00:00)
Title: JSession Refactor

JSession is currently a nightmare when trying to unit test parts of the CMS. This is largely because PHPUnit starts a session before the start of all tests.

One of the solutions to this is to abstract out the session_start stuff. So I've done this. The interface comes almost directly from symfony - https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php (with the Bag stuff removed as we don't need to go there yet)

Then moved all our code into a class that implements this session. This should make unit testing easier in the future. It easier for people who integrate sessions with Joomla to do so and in the future unit tests to be easier to write (as we can add in mock classes implementing the interface like here https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php)

One of the current issues is the compulsory cookie style stuff. I'm not sure how to deal with some of the set_cookie things so left them in JSession now to err on the side of caution. But I'm pretty sure with the right knowledge/adaptation of the interface we can move it into the handler class.