alltube/tests/ViewFactoryTest.php
2019-11-28 00:04:05 +01:00

47 lines
1.1 KiB
PHP

<?php
/**
* ViewFactoryTest class.
*/
namespace Alltube\Test;
use Alltube\LocaleManager;
use Alltube\ViewFactory;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
use Slim\Views\Smarty;
/**
* Unit tests for the ViewFactory class.
*/
class ViewFactoryTest extends BaseTest
{
/**
* Test the create() function.
*
* @return void
*/
public function testCreate()
{
$container = new Container();
$container['locale'] = LocaleManager::getInstance();
$view = ViewFactory::create($container);
$this->assertInstanceOf(Smarty::class, $view);
}
/**
* Test the create() function with a X-Forwarded-Proto header.
*
* @return void
*/
public function testCreateWithXForwardedProto()
{
$container = new Container();
$container['locale'] = LocaleManager::getInstance();
$request = Request::createFromEnvironment(Environment::mock());
$view = ViewFactory::create($container, $request->withHeader('X-Forwarded-Proto', 'https'));
$this->assertInstanceOf(Smarty::class, $view);
}
}