Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
5 changed files with 77 additions and 3 deletions
Showing only changes of commit 253f191113 - Show all commits

View File

@ -228,6 +228,7 @@ class Anime extends API {
/** /**
* Sort the list by title * Sort the list by title
* *
* @codeCoverageIgnore
* @param array $array * @param array $array
* @return void * @return void
*/ */

View File

@ -143,7 +143,7 @@ class Manga extends API {
* @codeCoverageIgnore * @codeCoverageIgnore
* @return array * @return array
*/ */
private function _check_cache($response) protected function _check_cache($response)
{ {
// Bail out early if there isn't any manga data // Bail out early if there isn't any manga data
$api_data = json_decode($response->getBody(), TRUE); $api_data = json_decode($response->getBody(), TRUE);
@ -215,6 +215,7 @@ class Manga extends API {
/** /**
* Sort the manga entries by their title * Sort the manga entries by their title
* *
* @codeCoverageIgnore
* @param array $array * @param array $array
* @return void * @return void
*/ */

View File

@ -5,6 +5,13 @@ use Aviat\AnimeClient\AnimeClient;
class AnimeClientTest extends AnimeClient_TestCase { 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 * Basic sanity test for _dir function
*/ */
@ -30,4 +37,39 @@ class AnimeClientTest extends AnimeClient_TestCase {
// Matches // Matches
$this->assertEquals('', AnimeClient::is_not_selected('foo', 'foo')); $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());
}
} }

View File

@ -53,4 +53,34 @@ class MangaModelTest extends AnimeClient_TestCase {
$this->assertEquals($expected_all[$key], $this->model->_get_list_from_api($key)); $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);
}
} }

View File

@ -143,9 +143,9 @@ class TestAnimeModel extends AnimeModel {
class TestMangaModel extends MangaModel { class TestMangaModel extends MangaModel {
use MockInjectionTrait; 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); return json_decode(file_get_contents($file), TRUE);
} }
} }