Convert SessionManager to a factory class

This commit is contained in:
Pierre Rudloff 2020-10-21 22:47:15 +02:00
parent 5b0ee7651b
commit de8c5e5dc7
10 changed files with 64 additions and 52 deletions

View file

@ -6,8 +6,10 @@
namespace Alltube\Test;
use Alltube\Exception\DependencyException;
use Alltube\Factory\LocaleManagerFactory;
use Alltube\Factory\SessionFactory;
use Alltube\Factory\ViewFactory;
use Alltube\LocaleManager;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -24,11 +26,13 @@ class ViewFactoryTest extends BaseTest
*
* @return void
* @throws SmartyException
* @throws DependencyException
*/
public function testCreate()
{
$container = new Container();
$container['locale'] = new LocaleManager();
$container['session'] = SessionFactory::create();
$container['locale'] = LocaleManagerFactory::create($container);
$view = ViewFactory::create($container);
$this->assertInstanceOf(Smarty::class, $view);
}
@ -38,11 +42,13 @@ class ViewFactoryTest extends BaseTest
*
* @return void
* @throws SmartyException
* @throws DependencyException
*/
public function testCreateWithXForwardedProto()
{
$container = new Container();
$container['locale'] = new LocaleManager();
$container['session'] = SessionFactory::create();
$container['locale'] = LocaleManagerFactory::create($container);
$request = Request::createFromEnvironment(Environment::mock());
$view = ViewFactory::create($container, $request->withHeader('X-Forwarded-Proto', 'https'));
$this->assertInstanceOf(Smarty::class, $view);