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