HummingBirdAnimeClient/tests/AnimeClient/UrlGeneratorTest.php

67 lines
1.5 KiB
PHP
Raw Normal View History

<?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
*
2021-02-04 11:57:01 -05:00
* PHP version 8
*
* @package HummingbirdAnimeClient
2022-03-04 12:32:17 -05:00
* @author Timothy J. Warren <tim@timshome.page>
* @copyright 2015 - 2022 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
2020-12-10 17:06:50 -05:00
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
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;
2022-03-04 12:19:47 -05:00
use InvalidArgumentException;
2015-09-14 15:49:20 -04:00
2022-03-04 12:19:47 -05:00
/**
* @internal
*/
final class UrlGeneratorTest extends AnimeClientTestCase
{
2015-09-14 15:49:20 -04:00
public function assetUrlProvider()
{
return [
'single argument' => [
'args' => [
2022-03-04 12:19:47 -05:00
'images',
2015-09-14 15:49:20 -04:00
],
2018-10-11 09:53:14 -04:00
'expected' => 'https://localhost/assets/images',
2015-09-14 15:49:20 -04:00
],
'multiple arguments' => [
'args' => [
2022-03-04 12:19:47 -05:00
'images', 'anime', 'foo.png',
2015-09-14 15:49:20 -04:00
],
2022-03-04 12:19:47 -05:00
'expected' => 'https://localhost/assets/images/anime/foo.png',
],
2015-09-14 15:49:20 -04:00
];
}
/**
* @dataProvider assetUrlProvider
2022-03-04 12:19:47 -05:00
* @param mixed $args
* @param mixed $expected
2015-09-14 15:49:20 -04:00
*/
public function testAssetUrl($args, $expected)
{
$urlGenerator = new UrlGenerator($this->container);
2017-02-15 15:56:10 -05:00
$result = $urlGenerator->assetUrl(...$args);
2022-03-04 12:19:47 -05:00
$this->assertSame($expected, $result);
2015-09-14 15:49:20 -04:00
}
2020-12-10 17:04:45 -05:00
public function testDefaultUrlInvalidType(): void
{
2022-03-04 12:19:47 -05:00
$this->expectException(InvalidArgumentException::class);
2020-12-10 17:04:45 -05:00
$this->expectExceptionMessage("Invalid default type: 'foo'");
$urlGenerator = new UrlGenerator($this->container);
$url = $urlGenerator->defaultUrl('foo');
}
2022-03-04 12:19:47 -05:00
}