More test coverage
This commit is contained in:
parent
6622014bd1
commit
253f191113
@ -228,6 +228,7 @@ class Anime extends API {
|
||||
/**
|
||||
* Sort the list by title
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param array $array
|
||||
* @return void
|
||||
*/
|
||||
|
@ -143,7 +143,7 @@ class Manga extends API {
|
||||
* @codeCoverageIgnore
|
||||
* @return array
|
||||
*/
|
||||
private function _check_cache($response)
|
||||
protected function _check_cache($response)
|
||||
{
|
||||
// Bail out early if there isn't any manga data
|
||||
$api_data = json_decode($response->getBody(), TRUE);
|
||||
@ -215,6 +215,7 @@ class Manga extends API {
|
||||
/**
|
||||
* Sort the manga entries by their title
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @param array $array
|
||||
* @return void
|
||||
*/
|
||||
|
@ -5,6 +5,13 @@ use Aviat\AnimeClient\AnimeClient;
|
||||
|
||||
class AnimeClientTest extends AnimeClient_TestCase {
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->anime_client = new AnimeClient();
|
||||
$this->anime_client->setContainer($this->container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic sanity test for _dir function
|
||||
*/
|
||||
@ -30,4 +37,39 @@ class AnimeClientTest extends AnimeClient_TestCase {
|
||||
// Matches
|
||||
$this->assertEquals('', AnimeClient::is_not_selected('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->anime_client->is_view_page());
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,34 @@ class MangaModelTest extends AnimeClient_TestCase {
|
||||
$this->assertEquals($expected_all[$key], $this->model->_get_list_from_api($key));
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetList()
|
||||
{
|
||||
$data = $this->model->get_all_lists();
|
||||
$this->assertEquals($data['Reading'], $this->model->get_list('Reading'));
|
||||
}
|
||||
|
||||
public function testGetAllLists()
|
||||
{
|
||||
$data = json_decode(file_get_contents($this->mockDir . '/manga-mapped.json'), TRUE);
|
||||
|
||||
foreach($data as &$val)
|
||||
{
|
||||
$this->sort_by_name($val);
|
||||
}
|
||||
|
||||
$this->assertEquals($data, $this->model->get_all_lists());
|
||||
}
|
||||
|
||||
private function sort_by_name(&$array)
|
||||
{
|
||||
$sort = array();
|
||||
|
||||
foreach ($array as $key => $item)
|
||||
{
|
||||
$sort[$key] = $item['manga']['title'];
|
||||
}
|
||||
|
||||
array_multisort($sort, SORT_ASC, $array);
|
||||
}
|
||||
}
|
@ -143,9 +143,9 @@ class TestAnimeModel extends AnimeModel {
|
||||
class TestMangaModel extends MangaModel {
|
||||
use MockInjectionTrait;
|
||||
|
||||
private function _check_cache($response)
|
||||
protected function _check_cache($response)
|
||||
{
|
||||
$file = __DIR__ . '/../../test_data/manga_list/manga-transformed.json';
|
||||
$file = __DIR__ . '/test_data/manga_list/manga-transformed.json';
|
||||
return json_decode(file_get_contents($file), TRUE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user