Use test config for controller tests
This commit is contained in:
parent
2051ee410c
commit
2a31951217
2 changed files with 13 additions and 13 deletions
|
@ -66,9 +66,13 @@ class FrontController
|
|||
*
|
||||
* @param Container $container Slim dependency container
|
||||
*/
|
||||
public function __construct(ContainerInterface $container)
|
||||
public function __construct(ContainerInterface $container, Config $config = null)
|
||||
{
|
||||
if (isset($config)) {
|
||||
$this->config = $config;
|
||||
} else {
|
||||
$this->config = Config::getInstance();
|
||||
}
|
||||
$this->download = new VideoDownload();
|
||||
$this->container = $container;
|
||||
$this->view = $this->container->get('view');
|
||||
|
|
|
@ -64,7 +64,7 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
return $view;
|
||||
};
|
||||
$this->controller = new FrontController($this->container);
|
||||
$this->controller = new FrontController($this->container, Config::getInstance('config_test.yml'));
|
||||
$this->container['router']->map(['GET'], '/', [$this->controller, 'index'])
|
||||
->setName('index');
|
||||
$this->container['router']->map(['GET'], '/video', [$this->controller, 'video'])
|
||||
|
@ -90,9 +90,7 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testConstructorWithStream()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->stream = true;
|
||||
$controller = new FrontController($this->container);
|
||||
$controller = new FrontController($this->container, new Config(['stream'=>true]));
|
||||
$this->assertInstanceOf(FrontController::class, $controller);
|
||||
}
|
||||
|
||||
|
@ -242,14 +240,13 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testVideoWithStream()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->stream = true;
|
||||
$result = $this->controller->video(
|
||||
$controller = new FrontController($this->container, new Config(['stream'=>true]));
|
||||
$result = $controller->video(
|
||||
$this->request->withQueryParams(['url'=>'https://www.youtube.com/watch?v=M7IpKCZ47pU']),
|
||||
$this->response
|
||||
);
|
||||
$this->assertTrue($result->isOk());
|
||||
$result = $this->controller->video(
|
||||
$result = $controller->video(
|
||||
$this->request->withQueryParams(['url'=>'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'audio'=>true]),
|
||||
$this->response
|
||||
);
|
||||
|
@ -313,9 +310,8 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testRedirectWithStream()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->stream = true;
|
||||
$result = $this->controller->redirect(
|
||||
$controller = new FrontController($this->container, new Config(['stream'=>true]));
|
||||
$result = $controller->redirect(
|
||||
$this->request->withQueryParams(['url'=>'https://www.youtube.com/watch?v=M7IpKCZ47pU']),
|
||||
$this->response
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue