Commit 8dd075c0 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Suppression du SessionManagerFactory inutilisé car mal configuré.

parent 75e60fae
Pipeline #11025 failed with stages
in 54 seconds
......@@ -281,8 +281,6 @@ return [
'factories' => [
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
// service de gestion de la session
'Zend\Session\SessionManager' => 'UnicaenApp\Session\SessionManagerFactory',
// service d'accès aux options de config de ce module
'unicaen-app_module_options' => 'UnicaenApp\Options\ModuleOptionsFactory',
// mapper d'accès aux individus de l'annuaire LDAP
......
<?php
namespace UnicaenApp\Session;
use Interop\Container\ContainerInterface;
use UnicaenApp\Options\ModuleOptions;
use Zend\Session\Config\SessionConfig;
use Zend\Session\SessionManager;
use Zend\Session\Validator\HttpUserAgent;
use Zend\Session\Validator\RemoteAddr;
/**
* Description of SessionManager
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class SessionManagerFactory
{
public function __invoke(ContainerInterface $container)
{
/** @var ModuleOptions $moduleOptions */
$moduleOptions = $container->get('unicaen-app_module_options');
$appInfos = $moduleOptions->getAppInfos();
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions([
'name' => md5($appInfos['nom']),
]);
$sessionManager = new SessionManager($sessionConfig);
$chain = $sessionManager->getValidatorChain();
$chain->attach('session.validate', array(new RemoteAddr(), 'isValid'));
$chain->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
return $sessionManager;
}
}
\ No newline at end of file
<?php
namespace UnicaenAppTest\Session;
use UnicaenApp\Options\ModuleOptions;
use UnicaenApp\Session\SessionManagerFactory;
use UnicaenAppTest\BaseServiceFactoryTest;
use Zend\Session\Container;
use Zend\Session\SessionManager;
/**
* Description of ModuleOptionsFactoryTest
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class ModuleOptionsFactoryTest extends BaseServiceFactoryTest
{
/**
* @var SessionManagerFactory
*/
protected $factory;
protected $factoryClass = SessionManagerFactory::class;
protected $serviceClass = SessionManager::class;
public function testCanCreateService()
{
$appInfos = [
'nom' => "Mon application",
];
$moduleOptions = $this->createMock(ModuleOptions::class);
$moduleOptions
->expects($this->once())
->method('getAppInfos')
->willReturn($appInfos);
$this->serviceManager
->expects($this->once())
->method('get')
->with('unicaen-app_module_options')
->willReturn($moduleOptions);
$service = $this->factory->__invoke($this->serviceManager);
/* @var $service \Zend\Session\SessionManager */
$this->assertInstanceOf($this->serviceClass, $service);
$this->assertNotEmpty($service->getValidatorChain()->getListeners('session.validate'));
$this->assertEquals($service->getConfig()->getName(), md5($appInfos['nom']));
}
}
\ No newline at end of file
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