2017-04-25 22:59:30 +00:00
|
|
|
<?php
|
2019-10-03 19:24:12 +00:00
|
|
|
|
2017-04-25 22:59:30 +00:00
|
|
|
/**
|
|
|
|
* ViewFactoryTest class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Alltube\Test;
|
|
|
|
|
2020-10-21 22:45:09 +00:00
|
|
|
use Alltube\Exception\ConfigException;
|
2020-10-21 20:47:15 +00:00
|
|
|
use Alltube\Exception\DependencyException;
|
2020-10-21 22:45:09 +00:00
|
|
|
use Alltube\Factory\ConfigFactory;
|
2020-10-21 20:47:15 +00:00
|
|
|
use Alltube\Factory\LocaleManagerFactory;
|
|
|
|
use Alltube\Factory\SessionFactory;
|
2020-10-20 21:29:50 +00:00
|
|
|
use Alltube\Factory\ViewFactory;
|
2017-04-25 22:59:30 +00:00
|
|
|
use Slim\Container;
|
2017-05-30 22:48:50 +00:00
|
|
|
use Slim\Http\Environment;
|
|
|
|
use Slim\Http\Request;
|
2017-04-25 22:59:30 +00:00
|
|
|
use Slim\Views\Smarty;
|
2020-05-13 19:33:05 +00:00
|
|
|
use SmartyException;
|
2017-04-25 22:59:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit tests for the ViewFactory class.
|
|
|
|
*/
|
2019-04-21 16:30:02 +00:00
|
|
|
class ViewFactoryTest extends BaseTest
|
2017-04-25 22:59:30 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Test the create() function.
|
|
|
|
*
|
|
|
|
* @return void
|
2020-05-13 19:33:05 +00:00
|
|
|
* @throws SmartyException
|
2020-10-21 20:47:15 +00:00
|
|
|
* @throws DependencyException
|
2020-10-21 22:45:09 +00:00
|
|
|
* @throws ConfigException
|
2017-04-25 22:59:30 +00:00
|
|
|
*/
|
|
|
|
public function testCreate()
|
|
|
|
{
|
2019-11-27 23:04:05 +00:00
|
|
|
$container = new Container();
|
2020-10-21 21:04:29 +00:00
|
|
|
$container['session'] = SessionFactory::create($container);
|
2020-10-21 20:47:15 +00:00
|
|
|
$container['locale'] = LocaleManagerFactory::create($container);
|
2020-10-21 22:45:09 +00:00
|
|
|
$container['config'] = ConfigFactory::create($container);
|
2019-11-27 23:04:05 +00:00
|
|
|
$view = ViewFactory::create($container);
|
2017-04-25 22:59:30 +00:00
|
|
|
$this->assertInstanceOf(Smarty::class, $view);
|
|
|
|
}
|
2017-05-30 22:48:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the create() function with a X-Forwarded-Proto header.
|
|
|
|
*
|
|
|
|
* @return void
|
2020-05-13 19:33:05 +00:00
|
|
|
* @throws SmartyException
|
2020-10-21 20:47:15 +00:00
|
|
|
* @throws DependencyException
|
2020-10-21 22:45:09 +00:00
|
|
|
* @throws ConfigException
|
2017-05-30 22:48:50 +00:00
|
|
|
*/
|
|
|
|
public function testCreateWithXForwardedProto()
|
|
|
|
{
|
2019-11-27 23:04:05 +00:00
|
|
|
$container = new Container();
|
2020-10-21 21:04:29 +00:00
|
|
|
$container['session'] = SessionFactory::create($container);
|
2020-10-21 20:47:15 +00:00
|
|
|
$container['locale'] = LocaleManagerFactory::create($container);
|
2020-10-21 22:45:09 +00:00
|
|
|
$container['config'] = ConfigFactory::create($container);
|
2017-05-30 22:48:50 +00:00
|
|
|
$request = Request::createFromEnvironment(Environment::mock());
|
2019-11-27 23:04:05 +00:00
|
|
|
$view = ViewFactory::create($container, $request->withHeader('X-Forwarded-Proto', 'https'));
|
2017-05-30 22:48:50 +00:00
|
|
|
$this->assertInstanceOf(Smarty::class, $view);
|
|
|
|
}
|
2017-04-25 22:59:30 +00:00
|
|
|
}
|