2017-01-12 15:41:20 -05:00
|
|
|
<?php declare(strict_types=1);
|
2017-02-16 11:09:37 -05:00
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
2018-08-22 13:48:27 -04:00
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
2019-12-03 15:17:25 -05:00
|
|
|
* PHP version 7.2
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2018-01-15 14:43:15 -05:00
|
|
|
* @copyright 2015 - 2018 Timothy J. Warren
|
2017-02-16 11:09:37 -05:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2018-10-01 11:35:51 -04:00
|
|
|
* @version 4.1
|
2017-03-07 20:53:58 -05:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2017-02-16 11:09:37 -05:00
|
|
|
*/
|
2017-02-15 11:49:38 -05:00
|
|
|
|
|
|
|
namespace Aviat\AnimeClient\Tests;
|
|
|
|
|
2016-10-20 22:32:17 -04:00
|
|
|
use Aura\Router\RouterFactory;
|
|
|
|
use Aura\Web\WebFactory;
|
|
|
|
use Aviat\AnimeClient\Controller;
|
2017-01-12 15:41:20 -05:00
|
|
|
use Aviat\AnimeClient\Controller\{
|
|
|
|
Anime as AnimeController,
|
2017-03-24 09:58:27 -04:00
|
|
|
Character as CharacterController,
|
2017-09-14 16:18:13 -04:00
|
|
|
AnimeCollection as AnimeCollectionController,
|
|
|
|
MangaCollection as MangaCollectionController,
|
2017-01-12 15:41:20 -05:00
|
|
|
Manga as MangaController
|
|
|
|
};
|
2015-09-14 10:54:50 -04:00
|
|
|
|
2017-02-15 16:40:18 -05:00
|
|
|
class ControllerTest extends AnimeClientTestCase {
|
2017-03-24 09:58:27 -04:00
|
|
|
|
2017-02-22 15:08:29 -05:00
|
|
|
protected $BaseController;
|
2015-09-14 10:54:50 -04:00
|
|
|
|
2019-12-06 09:15:49 -05:00
|
|
|
public function setUp(): void {
|
2015-09-14 10:54:50 -04:00
|
|
|
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');
|
2018-10-05 14:32:05 -04:00
|
|
|
$config->set('database', [
|
2015-10-15 09:25:30 -04:00
|
|
|
'type' => 'sqlite',
|
|
|
|
'database' => '',
|
|
|
|
'file' => ":memory:"
|
|
|
|
]);
|
2016-08-29 15:36:36 -04:00
|
|
|
$this->container->setInstance('config', $config);
|
2015-10-15 09:25:30 -04:00
|
|
|
|
|
|
|
$this->assertInstanceOf(
|
2018-01-18 16:21:45 -05:00
|
|
|
Controller::class,
|
2015-10-15 09:25:30 -04:00
|
|
|
new AnimeController($this->container)
|
|
|
|
);
|
|
|
|
$this->assertInstanceOf(
|
2018-01-18 16:21:45 -05:00
|
|
|
Controller::class,
|
2015-10-15 09:25:30 -04:00
|
|
|
new MangaController($this->container)
|
|
|
|
);
|
2017-03-24 09:58:27 -04:00
|
|
|
$this->assertInstanceOf(
|
2018-01-18 16:21:45 -05:00
|
|
|
Controller::class,
|
2017-03-24 09:58:27 -04:00
|
|
|
new CharacterController($this->container)
|
|
|
|
);
|
2015-10-15 09:25:30 -04:00
|
|
|
$this->assertInstanceOf(
|
2018-01-18 16:21:45 -05:00
|
|
|
Controller::class,
|
2017-09-14 16:18:13 -04:00
|
|
|
new AnimeCollectionController($this->container)
|
|
|
|
);
|
|
|
|
$this->assertInstanceOf(
|
2018-01-18 16:21:45 -05:00
|
|
|
Controller::class,
|
2017-09-14 16:18:13 -04:00
|
|
|
new MangaCollectionController($this->container)
|
2015-10-15 09:25:30 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
public function testBaseControllerSanity()
|
|
|
|
{
|
2018-01-18 16:21:45 -05:00
|
|
|
$this->assertTrue(\is_object($this->BaseController));
|
2015-09-14 10:54:50 -04:00
|
|
|
}
|
|
|
|
|
2017-03-31 14:15:29 -04:00
|
|
|
public function testFormatTitle()
|
2015-09-14 10:54:50 -04:00
|
|
|
{
|
2017-03-31 14:15:29 -04:00
|
|
|
$this->assertEquals(
|
|
|
|
$this->BaseController->formatTitle('foo', 'bar', 'baz'),
|
|
|
|
'foo · bar · baz'
|
|
|
|
);
|
2015-09-14 10:54:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|