Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
Fixed Session Service Provider registry
Browse files Browse the repository at this point in the history
The service provider was registering the wrong parameters
to the session listener instead of the actual session class

Signed-off-by: RJ Garcia <rj@bighead.net>
  • Loading branch information
ragboyjr committed May 4, 2016
1 parent 5f0fc5c commit cecdb85
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Silex/Provider/SessionServiceProvider.php
Expand Up @@ -38,7 +38,7 @@ public function register(Container $app)
$app['session.test'] = false;

$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) {
Expand All @@ -61,7 +61,7 @@ public function register(Container $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 () {
Expand Down
19 changes: 19 additions & 0 deletions tests/Silex/Tests/Provider/SessionServiceProviderTest.php
Expand Up @@ -15,6 +15,7 @@
use Silex\WebTestCase;
use Silex\Provider\SessionServiceProvider;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\HttpFoundation\Session;

/**
* SessionProvider test cases.
Expand Down Expand Up @@ -104,4 +105,22 @@ public function testWithRoutesThatDoesNotUseSession()
$client->request('get', '/robots.txt');
$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'));
}
}

0 comments on commit cecdb85

Please sign in to comment.