Replace homemade ChamiloSession and $_SESSION calls with the Silex\Provider\SessionServiceProvider
This will help a lot when running phpunit tests.
I've been testing and I have found some warnings due the session
/var/www/chamilo11$ phpunit -c tests/phpunit --filter testIs_username_available PHPUnit 3.7.12 by Sebastian Bergmann. Configuration read from /var/www/chamilo11/tests/phpunit/phpunit.xml E. Time: 12 seconds, Memory: 17.25Mb There was 1 error: 1) UserManagerTest::testIs_username_available session_start(): Cannot send session cookie - headers already sent by (output started at /usr/share/php/PHPUnit/Util/Printer.php:172) /var/www/chamilo11/main/inc/lib/chamilo_session.class.php:103 /var/www/chamilo11/main/inc/global.inc.php:437 /var/www/chamilo11/tests/phpunit/classes/UserManagerTest.lib.php:19 FAILURES! Tests: 2, Assertions: 1, Errors: 1.
With the that service provider we could simulate session values
Yeah I know it will be a lot of work ...
Updated by Julio Montoya over 6 years ago
- Status changed from New to Needs testing
- Priority changed from Low to Normal
- Target version set to 2.0
- % Done changed from 0 to 50
We're using right now 2 session "handlers" the ChamiloSession using calls like Session::get('session_value') and $_SESSION['session_value'];
Now, ChamiloSession is using the $app['session'] which is the same thing like before, but we can use all the benefits of the $app['session'] parameters like setting the session params like this example and using the security roles.
session.storage.options: An array of options that is passed to the constructor of the session.storage service. In case of the default NativeSessionStorage, the most useful options are: name: The cookie name (_SESS by default) id: The session id (null by default) cookie_lifetime: Cookie lifetime cookie_path: Cookie path cookie_domain: Cookie domain cookie_secure: Cookie secure (HTTPS) cookie_httponly: Whether the cookie is http only However, all of these are optional. Sessions last as long as the browser is open. To override this, set the lifetime option. For a full list of available options, read the PHP official documentation. session.test: Whether to simulate sessions or not (useful when writing functional tests).