Fix tests (#250)
This commit is contained in:
parent
aabcee25f0
commit
7772de5394
5 changed files with 23 additions and 5 deletions
|
@ -168,4 +168,14 @@ class LocaleManager
|
|||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy singleton instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function destroyInstance()
|
||||
{
|
||||
self::$instance = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ abstract class ControllerTest extends BaseTest
|
|||
$this->container = new Container();
|
||||
$this->request = Request::createFromEnvironment(Environment::mock());
|
||||
$this->response = new Response();
|
||||
$this->container['locale'] = LocaleManager::getInstance();
|
||||
$this->container['view'] = ViewFactory::create($this->container, $this->request);
|
||||
$this->container['locale'] = new LocaleManager();
|
||||
|
||||
$frontController = new FrontController($this->container);
|
||||
$downloadController = new DownloadController($this->container);
|
||||
|
|
|
@ -27,7 +27,7 @@ class LocaleManagerTest extends BaseTest
|
|||
protected function setUp()
|
||||
{
|
||||
$_SESSION[LocaleManager::class]['locale'] = 'foo_BAR';
|
||||
$this->localeManager = new LocaleManager();
|
||||
$this->localeManager = LocaleManager::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,7 @@ class LocaleManagerTest extends BaseTest
|
|||
protected function tearDown()
|
||||
{
|
||||
$this->localeManager->unsetLocale();
|
||||
LocaleManager::destroyInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +94,7 @@ class LocaleManagerTest extends BaseTest
|
|||
*/
|
||||
public function testEnv()
|
||||
{
|
||||
putenv('LANG=foo_BAR');
|
||||
$this->localeManager->setLocale(new Locale('foo_BAR'));
|
||||
$this->assertEquals('foo_BAR', getenv('LANG'));
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class LocaleMiddlewareTest extends BaseTest
|
|||
protected function setUp()
|
||||
{
|
||||
$this->container = new Container();
|
||||
$this->container['locale'] = new LocaleManager();
|
||||
$this->container['locale'] = LocaleManager::getInstance();
|
||||
$this->middleware = new LocaleMiddleware($this->container);
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ class LocaleMiddlewareTest extends BaseTest
|
|||
protected function tearDown()
|
||||
{
|
||||
$this->container['locale']->unsetLocale();
|
||||
LocaleManager::destroyInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\ViewFactory;
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
|
@ -24,7 +25,9 @@ class ViewFactoryTest extends BaseTest
|
|||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$view = ViewFactory::create(new Container());
|
||||
$container = new Container();
|
||||
$container['locale'] = LocaleManager::getInstance();
|
||||
$view = ViewFactory::create($container);
|
||||
$this->assertInstanceOf(Smarty::class, $view);
|
||||
}
|
||||
|
||||
|
@ -35,8 +38,10 @@ class ViewFactoryTest extends BaseTest
|
|||
*/
|
||||
public function testCreateWithXForwardedProto()
|
||||
{
|
||||
$container = new Container();
|
||||
$container['locale'] = LocaleManager::getInstance();
|
||||
$request = Request::createFromEnvironment(Environment::mock());
|
||||
$view = ViewFactory::create(new Container(), $request->withHeader('X-Forwarded-Proto', 'https'));
|
||||
$view = ViewFactory::create($container, $request->withHeader('X-Forwarded-Proto', 'https'));
|
||||
$this->assertInstanceOf(Smarty::class, $view);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue