HummingBirdAnimeClient/tests/AnimeClient/ControllerTest.php

94 lines
2.1 KiB
PHP
Raw Normal View History

2017-01-12 15:41:20 -05:00
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
2018-08-22 13:48:27 -04:00
* An API client for Kitsu to manage anime and manga watch lists
*
2023-07-13 11:08:05 -04:00
* PHP version 8.1
*
2023-07-13 11:08:05 -04:00
* @copyright 2015 - 2023 Timothy J. Warren <tim@timshome.page>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
2020-12-10 17:06:50 -05:00
* @version 5.2
2023-07-13 11:08:05 -04:00
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
2017-02-15 11:49:38 -05:00
namespace Aviat\AnimeClient\Tests;
2016-10-20 22:32:17 -04:00
use Aviat\AnimeClient\Controller;
2017-01-12 15:41:20 -05:00
use Aviat\AnimeClient\Controller\{
Anime as AnimeController,
AnimeCollection as AnimeCollectionController,
2022-03-04 12:19:47 -05:00
Character as CharacterController,
Manga as MangaController // MangaCollection as MangaCollectionController,
2017-01-12 15:41:20 -05:00
};
2022-03-04 12:19:47 -05:00
/**
* @internal
*/
final class ControllerTest extends AnimeClientTestCase
{
2017-02-22 15:08:29 -05:00
protected $BaseController;
2022-03-04 12:19:47 -05:00
protected function setUp(): void
{
parent::setUp();
// Create Request/Response Objects
2020-12-11 14:26:54 -05:00
$GLOBALS['_SERVER']['HTTP_REFERER'] = '';
$this->setSuperGlobals([
'_GET' => [],
'_POST' => [],
'_COOKIE' => [],
2020-12-11 14:26:54 -05:00
'_SERVER' => $GLOBALS['_SERVER'],
2022-03-04 12:19:47 -05:00
'_FILES' => [],
]);
2015-10-15 09:25:30 -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' => '',
2022-03-04 12:19:47 -05:00
'file' => ':memory:',
2015-10-15 09:25:30 -04:00
]);
$this->container->setInstance('config', $config);
2015-10-15 09:25:30 -04:00
$this->assertInstanceOf(
Controller::class,
2015-10-15 09:25:30 -04:00
new AnimeController($this->container)
);
$this->assertInstanceOf(
Controller::class,
2015-10-15 09:25:30 -04:00
new MangaController($this->container)
);
2017-03-24 09:58:27 -04:00
$this->assertInstanceOf(
Controller::class,
2017-03-24 09:58:27 -04:00
new CharacterController($this->container)
);
2015-10-15 09:25:30 -04:00
$this->assertInstanceOf(
Controller::class,
new AnimeCollectionController($this->container)
);
2020-08-26 15:22:14 -04:00
/* $this->assertInstanceOf(
Controller::class,
new MangaCollectionController($this->container)
2020-08-26 15:22:14 -04:00
); */
2015-10-15 09:25:30 -04:00
}
public function testBaseControllerSanity()
{
2022-03-04 12:19:47 -05:00
$this->assertIsObject($this->BaseController);
}
public function testFormatTitle()
{
2022-03-04 12:19:47 -05:00
$this->assertSame(
$this->BaseController->formatTitle('foo', 'bar', 'baz'),
'foo &middot; bar &middot; baz'
);
}
2022-03-04 12:19:47 -05:00
}