HummingBirdAnimeClient/tests/AnimeClient/UtilTest.php

102 lines
2.0 KiB
PHP

<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu to manage anime and manga watch lists
*
* PHP version 8
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2021 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 5.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests;
use Aviat\AnimeClient\Util;
class UtilTest extends AnimeClientTestCase {
protected $util;
public function setUp(): void {
parent::setUp();
$this->util = new Util($this->container);
}
public function testIsSelected()
{
// Failure to match
$this->assertEquals('', Util::isSelected('foo', 'bar'));
// Matches
$this->assertEquals('selected', Util::isSelected('foo', 'foo'));
}
public function testIsNotSelected()
{
// Failure to match
$this->assertEquals('selected', Util::isNotSelected('foo', 'bar'));
// Matches
$this->assertEquals('', Util::isNotSelected('foo', 'foo'));
}
public function dataIsViewPage()
{
return [
[
'uri' => '/anime/update',
'expected' => FALSE
],
[
'uri' => '/anime/watching',
'expected' => TRUE
],
[
'uri' => '/manga/reading',
'expected' => TRUE
],
[
'uri' => '/manga/update',
'expected' => FALSE
]
];
}
/**
* @dataProvider dataIsViewPage
*/
public function testIsViewPage($uri, $expected)
{
$this->setSuperGlobals([
'_SERVER' => [
'REQUEST_URI' => $uri
]
]);
$this->assertEquals($expected, $this->util->isViewPage());
}
/**
* @dataProvider dataIsViewPage
*/
public function testIsFormPage($uri, $expected)
{
$this->setSuperGlobals([
'_SERVER' => [
'REQUEST_URI' => $uri
]
]);
$this->assertEquals(!$expected, $this->util->isFormPage());
}
public function testAriaCurrent(): void
{
$this->assertEquals('true', Util::ariaCurrent(true));
$this->assertEquals('false', Util::ariaCurrent(false));
}
}