2015-09-14 10:54:50 -04:00
|
|
|
<?php
|
2015-09-15 13:19:29 -04:00
|
|
|
use \Aviat\AnimeClient\Controller;
|
2015-10-15 09:25:30 -04:00
|
|
|
use Aviat\AnimeClient\Controller\Anime as AnimeController;
|
|
|
|
use Aviat\AnimeClient\Controller\Manga as MangaController;
|
|
|
|
use Aviat\AnimeClient\Controller\Collection as CollectionController;
|
2015-09-14 10:54:50 -04:00
|
|
|
use \Aura\Web\WebFactory;
|
|
|
|
use \Aura\Router\RouterFactory;
|
|
|
|
|
2015-09-15 13:19:29 -04:00
|
|
|
class ControllerTest extends AnimeClient_TestCase {
|
2015-09-14 10:54:50 -04:00
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Create Request/Response Objects
|
2016-02-17 10:29:05 -05:00
|
|
|
$_SERVER['HTTP_REFERER'] = '';
|
|
|
|
$this->setSuperGlobals([
|
2015-09-14 10:54:50 -04:00
|
|
|
'_GET' => [],
|
|
|
|
'_POST' => [],
|
|
|
|
'_COOKIE' => [],
|
|
|
|
'_SERVER' => $_SERVER,
|
|
|
|
'_FILES' => []
|
|
|
|
]);
|
2015-10-15 09:25:30 -04:00
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
$this->BaseController = new Controller($this->container);
|
|
|
|
}
|
|
|
|
|
2015-10-15 09:25:30 -04:00
|
|
|
public function testControllersSanity()
|
|
|
|
{
|
|
|
|
$config = $this->container->get('config');
|
|
|
|
$config->set(['database', 'collection'], [
|
|
|
|
'type' => 'sqlite',
|
|
|
|
'database' => '',
|
|
|
|
'file' => ":memory:"
|
|
|
|
]);
|
|
|
|
$this->container->set('config', $config);
|
|
|
|
|
|
|
|
$this->assertInstanceOf(
|
|
|
|
'Aviat\AnimeClient\Controller',
|
|
|
|
new AnimeController($this->container)
|
|
|
|
);
|
|
|
|
$this->assertInstanceOf(
|
|
|
|
'Aviat\AnimeClient\Controller',
|
|
|
|
new MangaController($this->container)
|
|
|
|
);
|
|
|
|
$this->assertInstanceOf(
|
|
|
|
'Aviat\AnimeClient\Controller',
|
|
|
|
new CollectionController($this->container)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
public function testBaseControllerSanity()
|
|
|
|
{
|
|
|
|
$this->assertTrue(is_object($this->BaseController));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataGet()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'response' => [
|
|
|
|
'key' => 'response',
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'key' => 'config',
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataGet
|
|
|
|
*/
|
|
|
|
public function testGet($key)
|
|
|
|
{
|
|
|
|
$result = $this->BaseController->__get($key);
|
|
|
|
$this->assertEquals($this->container->get($key), $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetNull()
|
|
|
|
{
|
|
|
|
$result = $this->BaseController->__get('foo');
|
|
|
|
$this->assertNull($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|