Browse Source

A little more test coverage

pull/36/head
Timothy Warren 1 year ago
parent
commit
71ee0a324c
  1. 24
      src/AnimeClient/Anilist.php
  2. 12
      src/AnimeClient/MenuGenerator.php
  3. 2
      src/AnimeClient/UrlGenerator.php
  4. 11
      tests/AnimeClient/UrlGeneratorTest.php

24
src/AnimeClient/Anilist.php

@ -64,28 +64,4 @@ final class Anilist {
MangaReadingStatus::DROPPED => KMRS::DROPPED,
MangaReadingStatus::PLAN_TO_READ => KMRS::PLAN_TO_READ,
];
public static function getIdToWatchingStatusMap(): array
{
return [
'CURRENT' => AnimeWatchingStatus::WATCHING,
'COMPLETED' => AnimeWatchingStatus::COMPLETED,
'PAUSED' => AnimeWatchingStatus::ON_HOLD,
'DROPPED' => AnimeWatchingStatus::DROPPED,
'PLANNING' => AnimeWatchingStatus::PLAN_TO_WATCH,
'REPEATING' => AnimeWatchingStatus::WATCHING,
];
}
public static function getIdToReadingStatusMap(): array
{
return [
'CURRENT' => MangaReadingStatus::READING,
'COMPLETED' => MangaReadingStatus::COMPLETED,
'PAUSED' => MangaReadingStatus::ON_HOLD,
'DROPPED' => MangaReadingStatus::DROPPED,
'PLANNING' => MangaReadingStatus::PLAN_TO_READ,
'REPEATING' => MangaReadingStatus::READING,
];
}
}

12
src/AnimeClient/MenuGenerator.php

@ -49,15 +49,7 @@ final class MenuGenerator extends UrlGenerator {
*/
public static function new(ContainerInterface $container): self
{
try
{
return new static($container);
}
catch (\Throwable $e)
{
dump($e);
die();
}
return new self($container);
}
/**
@ -67,7 +59,7 @@ final class MenuGenerator extends UrlGenerator {
* @throws ConfigException
* @return string
*/
public function generate($menu) : string
public function generate(string $menu) : string
{
$menus = $this->config->get('menus');
$parsedConfig = $this->parseConfig($menus);

2
src/AnimeClient/UrlGenerator.php

@ -110,7 +110,9 @@ class UrlGenerator extends RoutingBase {
if ($defaultPath !== NULL)
{
// @codeCoverageIgnoreStart
return $this->url("{$type}/{$defaultPath}");
// @codeCoverageIgnoreEnd
}
throw new InvalidArgumentException("Invalid default type: '{$type}'");

11
tests/AnimeClient/UrlGeneratorTest.php

@ -18,6 +18,7 @@ namespace Aviat\AnimeClient\Tests;
use Aviat\AnimeClient\UrlGenerator;
use Aviat\Ion\Config;
use Aviat\Ion\Exception\DoubleRenderException;
class UrlGeneratorTest extends AnimeClientTestCase {
@ -49,4 +50,14 @@ class UrlGeneratorTest extends AnimeClientTestCase {
$result = $urlGenerator->assetUrl(...$args);
$this->assertEquals($expected, $result);
}
public function testDefaultUrlInvalidType(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage("Invalid default type: 'foo'");
$urlGenerator = new UrlGenerator($this->container);
$url = $urlGenerator->defaultUrl('foo');
}
}
Loading…
Cancel
Save