2017-02-16 11:09:37 -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
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
2020-04-10 15:39:39 -04:00
|
|
|
* PHP version 7.4
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2020-01-08 15:39:49 -05:00
|
|
|
* @copyright 2015 - 2020 Timothy J. Warren
|
2017-02-16 11:09:37 -05:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2020-08-04 09:30:21 -04:00
|
|
|
* @version 5.1
|
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;
|
2020-12-10 17:04:45 -05:00
|
|
|
use Aviat\Ion\Exception\DoubleRenderException;
|
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'
|
|
|
|
],
|
2018-10-11 09:53:14 -04:00
|
|
|
'expected' => 'https://localhost/assets/images',
|
2015-09-14 15:49:20 -04:00
|
|
|
],
|
|
|
|
'multiple arguments' => [
|
|
|
|
'args' => [
|
|
|
|
'images', 'anime', 'foo.png'
|
|
|
|
],
|
2018-10-11 09:53:14 -04:00
|
|
|
'expected' => 'https://localhost/assets/images/anime/foo.png'
|
2015-09-14 15:49:20 -04:00
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
2020-12-10 17:04:45 -05:00
|
|
|
|
|
|
|
public function testDefaultUrlInvalidType(): void
|
|
|
|
{
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
$this->expectExceptionMessage("Invalid default type: 'foo'");
|
|
|
|
|
|
|
|
$urlGenerator = new UrlGenerator($this->container);
|
|
|
|
$url = $urlGenerator->defaultUrl('foo');
|
|
|
|
|
|
|
|
}
|
2015-09-14 15:49:20 -04:00
|
|
|
}
|