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
|
|
|
*
|
2019-12-03 15:17:25 -05:00
|
|
|
* PHP version 7.2
|
2017-02-16 11:09:37 -05:00
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2019-12-06 09:16:35 -05:00
|
|
|
* @copyright 2015 - 2019 Timothy J. Warren
|
2017-02-16 11:09:37 -05:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2019-12-06 09:16:35 -05:00
|
|
|
* @version 4.2
|
2017-03-07 20:53:58 -05:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2017-02-16 11:09:37 -05:00
|
|
|
*/
|
2016-08-29 17:09:56 -04:00
|
|
|
|
|
|
|
namespace Aviat\AnimeClient\Tests;
|
|
|
|
|
|
|
|
use Aviat\AnimeClient\Util;
|
|
|
|
|
2017-02-15 16:40:18 -05:00
|
|
|
class UtilTest extends AnimeClientTestCase {
|
2019-12-06 09:15:49 -05:00
|
|
|
|
2017-02-22 15:08:29 -05:00
|
|
|
protected $util;
|
2016-08-29 17:09:56 -04:00
|
|
|
|
2019-12-06 09:15:49 -05:00
|
|
|
public function setUp(): void {
|
2016-08-29 17:09:56 -04:00
|
|
|
parent::setUp();
|
|
|
|
$this->util = new Util($this->container);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsSelected()
|
|
|
|
{
|
|
|
|
// Failure to match
|
2017-02-16 14:30:06 -05:00
|
|
|
$this->assertEquals('', Util::isSelected('foo', 'bar'));
|
2016-08-29 17:09:56 -04:00
|
|
|
|
|
|
|
// Matches
|
2017-02-16 14:30:06 -05:00
|
|
|
$this->assertEquals('selected', Util::isSelected('foo', 'foo'));
|
2016-08-29 17:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsNotSelected()
|
|
|
|
{
|
|
|
|
// Failure to match
|
2017-02-16 14:30:06 -05:00
|
|
|
$this->assertEquals('selected', Util::isNotSelected('foo', 'bar'));
|
2016-08-29 17:09:56 -04:00
|
|
|
|
|
|
|
// Matches
|
2017-02-16 14:30:06 -05:00
|
|
|
$this->assertEquals('', Util::isNotSelected('foo', 'foo'));
|
2016-08-29 17:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
]
|
|
|
|
]);
|
2017-02-16 14:30:06 -05:00
|
|
|
$this->assertEquals($expected, $this->util->isViewPage());
|
2016-08-29 17:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataIsViewPage
|
|
|
|
*/
|
|
|
|
public function testIsFormPage($uri, $expected)
|
|
|
|
{
|
|
|
|
$this->setSuperGlobals([
|
|
|
|
'_SERVER' => [
|
|
|
|
'REQUEST_URI' => $uri
|
|
|
|
]
|
|
|
|
]);
|
2017-02-16 14:30:06 -05:00
|
|
|
$this->assertEquals(!$expected, $this->util->isFormPage());
|
2016-08-29 17:09:56 -04:00
|
|
|
}
|
|
|
|
}
|