Stop using a singleton for LocaleManager (#298)
This commit is contained in:
parent
f5045b3ae7
commit
15636aa435
7 changed files with 9 additions and 46 deletions
|
@ -11,8 +11,7 @@ use Alltube\Controller\BaseController;
|
|||
use Alltube\Controller\DownloadController;
|
||||
use Alltube\Controller\FrontController;
|
||||
use Alltube\Exception\ConfigException;
|
||||
use Alltube\Exception\DependencyException;
|
||||
use Alltube\LocaleManagerFactory;
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\ViewFactory;
|
||||
use Psr\Log\NullLogger;
|
||||
use Slim\Container;
|
||||
|
@ -56,7 +55,6 @@ abstract class ControllerTest extends BaseTest
|
|||
/**
|
||||
* Prepare tests.
|
||||
* @throws ConfigException|SmartyException
|
||||
* @throws DependencyException
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -66,7 +64,7 @@ abstract class ControllerTest extends BaseTest
|
|||
$this->request = Request::createFromEnvironment(Environment::mock());
|
||||
$this->response = new Response();
|
||||
$this->container['config'] = Config::fromFile($this->getConfigFile());
|
||||
$this->container['locale'] = LocaleManagerFactory::create();
|
||||
$this->container['locale'] = new LocaleManager();
|
||||
$this->container['view'] = ViewFactory::create($this->container, $this->request);
|
||||
$this->container['logger'] = new NullLogger();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class LocaleManagerTest extends BaseTest
|
|||
protected function setUp(): void
|
||||
{
|
||||
$_SESSION[LocaleManager::class]['locale'] = 'foo_BAR';
|
||||
$this->localeManager = LocaleManager::getInstance();
|
||||
$this->localeManager = new LocaleManager();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,6 @@ class LocaleManagerTest extends BaseTest
|
|||
protected function tearDown(): void
|
||||
{
|
||||
$this->localeManager->unsetLocale();
|
||||
LocaleManager::destroyInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ class LocaleMiddlewareTest extends BaseTest
|
|||
protected function setUp(): void
|
||||
{
|
||||
$this->container = new Container();
|
||||
$this->container['locale'] = LocaleManager::getInstance();
|
||||
$this->container['locale'] = new LocaleManager();
|
||||
$this->middleware = new LocaleMiddleware($this->container);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@ class LocaleMiddlewareTest extends BaseTest
|
|||
protected function tearDown(): void
|
||||
{
|
||||
$this->container['locale']->unsetLocale();
|
||||
LocaleManager::destroyInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ class ViewFactoryTest extends BaseTest
|
|||
public function testCreate()
|
||||
{
|
||||
$container = new Container();
|
||||
$container['locale'] = LocaleManager::getInstance();
|
||||
$container['locale'] = new LocaleManager();
|
||||
$view = ViewFactory::create($container);
|
||||
$this->assertInstanceOf(Smarty::class, $view);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class ViewFactoryTest extends BaseTest
|
|||
public function testCreateWithXForwardedProto()
|
||||
{
|
||||
$container = new Container();
|
||||
$container['locale'] = LocaleManager::getInstance();
|
||||
$container['locale'] = new LocaleManager();
|
||||
$request = Request::createFromEnvironment(Environment::mock());
|
||||
$view = ViewFactory::create($container, $request->withHeader('X-Forwarded-Proto', 'https'));
|
||||
$this->assertInstanceOf(Smarty::class, $view);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue