2017-02-16 11:09:37 -05:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
|
|
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
|
|
|
*
|
|
|
|
* PHP version 7
|
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
|
|
* @copyright 2015 - 2017 Timothy J. Warren
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @version 4.0
|
2017-03-07 20:53:58 -05:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2017-02-16 11:09:37 -05:00
|
|
|
*/
|
2015-09-14 15:49:20 -04:00
|
|
|
|
2017-02-15 11:49:38 -05:00
|
|
|
namespace Aviat\AnimeClient\Tests;
|
|
|
|
|
2015-09-15 13:19:29 -04:00
|
|
|
use Aviat\AnimeClient\UrlGenerator;
|
2016-10-20 22:32:17 -04:00
|
|
|
use Aviat\Ion\Config;
|
2015-09-14 15:49:20 -04:00
|
|
|
|
2017-02-15 16:40:18 -05:00
|
|
|
class UrlGeneratorTest extends AnimeClientTestCase {
|
2015-09-14 15:49:20 -04:00
|
|
|
|
|
|
|
public function assetUrlProvider()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'single argument' => [
|
|
|
|
'args' => [
|
|
|
|
'images'
|
|
|
|
],
|
|
|
|
'expected' => '//localhost/assets/images',
|
|
|
|
],
|
|
|
|
'multiple arguments' => [
|
|
|
|
'args' => [
|
|
|
|
'images', 'anime', 'foo.png'
|
|
|
|
],
|
|
|
|
'expected' => '//localhost/assets/images/anime/foo.png'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider assetUrlProvider
|
|
|
|
*/
|
|
|
|
public function testAssetUrl($args, $expected)
|
|
|
|
{
|
|
|
|
$urlGenerator = new UrlGenerator($this->container);
|
|
|
|
|
2017-02-15 15:56:10 -05:00
|
|
|
$result = $urlGenerator->assetUrl(...$args);
|
2015-09-14 15:49:20 -04:00
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataFullUrl()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'default_view' => [
|
|
|
|
'config' => [
|
2016-01-06 11:08:56 -05:00
|
|
|
'routes' => [
|
|
|
|
'routes' => [],
|
|
|
|
'route_config' => [
|
|
|
|
'anime_path' => 'anime',
|
|
|
|
'manga_path' => 'manga',
|
|
|
|
'default_list' => 'manga',
|
|
|
|
'default_anime_path' => '/anime/watching',
|
|
|
|
'default_manga_path' => '/manga/all',
|
|
|
|
'default_to_list_view' => FALSE,
|
|
|
|
]
|
2015-09-14 15:49:20 -04:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'path' => '',
|
|
|
|
'type' => 'manga',
|
|
|
|
'expected' => '//localhost/manga/all',
|
|
|
|
],
|
|
|
|
'default_view_list' => [
|
|
|
|
'config' => [
|
2016-01-06 11:08:56 -05:00
|
|
|
'routes' => [
|
|
|
|
'routes' => [],
|
|
|
|
'route_config' => [
|
|
|
|
'anime_path' => 'anime',
|
|
|
|
'manga_path' => 'manga',
|
|
|
|
'default_list' => 'manga',
|
|
|
|
'default_anime_path' => '/anime/watching',
|
|
|
|
'default_manga_path' => '/manga/all',
|
|
|
|
'default_to_list_view' => TRUE,
|
|
|
|
]
|
2015-09-14 15:49:20 -04:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'path' => '',
|
|
|
|
'type' => 'manga',
|
|
|
|
'expected' => '//localhost/manga/all/list',
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataFullUrl
|
|
|
|
*/
|
|
|
|
public function testFullUrl($config, $path, $type, $expected)
|
|
|
|
{
|
|
|
|
$config = new Config($config);
|
2016-08-29 15:36:36 -04:00
|
|
|
$this->container->setInstance('config', $config);
|
2015-09-14 15:49:20 -04:00
|
|
|
$urlGenerator = new UrlGenerator($this->container);
|
|
|
|
|
2017-02-15 15:56:10 -05:00
|
|
|
$result = $urlGenerator->fullUrl($path, $type);
|
2015-09-14 15:49:20 -04:00
|
|
|
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
}
|