Commit cecdb85e authored by RJ Garcia's avatar RJ Garcia

Fixed Session Service Provider registry

The service provider was registering the wrong parameters
to the session listener instead of the actual session class
Signed-off-by: default avatarRJ Garcia <rj@bighead.net>
parent 5f0fc5c1
...@@ -38,7 +38,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -38,7 +38,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
$app['session.test'] = false; $app['session.test'] = false;
$app['session'] = function ($app) { $app['session'] = function ($app) {
return new Session($app['session.storage']); return new Session($app['session.storage'], $app['session.attribute_bag'], $app['session.flash_bag']);
}; };
$app['session.storage'] = function ($app) { $app['session.storage'] = function ($app) {
...@@ -61,7 +61,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -61,7 +61,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
}; };
$app['session.listener'] = function ($app) { $app['session.listener'] = function ($app) {
return new SessionListener($app, $app['session.attribute_bag'], $app['session.flash_bag']); return new SessionListener($app);
}; };
$app['session.storage.test'] = function () { $app['session.storage.test'] = function () {
......
...@@ -15,6 +15,7 @@ use Silex\Application; ...@@ -15,6 +15,7 @@ use Silex\Application;
use Silex\WebTestCase; use Silex\WebTestCase;
use Silex\Provider\SessionServiceProvider; use Silex\Provider\SessionServiceProvider;
use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpKernel\Client;
use Symfony\Component\HttpFoundation\Session;
/** /**
* SessionProvider test cases. * SessionProvider test cases.
...@@ -104,4 +105,22 @@ class SessionServiceProviderTest extends WebTestCase ...@@ -104,4 +105,22 @@ class SessionServiceProviderTest extends WebTestCase
$client->request('get', '/robots.txt'); $client->request('get', '/robots.txt');
$this->assertEquals('Informations for robots.', $client->getResponse()->getContent()); $this->assertEquals('Informations for robots.', $client->getResponse()->getContent());
} }
public function testSessionRegister()
{
$app = new Application();
$attrs = new Session\Attribute\AttributeBag();
$flash = new Session\Flash\FlashBag();
$app->register(new SessionServiceProvider(), array(
'session.attribute_bag' => $attrs,
'session.flash_bag' => $flash,
'session.test' => true,
));
$session = $app['session'];
$this->assertSame($flash, $session->getBag('flashes'));
$this->assertSame($attrs, $session->getBag('attributes'));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment